Source code: com/ubermq/chord/ChordIdentifierFactory.java
1 package com.ubermq.chord;
2
3 /**
4 * Specifies a factory interface to construct
5 * chord identifiers in various ways.
6 */
7 public interface ChordIdentifierFactory
8 {
9 /**
10 * Creates a chord identifier based on a Java object.
11 * Most implementations will require that the object's
12 * <code>hashCode</code> method is well-defined,
13 * however this is not a strict requirement, particularly
14 * if a 32-bit hash space is not sufficient. <P>
15 *
16 * @param o the object to create an identifier for
17 * @return an identifier
18 */
19 public ChordIdentifier createIdentifier(Object o);
20
21 /**
22 * Returns the identifier specified by a given URI. Generally
23 * the identifier will be contained in the path component
24 * of the URI, but this is ultimately implementation-specific.<P>
25 *
26 * @return a chord identifier, or null if the URI did not
27 * correctly specify an identifier.
28 */
29 public ChordIdentifier getIdentifier(java.net.URI uri);
30
31 /**
32 * Generates a random chord identifier.
33 *
34 * @return a randomly generated chord identifier
35 */
36 public ChordIdentifier createRandomIdentifier();
37
38 /**
39 * Returns the recommended size of the finger table. This
40 * should be a value that ensures O(log n) searches throughout
41 * the identifier space.<P>
42 *
43 * @return the recommended size of the finger table for this
44 * identifier set. The size should include space for finger 0,
45 * the immediate successor, and remaining finger entries for
46 * each 2^i spaced finger.
47 */
48 public int getFingerTableSize();
49 }