id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
102,700
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.lastIndex
public long lastIndex() { assertSegmentOpen(); return !isEmpty() ? offsetIndex.lastOffset() + descriptor.index() + skip : descriptor.index() - 1; }
java
public long lastIndex() { assertSegmentOpen(); return !isEmpty() ? offsetIndex.lastOffset() + descriptor.index() + skip : descriptor.index() - 1; }
[ "public", "long", "lastIndex", "(", ")", "{", "assertSegmentOpen", "(", ")", ";", "return", "!", "isEmpty", "(", ")", "?", "offsetIndex", ".", "lastOffset", "(", ")", "+", "descriptor", ".", "index", "(", ")", "+", "skip", ":", "descriptor", ".", "inde...
Returns the index of the last entry in the segment. @return The index of the last entry in the segment or {@code 0} if the segment is empty. @throws IllegalStateException if the segment is not open
[ "Returns", "the", "index", "of", "the", "last", "entry", "in", "the", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L284-L287
102,701
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.checkRange
private void checkRange(long index) { Assert.indexNot(isEmpty(), "segment is empty"); Assert.indexNot(index < firstIndex(), index + " is less than the first index in the segment"); Assert.indexNot(index > lastIndex(), index + " is greater than the last index in the segment"); }
java
private void checkRange(long index) { Assert.indexNot(isEmpty(), "segment is empty"); Assert.indexNot(index < firstIndex(), index + " is less than the first index in the segment"); Assert.indexNot(index > lastIndex(), index + " is greater than the last index in the segment"); }
[ "private", "void", "checkRange", "(", "long", "index", ")", "{", "Assert", ".", "indexNot", "(", "isEmpty", "(", ")", ",", "\"segment is empty\"", ")", ";", "Assert", ".", "indexNot", "(", "index", "<", "firstIndex", "(", ")", ",", "index", "+", "\" is l...
Checks the range of the given index. @throws IndexOutOfBoundsException if the {@code index} is invalid for the segment
[ "Checks", "the", "range", "of", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L324-L328
102,702
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.append
public long append(Entry entry) { Assert.notNull(entry, "entry"); Assert.stateNot(isFull(), "segment is full"); long index = nextIndex(); Assert.index(index == entry.getIndex(), "inconsistent index: %s", entry.getIndex()); // Calculate the offset of the entry. long offset = relativeOffset(inde...
java
public long append(Entry entry) { Assert.notNull(entry, "entry"); Assert.stateNot(isFull(), "segment is full"); long index = nextIndex(); Assert.index(index == entry.getIndex(), "inconsistent index: %s", entry.getIndex()); // Calculate the offset of the entry. long offset = relativeOffset(inde...
[ "public", "long", "append", "(", "Entry", "entry", ")", "{", "Assert", ".", "notNull", "(", "entry", ",", "\"entry\"", ")", ";", "Assert", ".", "stateNot", "(", "isFull", "(", ")", ",", "\"segment is full\"", ")", ";", "long", "index", "=", "nextIndex", ...
Commits an entry to the segment. @throws NullPointerException if {@code entry} is null @throws IllegalStateException if the segment is full @throws IndexOutOfBoundsException if the {@code entry} index does not match the next index
[ "Commits", "an", "entry", "to", "the", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L337-L416
102,703
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.term
public long term(long index) { assertSegmentOpen(); checkRange(index); // Get the offset of the index within this segment. long offset = relativeOffset(index); // Look up the term for the offset in the term index. return termIndex.lookup(offset); }
java
public long term(long index) { assertSegmentOpen(); checkRange(index); // Get the offset of the index within this segment. long offset = relativeOffset(index); // Look up the term for the offset in the term index. return termIndex.lookup(offset); }
[ "public", "long", "term", "(", "long", "index", ")", "{", "assertSegmentOpen", "(", ")", ";", "checkRange", "(", "index", ")", ";", "// Get the offset of the index within this segment.", "long", "offset", "=", "relativeOffset", "(", "index", ")", ";", "// Look up ...
Reads the term for the entry at the given index. @param index The index for which to read the term. @return The term for the given index. @throws IllegalStateException if the segment is not open or {@code index} is inconsistent
[ "Reads", "the", "term", "for", "the", "entry", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L425-L434
102,704
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.get
public synchronized <T extends Entry> T get(long index) { assertSegmentOpen(); checkRange(index); // Get the offset of the index within this segment. long offset = relativeOffset(index); // Get the start position of the entry from the memory index. long position = offsetIndex.position(offset);...
java
public synchronized <T extends Entry> T get(long index) { assertSegmentOpen(); checkRange(index); // Get the offset of the index within this segment. long offset = relativeOffset(index); // Get the start position of the entry from the memory index. long position = offsetIndex.position(offset);...
[ "public", "synchronized", "<", "T", "extends", "Entry", ">", "T", "get", "(", "long", "index", ")", "{", "assertSegmentOpen", "(", ")", ";", "checkRange", "(", "index", ")", ";", "// Get the offset of the index within this segment.", "long", "offset", "=", "rela...
Reads the entry at the given index. @param index The index from which to read the entry. @return The entry at the given index. @throws IllegalStateException if the segment is not open or {@code index} is inconsistent with the entry
[ "Reads", "the", "entry", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L443-L493
102,705
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.contains
public boolean contains(long index) { assertSegmentOpen(); if (!validIndex(index)) return false; // Check the memory index first for performance reasons. long offset = relativeOffset(index); return offsetIndex.contains(offset); }
java
public boolean contains(long index) { assertSegmentOpen(); if (!validIndex(index)) return false; // Check the memory index first for performance reasons. long offset = relativeOffset(index); return offsetIndex.contains(offset); }
[ "public", "boolean", "contains", "(", "long", "index", ")", "{", "assertSegmentOpen", "(", ")", ";", "if", "(", "!", "validIndex", "(", "index", ")", ")", "return", "false", ";", "// Check the memory index first for performance reasons.", "long", "offset", "=", ...
Returns a boolean value indicating whether the entry at the given index is active. @param index The index to check. @return Indicates whether the entry at the given index is active. @throws IllegalStateException if the segment is not open
[ "Returns", "a", "boolean", "value", "indicating", "whether", "the", "entry", "at", "the", "given", "index", "is", "active", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L514-L523
102,706
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.release
public boolean release(long index) { assertSegmentOpen(); long offset = offsetIndex.find(relativeOffset(index)); return offset != -1 && offsetPredicate.release(offset); }
java
public boolean release(long index) { assertSegmentOpen(); long offset = offsetIndex.find(relativeOffset(index)); return offset != -1 && offsetPredicate.release(offset); }
[ "public", "boolean", "release", "(", "long", "index", ")", "{", "assertSegmentOpen", "(", ")", ";", "long", "offset", "=", "offsetIndex", ".", "find", "(", "relativeOffset", "(", "index", ")", ")", ";", "return", "offset", "!=", "-", "1", "&&", "offsetPr...
Releases an entry from the segment. @param index The index of the entry to release. @return Indicates whether the entry was newly released from the segment. @throws IllegalStateException if the segment is not open
[ "Releases", "an", "entry", "from", "the", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L532-L536
102,707
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Segment.java
Segment.truncate
public Segment truncate(long index) { assertSegmentOpen(); Assert.index(index >= manager.commitIndex(), "cannot truncate committed index"); long offset = relativeOffset(index); long lastOffset = offsetIndex.lastOffset(); long diff = Math.abs(lastOffset - offset); skip = Math.max(skip - diff, 0...
java
public Segment truncate(long index) { assertSegmentOpen(); Assert.index(index >= manager.commitIndex(), "cannot truncate committed index"); long offset = relativeOffset(index); long lastOffset = offsetIndex.lastOffset(); long diff = Math.abs(lastOffset - offset); skip = Math.max(skip - diff, 0...
[ "public", "Segment", "truncate", "(", "long", "index", ")", "{", "assertSegmentOpen", "(", ")", ";", "Assert", ".", "index", "(", "index", ">=", "manager", ".", "commitIndex", "(", ")", ",", "\"cannot truncate committed index\"", ")", ";", "long", "offset", ...
Truncates entries after the given index. @param index The index after which to remove entries. @return The segment. @throws IllegalStateException if the segment is not open
[ "Truncates", "entries", "after", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L590-L608
102,708
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java
ServerStateMachineContext.update
void update(long index, Instant instant, Type type) { this.index = index; this.type = type; clock.set(instant); }
java
void update(long index, Instant instant, Type type) { this.index = index; this.type = type; clock.set(instant); }
[ "void", "update", "(", "long", "index", ",", "Instant", "instant", ",", "Type", "type", ")", "{", "this", ".", "index", "=", "index", ";", "this", ".", "type", "=", "type", ";", "clock", ".", "set", "(", "instant", ")", ";", "}" ]
Updates the state machine context.
[ "Updates", "the", "state", "machine", "context", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java#L53-L57
102,709
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java
ServerStateMachineContext.commit
void commit() { long index = this.index; for (ServerSessionContext session : sessions.sessions.values()) { session.commit(index); } }
java
void commit() { long index = this.index; for (ServerSessionContext session : sessions.sessions.values()) { session.commit(index); } }
[ "void", "commit", "(", ")", "{", "long", "index", "=", "this", ".", "index", ";", "for", "(", "ServerSessionContext", "session", ":", "sessions", ".", "sessions", ".", "values", "(", ")", ")", "{", "session", ".", "commit", "(", "index", ")", ";", "}...
Commits the state machine index.
[ "Commits", "the", "state", "machine", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java#L62-L67
102,710
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.onStateChange
public Listener<CopycatServer.State> onStateChange(Consumer<CopycatServer.State> listener) { return stateChangeListeners.add(listener); }
java
public Listener<CopycatServer.State> onStateChange(Consumer<CopycatServer.State> listener) { return stateChangeListeners.add(listener); }
[ "public", "Listener", "<", "CopycatServer", ".", "State", ">", "onStateChange", "(", "Consumer", "<", "CopycatServer", ".", "State", ">", "listener", ")", "{", "return", "stateChangeListeners", ".", "add", "(", "listener", ")", ";", "}" ]
Registers a state change listener. @param listener The state change listener. @return The listener context.
[ "Registers", "a", "state", "change", "listener", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L112-L114
102,711
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.setGlobalIndex
ServerContext setGlobalIndex(long globalIndex) { Assert.argNot(globalIndex < 0, "global index must be positive"); this.globalIndex = Math.max(this.globalIndex, globalIndex); log.compactor().majorIndex(this.globalIndex - 1); return this; }
java
ServerContext setGlobalIndex(long globalIndex) { Assert.argNot(globalIndex < 0, "global index must be positive"); this.globalIndex = Math.max(this.globalIndex, globalIndex); log.compactor().majorIndex(this.globalIndex - 1); return this; }
[ "ServerContext", "setGlobalIndex", "(", "long", "globalIndex", ")", "{", "Assert", ".", "argNot", "(", "globalIndex", "<", "0", ",", "\"global index must be positive\"", ")", ";", "this", ".", "globalIndex", "=", "Math", ".", "max", "(", "this", ".", "globalIn...
Sets the global index. @param globalIndex The global index. @return The Raft context.
[ "Sets", "the", "global", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L396-L401
102,712
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.reset
ServerContext reset() { // Delete the existing log. if (log != null) { log.close(); storage.deleteLog(name); } // Delete the existing snapshot store. if (snapshot != null) { snapshot.close(); storage.deleteSnapshotStore(name); } // Open the log. log = storage.op...
java
ServerContext reset() { // Delete the existing log. if (log != null) { log.close(); storage.deleteLog(name); } // Delete the existing snapshot store. if (snapshot != null) { snapshot.close(); storage.deleteSnapshotStore(name); } // Open the log. log = storage.op...
[ "ServerContext", "reset", "(", ")", "{", "// Delete the existing log.", "if", "(", "log", "!=", "null", ")", "{", "log", ".", "close", "(", ")", ";", "storage", ".", "deleteLog", "(", "name", ")", ";", "}", "// Delete the existing snapshot store.", "if", "("...
Resets the state log. @return The server context.
[ "Resets", "the", "state", "log", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L462-L495
102,713
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.connectClient
public void connectClient(Connection connection) { threadContext.checkThread(); // Note we do not use method references here because the "state" variable changes over time. // We have to use lambdas to ensure the request handler points to the current state. connection.handler(RegisterRequest.class, (Fu...
java
public void connectClient(Connection connection) { threadContext.checkThread(); // Note we do not use method references here because the "state" variable changes over time. // We have to use lambdas to ensure the request handler points to the current state. connection.handler(RegisterRequest.class, (Fu...
[ "public", "void", "connectClient", "(", "Connection", "connection", ")", "{", "threadContext", ".", "checkThread", "(", ")", ";", "// Note we do not use method references here because the \"state\" variable changes over time.", "// We have to use lambdas to ensure the request handler p...
Handles a connection from a client.
[ "Handles", "a", "connection", "from", "a", "client", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L516-L530
102,714
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.connectServer
public void connectServer(Connection connection) { threadContext.checkThread(); // Handlers for all request types are registered since requests can be proxied between servers. // Note we do not use method references here because the "state" variable changes over time. // We have to use lambdas to ensur...
java
public void connectServer(Connection connection) { threadContext.checkThread(); // Handlers for all request types are registered since requests can be proxied between servers. // Note we do not use method references here because the "state" variable changes over time. // We have to use lambdas to ensur...
[ "public", "void", "connectServer", "(", "Connection", "connection", ")", "{", "threadContext", ".", "checkThread", "(", ")", ";", "// Handlers for all request types are registered since requests can be proxied between servers.", "// Note we do not use method references here because the...
Handles a connection from another server.
[ "Handles", "a", "connection", "from", "another", "server", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L535-L558
102,715
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerContext.java
ServerContext.delete
public void delete() { // Delete the log. storage.deleteLog(name); // Delete the snapshot store. storage.deleteSnapshotStore(name); // Delete the metadata store. storage.deleteMetaStore(name); }
java
public void delete() { // Delete the log. storage.deleteLog(name); // Delete the snapshot store. storage.deleteSnapshotStore(name); // Delete the metadata store. storage.deleteMetaStore(name); }
[ "public", "void", "delete", "(", ")", "{", "// Delete the log.", "storage", ".", "deleteLog", "(", "name", ")", ";", "// Delete the snapshot store.", "storage", ".", "deleteSnapshotStore", "(", "name", ")", ";", "// Delete the metadata store.", "storage", ".", "dele...
Deletes the server context.
[ "Deletes", "the", "server", "context", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L661-L670
102,716
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java
ConnectionManager.getConnection
public CompletableFuture<Connection> getConnection(Address address) { Connection connection = connections.get(address); return connection == null ? createConnection(address) : CompletableFuture.completedFuture(connection); }
java
public CompletableFuture<Connection> getConnection(Address address) { Connection connection = connections.get(address); return connection == null ? createConnection(address) : CompletableFuture.completedFuture(connection); }
[ "public", "CompletableFuture", "<", "Connection", ">", "getConnection", "(", "Address", "address", ")", "{", "Connection", "connection", "=", "connections", ".", "get", "(", "address", ")", ";", "return", "connection", "==", "null", "?", "createConnection", "(",...
Returns the connection for the given member. @param address The member for which to get the connection. @return A completable future to be called once the connection is received.
[ "Returns", "the", "connection", "for", "the", "given", "member", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L46-L49
102,717
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java
ConnectionManager.resetConnection
public void resetConnection(Address address) { Connection connection = connections.remove(address); if (connection != null) { connection.close(); } }
java
public void resetConnection(Address address) { Connection connection = connections.remove(address); if (connection != null) { connection.close(); } }
[ "public", "void", "resetConnection", "(", "Address", "address", ")", "{", "Connection", "connection", "=", "connections", ".", "remove", "(", "address", ")", ";", "if", "(", "connection", "!=", "null", ")", "{", "connection", ".", "close", "(", ")", ";", ...
Resets the connection to the given address. @param address The address for which to reset the connection.
[ "Resets", "the", "connection", "to", "the", "given", "address", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L56-L61
102,718
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java
ConnectionManager.createConnection
private CompletableFuture<Connection> createConnection(Address address) { return connectionFutures.computeIfAbsent(address, a -> { CompletableFuture<Connection> future = client.connect(address).thenApply(connection -> { connection.onClose(c -> connections.remove(address, c)); connections.put(a...
java
private CompletableFuture<Connection> createConnection(Address address) { return connectionFutures.computeIfAbsent(address, a -> { CompletableFuture<Connection> future = client.connect(address).thenApply(connection -> { connection.onClose(c -> connections.remove(address, c)); connections.put(a...
[ "private", "CompletableFuture", "<", "Connection", ">", "createConnection", "(", "Address", "address", ")", "{", "return", "connectionFutures", ".", "computeIfAbsent", "(", "address", ",", "a", "->", "{", "CompletableFuture", "<", "Connection", ">", "future", "=",...
Creates a connection for the given member. @param address The member for which to create the connection. @return A completable future to be called once the connection has been created.
[ "Creates", "a", "connection", "for", "the", "given", "member", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L69-L79
102,719
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java
ConnectionManager.close
public CompletableFuture<Void> close() { CompletableFuture[] futures = new CompletableFuture[connections.size()]; for (CompletableFuture<Connection> future : this.connectionFutures.values()) { future.cancel(false); } int i = 0; for (Connection connection : connections.values()) { futur...
java
public CompletableFuture<Void> close() { CompletableFuture[] futures = new CompletableFuture[connections.size()]; for (CompletableFuture<Connection> future : this.connectionFutures.values()) { future.cancel(false); } int i = 0; for (Connection connection : connections.values()) { futur...
[ "public", "CompletableFuture", "<", "Void", ">", "close", "(", ")", "{", "CompletableFuture", "[", "]", "futures", "=", "new", "CompletableFuture", "[", "connections", ".", "size", "(", ")", "]", ";", "for", "(", "CompletableFuture", "<", "Connection", ">", ...
Closes the connection manager. @return A completable future to be completed once the connection manager is closed.
[ "Closes", "the", "connection", "manager", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L86-L99
102,720
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java
MinorCompactionTask.compactEntries
private void compactEntries(Segment segment, Segment compactSegment) { for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) { checkEntry(i, segment, compactSegment); } }
java
private void compactEntries(Segment segment, Segment compactSegment) { for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) { checkEntry(i, segment, compactSegment); } }
[ "private", "void", "compactEntries", "(", "Segment", "segment", ",", "Segment", "compactSegment", ")", "{", "for", "(", "long", "i", "=", "segment", ".", "firstIndex", "(", ")", ";", "i", "<=", "segment", ".", "lastIndex", "(", ")", ";", "i", "++", ")"...
Compacts entries from the given segment, rewriting them to the compact segment. @param segment The segment to compact. @param compactSegment The compact segment.
[ "Compacts", "entries", "from", "the", "given", "segment", "rewriting", "them", "to", "the", "compact", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L99-L103
102,721
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java
MinorCompactionTask.checkEntry
private void checkEntry(long index, Segment segment, Segment compactSegment) { try (Entry entry = segment.get(index)) { // If an entry was found, only remove the entry from the segment if it's not a tombstone that has been released. if (entry != null) { checkEntry(index, entry, segment, compactS...
java
private void checkEntry(long index, Segment segment, Segment compactSegment) { try (Entry entry = segment.get(index)) { // If an entry was found, only remove the entry from the segment if it's not a tombstone that has been released. if (entry != null) { checkEntry(index, entry, segment, compactS...
[ "private", "void", "checkEntry", "(", "long", "index", ",", "Segment", "segment", ",", "Segment", "compactSegment", ")", "{", "try", "(", "Entry", "entry", "=", "segment", ".", "get", "(", "index", ")", ")", "{", "// If an entry was found, only remove the entry ...
Compacts the entry at the given index. @param index The index at which to compact the entry. @param segment The segment to compact. @param compactSegment The segment to which to write the compacted segment.
[ "Compacts", "the", "entry", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L112-L121
102,722
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java
MinorCompactionTask.checkEntry
private void checkEntry(long index, Entry entry, Segment segment, Segment compactSegment) { // Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction // mode to the entry. Compaction.Mode mode = entry.getCompactionMode(); if (mode == Compaction.Mode.DEFAULT) { ...
java
private void checkEntry(long index, Entry entry, Segment segment, Segment compactSegment) { // Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction // mode to the entry. Compaction.Mode mode = entry.getCompactionMode(); if (mode == Compaction.Mode.DEFAULT) { ...
[ "private", "void", "checkEntry", "(", "long", "index", ",", "Entry", "entry", ",", "Segment", "segment", ",", "Segment", "compactSegment", ")", "{", "// Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction", "// mode to the entry.", "Com...
Compacts a command entry from a segment.
[ "Compacts", "a", "command", "entry", "from", "a", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L126-L175
102,723
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java
MinorCompactionTask.transferEntry
private void transferEntry(long index, Entry entry, Segment compactSegment) { compactSegment.append(entry); // If the entry was released in the prior segment, mark it as released in the compact segment. if (!segment.isLive(index)) { compactSegment.release(index); } }
java
private void transferEntry(long index, Entry entry, Segment compactSegment) { compactSegment.append(entry); // If the entry was released in the prior segment, mark it as released in the compact segment. if (!segment.isLive(index)) { compactSegment.release(index); } }
[ "private", "void", "transferEntry", "(", "long", "index", ",", "Entry", "entry", ",", "Segment", "compactSegment", ")", "{", "compactSegment", ".", "append", "(", "entry", ")", ";", "// If the entry was released in the prior segment, mark it as released in the compact segme...
Transfers an entry to the given compact segment.
[ "Transfers", "an", "entry", "to", "the", "given", "compact", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L188-L195
102,724
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java
MinorCompactionTask.mergeReleasedEntries
private void mergeReleasedEntries(Segment segment, Segment compactSegment) { for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) { if (!segment.isLive(i)) { compactSegment.release(i); } } }
java
private void mergeReleasedEntries(Segment segment, Segment compactSegment) { for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) { if (!segment.isLive(i)) { compactSegment.release(i); } } }
[ "private", "void", "mergeReleasedEntries", "(", "Segment", "segment", ",", "Segment", "compactSegment", ")", "{", "for", "(", "long", "i", "=", "segment", ".", "firstIndex", "(", ")", ";", "i", "<=", "segment", ".", "lastIndex", "(", ")", ";", "i", "++",...
Updates the new compact segment with entries that were released from the given segment during compaction.
[ "Updates", "the", "new", "compact", "segment", "with", "entries", "that", "were", "released", "from", "the", "given", "segment", "during", "compaction", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L200-L206
102,725
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java
SnapshotStore.open
private void open() { for (Snapshot snapshot : loadSnapshots()) { snapshots.put(snapshot.index(), snapshot); } if (!snapshots.isEmpty()) { currentSnapshot = snapshots.lastEntry().getValue(); } }
java
private void open() { for (Snapshot snapshot : loadSnapshots()) { snapshots.put(snapshot.index(), snapshot); } if (!snapshots.isEmpty()) { currentSnapshot = snapshots.lastEntry().getValue(); } }
[ "private", "void", "open", "(", ")", "{", "for", "(", "Snapshot", "snapshot", ":", "loadSnapshots", "(", ")", ")", "{", "snapshots", ".", "put", "(", "snapshot", ".", "index", "(", ")", ",", "snapshot", ")", ";", "}", "if", "(", "!", "snapshots", "...
Opens the snapshot manager.
[ "Opens", "the", "snapshot", "manager", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java#L91-L99
102,726
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java
SnapshotStore.createMemorySnapshot
private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) { HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE); Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this); LOGGER.debug("Created memory snapshot: {}", snapshot); return snap...
java
private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) { HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE); Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this); LOGGER.debug("Created memory snapshot: {}", snapshot); return snap...
[ "private", "Snapshot", "createMemorySnapshot", "(", "SnapshotDescriptor", "descriptor", ")", "{", "HeapBuffer", "buffer", "=", "HeapBuffer", ".", "allocate", "(", "SnapshotDescriptor", ".", "BYTES", ",", "Integer", ".", "MAX_VALUE", ")", ";", "Snapshot", "snapshot",...
Creates a memory snapshot.
[ "Creates", "a", "memory", "snapshot", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java#L212-L217
102,727
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.getPrevEntry
@SuppressWarnings("unused") protected Entry getPrevEntry(MemberState member) { long prevIndex = Math.min(member.getNextIndex() - 1, context.getLog().lastIndex()); while (prevIndex > 0) { Entry entry = context.getLog().get(prevIndex); if (entry != null) { return entry; } prevInd...
java
@SuppressWarnings("unused") protected Entry getPrevEntry(MemberState member) { long prevIndex = Math.min(member.getNextIndex() - 1, context.getLog().lastIndex()); while (prevIndex > 0) { Entry entry = context.getLog().get(prevIndex); if (entry != null) { return entry; } prevInd...
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "protected", "Entry", "getPrevEntry", "(", "MemberState", "member", ")", "{", "long", "prevIndex", "=", "Math", ".", "min", "(", "member", ".", "getNextIndex", "(", ")", "-", "1", ",", "context", ".", "getLo...
Gets the previous entry.
[ "Gets", "the", "previous", "entry", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L152-L163
102,728
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.sendAppendRequest
protected void sendAppendRequest(Connection connection, MemberState member, AppendRequest request) { long timestamp = System.nanoTime(); logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().address()); connection.<AppendRequest, AppendResponse>sendAndRe...
java
protected void sendAppendRequest(Connection connection, MemberState member, AppendRequest request) { long timestamp = System.nanoTime(); logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().address()); connection.<AppendRequest, AppendResponse>sendAndRe...
[ "protected", "void", "sendAppendRequest", "(", "Connection", "connection", ",", "MemberState", "member", ",", "AppendRequest", "request", ")", "{", "long", "timestamp", "=", "System", ".", "nanoTime", "(", ")", ";", "logger", ".", "trace", "(", "\"{} - Sending {...
Sends a commit message.
[ "Sends", "a", "commit", "message", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L192-L220
102,729
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.updateNextIndex
protected void updateNextIndex(MemberState member, AppendRequest request) { // If the match index was set, update the next index to be greater than the match index if necessary. if (!request.entries().isEmpty()) { member.setNextIndex(request.entries().get(request.entries().size()-1).getIndex()+1); } ...
java
protected void updateNextIndex(MemberState member, AppendRequest request) { // If the match index was set, update the next index to be greater than the match index if necessary. if (!request.entries().isEmpty()) { member.setNextIndex(request.entries().get(request.entries().size()-1).getIndex()+1); } ...
[ "protected", "void", "updateNextIndex", "(", "MemberState", "member", ",", "AppendRequest", "request", ")", "{", "// If the match index was set, update the next index to be greater than the match index if necessary.", "if", "(", "!", "request", ".", "entries", "(", ")", ".", ...
Updates the next index when the match index is updated.
[ "Updates", "the", "next", "index", "when", "the", "match", "index", "is", "updated", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L336-L341
102,730
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.sendConfigureRequest
protected void sendConfigureRequest(Connection connection, MemberState member, ConfigureRequest request) { logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress()); connection.<ConfigureRequest, ConfigureResponse>sendAndReceive(request).whenComp...
java
protected void sendConfigureRequest(Connection connection, MemberState member, ConfigureRequest request) { logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress()); connection.<ConfigureRequest, ConfigureResponse>sendAndReceive(request).whenComp...
[ "protected", "void", "sendConfigureRequest", "(", "Connection", "connection", ",", "MemberState", "member", ",", "ConfigureRequest", "request", ")", "{", "logger", ".", "trace", "(", "\"{} - Sending {} to {}\"", ",", "context", ".", "getCluster", "(", ")", ".", "m...
Sends a configuration message.
[ "Sends", "a", "configuration", "message", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L406-L424
102,731
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.sendInstallRequest
protected void sendInstallRequest(Connection connection, MemberState member, InstallRequest request) { logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress()); connection.<InstallRequest, InstallResponse>sendAndReceive(request).whenComplete((re...
java
protected void sendInstallRequest(Connection connection, MemberState member, InstallRequest request) { logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress()); connection.<InstallRequest, InstallResponse>sendAndReceive(request).whenComplete((re...
[ "protected", "void", "sendInstallRequest", "(", "Connection", "connection", ",", "MemberState", "member", ",", "InstallRequest", "request", ")", "{", "logger", ".", "trace", "(", "\"{} - Sending {} to {}\"", ",", "context", ".", "getCluster", "(", ")", ".", "membe...
Sends a snapshot message.
[ "Sends", "a", "snapshot", "message", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L539-L559
102,732
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.handleInstallRequestFailure
protected void handleInstallRequestFailure(MemberState member, InstallRequest request, Throwable error) { // Log the failed attempt to contact the member. failAttempt(member, error); }
java
protected void handleInstallRequestFailure(MemberState member, InstallRequest request, Throwable error) { // Log the failed attempt to contact the member. failAttempt(member, error); }
[ "protected", "void", "handleInstallRequestFailure", "(", "MemberState", "member", ",", "InstallRequest", "request", ",", "Throwable", "error", ")", "{", "// Log the failed attempt to contact the member.", "failAttempt", "(", "member", ",", "error", ")", ";", "}" ]
Handles an install request failure.
[ "Handles", "an", "install", "request", "failure", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L564-L567
102,733
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java
AbstractAppender.handleInstallResponseFailure
protected void handleInstallResponseFailure(MemberState member, InstallRequest request, Throwable error) { // Reset the member's snapshot index and offset to resend the snapshot from the start // once a connection to the member is re-established. member.setNextSnapshotIndex(0).setNextSnapshotOffset(0); ...
java
protected void handleInstallResponseFailure(MemberState member, InstallRequest request, Throwable error) { // Reset the member's snapshot index and offset to resend the snapshot from the start // once a connection to the member is re-established. member.setNextSnapshotIndex(0).setNextSnapshotOffset(0); ...
[ "protected", "void", "handleInstallResponseFailure", "(", "MemberState", "member", ",", "InstallRequest", "request", ",", "Throwable", "error", ")", "{", "// Reset the member's snapshot index and offset to resend the snapshot from the start", "// once a connection to the member is re-e...
Handles an install response failure.
[ "Handles", "an", "install", "response", "failure", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L572-L579
102,734
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java
EntryBuffer.append
public EntryBuffer append(Entry entry) { int offset = offset(entry.getIndex()); Entry oldEntry = buffer[offset]; buffer[offset] = entry.acquire(); if (oldEntry != null) { oldEntry.release(); } return this; }
java
public EntryBuffer append(Entry entry) { int offset = offset(entry.getIndex()); Entry oldEntry = buffer[offset]; buffer[offset] = entry.acquire(); if (oldEntry != null) { oldEntry.release(); } return this; }
[ "public", "EntryBuffer", "append", "(", "Entry", "entry", ")", "{", "int", "offset", "=", "offset", "(", "entry", ".", "getIndex", "(", ")", ")", ";", "Entry", "oldEntry", "=", "buffer", "[", "offset", "]", ";", "buffer", "[", "offset", "]", "=", "en...
Appends an entry to the buffer. @param entry The entry to append. @return The entry buffer.
[ "Appends", "an", "entry", "to", "the", "buffer", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L38-L46
102,735
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java
EntryBuffer.get
@SuppressWarnings("unchecked") public <T extends Entry> T get(long index) { Entry entry = buffer[offset(index)]; return entry != null && entry.getIndex() == index ? (T) entry.acquire() : null; }
java
@SuppressWarnings("unchecked") public <T extends Entry> T get(long index) { Entry entry = buffer[offset(index)]; return entry != null && entry.getIndex() == index ? (T) entry.acquire() : null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", "extends", "Entry", ">", "T", "get", "(", "long", "index", ")", "{", "Entry", "entry", "=", "buffer", "[", "offset", "(", "index", ")", "]", ";", "return", "entry", "!=", "null", ...
Looks up an entry in the buffer. @param index The entry index. @param <T> The entry type. @return The entry or {@code null} if the entry is not present in the index.
[ "Looks", "up", "an", "entry", "in", "the", "buffer", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L55-L59
102,736
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java
EntryBuffer.clear
public EntryBuffer clear() { for (int i = 0; i < buffer.length; i++) { buffer[i] = null; } return this; }
java
public EntryBuffer clear() { for (int i = 0; i < buffer.length; i++) { buffer[i] = null; } return this; }
[ "public", "EntryBuffer", "clear", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "buffer", ".", "length", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "null", ";", "}", "return", "this", ";", "}" ]
Clears the buffer and resets the index to the given index. @return The entry buffer.
[ "Clears", "the", "buffer", "and", "resets", "the", "index", "to", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L66-L71
102,737
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java
EntryBuffer.offset
private int offset(long index) { int offset = (int) (index % buffer.length); if (offset < 0) { offset += buffer.length; } return offset; }
java
private int offset(long index) { int offset = (int) (index % buffer.length); if (offset < 0) { offset += buffer.length; } return offset; }
[ "private", "int", "offset", "(", "long", "index", ")", "{", "int", "offset", "=", "(", "int", ")", "(", "index", "%", "buffer", ".", "length", ")", ";", "if", "(", "offset", "<", "0", ")", "{", "offset", "+=", "buffer", ".", "length", ";", "}", ...
Returns the buffer index for the given offset.
[ "Returns", "the", "buffer", "index", "for", "the", "given", "offset", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L76-L82
102,738
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSessionState.java
ClientSessionState.onStateChange
public Listener<Session.State> onStateChange(Consumer<Session.State> callback) { Listener<Session.State> listener = new Listener<Session.State>() { @Override public void accept(Session.State state) { callback.accept(state); } @Override public void close() { changeListen...
java
public Listener<Session.State> onStateChange(Consumer<Session.State> callback) { Listener<Session.State> listener = new Listener<Session.State>() { @Override public void accept(Session.State state) { callback.accept(state); } @Override public void close() { changeListen...
[ "public", "Listener", "<", "Session", ".", "State", ">", "onStateChange", "(", "Consumer", "<", "Session", ".", "State", ">", "callback", ")", "{", "Listener", "<", "Session", ".", "State", ">", "listener", "=", "new", "Listener", "<", "Session", ".", "S...
Registers a state change listener on the session manager. @param callback The state change listener callback. @return The state change listener.
[ "Registers", "a", "state", "change", "listener", "on", "the", "session", "manager", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSessionState.java#L142-L155
102,739
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java
TermIndex.term
public synchronized long term() { Map.Entry<Long, Long> entry = terms.lastEntry(); return entry != null ? entry.getValue() : 0; }
java
public synchronized long term() { Map.Entry<Long, Long> entry = terms.lastEntry(); return entry != null ? entry.getValue() : 0; }
[ "public", "synchronized", "long", "term", "(", ")", "{", "Map", ".", "Entry", "<", "Long", ",", "Long", ">", "entry", "=", "terms", ".", "lastEntry", "(", ")", ";", "return", "entry", "!=", "null", "?", "entry", ".", "getValue", "(", ")", ":", "0",...
Returns the highest term in the index. @return The highest term in the index.
[ "Returns", "the", "highest", "term", "in", "the", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L45-L48
102,740
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java
TermIndex.index
public synchronized void index(long offset, long term) { if (lookup(offset) != term) { terms.put(offset, term); } }
java
public synchronized void index(long offset, long term) { if (lookup(offset) != term) { terms.put(offset, term); } }
[ "public", "synchronized", "void", "index", "(", "long", "offset", ",", "long", "term", ")", "{", "if", "(", "lookup", "(", "offset", ")", "!=", "term", ")", "{", "terms", ".", "put", "(", "offset", ",", "term", ")", ";", "}", "}" ]
Indexes the given offset with the given term. @param offset The offset to index. @param term The term to index.
[ "Indexes", "the", "given", "offset", "with", "the", "given", "term", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L56-L60
102,741
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java
TermIndex.lookup
public synchronized long lookup(long offset) { Map.Entry<Long, Long> entry = terms.floorEntry(offset); return entry != null ? entry.getValue() : 0; }
java
public synchronized long lookup(long offset) { Map.Entry<Long, Long> entry = terms.floorEntry(offset); return entry != null ? entry.getValue() : 0; }
[ "public", "synchronized", "long", "lookup", "(", "long", "offset", ")", "{", "Map", ".", "Entry", "<", "Long", ",", "Long", ">", "entry", "=", "terms", ".", "floorEntry", "(", "offset", ")", ";", "return", "entry", "!=", "null", "?", "entry", ".", "g...
Looks up the term for the given offset. @param offset The offset for which to look up the term. @return The term for the entry at the given offset.
[ "Looks", "up", "the", "term", "for", "the", "given", "offset", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L68-L71
102,742
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/util/OffsetPredicate.java
OffsetPredicate.release
public boolean release(long offset) { Assert.argNot(offset < 0, "offset must be positive"); if (bits.size() <= offset) { while (bits.size() <= offset) { bits.resize(bits.size() * 2); } } return bits.set(offset); }
java
public boolean release(long offset) { Assert.argNot(offset < 0, "offset must be positive"); if (bits.size() <= offset) { while (bits.size() <= offset) { bits.resize(bits.size() * 2); } } return bits.set(offset); }
[ "public", "boolean", "release", "(", "long", "offset", ")", "{", "Assert", ".", "argNot", "(", "offset", "<", "0", ",", "\"offset must be positive\"", ")", ";", "if", "(", "bits", ".", "size", "(", ")", "<=", "offset", ")", "{", "while", "(", "bits", ...
Releases an offset from the segment. @param offset The offset to release. @return Indicates whether the offset was newly released.
[ "Releases", "an", "offset", "from", "the", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/OffsetPredicate.java#L62-L70
102,743
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSession.java
ClientSession.submit
public <T> CompletableFuture<T> submit(Operation<T> operation) { if (operation instanceof Query) { return submit((Query<T>) operation); } else if (operation instanceof Command) { return submit((Command<T>) operation); } else { throw new UnsupportedOperationException("unknown operation type...
java
public <T> CompletableFuture<T> submit(Operation<T> operation) { if (operation instanceof Query) { return submit((Query<T>) operation); } else if (operation instanceof Command) { return submit((Command<T>) operation); } else { throw new UnsupportedOperationException("unknown operation type...
[ "public", "<", "T", ">", "CompletableFuture", "<", "T", ">", "submit", "(", "Operation", "<", "T", ">", "operation", ")", "{", "if", "(", "operation", "instanceof", "Query", ")", "{", "return", "submit", "(", "(", "Query", "<", "T", ">", ")", "operat...
Submits an operation to the session. @param operation The operation to submit. @param <T> The operation result type. @return A completable future to be completed with the operation result.
[ "Submits", "an", "operation", "to", "the", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L97-L105
102,744
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSession.java
ClientSession.submit
public <T> CompletableFuture<T> submit(Command<T> command) { State state = state(); if (state == State.CLOSED || state == State.EXPIRED) { return Futures.exceptionalFuture(new ClosedSessionException("session closed")); } return submitter.submit(command); }
java
public <T> CompletableFuture<T> submit(Command<T> command) { State state = state(); if (state == State.CLOSED || state == State.EXPIRED) { return Futures.exceptionalFuture(new ClosedSessionException("session closed")); } return submitter.submit(command); }
[ "public", "<", "T", ">", "CompletableFuture", "<", "T", ">", "submit", "(", "Command", "<", "T", ">", "command", ")", "{", "State", "state", "=", "state", "(", ")", ";", "if", "(", "state", "==", "State", ".", "CLOSED", "||", "state", "==", "State"...
Submits a command to the session. @param command The command to submit. @param <T> The command result type. @return A completable future to be completed with the command result.
[ "Submits", "a", "command", "to", "the", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L114-L120
102,745
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSession.java
ClientSession.submit
public <T> CompletableFuture<T> submit(Query<T> query) { State state = state(); if (state == State.CLOSED || state == State.EXPIRED) { return Futures.exceptionalFuture(new ClosedSessionException("session closed")); } return submitter.submit(query); }
java
public <T> CompletableFuture<T> submit(Query<T> query) { State state = state(); if (state == State.CLOSED || state == State.EXPIRED) { return Futures.exceptionalFuture(new ClosedSessionException("session closed")); } return submitter.submit(query); }
[ "public", "<", "T", ">", "CompletableFuture", "<", "T", ">", "submit", "(", "Query", "<", "T", ">", "query", ")", "{", "State", "state", "=", "state", "(", ")", ";", "if", "(", "state", "==", "State", ".", "CLOSED", "||", "state", "==", "State", ...
Submits a query to the session. @param query The query to submit. @param <T> The query result type. @return A completable future to be completed with the query result.
[ "Submits", "a", "query", "to", "the", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L129-L135
102,746
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSession.java
ClientSession.kill
public CompletableFuture<Void> kill() { return submitter.close() .thenCompose(v -> listener.close()) .thenCompose(v -> manager.kill()) .thenCompose(v -> connection.close()); }
java
public CompletableFuture<Void> kill() { return submitter.close() .thenCompose(v -> listener.close()) .thenCompose(v -> manager.kill()) .thenCompose(v -> connection.close()); }
[ "public", "CompletableFuture", "<", "Void", ">", "kill", "(", ")", "{", "return", "submitter", ".", "close", "(", ")", ".", "thenCompose", "(", "v", "->", "listener", ".", "close", "(", ")", ")", ".", "thenCompose", "(", "v", "->", "manager", ".", "k...
Kills the session. @return A completable future to be completed once the session has been killed.
[ "Kills", "the", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L221-L226
102,747
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.calculateLastCompleted
private long calculateLastCompleted(long index) { // Calculate the last completed index as the lowest index acknowledged by all clients. long lastCompleted = index; for (ServerSessionContext session : executor.context().sessions().sessions.values()) { lastCompleted = Math.min(lastCompleted, session.ge...
java
private long calculateLastCompleted(long index) { // Calculate the last completed index as the lowest index acknowledged by all clients. long lastCompleted = index; for (ServerSessionContext session : executor.context().sessions().sessions.values()) { lastCompleted = Math.min(lastCompleted, session.ge...
[ "private", "long", "calculateLastCompleted", "(", "long", "index", ")", "{", "// Calculate the last completed index as the lowest index acknowledged by all clients.", "long", "lastCompleted", "=", "index", ";", "for", "(", "ServerSessionContext", "session", ":", "executor", "...
Calculates the last completed session event index.
[ "Calculates", "the", "last", "completed", "session", "event", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L238-L245
102,748
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.setLastCompleted
private void setLastCompleted(long lastCompleted) { if (!log.isOpen()) return; this.lastCompleted = Math.max(this.lastCompleted, lastCompleted); // Update the log compaction minor index. log.compactor().minorIndex(this.lastCompleted); completeSnapshot(); }
java
private void setLastCompleted(long lastCompleted) { if (!log.isOpen()) return; this.lastCompleted = Math.max(this.lastCompleted, lastCompleted); // Update the log compaction minor index. log.compactor().minorIndex(this.lastCompleted); completeSnapshot(); }
[ "private", "void", "setLastCompleted", "(", "long", "lastCompleted", ")", "{", "if", "(", "!", "log", ".", "isOpen", "(", ")", ")", "return", ";", "this", ".", "lastCompleted", "=", "Math", ".", "max", "(", "this", ".", "lastCompleted", ",", "lastComplet...
Updates the last completed event index based on a commit at the given index.
[ "Updates", "the", "last", "completed", "event", "index", "based", "on", "a", "commit", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L250-L260
102,749
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.keepAliveSession
private void keepAliveSession(long index, long timestamp, long commandSequence, long eventIndex, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); ...
java
private void keepAliveSession(long index, long timestamp, long commandSequence, long eventIndex, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); ...
[ "private", "void", "keepAliveSession", "(", "long", "index", ",", "long", "timestamp", ",", "long", "commandSequence", ",", "long", "eventIndex", ",", "ServerSessionContext", "session", ",", "CompletableFuture", "<", "Void", ">", "future", ",", "ThreadContext", "c...
Applies a keep alive for a session.
[ "Applies", "a", "keep", "alive", "for", "a", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L548-L580
102,750
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.sequenceCommand
private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); return; } Result result = session.ge...
java
private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); return; } Result result = session.ge...
[ "private", "void", "sequenceCommand", "(", "long", "sequence", ",", "ServerSessionContext", "session", ",", "CompletableFuture", "<", "Result", ">", "future", ",", "ThreadContext", "context", ")", "{", "if", "(", "!", "log", ".", "isOpen", "(", ")", ")", "{"...
Sequences a command according to the command sequence number.
[ "Sequences", "a", "command", "according", "to", "the", "command", "sequence", "number", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L817-L828
102,751
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.executeCommand
private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); ...
java
private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); ...
[ "private", "void", "executeCommand", "(", "long", "index", ",", "long", "sequence", ",", "long", "timestamp", ",", "ServerCommit", "commit", ",", "ServerSessionContext", "session", ",", "CompletableFuture", "<", "Result", ">", "future", ",", "ThreadContext", "cont...
Executes a state machine command.
[ "Executes", "a", "state", "machine", "command", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L833-L874
102,752
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
ServerStateMachine.executeQuery
private void executeQuery(ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); return; } // If the session is al...
java
private void executeQuery(ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) { if (!log.isOpen()) { context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed"))); return; } // If the session is al...
[ "private", "void", "executeQuery", "(", "ServerCommit", "commit", ",", "ServerSessionContext", "session", ",", "CompletableFuture", "<", "Result", ">", "future", ",", "ThreadContext", "context", ")", "{", "if", "(", "!", "log", ".", "isOpen", "(", ")", ")", ...
Executes a state machine query.
[ "Executes", "a", "state", "machine", "query", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L919-L945
102,753
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/LeaderState.java
LeaderState.query
private CompletableFuture<QueryResponse> query(QueryEntry entry) { Query.ConsistencyLevel consistency = entry.getQuery().consistency(); if (consistency == null) return queryLinearizable(entry); switch (consistency) { case SEQUENTIAL: return queryLocal(entry); case LINEARIZABLE_LEA...
java
private CompletableFuture<QueryResponse> query(QueryEntry entry) { Query.ConsistencyLevel consistency = entry.getQuery().consistency(); if (consistency == null) return queryLinearizable(entry); switch (consistency) { case SEQUENTIAL: return queryLocal(entry); case LINEARIZABLE_LEA...
[ "private", "CompletableFuture", "<", "QueryResponse", ">", "query", "(", "QueryEntry", "entry", ")", "{", "Query", ".", "ConsistencyLevel", "consistency", "=", "entry", ".", "getQuery", "(", ")", ".", "consistency", "(", ")", ";", "if", "(", "consistency", "...
Applies the given query entry to the state machine according to the query's consistency level.
[ "Applies", "the", "given", "query", "entry", "to", "the", "state", "machine", "according", "to", "the", "query", "s", "consistency", "level", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L567-L582
102,754
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/LeaderState.java
LeaderState.sequenceAndApply
private CompletableFuture<QueryResponse> sequenceAndApply(QueryEntry entry) { // Get the client's server session. If the session doesn't exist, return an unknown session error. ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession()); if (sessio...
java
private CompletableFuture<QueryResponse> sequenceAndApply(QueryEntry entry) { // Get the client's server session. If the session doesn't exist, return an unknown session error. ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession()); if (sessio...
[ "private", "CompletableFuture", "<", "QueryResponse", ">", "sequenceAndApply", "(", "QueryEntry", "entry", ")", "{", "// Get the client's server session. If the session doesn't exist, return an unknown session error.", "ServerSessionContext", "session", "=", "context", ".", "getSta...
Sequences and applies the given query entry.
[ "Sequences", "and", "applies", "the", "given", "query", "entry", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L613-L635
102,755
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/LeaderState.java
LeaderState.cancelAppendTimer
private void cancelAppendTimer() { if (appendTimer != null) { LOGGER.trace("{} - Cancelling append timer", context.getCluster().member().address()); appendTimer.cancel(); } }
java
private void cancelAppendTimer() { if (appendTimer != null) { LOGGER.trace("{} - Cancelling append timer", context.getCluster().member().address()); appendTimer.cancel(); } }
[ "private", "void", "cancelAppendTimer", "(", ")", "{", "if", "(", "appendTimer", "!=", "null", ")", "{", "LOGGER", ".", "trace", "(", "\"{} - Cancelling append timer\"", ",", "context", ".", "getCluster", "(", ")", ".", "member", "(", ")", ".", "address", ...
Cancels the append timer.
[ "Cancels", "the", "append", "timer", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L861-L866
102,756
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java
MajorCompactionManager.getCompactableGroups
public List<List<Segment>> getCompactableGroups(Storage storage, SegmentManager manager) { List<List<Segment>> compact = new ArrayList<>(); List<Segment> segments = null; for (Segment segment : getCompactableSegments(manager)) { // If this is the first segment in a segments list, add the segment. ...
java
public List<List<Segment>> getCompactableGroups(Storage storage, SegmentManager manager) { List<List<Segment>> compact = new ArrayList<>(); List<Segment> segments = null; for (Segment segment : getCompactableSegments(manager)) { // If this is the first segment in a segments list, add the segment. ...
[ "public", "List", "<", "List", "<", "Segment", ">", ">", "getCompactableGroups", "(", "Storage", "storage", ",", "SegmentManager", "manager", ")", "{", "List", "<", "List", "<", "Segment", ">>", "compact", "=", "new", "ArrayList", "<>", "(", ")", ";", "L...
Returns a list of segments lists to compact, where segments are grouped according to how they will be merged during compaction.
[ "Returns", "a", "list", "of", "segments", "lists", "to", "compact", "where", "segments", "are", "grouped", "according", "to", "how", "they", "will", "be", "merged", "during", "compaction", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java#L62-L89
102,757
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java
MajorCompactionManager.getCompactableSegments
private List<Segment> getCompactableSegments(SegmentManager manager) { List<Segment> segments = new ArrayList<>(manager.segments().size()); Iterator<Segment> iterator = manager.segments().iterator(); Segment segment = iterator.next(); while (iterator.hasNext()) { Segment nextSegment = iterator.nex...
java
private List<Segment> getCompactableSegments(SegmentManager manager) { List<Segment> segments = new ArrayList<>(manager.segments().size()); Iterator<Segment> iterator = manager.segments().iterator(); Segment segment = iterator.next(); while (iterator.hasNext()) { Segment nextSegment = iterator.nex...
[ "private", "List", "<", "Segment", ">", "getCompactableSegments", "(", "SegmentManager", "manager", ")", "{", "List", "<", "Segment", ">", "segments", "=", "new", "ArrayList", "<>", "(", "manager", ".", "segments", "(", ")", ".", "size", "(", ")", ")", "...
Returns a list of compactable log segments. @param manager The segment manager. @return A list of compactable log segments.
[ "Returns", "a", "list", "of", "compactable", "log", "segments", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java#L97-L116
102,758
atomix/copycat
client/src/main/java/io/atomix/copycat/client/session/ClientSessionSubmitter.java
ClientSessionSubmitter.close
public CompletableFuture<Void> close() { for (OperationAttempt attempt : new ArrayList<>(attempts.values())) { attempt.fail(new ClosedSessionException("session closed")); } attempts.clear(); return CompletableFuture.completedFuture(null); }
java
public CompletableFuture<Void> close() { for (OperationAttempt attempt : new ArrayList<>(attempts.values())) { attempt.fail(new ClosedSessionException("session closed")); } attempts.clear(); return CompletableFuture.completedFuture(null); }
[ "public", "CompletableFuture", "<", "Void", ">", "close", "(", ")", "{", "for", "(", "OperationAttempt", "attempt", ":", "new", "ArrayList", "<>", "(", "attempts", ".", "values", "(", ")", ")", ")", "{", "attempt", ".", "fail", "(", "new", "ClosedSession...
Closes the submitter. @return A completable future to be completed with a list of pending operations.
[ "Closes", "the", "submitter", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSessionSubmitter.java#L211-L217
102,759
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerMember.java
ServerMember.update
ServerMember update(Status status, Instant time) { if (this.status != status) { this.status = Assert.notNull(status, "status"); if (time.isAfter(updated)) { this.updated = Assert.notNull(time, "time"); } if (statusChangeListeners != null) { statusChangeListeners.accept(status...
java
ServerMember update(Status status, Instant time) { if (this.status != status) { this.status = Assert.notNull(status, "status"); if (time.isAfter(updated)) { this.updated = Assert.notNull(time, "time"); } if (statusChangeListeners != null) { statusChangeListeners.accept(status...
[ "ServerMember", "update", "(", "Status", "status", ",", "Instant", "time", ")", "{", "if", "(", "this", ".", "status", "!=", "status", ")", "{", "this", ".", "status", "=", "Assert", ".", "notNull", "(", "status", ",", "\"status\"", ")", ";", "if", "...
Updates the member status. @param status The member status. @return The member.
[ "Updates", "the", "member", "status", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerMember.java#L180-L191
102,760
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerMember.java
ServerMember.update
ServerMember update(Address clientAddress, Instant time) { if (clientAddress != null) { this.clientAddress = clientAddress; if (time.isAfter(updated)) { this.updated = Assert.notNull(time, "time"); } } return this; }
java
ServerMember update(Address clientAddress, Instant time) { if (clientAddress != null) { this.clientAddress = clientAddress; if (time.isAfter(updated)) { this.updated = Assert.notNull(time, "time"); } } return this; }
[ "ServerMember", "update", "(", "Address", "clientAddress", ",", "Instant", "time", ")", "{", "if", "(", "clientAddress", "!=", "null", ")", "{", "this", ".", "clientAddress", "=", "clientAddress", ";", "if", "(", "time", ".", "isAfter", "(", "updated", ")"...
Updates the member client address. @param clientAddress The member client address. @return The member.
[ "Updates", "the", "member", "client", "address", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerMember.java#L199-L207
102,761
atomix/copycat
examples/value-state-machine/src/main/java/io/atomix/copycat/examples/ValueStateMachine.java
ValueStateMachine.delete
private void delete(Commit<DeleteCommand> commit) { try { if (value != null) { value.close(); value = null; } } finally { commit.close(); } }
java
private void delete(Commit<DeleteCommand> commit) { try { if (value != null) { value.close(); value = null; } } finally { commit.close(); } }
[ "private", "void", "delete", "(", "Commit", "<", "DeleteCommand", ">", "commit", ")", "{", "try", "{", "if", "(", "value", "!=", "null", ")", "{", "value", ".", "close", "(", ")", ";", "value", "=", "null", ";", "}", "}", "finally", "{", "commit", ...
Deletes the value.
[ "Deletes", "the", "value", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/examples/value-state-machine/src/main/java/io/atomix/copycat/examples/ValueStateMachine.java#L70-L79
102,762
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.release
void release() { long references = --this.references; if (!state.active() && references == 0) { context.sessions().unregisterSession(id); log.release(id); if (closeIndex > 0) { log.release(closeIndex); } } }
java
void release() { long references = --this.references; if (!state.active() && references == 0) { context.sessions().unregisterSession(id); log.release(id); if (closeIndex > 0) { log.release(closeIndex); } } }
[ "void", "release", "(", ")", "{", "long", "references", "=", "--", "this", ".", "references", ";", "if", "(", "!", "state", ".", "active", "(", ")", "&&", "references", "==", "0", ")", "{", "context", ".", "sessions", "(", ")", ".", "unregisterSessio...
Releases a reference to the session.
[ "Releases", "a", "reference", "to", "the", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L131-L140
102,763
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.setKeepAliveIndex
ServerSessionContext setKeepAliveIndex(long keepAliveIndex) { long previousKeepAliveIndex = this.keepAliveIndex; this.keepAliveIndex = keepAliveIndex; if (previousKeepAliveIndex > 0) { log.release(previousKeepAliveIndex); } return this; }
java
ServerSessionContext setKeepAliveIndex(long keepAliveIndex) { long previousKeepAliveIndex = this.keepAliveIndex; this.keepAliveIndex = keepAliveIndex; if (previousKeepAliveIndex > 0) { log.release(previousKeepAliveIndex); } return this; }
[ "ServerSessionContext", "setKeepAliveIndex", "(", "long", "keepAliveIndex", ")", "{", "long", "previousKeepAliveIndex", "=", "this", ".", "keepAliveIndex", ";", "this", ".", "keepAliveIndex", "=", "keepAliveIndex", ";", "if", "(", "previousKeepAliveIndex", ">", "0", ...
Sets the current session keep alive index. @param keepAliveIndex The current session keep alive index. @return The server session.
[ "Sets", "the", "current", "session", "keep", "alive", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L195-L202
102,764
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.setRequestSequence
boolean setRequestSequence(long requestSequence) { if (requestSequence == this.requestSequence + 1) { this.requestSequence = requestSequence; return true; } else if (requestSequence <= this.requestSequence) { return true; } return false; }
java
boolean setRequestSequence(long requestSequence) { if (requestSequence == this.requestSequence + 1) { this.requestSequence = requestSequence; return true; } else if (requestSequence <= this.requestSequence) { return true; } return false; }
[ "boolean", "setRequestSequence", "(", "long", "requestSequence", ")", "{", "if", "(", "requestSequence", "==", "this", ".", "requestSequence", "+", "1", ")", "{", "this", ".", "requestSequence", "=", "requestSequence", ";", "return", "true", ";", "}", "else", ...
Checks and sets the current request sequence number. @param requestSequence The request sequence number to set. @return Indicates whether the given {@code requestSequence} number is the next sequence number.
[ "Checks", "and", "sets", "the", "current", "request", "sequence", "number", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L219-L227
102,765
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.resendEvents
ServerSessionContext resendEvents(long index) { clearEvents(index); for (EventHolder event : events) { sendEvent(event); } return this; }
java
ServerSessionContext resendEvents(long index) { clearEvents(index); for (EventHolder event : events) { sendEvent(event); } return this; }
[ "ServerSessionContext", "resendEvents", "(", "long", "index", ")", "{", "clearEvents", "(", "index", ")", ";", "for", "(", "EventHolder", "event", ":", "events", ")", "{", "sendEvent", "(", "event", ")", ";", "}", "return", "this", ";", "}" ]
Resends events from the given sequence. @param index The index from which to resend events. @return The server session.
[ "Resends", "events", "from", "the", "given", "sequence", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L495-L501
102,766
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.sendEvent
private void sendEvent(EventHolder event, Connection connection) { PublishRequest request = PublishRequest.builder() .withSession(id()) .withEventIndex(event.eventIndex) .withPreviousIndex(Math.max(event.previousIndex, completeIndex)) .withEvents(event.events) .build(); LOGGER.tra...
java
private void sendEvent(EventHolder event, Connection connection) { PublishRequest request = PublishRequest.builder() .withSession(id()) .withEventIndex(event.eventIndex) .withPreviousIndex(Math.max(event.previousIndex, completeIndex)) .withEvents(event.events) .build(); LOGGER.tra...
[ "private", "void", "sendEvent", "(", "EventHolder", "event", ",", "Connection", "connection", ")", "{", "PublishRequest", "request", "=", "PublishRequest", ".", "builder", "(", ")", ".", "withSession", "(", "id", "(", ")", ")", ".", "withEventIndex", "(", "e...
Sends an event.
[ "Sends", "an", "event", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L515-L525
102,767
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java
ServerSessionContext.cleanState
private void cleanState(long index) { // If the keep alive index is set, release the entry. if (keepAliveIndex > 0) { log.release(keepAliveIndex); } context.sessions().unregisterSession(id); // If no references to session commands are open, release session-related entries. if (references...
java
private void cleanState(long index) { // If the keep alive index is set, release the entry. if (keepAliveIndex > 0) { log.release(keepAliveIndex); } context.sessions().unregisterSession(id); // If no references to session commands are open, release session-related entries. if (references...
[ "private", "void", "cleanState", "(", "long", "index", ")", "{", "// If the keep alive index is set, release the entry.", "if", "(", "keepAliveIndex", ">", "0", ")", "{", "log", ".", "release", "(", "keepAliveIndex", ")", ";", "}", "context", ".", "sessions", "(...
Cleans session entries on close.
[ "Cleans", "session", "entries", "on", "close", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L578-L595
102,768
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/system/MetaStore.java
MetaStore.storeTerm
public synchronized MetaStore storeTerm(long term) { LOGGER.trace("Store term {}", term); metadataBuffer.writeLong(0, term).flush(); return this; }
java
public synchronized MetaStore storeTerm(long term) { LOGGER.trace("Store term {}", term); metadataBuffer.writeLong(0, term).flush(); return this; }
[ "public", "synchronized", "MetaStore", "storeTerm", "(", "long", "term", ")", "{", "LOGGER", ".", "trace", "(", "\"Store term {}\"", ",", "term", ")", ";", "metadataBuffer", ".", "writeLong", "(", "0", ",", "term", ")", ".", "flush", "(", ")", ";", "retu...
Stores the current server term. @param term The current server term. @return The metastore.
[ "Stores", "the", "current", "server", "term", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/system/MetaStore.java#L131-L135
102,769
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java
ServerSessionManager.registerConnection
ServerSessionManager registerConnection(String client, Connection connection) { ServerSessionContext session = clients.get(client); if (session != null) { session.setConnection(connection); } connections.put(client, connection); return this; }
java
ServerSessionManager registerConnection(String client, Connection connection) { ServerSessionContext session = clients.get(client); if (session != null) { session.setConnection(connection); } connections.put(client, connection); return this; }
[ "ServerSessionManager", "registerConnection", "(", "String", "client", ",", "Connection", "connection", ")", "{", "ServerSessionContext", "session", "=", "clients", ".", "get", "(", "client", ")", ";", "if", "(", "session", "!=", "null", ")", "{", "session", "...
Registers a connection.
[ "Registers", "a", "connection", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java#L66-L73
102,770
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java
ServerSessionManager.unregisterConnection
ServerSessionManager unregisterConnection(Connection connection) { Iterator<Map.Entry<String, Connection>> iterator = connections.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, Connection> entry = iterator.next(); if (entry.getValue().equals(connection)) { ServerSessio...
java
ServerSessionManager unregisterConnection(Connection connection) { Iterator<Map.Entry<String, Connection>> iterator = connections.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, Connection> entry = iterator.next(); if (entry.getValue().equals(connection)) { ServerSessio...
[ "ServerSessionManager", "unregisterConnection", "(", "Connection", "connection", ")", "{", "Iterator", "<", "Map", ".", "Entry", "<", "String", ",", "Connection", ">", ">", "iterator", "=", "connections", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ...
Unregisters a connection.
[ "Unregisters", "a", "connection", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java#L78-L91
102,771
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java
ServerSessionManager.unregisterSession
ServerSessionContext unregisterSession(long sessionId) { ServerSessionContext session = sessions.remove(sessionId); if (session != null) { clients.remove(session.client(), session); connections.remove(session.client(), session.getConnection()); } return session; }
java
ServerSessionContext unregisterSession(long sessionId) { ServerSessionContext session = sessions.remove(sessionId); if (session != null) { clients.remove(session.client(), session); connections.remove(session.client(), session.getConnection()); } return session; }
[ "ServerSessionContext", "unregisterSession", "(", "long", "sessionId", ")", "{", "ServerSessionContext", "session", "=", "sessions", ".", "remove", "(", "sessionId", ")", ";", "if", "(", "session", "!=", "null", ")", "{", "clients", ".", "remove", "(", "sessio...
Unregisters a session.
[ "Unregisters", "a", "session", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionManager.java#L110-L117
102,772
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java
LeaderAppender.updateHeartbeatTime
private void updateHeartbeatTime(MemberState member, Throwable error) { if (heartbeatFuture == null) { return; } if (error != null && member.getHeartbeatStartTime() == heartbeatTime) { int votingMemberSize = context.getClusterState().getActiveMemberStates().size() + (context.getCluster().member...
java
private void updateHeartbeatTime(MemberState member, Throwable error) { if (heartbeatFuture == null) { return; } if (error != null && member.getHeartbeatStartTime() == heartbeatTime) { int votingMemberSize = context.getClusterState().getActiveMemberStates().size() + (context.getCluster().member...
[ "private", "void", "updateHeartbeatTime", "(", "MemberState", "member", ",", "Throwable", "error", ")", "{", "if", "(", "heartbeatFuture", "==", "null", ")", "{", "return", ";", "}", "if", "(", "error", "!=", "null", "&&", "member", ".", "getHeartbeatStartTi...
Sets a commit time or fails the commit if a quorum of successful responses cannot be achieved.
[ "Sets", "a", "commit", "time", "or", "fails", "the", "commit", "if", "a", "quorum", "of", "successful", "responses", "cannot", "be", "achieved", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java#L243-L269
102,773
atomix/copycat
server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java
LeaderAppender.updateGlobalIndex
private void updateGlobalIndex() { context.checkThread(); // The global index may have increased even if the commit index didn't. Update the global index. // The global index is calculated by the minimum matchIndex for *all* servers in the cluster, including // passive members. This is critical since p...
java
private void updateGlobalIndex() { context.checkThread(); // The global index may have increased even if the commit index didn't. Update the global index. // The global index is calculated by the minimum matchIndex for *all* servers in the cluster, including // passive members. This is critical since p...
[ "private", "void", "updateGlobalIndex", "(", ")", "{", "context", ".", "checkThread", "(", ")", ";", "// The global index may have increased even if the commit index didn't. Update the global index.", "// The global index is calculated by the minimum matchIndex for *all* servers in the clu...
Updates the global index.
[ "Updates", "the", "global", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java#L291-L306
102,774
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/SegmentManager.java
SegmentManager.replaceSegments
public synchronized void replaceSegments(Collection<Segment> segments, Segment segment) { // Update the segment descriptor and lock the segment. segment.descriptor().update(System.currentTimeMillis()); segment.descriptor().lock(); // Iterate through old segments and remove them from the segments list. ...
java
public synchronized void replaceSegments(Collection<Segment> segments, Segment segment) { // Update the segment descriptor and lock the segment. segment.descriptor().update(System.currentTimeMillis()); segment.descriptor().lock(); // Iterate through old segments and remove them from the segments list. ...
[ "public", "synchronized", "void", "replaceSegments", "(", "Collection", "<", "Segment", ">", "segments", ",", "Segment", "segment", ")", "{", "// Update the segment descriptor and lock the segment.", "segment", ".", "descriptor", "(", ")", ".", "update", "(", "System"...
Inserts a segment. @param segment The segment to insert. @throws IllegalStateException if the segment is unknown
[ "Inserts", "a", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/SegmentManager.java#L264-L281
102,775
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/SegmentManager.java
SegmentManager.createIndex
private OffsetIndex createIndex(SegmentDescriptor descriptor) { return new DelegatingOffsetIndex(HeapBuffer.allocate(Math.min(DEFAULT_BUFFER_SIZE, descriptor.maxEntries()), OffsetIndex.size(descriptor.maxEntries()))); }
java
private OffsetIndex createIndex(SegmentDescriptor descriptor) { return new DelegatingOffsetIndex(HeapBuffer.allocate(Math.min(DEFAULT_BUFFER_SIZE, descriptor.maxEntries()), OffsetIndex.size(descriptor.maxEntries()))); }
[ "private", "OffsetIndex", "createIndex", "(", "SegmentDescriptor", "descriptor", ")", "{", "return", "new", "DelegatingOffsetIndex", "(", "HeapBuffer", ".", "allocate", "(", "Math", ".", "min", "(", "DEFAULT_BUFFER_SIZE", ",", "descriptor", ".", "maxEntries", "(", ...
Creates an in memory segment index.
[ "Creates", "an", "in", "memory", "segment", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/SegmentManager.java#L406-L408
102,776
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.currentSegment
private Segment currentSegment() { Segment segment = segments.currentSegment(); if (segment.isFull()) { segments.currentSegment().flush(); segment = segments.nextSegment(); } return segment; }
java
private Segment currentSegment() { Segment segment = segments.currentSegment(); if (segment.isFull()) { segments.currentSegment().flush(); segment = segments.nextSegment(); } return segment; }
[ "private", "Segment", "currentSegment", "(", ")", "{", "Segment", "segment", "=", "segments", ".", "currentSegment", "(", ")", ";", "if", "(", "segment", ".", "isFull", "(", ")", ")", "{", "segments", ".", "currentSegment", "(", ")", ".", "flush", "(", ...
Checks whether we need to roll over to a new segment.
[ "Checks", "whether", "we", "need", "to", "roll", "over", "to", "a", "new", "segment", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L253-L260
102,777
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.append
public long append(Entry entry) { Assert.notNull(entry, "entry"); assertIsOpen(); // Append the entry to the appropriate segment. long index = currentSegment().append(entry); entryBuffer.append(entry); return index; }
java
public long append(Entry entry) { Assert.notNull(entry, "entry"); assertIsOpen(); // Append the entry to the appropriate segment. long index = currentSegment().append(entry); entryBuffer.append(entry); return index; }
[ "public", "long", "append", "(", "Entry", "entry", ")", "{", "Assert", ".", "notNull", "(", "entry", ",", "\"entry\"", ")", ";", "assertIsOpen", "(", ")", ";", "// Append the entry to the appropriate segment.", "long", "index", "=", "currentSegment", "(", ")", ...
Appends an entry to the log. @param entry The entry to append. @return The appended entry index. @throws IllegalStateException If the log is not open @throws NullPointerException If {@code entry} is {@code null} @throws IndexOutOfBoundsException If the entry's index does not match the expected next log index.
[ "Appends", "an", "entry", "to", "the", "log", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L289-L297
102,778
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.contains
public boolean contains(long index) { if (!validIndex(index)) return false; Segment segment = segments.segment(index); return segment != null && segment.contains(index); }
java
public boolean contains(long index) { if (!validIndex(index)) return false; Segment segment = segments.segment(index); return segment != null && segment.contains(index); }
[ "public", "boolean", "contains", "(", "long", "index", ")", "{", "if", "(", "!", "validIndex", "(", "index", ")", ")", "return", "false", ";", "Segment", "segment", "=", "segments", ".", "segment", "(", "index", ")", ";", "return", "segment", "!=", "nu...
Returns a boolean value indicating whether the log contains a live entry at the given index. @param index The index to check. @return Indicates whether the log contains a live entry at the given index. @throws IllegalStateException If the log is not open.
[ "Returns", "a", "boolean", "value", "indicating", "whether", "the", "log", "contains", "a", "live", "entry", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L427-L433
102,779
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.release
public Log release(long index) { assertIsOpen(); assertValidIndex(index); Segment segment = segments.segment(index); Assert.index(segment != null, "invalid index: " + index); segment.release(index); return this; }
java
public Log release(long index) { assertIsOpen(); assertValidIndex(index); Segment segment = segments.segment(index); Assert.index(segment != null, "invalid index: " + index); segment.release(index); return this; }
[ "public", "Log", "release", "(", "long", "index", ")", "{", "assertIsOpen", "(", ")", ";", "assertValidIndex", "(", "index", ")", ";", "Segment", "segment", "=", "segments", ".", "segment", "(", "index", ")", ";", "Assert", ".", "index", "(", "segment", ...
Releases the entry at the given index. @param index The index of the entry to release. @return The log. @throws IllegalStateException If the log is not open. @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
[ "Releases", "the", "entry", "at", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L443-L451
102,780
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.commit
public Log commit(long index) { assertIsOpen(); if (index > 0) { assertValidIndex(index); segments.commitIndex(index); if (storage.flushOnCommit()) { segments.currentSegment().flush(); } } return this; }
java
public Log commit(long index) { assertIsOpen(); if (index > 0) { assertValidIndex(index); segments.commitIndex(index); if (storage.flushOnCommit()) { segments.currentSegment().flush(); } } return this; }
[ "public", "Log", "commit", "(", "long", "index", ")", "{", "assertIsOpen", "(", ")", ";", "if", "(", "index", ">", "0", ")", "{", "assertValidIndex", "(", "index", ")", ";", "segments", ".", "commitIndex", "(", "index", ")", ";", "if", "(", "storage"...
Commits entries up to the given index to the log. @param index The index up to which to commit entries. @return The log. @throws IllegalStateException If the log is not open.
[ "Commits", "entries", "up", "to", "the", "given", "index", "to", "the", "log", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L460-L470
102,781
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.truncate
public Log truncate(long index) { assertIsOpen(); if (index > 0) assertValidIndex(index); Assert.index(index >= segments.commitIndex(), "cannot truncate committed entries"); if (lastIndex() == index) return this; for (Segment segment : segments.reverseSegments()) { if (segment.va...
java
public Log truncate(long index) { assertIsOpen(); if (index > 0) assertValidIndex(index); Assert.index(index >= segments.commitIndex(), "cannot truncate committed entries"); if (lastIndex() == index) return this; for (Segment segment : segments.reverseSegments()) { if (segment.va...
[ "public", "Log", "truncate", "(", "long", "index", ")", "{", "assertIsOpen", "(", ")", ";", "if", "(", "index", ">", "0", ")", "assertValidIndex", "(", "index", ")", ";", "Assert", ".", "index", "(", "index", ">=", "segments", ".", "commitIndex", "(", ...
Truncates the log up to the given index. @param index The index at which to truncate the log. @return The updated log. @throws IllegalStateException If the log is not open. @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
[ "Truncates", "the", "log", "up", "to", "the", "given", "index", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L511-L530
102,782
atomix/copycat
server/src/main/java/io/atomix/copycat/server/storage/Log.java
Log.close
@Override public void close() { assertIsOpen(); flush(); compactor.close(); segments.close(); open = false; }
java
@Override public void close() { assertIsOpen(); flush(); compactor.close(); segments.close(); open = false; }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "assertIsOpen", "(", ")", ";", "flush", "(", ")", ";", "compactor", ".", "close", "(", ")", ";", "segments", ".", "close", "(", ")", ";", "open", "=", "false", ";", "}" ]
Closes the log. @throws IllegalStateException If the log is not open.
[ "Closes", "the", "log", "." ]
c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Log.java#L547-L554
102,783
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/BasicCacheEntry.java
BasicCacheEntry.checkFixity
@Override public Collection<FixityResult> checkFixity(final String algorithm) { try (FixityInputStream fixityInputStream = new FixityInputStream( this.getInputStream(), MessageDigest.getInstance(algorithm))) { // actually calculate the digest by consuming the stream ...
java
@Override public Collection<FixityResult> checkFixity(final String algorithm) { try (FixityInputStream fixityInputStream = new FixityInputStream( this.getInputStream(), MessageDigest.getInstance(algorithm))) { // actually calculate the digest by consuming the stream ...
[ "@", "Override", "public", "Collection", "<", "FixityResult", ">", "checkFixity", "(", "final", "String", "algorithm", ")", "{", "try", "(", "FixityInputStream", "fixityInputStream", "=", "new", "FixityInputStream", "(", "this", ".", "getInputStream", "(", ")", ...
Calculate the fixity of a CacheEntry by piping it through a simple fixity-calculating InputStream @param algorithm the digest algorithm to be used @return the fixity of this cache entry
[ "Calculate", "the", "fixity", "of", "a", "CacheEntry", "by", "piping", "it", "through", "a", "simple", "fixity", "-", "calculating", "InputStream" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/BasicCacheEntry.java#L63-L88
102,784
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/BasicCacheEntry.java
BasicCacheEntry.checkFixity
@Override public Collection<URI> checkFixity(final Collection<String> algorithms) throws UnsupportedAlgorithmException { try (InputStream binaryStream = this.getInputStream()) { final Map<String, DigestInputStream> digestInputStreams = new HashMap<>(); InputStream digestStream = bi...
java
@Override public Collection<URI> checkFixity(final Collection<String> algorithms) throws UnsupportedAlgorithmException { try (InputStream binaryStream = this.getInputStream()) { final Map<String, DigestInputStream> digestInputStreams = new HashMap<>(); InputStream digestStream = bi...
[ "@", "Override", "public", "Collection", "<", "URI", ">", "checkFixity", "(", "final", "Collection", "<", "String", ">", "algorithms", ")", "throws", "UnsupportedAlgorithmException", "{", "try", "(", "InputStream", "binaryStream", "=", "this", ".", "getInputStream...
Calculate fixity with list of digest algorithms of a CacheEntry by piping it through a simple fixity-calculating InputStream @param algorithms the digest algorithms to be used @return the checksums for the digest algorithms @throws UnsupportedAlgorithmException exception
[ "Calculate", "fixity", "with", "list", "of", "digest", "algorithms", "of", "a", "CacheEntry", "by", "piping", "it", "through", "a", "simple", "fixity", "-", "calculating", "InputStream" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/BasicCacheEntry.java#L98-L125
102,785
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java
JcrPropertyStatementListener.addedStatement
@Override public void addedStatement(final Statement input) { if (Operation.ADD == statements.get(input)) { return; } try { final Resource subject = input.getSubject(); validateSubject(subject); LOGGER.debug(">> adding statement {}", input); ...
java
@Override public void addedStatement(final Statement input) { if (Operation.ADD == statements.get(input)) { return; } try { final Resource subject = input.getSubject(); validateSubject(subject); LOGGER.debug(">> adding statement {}", input); ...
[ "@", "Override", "public", "void", "addedStatement", "(", "final", "Statement", "input", ")", "{", "if", "(", "Operation", ".", "ADD", "==", "statements", ".", "get", "(", "input", ")", ")", "{", "return", ";", "}", "try", "{", "final", "Resource", "su...
When a statement is added to the graph, serialize it to a JCR property @param input the input statement
[ "When", "a", "statement", "is", "added", "to", "the", "graph", "serialize", "it", "to", "a", "JCR", "property" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java#L115-L152
102,786
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java
JcrPropertyStatementListener.removedStatement
@Override public void removedStatement(final Statement s) { if (Operation.REMOVE == statements.get(s)) { return; } try { // if it's not about the right kind of node, ignore it. final Resource subject = s.getSubject(); validateSubject(subject); ...
java
@Override public void removedStatement(final Statement s) { if (Operation.REMOVE == statements.get(s)) { return; } try { // if it's not about the right kind of node, ignore it. final Resource subject = s.getSubject(); validateSubject(subject); ...
[ "@", "Override", "public", "void", "removedStatement", "(", "final", "Statement", "s", ")", "{", "if", "(", "Operation", ".", "REMOVE", "==", "statements", ".", "get", "(", "s", ")", ")", "{", "return", ";", "}", "try", "{", "// if it's not about the right...
When a statement is removed, remove it from the JCR properties @param s the given statement
[ "When", "a", "statement", "is", "removed", "remove", "it", "from", "the", "JCR", "properties" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java#L159-L194
102,787
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java
JcrPropertyStatementListener.validateSubject
private void validateSubject(final Resource subject) { final String subjectURI = subject.getURI(); // blank nodes are okay if (!subject.isAnon()) { // hash URIs with the same base as the topic are okay final int hashIndex = subjectURI.lastIndexOf("#"); if (!(h...
java
private void validateSubject(final Resource subject) { final String subjectURI = subject.getURI(); // blank nodes are okay if (!subject.isAnon()) { // hash URIs with the same base as the topic are okay final int hashIndex = subjectURI.lastIndexOf("#"); if (!(h...
[ "private", "void", "validateSubject", "(", "final", "Resource", "subject", ")", "{", "final", "String", "subjectURI", "=", "subject", ".", "getURI", "(", ")", ";", "// blank nodes are okay", "if", "(", "!", "subject", ".", "isAnon", "(", ")", ")", "{", "//...
If it's not the right kind of node, throw an appropriate unchecked exception. @param subject to validate
[ "If", "it", "s", "not", "the", "right", "kind", "of", "node", "throw", "an", "appropriate", "unchecked", "exception", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java#L201-L222
102,788
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java
JcrPropertyStatementListener.assertNoExceptions
public void assertNoExceptions() { if (!exceptions.isEmpty()) { throw new MalformedRdfException(exceptions.stream().map(Exception::getMessage).collect(joining("\n"))); } }
java
public void assertNoExceptions() { if (!exceptions.isEmpty()) { throw new MalformedRdfException(exceptions.stream().map(Exception::getMessage).collect(joining("\n"))); } }
[ "public", "void", "assertNoExceptions", "(", ")", "{", "if", "(", "!", "exceptions", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "MalformedRdfException", "(", "exceptions", ".", "stream", "(", ")", ".", "map", "(", "Exception", "::", "getMessage", ...
Assert that no exceptions were thrown while this listener was processing change
[ "Assert", "that", "no", "exceptions", "were", "thrown", "while", "this", "listener", "was", "processing", "change" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/JcrPropertyStatementListener.java#L227-L231
102,789
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java
AbstractFedoraBinary.delete
@Override public void delete() { final FedoraResource description = getDescription(); if (description != null) { description.delete(); } super.delete(); }
java
@Override public void delete() { final FedoraResource description = getDescription(); if (description != null) { description.delete(); } super.delete(); }
[ "@", "Override", "public", "void", "delete", "(", ")", "{", "final", "FedoraResource", "description", "=", "getDescription", "(", ")", ";", "if", "(", "description", "!=", "null", ")", "{", "description", ".", "delete", "(", ")", ";", "}", "super", ".", ...
When deleting the binary, we also need to clean up the description document.
[ "When", "deleting", "the", "binary", "we", "also", "need", "to", "clean", "up", "the", "description", "document", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java#L282-L291
102,790
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java
AbstractFedoraBinary.hasDescriptionProperty
protected boolean hasDescriptionProperty(final String relPath) { try { final Node descNode = getDescriptionNodeOrNull(); if (descNode == null) { return false; } return descNode.hasProperty(relPath); } catch (final RepositoryException e) { ...
java
protected boolean hasDescriptionProperty(final String relPath) { try { final Node descNode = getDescriptionNodeOrNull(); if (descNode == null) { return false; } return descNode.hasProperty(relPath); } catch (final RepositoryException e) { ...
[ "protected", "boolean", "hasDescriptionProperty", "(", "final", "String", "relPath", ")", "{", "try", "{", "final", "Node", "descNode", "=", "getDescriptionNodeOrNull", "(", ")", ";", "if", "(", "descNode", "==", "null", ")", "{", "return", "false", ";", "}"...
Check of the property exists on the description of this binary. @param relPath - path to the property @return true if property exists.
[ "Check", "of", "the", "property", "exists", "on", "the", "description", "of", "this", "binary", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java#L299-L310
102,791
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java
AbstractFedoraBinary.getDescriptionProperty
private Property getDescriptionProperty(final String relPath) { try { return getDescriptionNode().getProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
java
private Property getDescriptionProperty(final String relPath) { try { return getDescriptionNode().getProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
[ "private", "Property", "getDescriptionProperty", "(", "final", "String", "relPath", ")", "{", "try", "{", "return", "getDescriptionNode", "(", ")", ".", "getProperty", "(", "relPath", ")", ";", "}", "catch", "(", "final", "RepositoryException", "e", ")", "{", ...
Return the description property for this binary. @param relPath - path to the property @return Property object
[ "Return", "the", "description", "property", "for", "this", "binary", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java#L318-L324
102,792
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java
AbstractFedoraBinary.setContentSize
protected void setContentSize(final long size) { try { getDescriptionNode().setProperty(CONTENT_SIZE, size); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
java
protected void setContentSize(final long size) { try { getDescriptionNode().setProperty(CONTENT_SIZE, size); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
[ "protected", "void", "setContentSize", "(", "final", "long", "size", ")", "{", "try", "{", "getDescriptionNode", "(", ")", ".", "setProperty", "(", "CONTENT_SIZE", ",", "size", ")", ";", "}", "catch", "(", "final", "RepositoryException", "e", ")", "{", "th...
Set the content size @param size the new value of the content size.
[ "Set", "the", "content", "size" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/AbstractFedoraBinary.java#L331-L337
102,793
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraSessionUserUtil.java
FedoraSessionUserUtil.getUserURI
public static URI getUserURI(final String sessionUserId) { // user id could be in format <anonymous>, remove < at the beginning and the > at the end in this case. final String userId = (sessionUserId == null ? "anonymous" : sessionUserId).replaceAll("^<|>$", ""); try { final URI uri ...
java
public static URI getUserURI(final String sessionUserId) { // user id could be in format <anonymous>, remove < at the beginning and the > at the end in this case. final String userId = (sessionUserId == null ? "anonymous" : sessionUserId).replaceAll("^<|>$", ""); try { final URI uri ...
[ "public", "static", "URI", "getUserURI", "(", "final", "String", "sessionUserId", ")", "{", "// user id could be in format <anonymous>, remove < at the beginning and the > at the end in this case.", "final", "String", "userId", "=", "(", "sessionUserId", "==", "null", "?", "\...
Returns the user agent based on the session user id. @param sessionUserId the acting user's id for this session @return the uri of the user agent
[ "Returns", "the", "user", "agent", "based", "on", "the", "session", "user", "id", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraSessionUserUtil.java#L50-L64
102,794
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraSessionUserUtil.java
FedoraSessionUserUtil.buildDefaultURI
private static URI buildDefaultURI(final String userId) { // Construct the default URI for the user ID that is not a URI. String userAgentBaseUri = System.getProperty(USER_AGENT_BASE_URI_PROPERTY); if (isNullOrEmpty(userAgentBaseUri)) { // use the default local user agent base uri ...
java
private static URI buildDefaultURI(final String userId) { // Construct the default URI for the user ID that is not a URI. String userAgentBaseUri = System.getProperty(USER_AGENT_BASE_URI_PROPERTY); if (isNullOrEmpty(userAgentBaseUri)) { // use the default local user agent base uri ...
[ "private", "static", "URI", "buildDefaultURI", "(", "final", "String", "userId", ")", "{", "// Construct the default URI for the user ID that is not a URI.", "String", "userAgentBaseUri", "=", "System", ".", "getProperty", "(", "USER_AGENT_BASE_URI_PROPERTY", ")", ";", "if"...
Build default URI with the configured base uri for agent @param userId of which a URI will be created @return URI
[ "Build", "default", "URI", "with", "the", "configured", "base", "uri", "for", "agent" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraSessionUserUtil.java#L71-L83
102,795
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java
JcrRdfTools.getJcrNamespaceForRDFNamespace
public static String getJcrNamespaceForRDFNamespace( final String rdfNamespaceUri) { if (rdfNamespacesToJcrNamespaces.containsKey(rdfNamespaceUri)) { return rdfNamespacesToJcrNamespaces.get(rdfNamespaceUri); } return rdfNamespaceUri; }
java
public static String getJcrNamespaceForRDFNamespace( final String rdfNamespaceUri) { if (rdfNamespacesToJcrNamespaces.containsKey(rdfNamespaceUri)) { return rdfNamespacesToJcrNamespaces.get(rdfNamespaceUri); } return rdfNamespaceUri; }
[ "public", "static", "String", "getJcrNamespaceForRDFNamespace", "(", "final", "String", "rdfNamespaceUri", ")", "{", "if", "(", "rdfNamespacesToJcrNamespaces", ".", "containsKey", "(", "rdfNamespaceUri", ")", ")", "{", "return", "rdfNamespacesToJcrNamespaces", ".", "get...
Convert a Fedora RDF Namespace into its JCR equivalent @param rdfNamespaceUri a namespace from an RDF document @return the JCR namespace, or the RDF namespace if no matching JCR namespace is found
[ "Convert", "a", "Fedora", "RDF", "Namespace", "into", "its", "JCR", "equivalent" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java#L143-L149
102,796
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java
JcrRdfTools.getRDFNamespaceForJcrNamespace
public static String getRDFNamespaceForJcrNamespace( final String jcrNamespaceUri) { if (jcrNamespacesToRDFNamespaces.containsKey(jcrNamespaceUri)) { return jcrNamespacesToRDFNamespaces.get(jcrNamespaceUri); } return jcrNamespaceUri; }
java
public static String getRDFNamespaceForJcrNamespace( final String jcrNamespaceUri) { if (jcrNamespacesToRDFNamespaces.containsKey(jcrNamespaceUri)) { return jcrNamespacesToRDFNamespaces.get(jcrNamespaceUri); } return jcrNamespaceUri; }
[ "public", "static", "String", "getRDFNamespaceForJcrNamespace", "(", "final", "String", "jcrNamespaceUri", ")", "{", "if", "(", "jcrNamespacesToRDFNamespaces", ".", "containsKey", "(", "jcrNamespaceUri", ")", ")", "{", "return", "jcrNamespacesToRDFNamespaces", ".", "get...
Convert a JCR namespace into an RDF namespace fit for downstream consumption. @param jcrNamespaceUri a namespace from the JCR NamespaceRegistry @return an RDF namespace for downstream consumption.
[ "Convert", "a", "JCR", "namespace", "into", "an", "RDF", "namespace", "fit", "for", "downstream", "consumption", "." ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java#L158-L164
102,797
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java
JcrRdfTools.createValue
public Value createValue(final Node node, final RDFNode data, final String propertyName) throws RepositoryException { final ValueFactory valueFactory = node.getSession().getValueFactory(); return createValue(valueFactory, data, getPropertyType(no...
java
public Value createValue(final Node node, final RDFNode data, final String propertyName) throws RepositoryException { final ValueFactory valueFactory = node.getSession().getValueFactory(); return createValue(valueFactory, data, getPropertyType(no...
[ "public", "Value", "createValue", "(", "final", "Node", "node", ",", "final", "RDFNode", "data", ",", "final", "String", "propertyName", ")", "throws", "RepositoryException", "{", "final", "ValueFactory", "valueFactory", "=", "node", ".", "getSession", "(", ")",...
Create a JCR value from an RDFNode for a given JCR property @param node the JCR node we want a property for @param data an RDF Node (possibly with a DataType) @param propertyName name of the property to populate (used to use the right type for the value) @return the JCR value from an RDFNode for a given JCR property @t...
[ "Create", "a", "JCR", "value", "from", "an", "RDFNode", "for", "a", "given", "JCR", "property" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java#L174-L179
102,798
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java
JcrRdfTools.createValue
public Value createValue(final ValueFactory valueFactory, final RDFNode data, final int type) throws RepositoryException { assert (valueFactory != null); if (type == UNDEFINED || type == STRING) { return valueConverter.reverse().convert(data); } else if (type == REFERENCE |...
java
public Value createValue(final ValueFactory valueFactory, final RDFNode data, final int type) throws RepositoryException { assert (valueFactory != null); if (type == UNDEFINED || type == STRING) { return valueConverter.reverse().convert(data); } else if (type == REFERENCE |...
[ "public", "Value", "createValue", "(", "final", "ValueFactory", "valueFactory", ",", "final", "RDFNode", "data", ",", "final", "int", "type", ")", "throws", "RepositoryException", "{", "assert", "(", "valueFactory", "!=", "null", ")", ";", "if", "(", "type", ...
Create a JCR value from an RDF node with the given JCR type @param valueFactory the given value factory @param data the rdf node data @param type the given JCR type @return created value @throws RepositoryException if repository exception occurred
[ "Create", "a", "JCR", "value", "from", "an", "RDF", "node", "with", "the", "given", "JCR", "type" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java#L189-L227
102,799
fcrepo4/fcrepo4
fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java
JcrRdfTools.addMixin
public void addMixin(final FedoraResource resource, final Resource mixinResource, final Map<String,String> namespaces) throws RepositoryException { final Node node = getJcrNode(resource); final Session session = node.getSession(); fi...
java
public void addMixin(final FedoraResource resource, final Resource mixinResource, final Map<String,String> namespaces) throws RepositoryException { final Node node = getJcrNode(resource); final Session session = node.getSession(); fi...
[ "public", "void", "addMixin", "(", "final", "FedoraResource", "resource", ",", "final", "Resource", "mixinResource", ",", "final", "Map", "<", "String", ",", "String", ">", "namespaces", ")", "throws", "RepositoryException", "{", "final", "Node", "node", "=", ...
Add a mixin to a node @param resource the fedora resource @param mixinResource the mixin resource @param namespaces the namespace @throws RepositoryException if repository exception occurred
[ "Add", "a", "mixin", "to", "a", "node" ]
7489ad5bc8fb44e2442c93eceb7d97ac54553ab6
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/rdf/JcrRdfTools.java#L236-L267