View Javadoc
1   /**
2    * This Source Code Form is subject to the terms of the Mozilla Public
3    * License, v. 2.0. If a copy of the MPL was not distributed with this
4    * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5    *
6    * If it is not possible or desirable to put the notice in a particular
7    * file, then You may include the notice in a location (such as a LICENSE
8    * file in a relevant directory) where a recipient would be likely to look
9    * for such a notice.
10  
11   * 
12   */
13   
14  /*  ---------------------------------------------------------------------------
15   *  U.S. Government, Department of the Army
16   *  Army Materiel Command
17   *  Research Development Engineering Command
18   *  Communications Electronics Research Development and Engineering Center
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   * @author AO
41   */
42  public class AllFaults 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      
55      @Override
56      public boolean CheckTransactionalRule(AddDataRequestMsg req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
57          if (nullableFaultMsg == null) {
58              nullableFaultMsg = new AtomicReference<String>();
59          }
60          if (!req.isSuccess()) {
61              nullableFaultMsg.set("All faults, " + nullableFaultMsg.get());
62              return true;
63          }
64          return false;
65      }
66      
67      @Override
68      public boolean CheckTransactionalRule(String url, List<BrokerData> data, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
69          return false;
70      }
71      
72      @Override
73      public boolean CheckNonTransactionalRule(ServicePolicy pol, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg, boolean pooled) {
74          return false;
75      }
76      
77      @Override
78      public String GetDisplayName() {
79          return "All Faulting Transactions";
80      }
81      
82      @Override
83      public String GetHtmlFormattedHelp() {
84          return "This rule triggers on all faulting messages and applies only to transactional services. No parameters are required.<br>"
85                  + "Applies to transactional service policies only.";
86      }
87      
88      @Override
89      public List<NameValuePair> GetRequiredParameters() {
90          return new ArrayList<NameValuePair>();
91      }
92      
93      @Override
94      public List<NameValuePair> GetOptionalParameters() {
95          return new ArrayList<NameValuePair>();
96      }
97  
98      @Override
99      public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError,ServicePolicy policy) {
100        if (outError == null) {
101             outError = new AtomicReference<String>();
102         }
103         if (!(policy instanceof TransactionalWebServicePolicy)) {
104             outError.set("This rule only applies to Transactional Service Policies. " + outError.get());
105         }
106         if (Utility.stringIsNullOrEmpty(outError.get())) {
107             return true;
108         } else {
109             return false;
110         }
111      
112     }
113 
114     @Override
115     public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
116         return false;
117     }
118     
119        @Override
120     public org.miloss.fgsms.plugins.sla.AlertType GetType() {
121        return org.miloss.fgsms.plugins.sla.AlertType.Performance;
122     }
123        
124        @Override
125     public String GetHtmlFormattedDisplay(List<NameValuePair> params) {
126       
127         return Utility.encodeHTML(GetDisplayName());
128     }
129        
130        @Override
131     public List<PolicyType> GetAppliesTo() {
132         List<PolicyType> ret = new ArrayList<PolicyType>();
133         ret.add(PolicyType.TRANSACTIONAL);
134         return ret;
135     }
136 }
137