MCPcopy Create free account
hub / github.com/apache/mesos / Position

Class Position

src/java/src/org/apache/mesos/Log.java:57–105  ·  view source on GitHub ↗

An opaque identifier of a log entry's position within the log. Can be used to inidicate Log.Reader#read read ranges and Log.Writer#truncate truncation locations.

Source from the content-addressed store, hash-verified

55 * {@link Log.Writer#truncate truncation} locations.
56 */
57 public static class Position implements Comparable<Position> {
58 @Override
59 public int compareTo(Position that) {
60 return Long.signum(value - that.value);
61 }
62
63 @Override
64 public boolean equals(Object that) {
65 return that instanceof Position && value == ((Position) that).value;
66 }
67
68 @Override
69 public String toString() {
70 return "Position " + value;
71 }
72
73 /**
74 * Returns an "identity" of this position, useful for serializing
75 * to logs or across communication mediums.
76 *
77 * @return The identity in bytes.
78 */
79 public byte[] identity() {
80 byte[] bytes = new byte[8];
81 bytes[0] = (byte) (0xff & (value >> 56));
82 bytes[1] = (byte) (0xff & (value >> 48));
83 bytes[2] = (byte) (0xff & (value >> 40));
84 bytes[3] = (byte) (0xff & (value >> 32));
85 bytes[4] = (byte) (0xff & (value >> 24));
86 bytes[5] = (byte) (0xff & (value >> 16));
87 bytes[6] = (byte) (0xff & (value >> 8));
88 bytes[7] = (byte) (0xff & value);
89 return bytes;
90 }
91
92 /**
93 * Creates a position identified by an integral {@code value}.
94 * <p>
95 * Positions are typically only created by the log implementation. Log
96 * users should only ever need to call this constructor in unit tests.
97 *
98 * @param value The marker for this position in the log.
99 */
100 public Position(long value) {
101 this.value = value;
102 }
103
104 private final long value;
105 }
106
107 /**
108 * Represents an opaque data entry in the {@link Log} with a

Callers 3

_catchupMethod · 0.50
positionMethod · 0.50
__startMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected