View Javadoc

1   package org.apache.helix.model;
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  
23  import java.util.Map;
24  
25  import org.apache.helix.HelixProperty;
26  import org.apache.helix.ZNRecord;
27  import org.apache.log4j.Logger;
28  
29  
30  public class PersistentStats extends HelixProperty
31  {
32    private static final Logger _logger = Logger.getLogger(PersistentStats.class.getName());
33  
34    public enum PersistentStatsProperty
35  	  {
36  	    SESSION_ID,
37  	    FIELDS
38  	  }
39  	
40  //  private final ZNRecord _record;
41  	
42    public final static String nodeName = "PersistentStats";
43  	
44    
45    public PersistentStats(String id)
46    {
47      super(id);
48    }
49    
50    public PersistentStats(ZNRecord record)
51    {
52  //    _record = record;
53      super(record);
54  
55    }
56  
57    /*
58    public PersistentStats(ZNRecord record, Stat stat)
59    {
60      super(record, stat);
61    }
62  */
63  
64    public void setSessionId(String sessionId){
65      _record.setSimpleField(PersistentStatsProperty.SESSION_ID.toString(), sessionId);
66    }
67    public String getSessionId()
68    {
69      return _record.getSimpleField(PersistentStatsProperty.SESSION_ID.toString());
70    }
71  
72    public String getInstanceName()
73    {
74      return _record.getId();
75    }
76  
77    /*
78    public String getVersion()
79    {
80      return _record.getSimpleField(CLUSTER_MANAGER_VERSION.toString());
81    }
82    */
83    
84    
85    public Map<String, Map<String, String>> getMapFields() {
86  	  return _record.getMapFields();
87    }
88    
89    
90    public Map<String, String> getStatFields(String statName) {
91  	  return _record.getMapField(statName);
92    }
93  
94  @Override
95  public boolean isValid() {
96  	// TODO Auto-generated method stub
97  	return true;
98  }
99    
100 }
101 
102