View Javadoc

1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.activecluster.group;
19  
20  /***
21   * Represents the membership of a Group for a Node
22   *
23   * @version $Revision: 1.1 $
24   */
25  public class Membership {
26      public static final int STATUS_REQUESTED = 1;
27      public static final int STATUS_SYNCHONIZING = 2;
28      public static final int STATUS_FAILED = 3;
29      public static final int STATUS_OK = 4;
30  
31      private Group group;
32      private int index;
33      private int status = STATUS_REQUESTED;
34  
35      public Membership(Group group, int index) {
36          this.group = group;
37          this.index = index;
38      }
39  
40      public int getIndex() {
41          return index;
42      }
43  
44      public void setIndex(int index) {
45          this.index = index;
46      }
47  
48      public int getStatus() {
49          return status;
50      }
51  
52      public void setStatus(int status) {
53          this.status = status;
54      }
55  
56      /***
57       * @return the weighting of this membership
58       */
59      public int getWeighting() {
60          // lets make master heavy and the further from the end of the
61          // list of slaves, the lighter we become
62          return group.getMaximumMemberCount() - getIndex();
63      }
64  }