View Javadoc

1   package org.apache.helix;
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  enum Type
23  {
24    CLUSTER, INSTANCE, CONTROLLER, RESOURCE;
25  }
26  
27  public enum PropertyType
28  {
29  
30    // @formatter:off
31    // CLUSTER PROPERTIES
32    CONFIGS(Type.CLUSTER, true, false, false, false, true),
33    LIVEINSTANCES(Type.CLUSTER, false, false, false, true, true),
34    INSTANCES(Type.CLUSTER, true, false),
35    IDEALSTATES(Type.CLUSTER, true, false, false, false, true),
36    EXTERNALVIEW(Type.CLUSTER, true, false),
37    STATEMODELDEFS(Type.CLUSTER, true, false, false, false, true),
38    CONTROLLER(Type.CLUSTER, true, false),
39    PROPERTYSTORE(Type.CLUSTER, true, false),
40  
41    // INSTANCE PROPERTIES
42    MESSAGES(Type.INSTANCE, true, true, true),
43    CURRENTSTATES(Type.INSTANCE, true, true, false, false, true),
44    STATUSUPDATES(Type.INSTANCE, true, true, false, false, false, true),
45    ERRORS(Type.INSTANCE, true, true),
46    HEALTHREPORT(Type.INSTANCE, true, false, false, false, false, true),
47  
48    // CONTROLLER PROPERTY
49    LEADER(Type.CONTROLLER, false, false, true, true),
50    HISTORY(Type.CONTROLLER, true, true, true),
51    PAUSE(Type.CONTROLLER, true, false, true),
52    MESSAGES_CONTROLLER(Type.CONTROLLER, true, false, true),
53    STATUSUPDATES_CONTROLLER(Type.CONTROLLER, true, true, true),
54    ERRORS_CONTROLLER(Type.CONTROLLER, true, true, true),
55    PERSISTENTSTATS(Type.CONTROLLER, true, false, false, false),
56    ALERTS(Type.CONTROLLER, true, false, false, false),
57    ALERT_STATUS(Type.CONTROLLER, true, false, false, false),
58    ALERT_HISTORY(Type.CONTROLLER, true, false, false, false);
59  
60    // @formatter:on
61  
62    Type    type;
63    
64    boolean isPersistent;
65  
66    boolean mergeOnUpdate;
67  
68    boolean updateOnlyOnExists;
69  
70    boolean createOnlyIfAbsent;
71  
72    /**
73     * "isCached" defines whether the property is cached in data accessor if data is cached,
74     * then read from zk can be optimized
75     */
76    boolean isCached;
77  
78    boolean usePropertyTransferServer;
79  
80    private PropertyType(Type type, boolean isPersistent, boolean mergeOnUpdate)
81    {
82      this(type, isPersistent, mergeOnUpdate, false);
83    }
84  
85    private PropertyType(Type type,
86                         boolean isPersistent,
87                         boolean mergeOnUpdate,
88                         boolean updateOnlyOnExists)
89    {
90      this(type, isPersistent, mergeOnUpdate, false, false);
91    }
92  
93    private PropertyType(Type type,
94                         boolean isPersistent,
95                         boolean mergeOnUpdate,
96                         boolean updateOnlyOnExists,
97                         boolean createOnlyIfAbsent)
98    {
99      this(type, isPersistent, mergeOnUpdate, updateOnlyOnExists, createOnlyIfAbsent, false);
100   }
101 
102   private PropertyType(Type type,
103                        boolean isPersistent,
104                        boolean mergeOnUpdate,
105                        boolean updateOnlyOnExists,
106                        boolean createOnlyIfAbsent,
107                        boolean isCached)
108   {
109     this(type,
110          isPersistent,
111          mergeOnUpdate,
112          updateOnlyOnExists,
113          createOnlyIfAbsent,
114          isCached,
115          false);
116   }
117 
118   private PropertyType(Type type,
119                        boolean isPersistent,
120                        boolean mergeOnUpdate,
121                        boolean updateOnlyOnExists,
122                        boolean createOnlyIfAbsent,
123                        boolean isCached,
124                        boolean isAsyncWrite)
125   {
126     this.type = type;
127     this.isPersistent = isPersistent;
128     this.mergeOnUpdate = mergeOnUpdate;
129     this.updateOnlyOnExists = updateOnlyOnExists;
130     this.createOnlyIfAbsent = createOnlyIfAbsent;
131     this.isCached = isCached;
132     this.usePropertyTransferServer = isAsyncWrite;
133   }
134 
135   public boolean isCreateOnlyIfAbsent()
136   {
137     return createOnlyIfAbsent;
138   }
139 
140   public void setCreateIfAbsent(boolean createIfAbsent)
141   {
142     this.createOnlyIfAbsent = createIfAbsent;
143   }
144 
145   public Type getType()
146   {
147     return type;
148   }
149 
150   public void setType(Type type)
151   {
152     this.type = type;
153   }
154 
155   public boolean isPersistent()
156   {
157     return isPersistent;
158   }
159 
160   public void setPersistent(boolean isPersistent)
161   {
162     this.isPersistent = isPersistent;
163   }
164 
165   public boolean isMergeOnUpdate()
166   {
167     return mergeOnUpdate;
168   }
169 
170   public void setMergeOnUpdate(boolean mergeOnUpdate)
171   {
172     this.mergeOnUpdate = mergeOnUpdate;
173   }
174 
175   public boolean isUpdateOnlyOnExists()
176   {
177     return updateOnlyOnExists;
178   }
179 
180   public void setUpdateOnlyOnExists(boolean updateOnlyOnExists)
181   {
182     this.updateOnlyOnExists = updateOnlyOnExists;
183   }
184 
185   public boolean isCached()
186   {
187     return isCached;
188   }
189 
190   public boolean usePropertyTransferServer()
191   {
192     return usePropertyTransferServer;
193   }
194 
195 }