KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > l2 > state > EnrollmentFactory


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.l2.state;
5
6 import com.tc.net.groups.NodeID;
7
8 import java.util.Random JavaDoc;
9
10 public class EnrollmentFactory {
11
12   public static Enrollment createEnrollment(NodeID nodeID, boolean isNew) {
13     int[] weights = createWeigth();
14     Enrollment e = new Enrollment(nodeID, isNew, weights);
15     return e;
16   }
17
18   //TODO:: Create weights based on hardware config, ip address, port number, nodeID, process id etc
19
// FIXME:: This is a temperary implementation
20
private static int[] createWeigth() {
21     int[] weights = new int[2];
22     Random JavaDoc r = new Random JavaDoc();
23     weights[1] = r.nextInt();
24     weights[0] = r.nextInt();
25     return weights;
26   }
27   
28   // FIXME:: This is a temperary implementation
29
private static int[] createMaxWeigth() {
30     int[] weights = new int[2];
31     weights[1] = Integer.MAX_VALUE;
32     weights[0] = Integer.MAX_VALUE;
33     return weights;
34   }
35
36
37   public static Enrollment createTrumpEnrollment(NodeID myNodeId) {
38     int[] weights = createMaxWeigth();
39     Enrollment e = new Enrollment(myNodeId, false, weights);
40     return e;
41   }
42
43 }
44
Popular Tags