View Javadoc

1   package org.apache.helix.monitoring;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  public class StateTransitionContext
23  {
24    private final String _resourceName;
25    private final String _clusterName;
26    private final String _instanceName;
27    private final String _transition;
28    
29    public StateTransitionContext(
30        String clusterName, 
31        String instanceName,
32        String resourceName, 
33        String transition
34        )
35    {
36      _clusterName = clusterName;
37      _resourceName = resourceName; 
38      _transition = transition;
39      _instanceName = instanceName;
40    }
41    
42    public String getClusterName()
43    {
44      return _clusterName;
45    }
46    
47    public String getInstanceName()
48    {
49      return _instanceName;
50    }
51    
52    public String getResourceName()
53    {
54      return _resourceName;
55    }
56    
57    public String getTransition()
58    {
59      return _transition;
60    }
61    
62    @Override
63    public boolean equals(Object other)
64    {
65      if(! (other instanceof StateTransitionContext))
66      {
67        return false;
68      }
69      
70      StateTransitionContext otherCxt = (StateTransitionContext) other;  
71      return
72        _clusterName.equals(otherCxt.getClusterName()) &&
73        // _instanceName.equals(otherCxt.getInstanceName()) &&
74        _resourceName.equals(otherCxt.getResourceName()) &&
75        _transition.equals(otherCxt.getTransition()) ;
76    }
77      
78  
79    // In the report, we will gather per transition time statistics
80   @Override
81    public int hashCode()
82    {
83      return toString().hashCode();
84    }
85    
86    public String toString()
87    {
88       return "Cluster=" + _clusterName + "," + 
89             // "instance=" + _instanceName + "," +
90             "Resource=" + _resourceName +"," + 
91             "Transition=" + _transition;    
92    }
93    
94  }