1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.miloss.fgsms.sla.rules;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.concurrent.atomic.AtomicReference;
26 import org.miloss.fgsms.common.Utility;
27 import org.miloss.fgsms.plugins.sla.SLARuleInterface;
28 import org.miloss.fgsms.services.interfaces.common.MachinePerformanceData;
29 import org.miloss.fgsms.services.interfaces.common.NameValuePair;
30 import org.miloss.fgsms.services.interfaces.common.PolicyType;
31 import org.miloss.fgsms.services.interfaces.common.ProcessPerformanceData;
32 import org.miloss.fgsms.services.interfaces.datacollector.AddDataRequestMsg;
33 import org.miloss.fgsms.services.interfaces.datacollector.BrokerData;
34 import org.miloss.fgsms.services.interfaces.policyconfiguration.ServicePolicy;
35 import org.miloss.fgsms.services.interfaces.policyconfiguration.TransactionalWebServicePolicy;
36 import org.miloss.fgsms.services.interfaces.status.SetStatusRequestMsg;
37
38
39
40
41
42 public class AllSuccesses implements SLARuleInterface {
43
44 @Override
45 public boolean CheckTransactionalRule(SetStatusRequestMsg req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
46 return false;
47 }
48
49 @Override
50 public boolean CheckTransactionalRule(ProcessPerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
51 return false;
52 }
53
54 @Override
55 public boolean CheckTransactionalRule(AddDataRequestMsg req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
56 if (nullableFaultMsg == null) {
57 nullableFaultMsg = new AtomicReference<String>();
58 }
59 if (req.isSuccess()) {
60 nullableFaultMsg.set("All Success, " + nullableFaultMsg.get());
61 return true;
62 }
63 return false;
64 }
65
66 @Override
67 public boolean CheckTransactionalRule(String url, List<BrokerData> data, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
68 return false;
69 }
70
71 @Override
72 public boolean CheckNonTransactionalRule(ServicePolicy pol, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg, boolean pooled) {
73 return false;
74 }
75
76 @Override
77 public String GetDisplayName() {
78 return "All Successful Transactions";
79 }
80
81 @Override
82 public String GetHtmlFormattedHelp() {
83 return "This rule triggers on all successful messages and applies only to transactional services. No parameters are required.<Br>"
84 + "Applies to transactional service policies only.";
85 }
86
87 @Override
88 public List<NameValuePair> GetRequiredParameters() {
89 return new ArrayList<NameValuePair>();
90 }
91
92 @Override
93 public List<NameValuePair> GetOptionalParameters() {
94 return new ArrayList<NameValuePair>();
95 }
96
97 @Override
98 public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError, ServicePolicy policy) {
99 if (outError == null) {
100 outError = new AtomicReference<String>();
101 }
102 if (!(policy instanceof TransactionalWebServicePolicy)) {
103 outError.set("This rule only applies to Transactional Service Policies. " + outError.get());
104 }
105 if (Utility.stringIsNullOrEmpty(outError.get())) {
106 return true;
107 } else {
108 return false;
109 }
110 }
111
112 @Override
113 public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
114 return false;
115 }
116 @Override
117 public org.miloss.fgsms.plugins.sla.AlertType GetType() {
118 return org.miloss.fgsms.plugins.sla.AlertType.Performance;
119 }
120
121 @Override
122 public String GetHtmlFormattedDisplay(List<NameValuePair> params) {
123
124 return Utility.encodeHTML(GetDisplayName());
125 }
126
127 @Override
128 public List<PolicyType> GetAppliesTo() {
129 List<PolicyType> ret = new ArrayList<PolicyType>();
130 ret.add(PolicyType.TRANSACTIONAL);
131 return ret;
132 }
133 }