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
27,500
atomix/atomix
core/src/main/java/io/atomix/core/AtomixConfig.java
AtomixConfig.setPartitionGroups
public AtomixConfig setPartitionGroups(Map<String, PartitionGroupConfig<?>> partitionGroups) { partitionGroups.forEach((name, group) -> group.setName(name)); this.partitionGroups = partitionGroups; return this; }
java
public AtomixConfig setPartitionGroups(Map<String, PartitionGroupConfig<?>> partitionGroups) { partitionGroups.forEach((name, group) -> group.setName(name)); this.partitionGroups = partitionGroups; return this; }
[ "public", "AtomixConfig", "setPartitionGroups", "(", "Map", "<", "String", ",", "PartitionGroupConfig", "<", "?", ">", ">", "partitionGroups", ")", "{", "partitionGroups", ".", "forEach", "(", "(", "name", ",", "group", ")", "->", "group", ".", "setName", "(...
Sets the partition group configurations. @param partitionGroups the partition group configurations @return the Atomix configuration
[ "Sets", "the", "partition", "group", "configurations", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/AtomixConfig.java#L123-L127
27,501
atomix/atomix
core/src/main/java/io/atomix/core/AtomixConfig.java
AtomixConfig.getPrimitiveDefault
@SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>> C getPrimitiveDefault(String name) { return (C) primitiveDefaults.get(name); }
java
@SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>> C getPrimitiveDefault(String name) { return (C) primitiveDefaults.get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "C", "extends", "PrimitiveConfig", "<", "C", ">", ">", "C", "getPrimitiveDefault", "(", "String", "name", ")", "{", "return", "(", "C", ")", "primitiveDefaults", ".", "get", "(", "name", ")...
Returns a default primitive configuration. @param name the primitive name @param <C> the configuration type @return the primitive configuration
[ "Returns", "a", "default", "primitive", "configuration", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/AtomixConfig.java#L167-L170
27,502
atomix/atomix
core/src/main/java/io/atomix/core/AtomixConfig.java
AtomixConfig.addPrimitive
public AtomixConfig addPrimitive(String name, PrimitiveConfig config) { primitives.put(name, config); return this; }
java
public AtomixConfig addPrimitive(String name, PrimitiveConfig config) { primitives.put(name, config); return this; }
[ "public", "AtomixConfig", "addPrimitive", "(", "String", "name", ",", "PrimitiveConfig", "config", ")", "{", "primitives", ".", "put", "(", "name", ",", "config", ")", ";", "return", "this", ";", "}" ]
Adds a primitive configuration. @param name the primitive name @param config the primitive configuration @return the primitive configuration holder
[ "Adds", "a", "primitive", "configuration", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/AtomixConfig.java#L199-L202
27,503
atomix/atomix
core/src/main/java/io/atomix/core/AtomixConfig.java
AtomixConfig.getPrimitive
@SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>> C getPrimitive(String name) { return (C) primitives.get(name); }
java
@SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>> C getPrimitive(String name) { return (C) primitives.get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "C", "extends", "PrimitiveConfig", "<", "C", ">", ">", "C", "getPrimitive", "(", "String", "name", ")", "{", "return", "(", "C", ")", "primitives", ".", "get", "(", "name", ")", ";", "}...
Returns a primitive configuration. @param name the primitive name @param <C> the configuration type @return the primitive configuration
[ "Returns", "a", "primitive", "configuration", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/AtomixConfig.java#L211-L214
27,504
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.isRunningOutOfDiskSpace
private boolean isRunningOutOfDiskSpace() { // If there's not enough space left to allocate two log segments return raft.getStorage().statistics().getUsableSpace() < raft.getStorage().maxLogSegmentSize() * SEGMENT_BUFFER_FACTOR // Or the used disk percentage has surpassed the free disk buffer percentage...
java
private boolean isRunningOutOfDiskSpace() { // If there's not enough space left to allocate two log segments return raft.getStorage().statistics().getUsableSpace() < raft.getStorage().maxLogSegmentSize() * SEGMENT_BUFFER_FACTOR // Or the used disk percentage has surpassed the free disk buffer percentage...
[ "private", "boolean", "isRunningOutOfDiskSpace", "(", ")", "{", "// If there's not enough space left to allocate two log segments", "return", "raft", ".", "getStorage", "(", ")", ".", "statistics", "(", ")", ".", "getUsableSpace", "(", ")", "<", "raft", ".", "getStora...
Returns a boolean indicating whether the node is running out of disk space.
[ "Returns", "a", "boolean", "indicating", "whether", "the", "node", "is", "running", "out", "of", "disk", "space", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L118-L123
27,505
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.isRunningOutOfMemory
private boolean isRunningOutOfMemory() { StorageLevel level = raft.getStorage().storageLevel(); if (level == StorageLevel.MEMORY || level == StorageLevel.MAPPED) { long freeMemory = raft.getStorage().statistics().getFreeMemory(); long totalMemory = raft.getStorage().statistics().getTotalMemory(); ...
java
private boolean isRunningOutOfMemory() { StorageLevel level = raft.getStorage().storageLevel(); if (level == StorageLevel.MEMORY || level == StorageLevel.MAPPED) { long freeMemory = raft.getStorage().statistics().getFreeMemory(); long totalMemory = raft.getStorage().statistics().getTotalMemory(); ...
[ "private", "boolean", "isRunningOutOfMemory", "(", ")", "{", "StorageLevel", "level", "=", "raft", ".", "getStorage", "(", ")", ".", "storageLevel", "(", ")", ";", "if", "(", "level", "==", "StorageLevel", ".", "MEMORY", "||", "level", "==", "StorageLevel", ...
Returns a boolean indicating whether the node is running out of memory.
[ "Returns", "a", "boolean", "indicating", "whether", "the", "node", "is", "running", "out", "of", "memory", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L128-L138
27,506
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.takeSnapshots
private CompletableFuture<Void> takeSnapshots(boolean rescheduleAfterCompletion, boolean force) { // If compaction is already in progress, return the existing future and reschedule if this is a scheduled compaction. if (compactFuture != null) { if (rescheduleAfterCompletion) { compactFuture.whenCo...
java
private CompletableFuture<Void> takeSnapshots(boolean rescheduleAfterCompletion, boolean force) { // If compaction is already in progress, return the existing future and reschedule if this is a scheduled compaction. if (compactFuture != null) { if (rescheduleAfterCompletion) { compactFuture.whenCo...
[ "private", "CompletableFuture", "<", "Void", ">", "takeSnapshots", "(", "boolean", "rescheduleAfterCompletion", ",", "boolean", "force", ")", "{", "// If compaction is already in progress, return the existing future and reschedule if this is a scheduled compaction.", "if", "(", "co...
Takes a snapshot of all services and compacts logs if the server is not under high load or disk needs to be freed.
[ "Takes", "a", "snapshot", "of", "all", "services", "and", "compacts", "logs", "if", "the", "server", "is", "not", "under", "high", "load", "or", "disk", "needs", "to", "be", "freed", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L159-L226
27,507
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.takeSnapshots
private CompletableFuture<Snapshot> takeSnapshots() { ComposableFuture<Snapshot> future = new ComposableFuture<>(); stateContext.execute(() -> { try { future.complete(snapshot()); } catch (Exception e) { future.completeExceptionally(e); } }); return future; }
java
private CompletableFuture<Snapshot> takeSnapshots() { ComposableFuture<Snapshot> future = new ComposableFuture<>(); stateContext.execute(() -> { try { future.complete(snapshot()); } catch (Exception e) { future.completeExceptionally(e); } }); return future; }
[ "private", "CompletableFuture", "<", "Snapshot", ">", "takeSnapshots", "(", ")", "{", "ComposableFuture", "<", "Snapshot", ">", "future", "=", "new", "ComposableFuture", "<>", "(", ")", ";", "stateContext", ".", "execute", "(", "(", ")", "->", "{", "try", ...
Takes and persists snapshots of provided services. @return future to be completed once all snapshots have been completed
[ "Takes", "and", "persists", "snapshots", "of", "provided", "services", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L233-L243
27,508
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.scheduleCompletion
private void scheduleCompletion(Snapshot snapshot) { stateContext.schedule(SNAPSHOT_COMPLETION_DELAY, () -> { if (completeSnapshot(snapshot.index())) { logger.debug("Completing snapshot {}", snapshot.index()); snapshot.complete(); // If log compaction is being forced, immediately compa...
java
private void scheduleCompletion(Snapshot snapshot) { stateContext.schedule(SNAPSHOT_COMPLETION_DELAY, () -> { if (completeSnapshot(snapshot.index())) { logger.debug("Completing snapshot {}", snapshot.index()); snapshot.complete(); // If log compaction is being forced, immediately compa...
[ "private", "void", "scheduleCompletion", "(", "Snapshot", "snapshot", ")", "{", "stateContext", ".", "schedule", "(", "SNAPSHOT_COMPLETION_DELAY", ",", "(", ")", "->", "{", "if", "(", "completeSnapshot", "(", "snapshot", ".", "index", "(", ")", ")", ")", "{"...
Schedules a completion check for the snapshot at the given index. @param snapshot the snapshot to complete
[ "Schedules", "a", "completion", "check", "for", "the", "snapshot", "at", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L250-L265
27,509
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.scheduleCompaction
private void scheduleCompaction(long lastApplied) { // Schedule compaction after a randomized delay to discourage snapshots on multiple nodes at the same time. logger.trace("Scheduling compaction in {}", COMPACT_DELAY); stateContext.schedule(COMPACT_DELAY, () -> compactLogs(lastApplied)); }
java
private void scheduleCompaction(long lastApplied) { // Schedule compaction after a randomized delay to discourage snapshots on multiple nodes at the same time. logger.trace("Scheduling compaction in {}", COMPACT_DELAY); stateContext.schedule(COMPACT_DELAY, () -> compactLogs(lastApplied)); }
[ "private", "void", "scheduleCompaction", "(", "long", "lastApplied", ")", "{", "// Schedule compaction after a randomized delay to discourage snapshots on multiple nodes at the same time.", "logger", ".", "trace", "(", "\"Scheduling compaction in {}\"", ",", "COMPACT_DELAY", ")", "...
Schedules a log compaction. @param lastApplied the last applied index at the start of snapshotting. This represents the highest index before which segments can be safely removed from disk
[ "Schedules", "a", "log", "compaction", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L273-L277
27,510
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.compactLogs
private void compactLogs(long compactIndex) { raft.getThreadContext().execute(() -> { logger.debug("Compacting logs up to index {}", compactIndex); try { raft.getLog().compact(compactIndex); } catch (Exception e) { logger.error("An exception occurred during log compaction: {}", e);...
java
private void compactLogs(long compactIndex) { raft.getThreadContext().execute(() -> { logger.debug("Compacting logs up to index {}", compactIndex); try { raft.getLog().compact(compactIndex); } catch (Exception e) { logger.error("An exception occurred during log compaction: {}", e);...
[ "private", "void", "compactLogs", "(", "long", "compactIndex", ")", "{", "raft", ".", "getThreadContext", "(", ")", ".", "execute", "(", "(", ")", "->", "{", "logger", ".", "debug", "(", "\"Compacting logs up to index {}\"", ",", "compactIndex", ")", ";", "t...
Compacts logs up to the given index. @param compactIndex the index to which to compact logs
[ "Compacts", "logs", "up", "to", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L284-L298
27,511
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.applyIndex
@SuppressWarnings("unchecked") private void applyIndex(long index) { // Apply entries prior to this entry. if (reader.hasNext() && reader.getNextIndex() == index) { // Read the entry from the log. If the entry is non-null then apply it, otherwise // simply update the last applied index and return ...
java
@SuppressWarnings("unchecked") private void applyIndex(long index) { // Apply entries prior to this entry. if (reader.hasNext() && reader.getNextIndex() == index) { // Read the entry from the log. If the entry is non-null then apply it, otherwise // simply update the last applied index and return ...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "applyIndex", "(", "long", "index", ")", "{", "// Apply entries prior to this entry.", "if", "(", "reader", ".", "hasNext", "(", ")", "&&", "reader", ".", "getNextIndex", "(", ")", "==", "i...
Applies the next entry in the log up to the given index. @param index the index up to which to apply the entry
[ "Applies", "the", "next", "entry", "in", "the", "log", "up", "to", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L353-L385
27,512
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.snapshot
Snapshot snapshot() { Snapshot snapshot = raft.getSnapshotStore().newTemporarySnapshot(raft.getLastApplied(), new WallClockTimestamp()); try (SnapshotWriter writer = snapshot.openWriter()) { for (RaftServiceContext service : raft.getServices()) { writer.buffer().mark(); SnapshotWriter serv...
java
Snapshot snapshot() { Snapshot snapshot = raft.getSnapshotStore().newTemporarySnapshot(raft.getLastApplied(), new WallClockTimestamp()); try (SnapshotWriter writer = snapshot.openWriter()) { for (RaftServiceContext service : raft.getServices()) { writer.buffer().mark(); SnapshotWriter serv...
[ "Snapshot", "snapshot", "(", ")", "{", "Snapshot", "snapshot", "=", "raft", ".", "getSnapshotStore", "(", ")", ".", "newTemporarySnapshot", "(", "raft", ".", "getLastApplied", "(", ")", ",", "new", "WallClockTimestamp", "(", ")", ")", ";", "try", "(", "Sna...
Takes snapshots for the given index.
[ "Takes", "snapshots", "for", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L452-L468
27,513
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.snapshotService
private void snapshotService(SnapshotWriter writer, RaftServiceContext service) { writer.writeLong(service.serviceId().id()); writer.writeString(service.serviceType().name()); writer.writeString(service.serviceName()); byte[] config = Serializer.using(service.serviceType().namespace()).encode(service.se...
java
private void snapshotService(SnapshotWriter writer, RaftServiceContext service) { writer.writeLong(service.serviceId().id()); writer.writeString(service.serviceType().name()); writer.writeString(service.serviceName()); byte[] config = Serializer.using(service.serviceType().namespace()).encode(service.se...
[ "private", "void", "snapshotService", "(", "SnapshotWriter", "writer", ",", "RaftServiceContext", "service", ")", "{", "writer", ".", "writeLong", "(", "service", ".", "serviceId", "(", ")", ".", "id", "(", ")", ")", ";", "writer", ".", "writeString", "(", ...
Takes a snapshot of the given service. @param writer the snapshot writer @param service the service to snapshot
[ "Takes", "a", "snapshot", "of", "the", "given", "service", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L476-L487
27,514
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.install
void install(Snapshot snapshot) { logger.debug("Installing snapshot {}", snapshot); try (SnapshotReader reader = snapshot.openReader()) { while (reader.hasRemaining()) { try { int length = reader.readInt(); if (length > 0) { SnapshotReader serviceReader = new Snapsh...
java
void install(Snapshot snapshot) { logger.debug("Installing snapshot {}", snapshot); try (SnapshotReader reader = snapshot.openReader()) { while (reader.hasRemaining()) { try { int length = reader.readInt(); if (length > 0) { SnapshotReader serviceReader = new Snapsh...
[ "void", "install", "(", "Snapshot", "snapshot", ")", "{", "logger", ".", "debug", "(", "\"Installing snapshot {}\"", ",", "snapshot", ")", ";", "try", "(", "SnapshotReader", "reader", "=", "snapshot", ".", "openReader", "(", ")", ")", "{", "while", "(", "r...
Prepares sessions for the given index. @param snapshot the snapshot to install
[ "Prepares", "sessions", "for", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L494-L510
27,515
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.installService
private void installService(SnapshotReader reader) { PrimitiveId primitiveId = PrimitiveId.from(reader.readLong()); try { PrimitiveType primitiveType = raft.getPrimitiveTypes().getPrimitiveType(reader.readString()); String serviceName = reader.readString(); byte[] serviceConfig = reader.readBy...
java
private void installService(SnapshotReader reader) { PrimitiveId primitiveId = PrimitiveId.from(reader.readLong()); try { PrimitiveType primitiveType = raft.getPrimitiveTypes().getPrimitiveType(reader.readString()); String serviceName = reader.readString(); byte[] serviceConfig = reader.readBy...
[ "private", "void", "installService", "(", "SnapshotReader", "reader", ")", "{", "PrimitiveId", "primitiveId", "=", "PrimitiveId", ".", "from", "(", "reader", ".", "readLong", "(", ")", ")", ";", "try", "{", "PrimitiveType", "primitiveType", "=", "raft", ".", ...
Restores the service associated with the given snapshot. @param reader the snapshot reader
[ "Restores", "the", "service", "associated", "with", "the", "given", "snapshot", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L517-L537
27,516
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.completeSnapshot
private boolean completeSnapshot(long index) { // Compute the lowest completed index for all sessions that belong to this state machine. long lastCompleted = index; for (RaftSession session : raft.getSessions().getSessions()) { lastCompleted = Math.min(lastCompleted, session.getLastCompleted()); }...
java
private boolean completeSnapshot(long index) { // Compute the lowest completed index for all sessions that belong to this state machine. long lastCompleted = index; for (RaftSession session : raft.getSessions().getSessions()) { lastCompleted = Math.min(lastCompleted, session.getLastCompleted()); }...
[ "private", "boolean", "completeSnapshot", "(", "long", "index", ")", "{", "// Compute the lowest completed index for all sessions that belong to this state machine.", "long", "lastCompleted", "=", "index", ";", "for", "(", "RaftSession", "session", ":", "raft", ".", "getSes...
Determines whether to complete the snapshot at the given index. @param index the index of the snapshot to complete @return whether to complete the snapshot at the given index
[ "Determines", "whether", "to", "complete", "the", "snapshot", "at", "the", "given", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L545-L552
27,517
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.getOrInitializeService
private RaftServiceContext getOrInitializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) { // Get the state machine executor or create one if it doesn't already exist. RaftServiceContext service = raft.getServices().getService(serviceName); if (service == nu...
java
private RaftServiceContext getOrInitializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) { // Get the state machine executor or create one if it doesn't already exist. RaftServiceContext service = raft.getServices().getService(serviceName); if (service == nu...
[ "private", "RaftServiceContext", "getOrInitializeService", "(", "PrimitiveId", "primitiveId", ",", "PrimitiveType", "primitiveType", ",", "String", "serviceName", ",", "byte", "[", "]", "config", ")", "{", "// Get the state machine executor or create one if it doesn't already e...
Gets or initializes a service context.
[ "Gets", "or", "initializes", "a", "service", "context", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L656-L663
27,518
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.initializeService
@SuppressWarnings("unchecked") private RaftServiceContext initializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) { RaftServiceContext oldService = raft.getServices().getService(serviceName); ServiceConfig serviceConfig = config == null ? new ServiceConfig() ...
java
@SuppressWarnings("unchecked") private RaftServiceContext initializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) { RaftServiceContext oldService = raft.getServices().getService(serviceName); ServiceConfig serviceConfig = config == null ? new ServiceConfig() ...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "RaftServiceContext", "initializeService", "(", "PrimitiveId", "primitiveId", ",", "PrimitiveType", "primitiveType", ",", "String", "serviceName", ",", "byte", "[", "]", "config", ")", "{", "RaftServiceCon...
Initializes a new service.
[ "Initializes", "a", "new", "service", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L668-L687
27,519
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.applyOpenSession
private long applyOpenSession(Indexed<OpenSessionEntry> entry) { PrimitiveType primitiveType = raft.getPrimitiveTypes().getPrimitiveType(entry.entry().serviceType()); // Get the state machine executor or create one if it doesn't already exist. RaftServiceContext service = getOrInitializeService( Pr...
java
private long applyOpenSession(Indexed<OpenSessionEntry> entry) { PrimitiveType primitiveType = raft.getPrimitiveTypes().getPrimitiveType(entry.entry().serviceType()); // Get the state machine executor or create one if it doesn't already exist. RaftServiceContext service = getOrInitializeService( Pr...
[ "private", "long", "applyOpenSession", "(", "Indexed", "<", "OpenSessionEntry", ">", "entry", ")", "{", "PrimitiveType", "primitiveType", "=", "raft", ".", "getPrimitiveTypes", "(", ")", ".", "getPrimitiveType", "(", "entry", ".", "entry", "(", ")", ".", "serv...
Applies an open session entry to the state machine.
[ "Applies", "an", "open", "session", "entry", "to", "the", "state", "machine", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L692-L721
27,520
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.applyCloseSession
private void applyCloseSession(Indexed<CloseSessionEntry> entry) { RaftSession session = raft.getSessions().getSession(entry.entry().session()); // If the server session is null, the session either never existed or already expired. if (session == null) { throw new RaftException.UnknownSession("Unknow...
java
private void applyCloseSession(Indexed<CloseSessionEntry> entry) { RaftSession session = raft.getSessions().getSession(entry.entry().session()); // If the server session is null, the session either never existed or already expired. if (session == null) { throw new RaftException.UnknownSession("Unknow...
[ "private", "void", "applyCloseSession", "(", "Indexed", "<", "CloseSessionEntry", ">", "entry", ")", "{", "RaftSession", "session", "=", "raft", ".", "getSessions", "(", ")", ".", "getSession", "(", "entry", ".", "entry", "(", ")", ".", "session", "(", ")"...
Applies a close session entry to the state machine.
[ "Applies", "a", "close", "session", "entry", "to", "the", "state", "machine", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L726-L742
27,521
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java
RaftServiceManager.applyMetadata
private MetadataResult applyMetadata(Indexed<MetadataEntry> entry) { // If the session ID is non-zero, read the metadata for the associated state machine. if (entry.entry().session() > 0) { RaftSession session = raft.getSessions().getSession(entry.entry().session()); // If the session is null, retu...
java
private MetadataResult applyMetadata(Indexed<MetadataEntry> entry) { // If the session ID is non-zero, read the metadata for the associated state machine. if (entry.entry().session() > 0) { RaftSession session = raft.getSessions().getSession(entry.entry().session()); // If the session is null, retu...
[ "private", "MetadataResult", "applyMetadata", "(", "Indexed", "<", "MetadataEntry", ">", "entry", ")", "{", "// If the session ID is non-zero, read the metadata for the associated state machine.", "if", "(", "entry", ".", "entry", "(", ")", ".", "session", "(", ")", ">"...
Applies a metadata entry to the state machine.
[ "Applies", "a", "metadata", "entry", "to", "the", "state", "machine", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftServiceManager.java#L747-L772
27,522
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.serialize
public byte[] serialize(final Object obj, final int bufferSize) { return kryoOutputPool.run(output -> { return kryoPool.run(kryo -> { kryo.writeClassAndObject(output, obj); output.flush(); return output.getByteArrayOutputStream().toByteArray(); }); }, bufferSize); }
java
public byte[] serialize(final Object obj, final int bufferSize) { return kryoOutputPool.run(output -> { return kryoPool.run(kryo -> { kryo.writeClassAndObject(output, obj); output.flush(); return output.getByteArrayOutputStream().toByteArray(); }); }, bufferSize); }
[ "public", "byte", "[", "]", "serialize", "(", "final", "Object", "obj", ",", "final", "int", "bufferSize", ")", "{", "return", "kryoOutputPool", ".", "run", "(", "output", "->", "{", "return", "kryoPool", ".", "run", "(", "kryo", "->", "{", "kryo", "."...
Serializes given object to byte array using Kryo instance in pool. @param obj Object to serialize @param bufferSize maximum size of serialized bytes @return serialized bytes
[ "Serializes", "given", "object", "to", "byte", "array", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L344-L352
27,523
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.serialize
public void serialize(final Object obj, final ByteBuffer buffer) { ByteBufferOutput out = new ByteBufferOutput(buffer); Kryo kryo = borrow(); try { kryo.writeClassAndObject(out, obj); out.flush(); } finally { release(kryo); } }
java
public void serialize(final Object obj, final ByteBuffer buffer) { ByteBufferOutput out = new ByteBufferOutput(buffer); Kryo kryo = borrow(); try { kryo.writeClassAndObject(out, obj); out.flush(); } finally { release(kryo); } }
[ "public", "void", "serialize", "(", "final", "Object", "obj", ",", "final", "ByteBuffer", "buffer", ")", "{", "ByteBufferOutput", "out", "=", "new", "ByteBufferOutput", "(", "buffer", ")", ";", "Kryo", "kryo", "=", "borrow", "(", ")", ";", "try", "{", "k...
Serializes given object to byte buffer using Kryo instance in pool. @param obj Object to serialize @param buffer to write to
[ "Serializes", "given", "object", "to", "byte", "buffer", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L360-L369
27,524
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.serialize
public void serialize(final Object obj, final OutputStream stream, final int bufferSize) { ByteBufferOutput out = new ByteBufferOutput(stream, bufferSize); Kryo kryo = borrow(); try { kryo.writeClassAndObject(out, obj); out.flush(); } finally { release(kryo); } }
java
public void serialize(final Object obj, final OutputStream stream, final int bufferSize) { ByteBufferOutput out = new ByteBufferOutput(stream, bufferSize); Kryo kryo = borrow(); try { kryo.writeClassAndObject(out, obj); out.flush(); } finally { release(kryo); } }
[ "public", "void", "serialize", "(", "final", "Object", "obj", ",", "final", "OutputStream", "stream", ",", "final", "int", "bufferSize", ")", "{", "ByteBufferOutput", "out", "=", "new", "ByteBufferOutput", "(", "stream", ",", "bufferSize", ")", ";", "Kryo", ...
Serializes given object to OutputStream using Kryo instance in pool. @param obj Object to serialize @param stream to write to @param bufferSize size of the buffer in front of the stream
[ "Serializes", "given", "object", "to", "OutputStream", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L388-L397
27,525
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.deserialize
public <T> T deserialize(final byte[] bytes) { return kryoInputPool.run(input -> { input.setInputStream(new ByteArrayInputStream(bytes)); return kryoPool.run(kryo -> { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(input); return obj; }); }, DEFAULT_...
java
public <T> T deserialize(final byte[] bytes) { return kryoInputPool.run(input -> { input.setInputStream(new ByteArrayInputStream(bytes)); return kryoPool.run(kryo -> { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(input); return obj; }); }, DEFAULT_...
[ "public", "<", "T", ">", "T", "deserialize", "(", "final", "byte", "[", "]", "bytes", ")", "{", "return", "kryoInputPool", ".", "run", "(", "input", "->", "{", "input", ".", "setInputStream", "(", "new", "ByteArrayInputStream", "(", "bytes", ")", ")", ...
Deserializes given byte array to Object using Kryo instance in pool. @param bytes serialized bytes @param <T> deserialized Object type @return deserialized Object
[ "Deserializes", "given", "byte", "array", "to", "Object", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L406-L415
27,526
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.deserialize
public <T> T deserialize(final ByteBuffer buffer) { ByteBufferInput in = new ByteBufferInput(buffer); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); } }
java
public <T> T deserialize(final ByteBuffer buffer) { ByteBufferInput in = new ByteBufferInput(buffer); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); } }
[ "public", "<", "T", ">", "T", "deserialize", "(", "final", "ByteBuffer", "buffer", ")", "{", "ByteBufferInput", "in", "=", "new", "ByteBufferInput", "(", "buffer", ")", ";", "Kryo", "kryo", "=", "borrow", "(", ")", ";", "try", "{", "@", "SuppressWarnings...
Deserializes given byte buffer to Object using Kryo instance in pool. @param buffer input with serialized bytes @param <T> deserialized Object type @return deserialized Object
[ "Deserializes", "given", "byte", "buffer", "to", "Object", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L424-L434
27,527
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.deserialize
public <T> T deserialize(final InputStream stream, final int bufferSize) { ByteBufferInput in = new ByteBufferInput(stream, bufferSize); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); ...
java
public <T> T deserialize(final InputStream stream, final int bufferSize) { ByteBufferInput in = new ByteBufferInput(stream, bufferSize); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); ...
[ "public", "<", "T", ">", "T", "deserialize", "(", "final", "InputStream", "stream", ",", "final", "int", "bufferSize", ")", "{", "ByteBufferInput", "in", "=", "new", "ByteBufferInput", "(", "stream", ",", "bufferSize", ")", ";", "Kryo", "kryo", "=", "borro...
Deserializes given InputStream to an Object using Kryo instance in pool. @param stream input stream @param <T> deserialized Object type @param bufferSize size of the buffer in front of the stream @return deserialized Object
[ "Deserializes", "given", "InputStream", "to", "an", "Object", "using", "Kryo", "instance", "in", "pool", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L455-L465
27,528
atomix/atomix
utils/src/main/java/io/atomix/utils/serializer/Namespace.java
Namespace.create
@Override public Kryo create() { LOGGER.trace("Creating Kryo instance for {}", this); Kryo kryo = new Kryo(); kryo.setClassLoader(classLoader); kryo.setRegistrationRequired(registrationRequired); // If compatible serialization is enabled, override the default serializer. if (compatible) { ...
java
@Override public Kryo create() { LOGGER.trace("Creating Kryo instance for {}", this); Kryo kryo = new Kryo(); kryo.setClassLoader(classLoader); kryo.setRegistrationRequired(registrationRequired); // If compatible serialization is enabled, override the default serializer. if (compatible) { ...
[ "@", "Override", "public", "Kryo", "create", "(", ")", "{", "LOGGER", ".", "trace", "(", "\"Creating Kryo instance for {}\"", ",", "this", ")", ";", "Kryo", "kryo", "=", "new", "Kryo", "(", ")", ";", "kryo", ".", "setClassLoader", "(", "classLoader", ")", ...
Creates a Kryo instance. @return Kryo instance
[ "Creates", "a", "Kryo", "instance", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/serializer/Namespace.java#L487-L513
27,529
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/session/PrimaryBackupSessionClient.java
PrimaryBackupSessionClient.handleEvent
private void handleEvent(PrimitiveEvent event) { log.trace("Received {}", event); Set<Consumer<PrimitiveEvent>> listeners = eventListeners.get(event.type()); if (listeners != null) { listeners.forEach(l -> l.accept(event)); } }
java
private void handleEvent(PrimitiveEvent event) { log.trace("Received {}", event); Set<Consumer<PrimitiveEvent>> listeners = eventListeners.get(event.type()); if (listeners != null) { listeners.forEach(l -> l.accept(event)); } }
[ "private", "void", "handleEvent", "(", "PrimitiveEvent", "event", ")", "{", "log", ".", "trace", "(", "\"Received {}\"", ",", "event", ")", ";", "Set", "<", "Consumer", "<", "PrimitiveEvent", ">", ">", "listeners", "=", "eventListeners", ".", "get", "(", "...
Handles a primitive event.
[ "Handles", "a", "primitive", "event", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/session/PrimaryBackupSessionClient.java#L265-L271
27,530
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/session/PrimaryBackupSessionClient.java
PrimaryBackupSessionClient.connect
private void connect(int attempt, CompletableFuture<SessionClient> future) { if (attempt > MAX_ATTEMPTS) { future.completeExceptionally(new PrimitiveException.Unavailable()); return; } primaryElection.getTerm().whenCompleteAsync((term, error) -> { if (error == null) { if (term.pri...
java
private void connect(int attempt, CompletableFuture<SessionClient> future) { if (attempt > MAX_ATTEMPTS) { future.completeExceptionally(new PrimitiveException.Unavailable()); return; } primaryElection.getTerm().whenCompleteAsync((term, error) -> { if (error == null) { if (term.pri...
[ "private", "void", "connect", "(", "int", "attempt", ",", "CompletableFuture", "<", "SessionClient", ">", "future", ")", "{", "if", "(", "attempt", ">", "MAX_ATTEMPTS", ")", "{", "future", ".", "completeExceptionally", "(", "new", "PrimitiveException", ".", "U...
Recursively connects to the partition.
[ "Recursively", "connects", "to", "the", "partition", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/session/PrimaryBackupSessionClient.java#L285-L309
27,531
atomix/atomix
core/src/main/java/io/atomix/core/semaphore/impl/BlockingDistributedSemaphore.java
BlockingDistributedSemaphore.complete
private <T> T complete(CompletableFuture<T> future, int acquirePermits) { AtomicBoolean needRelease = new AtomicBoolean(false); try { return future.thenApply(value -> { if (needRelease.get()) { if (acquirePermits > 0) { asyncSemaphore.release(acquirePermits); } ...
java
private <T> T complete(CompletableFuture<T> future, int acquirePermits) { AtomicBoolean needRelease = new AtomicBoolean(false); try { return future.thenApply(value -> { if (needRelease.get()) { if (acquirePermits > 0) { asyncSemaphore.release(acquirePermits); } ...
[ "private", "<", "T", ">", "T", "complete", "(", "CompletableFuture", "<", "T", ">", "future", ",", "int", "acquirePermits", ")", "{", "AtomicBoolean", "needRelease", "=", "new", "AtomicBoolean", "(", "false", ")", ";", "try", "{", "return", "future", ".", ...
Use for complete acquire or tryAcquire. If interrupt or timeout before the future completed, set needRelease to true. When the future completes, release these permits.
[ "Use", "for", "complete", "acquire", "or", "tryAcquire", ".", "If", "interrupt", "or", "timeout", "before", "the", "future", "completed", "set", "needRelease", "to", "true", ".", "When", "the", "future", "completes", "release", "these", "permits", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/semaphore/impl/BlockingDistributedSemaphore.java#L156-L183
27,532
atomix/atomix
core/src/main/java/io/atomix/core/barrier/impl/DefaultDistributedCyclicBarrierService.java
DefaultDistributedCyclicBarrierService.timeout
private void timeout(long barrierId) { if (this.barrierId == barrierId && !broken) { broken = true; parties.forEach(session -> getSession(session).accept(client -> client.broken(barrierId))); } }
java
private void timeout(long barrierId) { if (this.barrierId == barrierId && !broken) { broken = true; parties.forEach(session -> getSession(session).accept(client -> client.broken(barrierId))); } }
[ "private", "void", "timeout", "(", "long", "barrierId", ")", "{", "if", "(", "this", ".", "barrierId", "==", "barrierId", "&&", "!", "broken", ")", "{", "broken", "=", "true", ";", "parties", ".", "forEach", "(", "session", "->", "getSession", "(", "se...
Times out the given barrier instance. @param barrierId the barrier ID to time out
[ "Times", "out", "the", "given", "barrier", "instance", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/barrier/impl/DefaultDistributedCyclicBarrierService.java#L119-L124
27,533
atomix/atomix
primitive/src/main/java/io/atomix/primitive/service/impl/DefaultServiceExecutor.java
DefaultServiceExecutor.runTasks
private void runTasks() { // Execute any tasks that were queue during execution of the command. if (!tasks.isEmpty()) { for (Runnable task : tasks) { log.trace("Executing task {}", task); task.run(); } tasks.clear(); } }
java
private void runTasks() { // Execute any tasks that were queue during execution of the command. if (!tasks.isEmpty()) { for (Runnable task : tasks) { log.trace("Executing task {}", task); task.run(); } tasks.clear(); } }
[ "private", "void", "runTasks", "(", ")", "{", "// Execute any tasks that were queue during execution of the command.", "if", "(", "!", "tasks", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Runnable", "task", ":", "tasks", ")", "{", "log", ".", "trace", "("...
Executes tasks after an operation.
[ "Executes", "tasks", "after", "an", "operation", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/primitive/src/main/java/io/atomix/primitive/service/impl/DefaultServiceExecutor.java#L195-L204
27,534
atomix/atomix
core/src/main/java/io/atomix/core/semaphore/impl/AbstractAtomicSemaphoreService.java
AbstractAtomicSemaphoreService.release
private void release(long sessionId, int releasePermits) { increaseAvailable(releasePermits); holders.computeIfPresent(sessionId, (id, acquired) -> { acquired -= releasePermits; if (acquired <= 0) { return null; } return acquired; }); checkAndNotifyWaiters(); }
java
private void release(long sessionId, int releasePermits) { increaseAvailable(releasePermits); holders.computeIfPresent(sessionId, (id, acquired) -> { acquired -= releasePermits; if (acquired <= 0) { return null; } return acquired; }); checkAndNotifyWaiters(); }
[ "private", "void", "release", "(", "long", "sessionId", ",", "int", "releasePermits", ")", "{", "increaseAvailable", "(", "releasePermits", ")", ";", "holders", ".", "computeIfPresent", "(", "sessionId", ",", "(", "id", ",", "acquired", ")", "->", "{", "acqu...
Release permits and traverse the queue to remove waiters that meet the requirement. @param sessionId sessionId @param releasePermits permits to release
[ "Release", "permits", "and", "traverse", "the", "queue", "to", "remove", "waiters", "that", "meet", "the", "requirement", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/semaphore/impl/AbstractAtomicSemaphoreService.java#L194-L205
27,535
atomix/atomix
core/src/main/java/io/atomix/core/workqueue/Task.java
Task.map
public <F> Task<F> map(Function<E, F> mapper) { return new Task<>(taskId, mapper.apply(payload)); }
java
public <F> Task<F> map(Function<E, F> mapper) { return new Task<>(taskId, mapper.apply(payload)); }
[ "public", "<", "F", ">", "Task", "<", "F", ">", "map", "(", "Function", "<", "E", ",", "F", ">", "mapper", ")", "{", "return", "new", "Task", "<>", "(", "taskId", ",", "mapper", ".", "apply", "(", "payload", ")", ")", ";", "}" ]
Maps task from one payload type to another. @param <F> future type @param mapper type mapper. @return mapped task.
[ "Maps", "task", "from", "one", "payload", "type", "to", "another", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/workqueue/Task.java#L72-L74
27,536
atomix/atomix
storage/src/main/java/io/atomix/storage/statistics/StorageStatistics.java
StorageStatistics.getFreeMemory
public long getFreeMemory() { try { return (long) mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "FreePhysicalMemorySize"); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("An exception occurred during memory check", e); } } ...
java
public long getFreeMemory() { try { return (long) mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "FreePhysicalMemorySize"); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("An exception occurred during memory check", e); } } ...
[ "public", "long", "getFreeMemory", "(", ")", "{", "try", "{", "return", "(", "long", ")", "mBeanServer", ".", "getAttribute", "(", "new", "ObjectName", "(", "\"java.lang\"", ",", "\"type\"", ",", "\"OperatingSystem\"", ")", ",", "\"FreePhysicalMemorySize\"", ")"...
Returns the amount of free memory remaining. @return the amount of free memory remaining if successful, -1 return indicates failure.
[ "Returns", "the", "amount", "of", "free", "memory", "remaining", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/statistics/StorageStatistics.java#L73-L82
27,537
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/roles/AbstractAppender.java
AbstractAppender.handleConfigureResponseOk
@SuppressWarnings("unused") protected void handleConfigureResponseOk(RaftMemberContext member, ConfigureRequest request, ConfigureResponse response) { // Reset the member failure count and update the member's status if necessary. succeedAttempt(member); // Update the member's current configuration term a...
java
@SuppressWarnings("unused") protected void handleConfigureResponseOk(RaftMemberContext member, ConfigureRequest request, ConfigureResponse response) { // Reset the member failure count and update the member's status if necessary. succeedAttempt(member); // Update the member's current configuration term a...
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "protected", "void", "handleConfigureResponseOk", "(", "RaftMemberContext", "member", ",", "ConfigureRequest", "request", ",", "ConfigureResponse", "response", ")", "{", "// Reset the member failure count and update the member's ...
Handles an OK configuration response.
[ "Handles", "an", "OK", "configuration", "response", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/roles/AbstractAppender.java#L385-L396
27,538
atomix/atomix
protocols/log/src/main/java/io/atomix/protocols/log/partition/LogPartition.java
LogPartition.join
CompletableFuture<Partition> join( PartitionManagementService managementService, ThreadContextFactory threadFactory) { election = managementService.getElectionService().getElectionFor(partitionId); server = new LogPartitionServer( this, managementService, config, thre...
java
CompletableFuture<Partition> join( PartitionManagementService managementService, ThreadContextFactory threadFactory) { election = managementService.getElectionService().getElectionFor(partitionId); server = new LogPartitionServer( this, managementService, config, thre...
[ "CompletableFuture", "<", "Partition", ">", "join", "(", "PartitionManagementService", "managementService", ",", "ThreadContextFactory", "threadFactory", ")", "{", "election", "=", "managementService", ".", "getElectionService", "(", ")", ".", "getElectionFor", "(", "pa...
Joins the log partition.
[ "Joins", "the", "log", "partition", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/log/src/main/java/io/atomix/protocols/log/partition/LogPartition.java#L104-L115
27,539
atomix/atomix
rest/src/main/java/io/atomix/rest/impl/EventManager.java
EventManager.getEventLog
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> getEventLog(Class<?> type, String name) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).get(name); }
java
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> getEventLog(Class<?> type, String name) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "L", ",", "E", ">", "EventLog", "<", "L", ",", "E", ">", "getEventLog", "(", "Class", "<", "?", ">", "type", ",", "String", "name", ")", "{", "return", "eventRegistries", ".", "computeI...
Returns an event log if it already exists. @param type the log type @param name the log name @param <L> the listener type @param <E> the event type @return the event log
[ "Returns", "an", "event", "log", "if", "it", "already", "exists", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/rest/src/main/java/io/atomix/rest/impl/EventManager.java#L38-L41
27,540
atomix/atomix
rest/src/main/java/io/atomix/rest/impl/EventManager.java
EventManager.getOrCreateEventLog
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> getOrCreateEventLog(Class<?> type, String name, Function<EventLog<L, E>, L> listenerFactory) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()) .computeIfAbsent(name, n -> new EventLog<>(listenerFactory)); }
java
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> getOrCreateEventLog(Class<?> type, String name, Function<EventLog<L, E>, L> listenerFactory) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()) .computeIfAbsent(name, n -> new EventLog<>(listenerFactory)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "L", ",", "E", ">", "EventLog", "<", "L", ",", "E", ">", "getOrCreateEventLog", "(", "Class", "<", "?", ">", "type", ",", "String", "name", ",", "Function", "<", "EventLog", "<", "L", ...
Returns an event log, creating a new log if none exists. @param type the log type @param name the log name @param <L> the listener type @param <E> the event type @return the event log
[ "Returns", "an", "event", "log", "creating", "a", "new", "log", "if", "none", "exists", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/rest/src/main/java/io/atomix/rest/impl/EventManager.java#L52-L56
27,541
atomix/atomix
rest/src/main/java/io/atomix/rest/impl/EventManager.java
EventManager.removeEventLog
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> removeEventLog(Class<?> type, String name) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).remove(name); }
java
@SuppressWarnings("unchecked") public <L, E> EventLog<L, E> removeEventLog(Class<?> type, String name) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).remove(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "L", ",", "E", ">", "EventLog", "<", "L", ",", "E", ">", "removeEventLog", "(", "Class", "<", "?", ">", "type", ",", "String", "name", ")", "{", "return", "eventRegistries", ".", "compu...
Removes and returns the given event log. @param type the log type @param name the log name @param <L> the listener type @param <E> the event type @return the removed event log or {@code null} if non exits
[ "Removes", "and", "returns", "the", "given", "event", "log", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/rest/src/main/java/io/atomix/rest/impl/EventManager.java#L67-L70
27,542
atomix/atomix
rest/src/main/java/io/atomix/rest/impl/EventManager.java
EventManager.getEventLogNames
public Set<String> getEventLogNames(Class<?> type) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).keySet(); }
java
public Set<String> getEventLogNames(Class<?> type) { return eventRegistries.computeIfAbsent(type, t -> new ConcurrentHashMap<>()).keySet(); }
[ "public", "Set", "<", "String", ">", "getEventLogNames", "(", "Class", "<", "?", ">", "type", ")", "{", "return", "eventRegistries", ".", "computeIfAbsent", "(", "type", ",", "t", "->", "new", "ConcurrentHashMap", "<>", "(", ")", ")", ".", "keySet", "(",...
Returns event log names for the given type. @param type the type for which to return event log names @return event log names for the given type
[ "Returns", "event", "log", "names", "for", "the", "given", "type", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/rest/src/main/java/io/atomix/rest/impl/EventManager.java#L78-L80
27,543
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java
PrimaryBackupServerContext.getService
private CompletableFuture<PrimaryBackupServiceContext> getService(PrimitiveRequest request) { return services.computeIfAbsent(request.primitive().name(), n -> { PrimitiveType primitiveType = primitiveTypes.getPrimitiveType(request.primitive().type()); PrimaryBackupServiceContext service = new PrimaryBac...
java
private CompletableFuture<PrimaryBackupServiceContext> getService(PrimitiveRequest request) { return services.computeIfAbsent(request.primitive().name(), n -> { PrimitiveType primitiveType = primitiveTypes.getPrimitiveType(request.primitive().type()); PrimaryBackupServiceContext service = new PrimaryBac...
[ "private", "CompletableFuture", "<", "PrimaryBackupServiceContext", ">", "getService", "(", "PrimitiveRequest", "request", ")", "{", "return", "services", ".", "computeIfAbsent", "(", "request", ".", "primitive", "(", ")", ".", "name", "(", ")", ",", "n", "->", ...
Returns the service context for the given request.
[ "Returns", "the", "service", "context", "for", "the", "given", "request", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java#L147-L171
27,544
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java
PrimaryBackupServerContext.metadata
private CompletableFuture<MetadataResponse> metadata(MetadataRequest request) { return CompletableFuture.completedFuture(MetadataResponse.ok(services.entrySet().stream() .filter(entry -> Futures.get(entry.getValue()).serviceType().name().equals(request.primitiveType())) .map(entry -> entry.getKey())...
java
private CompletableFuture<MetadataResponse> metadata(MetadataRequest request) { return CompletableFuture.completedFuture(MetadataResponse.ok(services.entrySet().stream() .filter(entry -> Futures.get(entry.getValue()).serviceType().name().equals(request.primitiveType())) .map(entry -> entry.getKey())...
[ "private", "CompletableFuture", "<", "MetadataResponse", ">", "metadata", "(", "MetadataRequest", "request", ")", "{", "return", "CompletableFuture", ".", "completedFuture", "(", "MetadataResponse", ".", "ok", "(", "services", ".", "entrySet", "(", ")", ".", "stre...
Handles a metadata request.
[ "Handles", "a", "metadata", "request", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java#L176-L181
27,545
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java
PrimaryBackupServerContext.unregisterListeners
private void unregisterListeners() { protocol.unregisterExecuteHandler(); protocol.unregisterBackupHandler(); protocol.unregisterRestoreHandler(); protocol.unregisterCloseHandler(); protocol.unregisterMetadataHandler(); }
java
private void unregisterListeners() { protocol.unregisterExecuteHandler(); protocol.unregisterBackupHandler(); protocol.unregisterRestoreHandler(); protocol.unregisterCloseHandler(); protocol.unregisterMetadataHandler(); }
[ "private", "void", "unregisterListeners", "(", ")", "{", "protocol", ".", "unregisterExecuteHandler", "(", ")", ";", "protocol", ".", "unregisterBackupHandler", "(", ")", ";", "protocol", ".", "unregisterRestoreHandler", "(", ")", ";", "protocol", ".", "unregister...
Unregisters message listeners.
[ "Unregisters", "message", "listeners", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/impl/PrimaryBackupServerContext.java#L197-L203
27,546
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java
NettyMessagingService.executeOnTransientConnection
private <T> CompletableFuture<T> executeOnTransientConnection( Address address, Function<ClientConnection, CompletableFuture<T>> callback, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); if (address.equals(returnAddress)) { callback.apply(localConnection).wh...
java
private <T> CompletableFuture<T> executeOnTransientConnection( Address address, Function<ClientConnection, CompletableFuture<T>> callback, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); if (address.equals(returnAddress)) { callback.apply(localConnection).wh...
[ "private", "<", "T", ">", "CompletableFuture", "<", "T", ">", "executeOnTransientConnection", "(", "Address", "address", ",", "Function", "<", "ClientConnection", ",", "CompletableFuture", "<", "T", ">", ">", "callback", ",", "Executor", "executor", ")", "{", ...
Executes the given callback on a transient connection. @param address the connection address @param callback the callback to execute @param executor an executor on which to complete the callback future @param <T> the callback response type
[ "Executes", "the", "given", "callback", "on", "a", "transient", "connection", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java#L366-L397
27,547
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java
NettyMessagingService.bootstrapClient
private CompletableFuture<Channel> bootstrapClient(Address address) { CompletableFuture<Channel> future = new OrderedFuture<>(); Bootstrap bootstrap = new Bootstrap(); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, ...
java
private CompletableFuture<Channel> bootstrapClient(Address address) { CompletableFuture<Channel> future = new OrderedFuture<>(); Bootstrap bootstrap = new Bootstrap(); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, ...
[ "private", "CompletableFuture", "<", "Channel", ">", "bootstrapClient", "(", "Address", "address", ")", "{", "CompletableFuture", "<", "Channel", ">", "future", "=", "new", "OrderedFuture", "<>", "(", ")", ";", "Bootstrap", "bootstrap", "=", "new", "Bootstrap", ...
Bootstraps a new channel to the given address. @param address the address to which to connect @return a future to be completed with the connected channel
[ "Bootstraps", "a", "new", "channel", "to", "the", "given", "address", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java#L471-L502
27,548
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java
NettyMessagingService.bootstrapServer
private CompletableFuture<Void> bootstrapServer() { ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_REUSEADDR, true); b.option(ChannelOption.SO_BACKLOG, 128); b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024)); b.childOpti...
java
private CompletableFuture<Void> bootstrapServer() { ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_REUSEADDR, true); b.option(ChannelOption.SO_BACKLOG, 128); b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024)); b.childOpti...
[ "private", "CompletableFuture", "<", "Void", ">", "bootstrapServer", "(", ")", "{", "ServerBootstrap", "b", "=", "new", "ServerBootstrap", "(", ")", ";", "b", ".", "option", "(", "ChannelOption", ".", "SO_REUSEADDR", ",", "true", ")", ";", "b", ".", "optio...
Bootstraps a server. @return a future to be completed once the server has been bound to all interfaces
[ "Bootstraps", "a", "server", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java#L509-L532
27,549
atomix/atomix
utils/src/main/java/io/atomix/utils/misc/StringUtils.java
StringUtils.split
public static String[] split(String input, String regex) { if (input == null) { return null; } String[] arr = input.split(regex); List<String> results = new ArrayList<>(arr.length); for (String a : arr) { if (!a.trim().isEmpty()) { results.add(a); } } return results...
java
public static String[] split(String input, String regex) { if (input == null) { return null; } String[] arr = input.split(regex); List<String> results = new ArrayList<>(arr.length); for (String a : arr) { if (!a.trim().isEmpty()) { results.add(a); } } return results...
[ "public", "static", "String", "[", "]", "split", "(", "String", "input", ",", "String", "regex", ")", "{", "if", "(", "input", "==", "null", ")", "{", "return", "null", ";", "}", "String", "[", "]", "arr", "=", "input", ".", "split", "(", "regex", ...
Splits the input string with the given regex and filters empty strings. @param input the string to split. @return the array of strings computed by splitting this string
[ "Splits", "the", "input", "string", "with", "the", "given", "regex", "and", "filters", "empty", "strings", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/misc/StringUtils.java#L35-L47
27,550
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.awaitState
public void awaitState(State state, Consumer<State> listener) { if (this.state == state) { listener.accept(this.state); } else { addStateChangeListener(new Consumer<State>() { @Override public void accept(State state) { listener.accept(state); removeStateChangeLis...
java
public void awaitState(State state, Consumer<State> listener) { if (this.state == state) { listener.accept(this.state); } else { addStateChangeListener(new Consumer<State>() { @Override public void accept(State state) { listener.accept(state); removeStateChangeLis...
[ "public", "void", "awaitState", "(", "State", "state", ",", "Consumer", "<", "State", ">", "listener", ")", "{", "if", "(", "this", ".", "state", "==", "state", ")", "{", "listener", ".", "accept", "(", "this", ".", "state", ")", ";", "}", "else", ...
Awaits a state change. @param state the state for which to wait @param listener the listener to call when the next state change occurs
[ "Awaits", "a", "state", "change", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L234-L246
27,551
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.getLeader
public DefaultRaftMember getLeader() { // Store in a local variable to prevent race conditions and/or multiple volatile lookups. MemberId leader = this.leader; return leader != null ? cluster.getMember(leader) : null; }
java
public DefaultRaftMember getLeader() { // Store in a local variable to prevent race conditions and/or multiple volatile lookups. MemberId leader = this.leader; return leader != null ? cluster.getMember(leader) : null; }
[ "public", "DefaultRaftMember", "getLeader", "(", ")", "{", "// Store in a local variable to prevent race conditions and/or multiple volatile lookups.", "MemberId", "leader", "=", "this", ".", "leader", ";", "return", "leader", "!=", "null", "?", "cluster", ".", "getMember",...
Returns the state leader. @return The state leader.
[ "Returns", "the", "state", "leader", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L406-L410
27,552
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.isLeader
public boolean isLeader() { MemberId leader = this.leader; return leader != null && leader.equals(cluster.getMember().memberId()); }
java
public boolean isLeader() { MemberId leader = this.leader; return leader != null && leader.equals(cluster.getMember().memberId()); }
[ "public", "boolean", "isLeader", "(", ")", "{", "MemberId", "leader", "=", "this", ".", "leader", ";", "return", "leader", "!=", "null", "&&", "leader", ".", "equals", "(", "cluster", ".", "getMember", "(", ")", ".", "memberId", "(", ")", ")", ";", "...
Returns a boolean indicating whether this server is the current leader. @return Indicates whether this server is the leader.
[ "Returns", "a", "boolean", "indicating", "whether", "this", "server", "is", "the", "current", "leader", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L417-L420
27,553
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.setLastApplied
public void setLastApplied(long lastApplied) { this.lastApplied = Math.max(this.lastApplied, lastApplied); if (state == State.ACTIVE) { threadContext.execute(() -> { if (state == State.ACTIVE && this.lastApplied >= firstCommitIndex) { state = State.READY; stateChangeListeners.f...
java
public void setLastApplied(long lastApplied) { this.lastApplied = Math.max(this.lastApplied, lastApplied); if (state == State.ACTIVE) { threadContext.execute(() -> { if (state == State.ACTIVE && this.lastApplied >= firstCommitIndex) { state = State.READY; stateChangeListeners.f...
[ "public", "void", "setLastApplied", "(", "long", "lastApplied", ")", "{", "this", ".", "lastApplied", "=", "Math", ".", "max", "(", "this", ".", "lastApplied", ",", "lastApplied", ")", ";", "if", "(", "state", "==", "State", ".", "ACTIVE", ")", "{", "t...
Sets the last applied index. @param lastApplied the last applied index
[ "Sets", "the", "last", "applied", "index", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L531-L541
27,554
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.compact
public CompletableFuture<Void> compact() { ComposableFuture<Void> future = new ComposableFuture<>(); threadContext.execute(() -> stateMachine.compact().whenComplete(future)); return future; }
java
public CompletableFuture<Void> compact() { ComposableFuture<Void> future = new ComposableFuture<>(); threadContext.execute(() -> stateMachine.compact().whenComplete(future)); return future; }
[ "public", "CompletableFuture", "<", "Void", ">", "compact", "(", ")", "{", "ComposableFuture", "<", "Void", ">", "future", "=", "new", "ComposableFuture", "<>", "(", ")", ";", "threadContext", ".", "execute", "(", "(", ")", "->", "stateMachine", ".", "comp...
Compacts the server logs. @return a future to be completed once the logs have been compacted
[ "Compacts", "the", "server", "logs", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L665-L669
27,555
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.registerHandlers
private void registerHandlers(RaftServerProtocol protocol) { protocol.registerOpenSessionHandler(request -> runOnContextIfReady(() -> role.onOpenSession(request), OpenSessionResponse::builder)); protocol.registerCloseSessionHandler(request -> runOnContextIfReady(() -> role.onCloseSession(request), CloseSessionR...
java
private void registerHandlers(RaftServerProtocol protocol) { protocol.registerOpenSessionHandler(request -> runOnContextIfReady(() -> role.onOpenSession(request), OpenSessionResponse::builder)); protocol.registerCloseSessionHandler(request -> runOnContextIfReady(() -> role.onCloseSession(request), CloseSessionR...
[ "private", "void", "registerHandlers", "(", "RaftServerProtocol", "protocol", ")", "{", "protocol", ".", "registerOpenSessionHandler", "(", "request", "->", "runOnContextIfReady", "(", "(", ")", "->", "role", ".", "onOpenSession", "(", "request", ")", ",", "OpenSe...
Registers server handlers on the configured protocol.
[ "Registers", "server", "handlers", "on", "the", "configured", "protocol", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L681-L697
27,556
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.unregisterHandlers
private void unregisterHandlers(RaftServerProtocol protocol) { protocol.unregisterOpenSessionHandler(); protocol.unregisterCloseSessionHandler(); protocol.unregisterKeepAliveHandler(); protocol.unregisterMetadataHandler(); protocol.unregisterConfigureHandler(); protocol.unregisterInstallHandler(...
java
private void unregisterHandlers(RaftServerProtocol protocol) { protocol.unregisterOpenSessionHandler(); protocol.unregisterCloseSessionHandler(); protocol.unregisterKeepAliveHandler(); protocol.unregisterMetadataHandler(); protocol.unregisterConfigureHandler(); protocol.unregisterInstallHandler(...
[ "private", "void", "unregisterHandlers", "(", "RaftServerProtocol", "protocol", ")", "{", "protocol", ".", "unregisterOpenSessionHandler", "(", ")", ";", "protocol", ".", "unregisterCloseSessionHandler", "(", ")", ";", "protocol", ".", "unregisterKeepAliveHandler", "(",...
Unregisters server handlers on the configured protocol.
[ "Unregisters", "server", "handlers", "on", "the", "configured", "protocol", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L728-L744
27,557
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java
RaftContext.anoint
public CompletableFuture<Void> anoint() { if (role.role() == RaftServer.Role.LEADER) { return CompletableFuture.completedFuture(null); } CompletableFuture<Void> future = new CompletableFuture<>(); threadContext.execute(() -> { // Register a leader election listener to wait for the election...
java
public CompletableFuture<Void> anoint() { if (role.role() == RaftServer.Role.LEADER) { return CompletableFuture.completedFuture(null); } CompletableFuture<Void> future = new CompletableFuture<>(); threadContext.execute(() -> { // Register a leader election listener to wait for the election...
[ "public", "CompletableFuture", "<", "Void", ">", "anoint", "(", ")", "{", "if", "(", "role", ".", "role", "(", ")", "==", "RaftServer", ".", "Role", ".", "LEADER", ")", "{", "return", "CompletableFuture", ".", "completedFuture", "(", "null", ")", ";", ...
Attempts to become the leader.
[ "Attempts", "to", "become", "the", "leader", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/impl/RaftContext.java#L749-L792
27,558
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java
MemberSelector.state
public State state() { if (selectionsIterator == null) { return State.RESET; } else if (hasNext()) { return State.ITERATE; } else { return State.COMPLETE; } }
java
public State state() { if (selectionsIterator == null) { return State.RESET; } else if (hasNext()) { return State.ITERATE; } else { return State.COMPLETE; } }
[ "public", "State", "state", "(", ")", "{", "if", "(", "selectionsIterator", "==", "null", ")", "{", "return", "State", ".", "RESET", ";", "}", "else", "if", "(", "hasNext", "(", ")", ")", "{", "return", "State", ".", "ITERATE", ";", "}", "else", "{...
Returns the address selector state. @return The address selector state.
[ "Returns", "the", "address", "selector", "state", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java#L81-L89
27,559
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java
MemberSelector.reset
public MemberSelector reset() { if (selectionsIterator != null) { this.selections = strategy.selectConnections(leader, Lists.newLinkedList(members)); this.selectionsIterator = null; } return this; }
java
public MemberSelector reset() { if (selectionsIterator != null) { this.selections = strategy.selectConnections(leader, Lists.newLinkedList(members)); this.selectionsIterator = null; } return this; }
[ "public", "MemberSelector", "reset", "(", ")", "{", "if", "(", "selectionsIterator", "!=", "null", ")", "{", "this", ".", "selections", "=", "strategy", ".", "selectConnections", "(", "leader", ",", "Lists", ".", "newLinkedList", "(", "members", ")", ")", ...
Resets the member iterator. @return The member selector.
[ "Resets", "the", "member", "iterator", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java#L123-L129
27,560
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java
MemberSelector.reset
public MemberSelector reset(MemberId leader, Collection<MemberId> members) { if (changed(leader, members)) { this.leader = leader != null && members.contains(leader) ? leader : null; this.members = Sets.newLinkedHashSet(members); this.selections = strategy.selectConnections(leader, Lists.newLinked...
java
public MemberSelector reset(MemberId leader, Collection<MemberId> members) { if (changed(leader, members)) { this.leader = leader != null && members.contains(leader) ? leader : null; this.members = Sets.newLinkedHashSet(members); this.selections = strategy.selectConnections(leader, Lists.newLinked...
[ "public", "MemberSelector", "reset", "(", "MemberId", "leader", ",", "Collection", "<", "MemberId", ">", "members", ")", "{", "if", "(", "changed", "(", "leader", ",", "members", ")", ")", "{", "this", ".", "leader", "=", "leader", "!=", "null", "&&", ...
Resets the connection leader and members. @param members The collection of members. @return The member selector.
[ "Resets", "the", "connection", "leader", "and", "members", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/MemberSelector.java#L137-L145
27,561
atomix/atomix
protocols/gossip/src/main/java/io/atomix/protocols/gossip/value/CrdtValueDelegate.java
CrdtValueDelegate.encode
private String encode(Object value) { return BaseEncoding.base16().encode(valueSerializer.encode(value)); }
java
private String encode(Object value) { return BaseEncoding.base16().encode(valueSerializer.encode(value)); }
[ "private", "String", "encode", "(", "Object", "value", ")", "{", "return", "BaseEncoding", ".", "base16", "(", ")", ".", "encode", "(", "valueSerializer", ".", "encode", "(", "value", ")", ")", ";", "}" ]
Encodes the given value to a string for internal storage. @param value the value to encode @return the encoded value
[ "Encodes", "the", "given", "value", "to", "a", "string", "for", "internal", "storage", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/gossip/src/main/java/io/atomix/protocols/gossip/value/CrdtValueDelegate.java#L128-L130
27,562
atomix/atomix
protocols/gossip/src/main/java/io/atomix/protocols/gossip/value/CrdtValueDelegate.java
CrdtValueDelegate.decode
protected V decode(String value) { return valueSerializer.decode(BaseEncoding.base16().decode(value)); }
java
protected V decode(String value) { return valueSerializer.decode(BaseEncoding.base16().decode(value)); }
[ "protected", "V", "decode", "(", "String", "value", ")", "{", "return", "valueSerializer", ".", "decode", "(", "BaseEncoding", ".", "base16", "(", ")", ".", "decode", "(", "value", ")", ")", ";", "}" ]
Decodes the given value from a string. @param value the value to decode @return the decoded value
[ "Decodes", "the", "given", "value", "from", "a", "string", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/gossip/src/main/java/io/atomix/protocols/gossip/value/CrdtValueDelegate.java#L138-L140
27,563
atomix/atomix
storage/src/main/java/io/atomix/storage/journal/JournalSegment.java
JournalSegment.map
private void map() { if (storageLevel == StorageLevel.MAPPED) { MappedByteBuffer buffer = writer.map(); readers.forEach(reader -> reader.map(buffer)); } }
java
private void map() { if (storageLevel == StorageLevel.MAPPED) { MappedByteBuffer buffer = writer.map(); readers.forEach(reader -> reader.map(buffer)); } }
[ "private", "void", "map", "(", ")", "{", "if", "(", "storageLevel", "==", "StorageLevel", ".", "MAPPED", ")", "{", "MappedByteBuffer", "buffer", "=", "writer", ".", "map", "(", ")", ";", "readers", ".", "forEach", "(", "reader", "->", "reader", ".", "m...
Maps the log segment into memory.
[ "Maps", "the", "log", "segment", "into", "memory", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/journal/JournalSegment.java#L180-L185
27,564
atomix/atomix
storage/src/main/java/io/atomix/storage/journal/JournalSegment.java
JournalSegment.unmap
private void unmap() { if (storageLevel == StorageLevel.MAPPED) { writer.unmap(); readers.forEach(reader -> reader.unmap()); } }
java
private void unmap() { if (storageLevel == StorageLevel.MAPPED) { writer.unmap(); readers.forEach(reader -> reader.unmap()); } }
[ "private", "void", "unmap", "(", ")", "{", "if", "(", "storageLevel", "==", "StorageLevel", ".", "MAPPED", ")", "{", "writer", ".", "unmap", "(", ")", ";", "readers", ".", "forEach", "(", "reader", "->", "reader", ".", "unmap", "(", ")", ")", ";", ...
Unmaps the log segment from memory.
[ "Unmaps", "the", "log", "segment", "from", "memory", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/journal/JournalSegment.java#L190-L195
27,565
atomix/atomix
storage/src/main/java/io/atomix/storage/journal/JournalSegment.java
JournalSegment.createReader
MappableJournalSegmentReader<E> createReader() { checkOpen(); MappableJournalSegmentReader<E> reader = new MappableJournalSegmentReader<>( openChannel(file.file()), this, maxEntrySize, index, namespace); MappedByteBuffer buffer = writer.buffer(); if (buffer != null) { reader.map(buffer); ...
java
MappableJournalSegmentReader<E> createReader() { checkOpen(); MappableJournalSegmentReader<E> reader = new MappableJournalSegmentReader<>( openChannel(file.file()), this, maxEntrySize, index, namespace); MappedByteBuffer buffer = writer.buffer(); if (buffer != null) { reader.map(buffer); ...
[ "MappableJournalSegmentReader", "<", "E", ">", "createReader", "(", ")", "{", "checkOpen", "(", ")", ";", "MappableJournalSegmentReader", "<", "E", ">", "reader", "=", "new", "MappableJournalSegmentReader", "<>", "(", "openChannel", "(", "file", ".", "file", "("...
Creates a new segment reader. @return A new segment reader.
[ "Creates", "a", "new", "segment", "reader", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/journal/JournalSegment.java#L212-L222
27,566
atomix/atomix
storage/src/main/java/io/atomix/storage/journal/JournalSegment.java
JournalSegment.close
@Override public void close() { unmap(); writer.close(); readers.forEach(reader -> reader.close()); open = false; }
java
@Override public void close() { unmap(); writer.close(); readers.forEach(reader -> reader.close()); open = false; }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "unmap", "(", ")", ";", "writer", ".", "close", "(", ")", ";", "readers", ".", "forEach", "(", "reader", "->", "reader", ".", "close", "(", ")", ")", ";", "open", "=", "false", ";", "}" ]
Closes the segment.
[ "Closes", "the", "segment", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/journal/JournalSegment.java#L252-L258
27,567
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Futures.java
Futures.completedFutureAsync
public static <T> CompletableFuture<T> completedFutureAsync(T result, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> future.complete(result)); return future; }
java
public static <T> CompletableFuture<T> completedFutureAsync(T result, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> future.complete(result)); return future; }
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "T", ">", "completedFutureAsync", "(", "T", "result", ",", "Executor", "executor", ")", "{", "CompletableFuture", "<", "T", ">", "future", "=", "new", "CompletableFuture", "<>", "(", ")", ";", "e...
Creates a future that is asynchronously completed. @param result The future result. @param executor The executor on which to complete the future. @return The completed future.
[ "Creates", "a", "future", "that", "is", "asynchronously", "completed", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Futures.java#L83-L87
27,568
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Futures.java
Futures.exceptionalFutureAsync
public static <T> CompletableFuture<T> exceptionalFutureAsync(Throwable t, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { future.completeExceptionally(t); }); return future; }
java
public static <T> CompletableFuture<T> exceptionalFutureAsync(Throwable t, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { future.completeExceptionally(t); }); return future; }
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "T", ">", "exceptionalFutureAsync", "(", "Throwable", "t", ",", "Executor", "executor", ")", "{", "CompletableFuture", "<", "T", ">", "future", "=", "new", "CompletableFuture", "<>", "(", ")", ";",...
Creates a future that is asynchronously completed exceptionally. @param t The future exception. @param executor The executor on which to complete the future. @return The exceptionally completed future.
[ "Creates", "a", "future", "that", "is", "asynchronously", "completed", "exceptionally", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Futures.java#L108-L114
27,569
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Futures.java
Futures.orderedFuture
public static <T> CompletableFuture<T> orderedFuture(CompletableFuture<T> future) { CompletableFuture<T> newFuture = new OrderedFuture<>(); future.whenComplete((r, e) -> { if (e == null) { newFuture.complete(r); } else { newFuture.completeExceptionally(e); } }); return ...
java
public static <T> CompletableFuture<T> orderedFuture(CompletableFuture<T> future) { CompletableFuture<T> newFuture = new OrderedFuture<>(); future.whenComplete((r, e) -> { if (e == null) { newFuture.complete(r); } else { newFuture.completeExceptionally(e); } }); return ...
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "T", ">", "orderedFuture", "(", "CompletableFuture", "<", "T", ">", "future", ")", "{", "CompletableFuture", "<", "T", ">", "newFuture", "=", "new", "OrderedFuture", "<>", "(", ")", ";", "future"...
Returns a future that completes callbacks in add order. @param <T> future value type @return a new completable future that will complete added callbacks in the order in which they were added
[ "Returns", "a", "future", "that", "completes", "callbacks", "in", "add", "order", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Futures.java#L132-L142
27,570
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Futures.java
Futures.asyncFuture
public static <T> CompletableFuture<T> asyncFuture(CompletableFuture<T> future, Executor executor) { CompletableFuture<T> newFuture = new AtomixFuture<>(); future.whenComplete((result, error) -> { executor.execute(() -> { if (error == null) { newFuture.complete(result); } else { ...
java
public static <T> CompletableFuture<T> asyncFuture(CompletableFuture<T> future, Executor executor) { CompletableFuture<T> newFuture = new AtomixFuture<>(); future.whenComplete((result, error) -> { executor.execute(() -> { if (error == null) { newFuture.complete(result); } else { ...
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "T", ">", "asyncFuture", "(", "CompletableFuture", "<", "T", ">", "future", ",", "Executor", "executor", ")", "{", "CompletableFuture", "<", "T", ">", "newFuture", "=", "new", "AtomixFuture", "<>",...
Returns a wrapped future that will be completed on the given executor. @param future the future to be completed on the given executor @param executor the executor with which to complete the future @param <T> the future value type @return a wrapped future to be completed on the given executor
[ "Returns", "a", "wrapped", "future", "that", "will", "be", "completed", "on", "the", "given", "executor", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Futures.java#L152-L164
27,571
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Futures.java
Futures.allOf
public static <T> CompletableFuture<T> allOf( List<CompletableFuture<T>> futures, BinaryOperator<T> reducer, T emptyValue) { return allOf(futures).thenApply(resultList -> resultList.stream().reduce(reducer).orElse(emptyValue)); }
java
public static <T> CompletableFuture<T> allOf( List<CompletableFuture<T>> futures, BinaryOperator<T> reducer, T emptyValue) { return allOf(futures).thenApply(resultList -> resultList.stream().reduce(reducer).orElse(emptyValue)); }
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "T", ">", "allOf", "(", "List", "<", "CompletableFuture", "<", "T", ">", ">", "futures", ",", "BinaryOperator", "<", "T", ">", "reducer", ",", "T", "emptyValue", ")", "{", "return", "allOf", ...
Returns a new CompletableFuture completed by reducing a list of computed values when all of the given CompletableFuture complete. @param futures the CompletableFutures @param reducer reducer for computing the result @param emptyValue zero value to be returned if the input future list is empty @param <T> v...
[ "Returns", "a", "new", "CompletableFuture", "completed", "by", "reducing", "a", "list", "of", "computed", "values", "when", "all", "of", "the", "given", "CompletableFuture", "complete", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Futures.java#L206-L209
27,572
atomix/atomix
protocols/primary-backup/src/main/java/io/atomix/protocols/backup/roles/PrimaryBackupRole.java
PrimaryBackupRole.execute
public CompletableFuture<ExecuteResponse> execute(ExecuteRequest request) { logRequest(request); return CompletableFuture.completedFuture(logResponse(ExecuteResponse.error())); }
java
public CompletableFuture<ExecuteResponse> execute(ExecuteRequest request) { logRequest(request); return CompletableFuture.completedFuture(logResponse(ExecuteResponse.error())); }
[ "public", "CompletableFuture", "<", "ExecuteResponse", ">", "execute", "(", "ExecuteRequest", "request", ")", "{", "logRequest", "(", "request", ")", ";", "return", "CompletableFuture", ".", "completedFuture", "(", "logResponse", "(", "ExecuteResponse", ".", "error"...
Handles an execute response. @param request the execute request @return future to be completed with the execute response
[ "Handles", "an", "execute", "response", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/primary-backup/src/main/java/io/atomix/protocols/backup/roles/PrimaryBackupRole.java#L85-L88
27,573
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java
RaftSessionListener.addEventListener
public void addEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { executor.execute(() -> eventListeners.computeIfAbsent(eventType.canonicalize(), e -> Sets.newLinkedHashSet()).add(listener)); }
java
public void addEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { executor.execute(() -> eventListeners.computeIfAbsent(eventType.canonicalize(), e -> Sets.newLinkedHashSet()).add(listener)); }
[ "public", "void", "addEventListener", "(", "EventType", "eventType", ",", "Consumer", "<", "PrimitiveEvent", ">", "listener", ")", "{", "executor", ".", "execute", "(", "(", ")", "->", "eventListeners", ".", "computeIfAbsent", "(", "eventType", ".", "canonicaliz...
Adds an event listener to the session. @param listener the event listener callback
[ "Adds", "an", "event", "listener", "to", "the", "session", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java#L69-L71
27,574
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java
RaftSessionListener.removeEventListener
public void removeEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { executor.execute(() -> eventListeners.computeIfAbsent(eventType.canonicalize(), e -> Sets.newLinkedHashSet()).remove(listener)); }
java
public void removeEventListener(EventType eventType, Consumer<PrimitiveEvent> listener) { executor.execute(() -> eventListeners.computeIfAbsent(eventType.canonicalize(), e -> Sets.newLinkedHashSet()).remove(listener)); }
[ "public", "void", "removeEventListener", "(", "EventType", "eventType", ",", "Consumer", "<", "PrimitiveEvent", ">", "listener", ")", "{", "executor", ".", "execute", "(", "(", ")", "->", "eventListeners", ".", "computeIfAbsent", "(", "eventType", ".", "canonica...
Removes an event listener from the session. @param listener the event listener callback
[ "Removes", "an", "event", "listener", "from", "the", "session", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java#L78-L80
27,575
atomix/atomix
protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java
RaftSessionListener.close
public CompletableFuture<Void> close() { protocol.unregisterPublishListener(state.getSessionId()); return CompletableFuture.completedFuture(null); }
java
public CompletableFuture<Void> close() { protocol.unregisterPublishListener(state.getSessionId()); return CompletableFuture.completedFuture(null); }
[ "public", "CompletableFuture", "<", "Void", ">", "close", "(", ")", "{", "protocol", ".", "unregisterPublishListener", "(", "state", ".", "getSessionId", "(", ")", ")", ";", "return", "CompletableFuture", ".", "completedFuture", "(", "null", ")", ";", "}" ]
Closes the session event listener. @return A completable future to be completed once the listener is closed.
[ "Closes", "the", "session", "event", "listener", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/impl/RaftSessionListener.java#L141-L144
27,576
atomix/atomix
primitive/src/main/java/io/atomix/primitive/operation/Operations.java
Operations.findMethods
private static Map<Method, OperationId> findMethods(Class<?> type) { Map<Method, OperationId> operations = new HashMap<>(); for (Method method : type.getDeclaredMethods()) { OperationId operationId = getOperationId(method); if (operationId != null) { if (operations.values().stream().anyMatch...
java
private static Map<Method, OperationId> findMethods(Class<?> type) { Map<Method, OperationId> operations = new HashMap<>(); for (Method method : type.getDeclaredMethods()) { OperationId operationId = getOperationId(method); if (operationId != null) { if (operations.values().stream().anyMatch...
[ "private", "static", "Map", "<", "Method", ",", "OperationId", ">", "findMethods", "(", "Class", "<", "?", ">", "type", ")", "{", "Map", "<", "Method", ",", "OperationId", ">", "operations", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Me...
Recursively finds operations defined by the given type and its implemented interfaces. @param type the type for which to find operations @return the operations defined by the given type and its parent interfaces
[ "Recursively", "finds", "operations", "defined", "by", "the", "given", "type", "and", "its", "implemented", "interfaces", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/primitive/src/main/java/io/atomix/primitive/operation/Operations.java#L50-L65
27,577
atomix/atomix
primitive/src/main/java/io/atomix/primitive/operation/Operations.java
Operations.getOperationId
private static OperationId getOperationId(Method method) { Command command = method.getAnnotation(Command.class); if (command != null) { String name = command.value().equals("") ? method.getName() : command.value(); return OperationId.from(name, OperationType.COMMAND); } Query query = method...
java
private static OperationId getOperationId(Method method) { Command command = method.getAnnotation(Command.class); if (command != null) { String name = command.value().equals("") ? method.getName() : command.value(); return OperationId.from(name, OperationType.COMMAND); } Query query = method...
[ "private", "static", "OperationId", "getOperationId", "(", "Method", "method", ")", "{", "Command", "command", "=", "method", ".", "getAnnotation", "(", "Command", ".", "class", ")", ";", "if", "(", "command", "!=", "null", ")", "{", "String", "name", "=",...
Returns the operation ID for the given method. @param method the method for which to lookup the operation ID @return the operation ID for the given method or null if the method is not annotated
[ "Returns", "the", "operation", "ID", "for", "the", "given", "method", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/primitive/src/main/java/io/atomix/primitive/operation/Operations.java#L117-L134
27,578
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyUnicastService.java
NettyUnicastService.bind
private void bind(Bootstrap bootstrap, Iterator<String> ifaces, int port, CompletableFuture<Void> future) { if (ifaces.hasNext()) { String iface = ifaces.next(); bootstrap.bind(iface, port).addListener((ChannelFutureListener) f -> { if (f.isSuccess()) { log.info("UDP server listening f...
java
private void bind(Bootstrap bootstrap, Iterator<String> ifaces, int port, CompletableFuture<Void> future) { if (ifaces.hasNext()) { String iface = ifaces.next(); bootstrap.bind(iface, port).addListener((ChannelFutureListener) f -> { if (f.isSuccess()) { log.info("UDP server listening f...
[ "private", "void", "bind", "(", "Bootstrap", "bootstrap", ",", "Iterator", "<", "String", ">", "ifaces", ",", "int", "port", ",", "CompletableFuture", "<", "Void", ">", "future", ")", "{", "if", "(", "ifaces", ".", "hasNext", "(", ")", ")", "{", "Strin...
Recursively binds the given bootstrap to the given interfaces. @param bootstrap the bootstrap to bind @param ifaces an iterator of interfaces to which to bind @param port the port to which to bind @param future the future to completed once the bootstrap has been bound to all provided interfaces
[ "Recursively", "binds", "the", "given", "bootstrap", "to", "the", "given", "interfaces", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyUnicastService.java#L153-L169
27,579
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.getSubscriberNodes
private Stream<MemberId> getSubscriberNodes(String topicName) { InternalTopic topic = topics.get(topicName); if (topic == null) { return Stream.empty(); } return topic.remoteSubscriptions().stream() .filter(s -> !s.isTombstone()) .map(s -> s.memberId()) .distinct(); }
java
private Stream<MemberId> getSubscriberNodes(String topicName) { InternalTopic topic = topics.get(topicName); if (topic == null) { return Stream.empty(); } return topic.remoteSubscriptions().stream() .filter(s -> !s.isTombstone()) .map(s -> s.memberId()) .distinct(); }
[ "private", "Stream", "<", "MemberId", ">", "getSubscriberNodes", "(", "String", "topicName", ")", "{", "InternalTopic", "topic", "=", "topics", ".", "get", "(", "topicName", ")", ";", "if", "(", "topic", "==", "null", ")", "{", "return", "Stream", ".", "...
Returns a collection of nodes that subscribe to the given topic. @param topicName the topic for which to return the collection of subscriber nodes @return the collection of subscribers for the given topic
[ "Returns", "a", "collection", "of", "nodes", "that", "subscribe", "to", "the", "given", "topic", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L142-L151
27,580
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.getNextMemberId
private MemberId getNextMemberId(String topicName) { InternalTopic topic = topics.get(topicName); if (topic == null) { return null; } TopicIterator iterator = topic.iterator(); if (iterator.hasNext()) { return iterator.next().memberId(); } return null; }
java
private MemberId getNextMemberId(String topicName) { InternalTopic topic = topics.get(topicName); if (topic == null) { return null; } TopicIterator iterator = topic.iterator(); if (iterator.hasNext()) { return iterator.next().memberId(); } return null; }
[ "private", "MemberId", "getNextMemberId", "(", "String", "topicName", ")", "{", "InternalTopic", "topic", "=", "topics", ".", "get", "(", "topicName", ")", ";", "if", "(", "topic", "==", "null", ")", "{", "return", "null", ";", "}", "TopicIterator", "itera...
Returns the next node ID for the given message topic. @param topicName the topic for which to return the next node ID @return the next node ID for the given message topic
[ "Returns", "the", "next", "node", "ID", "for", "the", "given", "message", "topic", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L159-L170
27,581
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.update
private void update(Collection<InternalSubscriptionInfo> subscriptions) { for (InternalSubscriptionInfo subscription : subscriptions) { InternalTopic topic = topics.computeIfAbsent(subscription.topic, InternalTopic::new); InternalSubscriptionInfo matchingSubscription = topic.remoteSubscriptions().stream...
java
private void update(Collection<InternalSubscriptionInfo> subscriptions) { for (InternalSubscriptionInfo subscription : subscriptions) { InternalTopic topic = topics.computeIfAbsent(subscription.topic, InternalTopic::new); InternalSubscriptionInfo matchingSubscription = topic.remoteSubscriptions().stream...
[ "private", "void", "update", "(", "Collection", "<", "InternalSubscriptionInfo", ">", "subscriptions", ")", "{", "for", "(", "InternalSubscriptionInfo", "subscription", ":", "subscriptions", ")", "{", "InternalTopic", "topic", "=", "topics", ".", "computeIfAbsent", ...
Handles a collection of subscription updates received via the gossip protocol. @param subscriptions a collection of subscriptions provided by the sender
[ "Handles", "a", "collection", "of", "subscription", "updates", "received", "via", "the", "gossip", "protocol", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L207-L220
27,582
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.gossip
private void gossip() { List<Member> members = membershipService.getMembers() .stream() .filter(node -> !localMemberId.equals(node.id())) .filter(node -> node.isReachable()) .collect(Collectors.toList()); if (!members.isEmpty()) { Collections.shuffle(members); Member...
java
private void gossip() { List<Member> members = membershipService.getMembers() .stream() .filter(node -> !localMemberId.equals(node.id())) .filter(node -> node.isReachable()) .collect(Collectors.toList()); if (!members.isEmpty()) { Collections.shuffle(members); Member...
[ "private", "void", "gossip", "(", ")", "{", "List", "<", "Member", ">", "members", "=", "membershipService", ".", "getMembers", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "node", "->", "!", "localMemberId", ".", "equals", "(", "node", ".", ...
Sends a gossip message to an active peer.
[ "Sends", "a", "gossip", "message", "to", "an", "active", "peer", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L225-L237
27,583
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.updateNodes
private CompletableFuture<Void> updateNodes() { List<CompletableFuture<Void>> futures = membershipService.getMembers() .stream() .filter(node -> !localMemberId.equals(node.id())) .map(this::updateNode) .collect(Collectors.toList()); return CompletableFuture.allOf(futures.toArray(...
java
private CompletableFuture<Void> updateNodes() { List<CompletableFuture<Void>> futures = membershipService.getMembers() .stream() .filter(node -> !localMemberId.equals(node.id())) .map(this::updateNode) .collect(Collectors.toList()); return CompletableFuture.allOf(futures.toArray(...
[ "private", "CompletableFuture", "<", "Void", ">", "updateNodes", "(", ")", "{", "List", "<", "CompletableFuture", "<", "Void", ">>", "futures", "=", "membershipService", ".", "getMembers", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "node", "->"...
Updates all active peers with a given subscription.
[ "Updates", "all", "active", "peers", "with", "a", "given", "subscription", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L242-L249
27,584
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.updateNode
private CompletableFuture<Void> updateNode(Member member) { long updateTime = System.currentTimeMillis(); long lastUpdateTime = updateTimes.getOrDefault(member.id(), 0L); Collection<InternalSubscriptionInfo> subscriptions = topics.values() .stream() .flatMap(t -> t.remoteSubscriptions().str...
java
private CompletableFuture<Void> updateNode(Member member) { long updateTime = System.currentTimeMillis(); long lastUpdateTime = updateTimes.getOrDefault(member.id(), 0L); Collection<InternalSubscriptionInfo> subscriptions = topics.values() .stream() .flatMap(t -> t.remoteSubscriptions().str...
[ "private", "CompletableFuture", "<", "Void", ">", "updateNode", "(", "Member", "member", ")", "{", "long", "updateTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "long", "lastUpdateTime", "=", "updateTimes", ".", "getOrDefault", "(", "member", "...
Sends an update to the given node. @param member the node to which to send the update
[ "Sends", "an", "update", "to", "the", "given", "node", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L256-L274
27,585
atomix/atomix
cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java
DefaultClusterEventService.purgeTombstones
private void purgeTombstones() { long minTombstoneTime = membershipService.getMembers() .stream() .map(node -> updateTimes.getOrDefault(node.id(), 0L)) .reduce(Math::min) .orElse(0L); for (InternalTopic topic : topics.values()) { topic.purgeTombstones(minTombstoneTime); ...
java
private void purgeTombstones() { long minTombstoneTime = membershipService.getMembers() .stream() .map(node -> updateTimes.getOrDefault(node.id(), 0L)) .reduce(Math::min) .orElse(0L); for (InternalTopic topic : topics.values()) { topic.purgeTombstones(minTombstoneTime); ...
[ "private", "void", "purgeTombstones", "(", ")", "{", "long", "minTombstoneTime", "=", "membershipService", ".", "getMembers", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "node", "->", "updateTimes", ".", "getOrDefault", "(", "node", ".", "id", "(",...
Purges tombstones from the subscription list.
[ "Purges", "tombstones", "from", "the", "subscription", "list", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/DefaultClusterEventService.java#L279-L288
27,586
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Retries.java
Retries.retryable
public static <U, V> Function<U, V> retryable(Function<U, V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries) { return new Retry...
java
public static <U, V> Function<U, V> retryable(Function<U, V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries) { return new Retry...
[ "public", "static", "<", "U", ",", "V", ">", "Function", "<", "U", ",", "V", ">", "retryable", "(", "Function", "<", "U", ",", "V", ">", "base", ",", "Class", "<", "?", "extends", "Throwable", ">", "exceptionClass", ",", "int", "maxRetries", ",", "...
Returns a function that retries execution on failure. @param base base function @param exceptionClass type of exception for which to retry @param maxRetries max number of retries before giving up @param maxDelayBetweenRetries max delay between successive retries. The actual delay is randomly picked from the interval (0...
[ "Returns", "a", "function", "that", "retries", "execution", "on", "failure", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Retries.java#L38-L43
27,587
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Retries.java
Retries.retryable
public static <V> Supplier<V> retryable(Supplier<V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries) { return () -> new RetryingFunction<>(v -> ba...
java
public static <V> Supplier<V> retryable(Supplier<V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries) { return () -> new RetryingFunction<>(v -> ba...
[ "public", "static", "<", "V", ">", "Supplier", "<", "V", ">", "retryable", "(", "Supplier", "<", "V", ">", "base", ",", "Class", "<", "?", "extends", "Throwable", ">", "exceptionClass", ",", "int", "maxRetries", ",", "int", "maxDelayBetweenRetries", ")", ...
Returns a Supplier that retries execution on failure. @param base base supplier @param exceptionClass type of exception for which to retry @param maxRetries max number of retries before giving up @param maxDelayBetweenRetries max delay between successive retries. The actual delay is randomly picked from the interval (0...
[ "Returns", "a", "Supplier", "that", "retries", "execution", "on", "failure", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Retries.java#L55-L63
27,588
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Retries.java
Retries.randomDelay
public static void randomDelay(int ms) { try { Thread.sleep(ThreadLocalRandom.current().nextInt(ms)); } catch (InterruptedException e) { throw new RuntimeException("Interrupted", e); } }
java
public static void randomDelay(int ms) { try { Thread.sleep(ThreadLocalRandom.current().nextInt(ms)); } catch (InterruptedException e) { throw new RuntimeException("Interrupted", e); } }
[ "public", "static", "void", "randomDelay", "(", "int", "ms", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "ThreadLocalRandom", ".", "current", "(", ")", ".", "nextInt", "(", "ms", ")", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")"...
Suspends the current thread for a random number of millis between 0 and the indicated limit. @param ms max number of millis
[ "Suspends", "the", "current", "thread", "for", "a", "random", "number", "of", "millis", "between", "0", "and", "the", "indicated", "limit", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Retries.java#L71-L77
27,589
atomix/atomix
utils/src/main/java/io/atomix/utils/concurrent/Retries.java
Retries.delay
public static void delay(int ms, int nanos) { try { Thread.sleep(ms, nanos); } catch (InterruptedException e) { throw new RuntimeException("Interrupted", e); } }
java
public static void delay(int ms, int nanos) { try { Thread.sleep(ms, nanos); } catch (InterruptedException e) { throw new RuntimeException("Interrupted", e); } }
[ "public", "static", "void", "delay", "(", "int", "ms", ",", "int", "nanos", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "ms", ",", "nanos", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "RuntimeException", ...
Suspends the current thread for a specified number of millis and nanos. @param ms number of millis @param nanos number of nanos
[ "Suspends", "the", "current", "thread", "for", "a", "specified", "number", "of", "millis", "and", "nanos", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/utils/src/main/java/io/atomix/utils/concurrent/Retries.java#L85-L91
27,590
atomix/atomix
core/src/main/java/io/atomix/core/tree/impl/DefaultDocumentTreeNode.java
DefaultDocumentTreeNode.addChild
public Versioned<V> addChild(String name, V newValue, long newVersion) { DefaultDocumentTreeNode<V> child = (DefaultDocumentTreeNode<V>) children.get(name); if (child != null) { return child.value(); } children.put(name, new DefaultDocumentTreeNode<>( new DocumentPath(name, path()), newVal...
java
public Versioned<V> addChild(String name, V newValue, long newVersion) { DefaultDocumentTreeNode<V> child = (DefaultDocumentTreeNode<V>) children.get(name); if (child != null) { return child.value(); } children.put(name, new DefaultDocumentTreeNode<>( new DocumentPath(name, path()), newVal...
[ "public", "Versioned", "<", "V", ">", "addChild", "(", "String", "name", ",", "V", "newValue", ",", "long", "newVersion", ")", "{", "DefaultDocumentTreeNode", "<", "V", ">", "child", "=", "(", "DefaultDocumentTreeNode", "<", "V", ">", ")", "children", ".",...
Adds a new child only if one does not exist with the name. @param name relative path name of the child node @param newValue new value to set @param newVersion new version to set @return previous value; can be {@code null} if no child currently exists with that relative path name. a non null return value indica...
[ "Adds", "a", "new", "child", "only", "if", "one", "does", "not", "exist", "with", "the", "name", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/tree/impl/DefaultDocumentTreeNode.java#L98-L106
27,591
atomix/atomix
core/src/main/java/io/atomix/core/tree/impl/DefaultDocumentTreeNode.java
DefaultDocumentTreeNode.update
public Versioned<V> update(V newValue, long newVersion) { Versioned<V> previousValue = value; value = new Versioned<>(newValue, newVersion); return previousValue; }
java
public Versioned<V> update(V newValue, long newVersion) { Versioned<V> previousValue = value; value = new Versioned<>(newValue, newVersion); return previousValue; }
[ "public", "Versioned", "<", "V", ">", "update", "(", "V", "newValue", ",", "long", "newVersion", ")", "{", "Versioned", "<", "V", ">", "previousValue", "=", "value", ";", "value", "=", "new", "Versioned", "<>", "(", "newValue", ",", "newVersion", ")", ...
Updates the node value. @param newValue new value to set @param newVersion new version to set @return previous value
[ "Updates", "the", "node", "value", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/tree/impl/DefaultDocumentTreeNode.java#L115-L119
27,592
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.checkFailures
private void checkFailures() { for (SwimMember member : members.values()) { if (member.getState() == State.SUSPECT && System.currentTimeMillis() - member.getUpdated() > config.getFailureTimeout().toMillis()) { member.setState(State.DEAD); members.remove(member.id()); randomMembers.remo...
java
private void checkFailures() { for (SwimMember member : members.values()) { if (member.getState() == State.SUSPECT && System.currentTimeMillis() - member.getUpdated() > config.getFailureTimeout().toMillis()) { member.setState(State.DEAD); members.remove(member.id()); randomMembers.remo...
[ "private", "void", "checkFailures", "(", ")", "{", "for", "(", "SwimMember", "member", ":", "members", ".", "values", "(", ")", ")", "{", "if", "(", "member", ".", "getState", "(", ")", "==", "State", ".", "SUSPECT", "&&", "System", ".", "currentTimeMi...
Checks suspect nodes for failures.
[ "Checks", "suspect", "nodes", "for", "failures", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L329-L341
27,593
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.sync
private void sync() { List<SwimMember> syncMembers = discoveryService.getNodes().stream() .map(node -> new SwimMember(MemberId.from(node.id().id()), node.address())) .filter(member -> !member.id().equals(localMember.id())) .collect(Collectors.toList()); for (SwimMember member : syncMembe...
java
private void sync() { List<SwimMember> syncMembers = discoveryService.getNodes().stream() .map(node -> new SwimMember(MemberId.from(node.id().id()), node.address())) .filter(member -> !member.id().equals(localMember.id())) .collect(Collectors.toList()); for (SwimMember member : syncMembe...
[ "private", "void", "sync", "(", ")", "{", "List", "<", "SwimMember", ">", "syncMembers", "=", "discoveryService", ".", "getNodes", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "node", "->", "new", "SwimMember", "(", "MemberId", ".", "from", "(",...
Synchronizes the node state with peers.
[ "Synchronizes", "the", "node", "state", "with", "peers", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L346-L354
27,594
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.sync
private void sync(ImmutableMember member) { LOGGER.trace("{} - Synchronizing membership with {}", localMember.id(), member); bootstrapService.getMessagingService().sendAndReceive( member.address(), MEMBERSHIP_SYNC, SERIALIZER.encode(localMember.copy()), false, config.getProbeTimeout()) .whenComp...
java
private void sync(ImmutableMember member) { LOGGER.trace("{} - Synchronizing membership with {}", localMember.id(), member); bootstrapService.getMessagingService().sendAndReceive( member.address(), MEMBERSHIP_SYNC, SERIALIZER.encode(localMember.copy()), false, config.getProbeTimeout()) .whenComp...
[ "private", "void", "sync", "(", "ImmutableMember", "member", ")", "{", "LOGGER", ".", "trace", "(", "\"{} - Synchronizing membership with {}\"", ",", "localMember", ".", "id", "(", ")", ",", "member", ")", ";", "bootstrapService", ".", "getMessagingService", "(", ...
Synchronizes the node state with the given peer. @param member the peer with which to synchronize the node state
[ "Synchronizes", "the", "node", "state", "with", "the", "given", "peer", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L361-L373
27,595
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.handleSync
private Collection<ImmutableMember> handleSync(ImmutableMember member) { updateState(member); return new ArrayList<>(members.values().stream().map(SwimMember::copy).collect(Collectors.toList())); }
java
private Collection<ImmutableMember> handleSync(ImmutableMember member) { updateState(member); return new ArrayList<>(members.values().stream().map(SwimMember::copy).collect(Collectors.toList())); }
[ "private", "Collection", "<", "ImmutableMember", ">", "handleSync", "(", "ImmutableMember", "member", ")", "{", "updateState", "(", "member", ")", ";", "return", "new", "ArrayList", "<>", "(", "members", ".", "values", "(", ")", ".", "stream", "(", ")", "....
Handles a synchronize request from a peer. @param member the peer from which to handle the request
[ "Handles", "a", "synchronize", "request", "from", "a", "peer", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L380-L383
27,596
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.probe
private void probe() { // First get a sorted list of discovery service nodes that are not present in the SWIM members. // This is necessary to ensure we attempt to probe all nodes that are provided by the discovery provider. List<SwimMember> probeMembers = Lists.newArrayList(discoveryService.getNodes().stre...
java
private void probe() { // First get a sorted list of discovery service nodes that are not present in the SWIM members. // This is necessary to ensure we attempt to probe all nodes that are provided by the discovery provider. List<SwimMember> probeMembers = Lists.newArrayList(discoveryService.getNodes().stre...
[ "private", "void", "probe", "(", ")", "{", "// First get a sorted list of discovery service nodes that are not present in the SWIM members.", "// This is necessary to ensure we attempt to probe all nodes that are provided by the discovery provider.", "List", "<", "SwimMember", ">", "probeMem...
Sends probes to all members or to the next member in round robin fashion.
[ "Sends", "probes", "to", "all", "members", "or", "to", "the", "next", "member", "in", "round", "robin", "fashion", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L388-L406
27,597
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.probe
private void probe(ImmutableMember member) { LOGGER.trace("{} - Probing {}", localMember.id(), member); bootstrapService.getMessagingService().sendAndReceive( member.address(), MEMBERSHIP_PROBE, SERIALIZER.encode(Pair.of(localMember.copy(), member)), false, config.getProbeTimeout()) .whenComplet...
java
private void probe(ImmutableMember member) { LOGGER.trace("{} - Probing {}", localMember.id(), member); bootstrapService.getMessagingService().sendAndReceive( member.address(), MEMBERSHIP_PROBE, SERIALIZER.encode(Pair.of(localMember.copy(), member)), false, config.getProbeTimeout()) .whenComplet...
[ "private", "void", "probe", "(", "ImmutableMember", "member", ")", "{", "LOGGER", ".", "trace", "(", "\"{} - Probing {}\"", ",", "localMember", ".", "id", "(", ")", ",", "member", ")", ";", "bootstrapService", ".", "getMessagingService", "(", ")", ".", "send...
Probes the given member. @param member the member to probe
[ "Probes", "the", "given", "member", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L413-L429
27,598
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.handleProbe
private ImmutableMember handleProbe(Pair<ImmutableMember, ImmutableMember> members) { ImmutableMember remoteMember = members.getLeft(); ImmutableMember localMember = members.getRight(); LOGGER.trace("{} - Received probe {} from {}", this.localMember.id(), localMember, remoteMember); // If the probe in...
java
private ImmutableMember handleProbe(Pair<ImmutableMember, ImmutableMember> members) { ImmutableMember remoteMember = members.getLeft(); ImmutableMember localMember = members.getRight(); LOGGER.trace("{} - Received probe {} from {}", this.localMember.id(), localMember, remoteMember); // If the probe in...
[ "private", "ImmutableMember", "handleProbe", "(", "Pair", "<", "ImmutableMember", ",", "ImmutableMember", ">", "members", ")", "{", "ImmutableMember", "remoteMember", "=", "members", ".", "getLeft", "(", ")", ";", "ImmutableMember", "localMember", "=", "members", ...
Handles a probe from another peer. @param members the probing member and local member info @return the current term
[ "Handles", "a", "probe", "from", "another", "peer", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L437-L461
27,599
atomix/atomix
cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
SwimMembershipProtocol.requestProbes
private void requestProbes(ImmutableMember suspect) { Collection<SwimMember> members = selectRandomMembers(config.getSuspectProbes() - 1, suspect); if (!members.isEmpty()) { AtomicInteger counter = new AtomicInteger(); AtomicBoolean succeeded = new AtomicBoolean(); for (SwimMember member : mem...
java
private void requestProbes(ImmutableMember suspect) { Collection<SwimMember> members = selectRandomMembers(config.getSuspectProbes() - 1, suspect); if (!members.isEmpty()) { AtomicInteger counter = new AtomicInteger(); AtomicBoolean succeeded = new AtomicBoolean(); for (SwimMember member : mem...
[ "private", "void", "requestProbes", "(", "ImmutableMember", "suspect", ")", "{", "Collection", "<", "SwimMember", ">", "members", "=", "selectRandomMembers", "(", "config", ".", "getSuspectProbes", "(", ")", "-", "1", ",", "suspect", ")", ";", "if", "(", "!"...
Requests probes from n peers.
[ "Requests", "probes", "from", "n", "peers", "." ]
3a94b7c80576d762dd0d396d4645df07a0b37c31
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java#L466-L486