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.AlertType;
28  import org.miloss.fgsms.plugins.sla.SLARuleInterface;
29  import org.miloss.fgsms.services.interfaces.common.MachinePerformanceData;
30  import org.miloss.fgsms.services.interfaces.common.NameValuePair;
31  import org.miloss.fgsms.services.interfaces.common.PolicyType;
32  import org.miloss.fgsms.services.interfaces.common.ProcessPerformanceData;
33  import org.miloss.fgsms.services.interfaces.datacollector.AddDataRequestMsg;
34  import org.miloss.fgsms.services.interfaces.datacollector.BrokerData;
35  import org.miloss.fgsms.services.interfaces.policyconfiguration.ServicePolicy;
36  import org.miloss.fgsms.services.interfaces.status.SetStatusRequestMsg;
37  
38  /**
39   *Note, this rule is triggered from other functions
40   * @author AO
41   */
42  public class ChangeInAvailabilityStatus 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(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
56          return false;
57      }
58  
59      @Override
60      public boolean CheckTransactionalRule(AddDataRequestMsg req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
61          return false;
62      }
63  
64      @Override
65      public boolean CheckTransactionalRule(String url, List<BrokerData> data, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) {
66          return false;
67      }
68  
69      @Override
70      public boolean CheckNonTransactionalRule(ServicePolicy pol, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg, boolean pooled) {
71          return false;
72      }
73  
74      @Override
75      public String GetDisplayName() {
76          return "Change in Availability Status";
77      }
78  
79      @Override
80      public String GetHtmlFormattedHelp() {
81          return "This rule triggers every time a service's status changes from up to down or down to up. This applies to all policy types.";
82      }
83  
84      @Override
85      public List<NameValuePair> GetRequiredParameters() {
86          return new ArrayList<NameValuePair>();
87      }
88  
89      @Override
90      public List<NameValuePair> GetOptionalParameters() {
91          return new ArrayList<NameValuePair>();
92      }
93  
94      @Override
95      public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError, ServicePolicy policy) {
96          return true;
97      }
98  
99      @Override
100     public AlertType GetType() {
101         return AlertType.Status;
102     }
103 
104     @Override
105     public String GetHtmlFormattedDisplay(List<NameValuePair> params) {
106 
107         return Utility.encodeHTML(GetDisplayName());
108     }
109     
110      @Override
111     public List<PolicyType> GetAppliesTo() {
112      return Utility.getAllPolicyTypes();
113     }
114 }