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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionManager.java | MinorCompactionManager.getCompactableSegments | private Iterable<Segment> getCompactableSegments(Storage storage, SegmentManager manager) {
List<Segment> segments = new ArrayList<>(manager.segments().size());
Iterator<Segment> iterator = manager.segments().iterator();
Segment segment = iterator.next();
while (iterator.hasNext()) {
Segment nextS... | java | private Iterable<Segment> getCompactableSegments(Storage storage, SegmentManager manager) {
List<Segment> segments = new ArrayList<>(manager.segments().size());
Iterator<Segment> iterator = manager.segments().iterator();
Segment segment = iterator.next();
while (iterator.hasNext()) {
Segment nextS... | [
"private",
"Iterable",
"<",
"Segment",
">",
"getCompactableSegments",
"(",
"Storage",
"storage",
",",
"SegmentManager",
"manager",
")",
"{",
"List",
"<",
"Segment",
">",
"segments",
"=",
"new",
"ArrayList",
"<>",
"(",
"manager",
".",
"segments",
"(",
")",
".... | Returns a list of compactable segments.
@return A list of compactable segments. | [
"Returns",
"a",
"list",
"of",
"compactable",
"segments",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionManager.java#L80-L104 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.init | public void init(StateMachineExecutor executor) {
this.executor = Assert.notNull(executor, "executor");
this.context = executor.context();
this.clock = context.clock();
this.sessions = context.sessions();
if (this instanceof SessionListener) {
executor.context().sessions().addListener((Session... | java | public void init(StateMachineExecutor executor) {
this.executor = Assert.notNull(executor, "executor");
this.context = executor.context();
this.clock = context.clock();
this.sessions = context.sessions();
if (this instanceof SessionListener) {
executor.context().sessions().addListener((Session... | [
"public",
"void",
"init",
"(",
"StateMachineExecutor",
"executor",
")",
"{",
"this",
".",
"executor",
"=",
"Assert",
".",
"notNull",
"(",
"executor",
",",
"\"executor\"",
")",
";",
"this",
".",
"context",
"=",
"executor",
".",
"context",
"(",
")",
";",
"... | Initializes the state machine.
@param executor The state machine executor.
@throws NullPointerException if {@code context} is null | [
"Initializes",
"the",
"state",
"machine",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L231-L240 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.registerOperations | private void registerOperations() {
Class<?> type = getClass();
for (Method method : type.getMethods()) {
if (isOperationMethod(method)) {
registerMethod(method);
}
}
} | java | private void registerOperations() {
Class<?> type = getClass();
for (Method method : type.getMethods()) {
if (isOperationMethod(method)) {
registerMethod(method);
}
}
} | [
"private",
"void",
"registerOperations",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"getClass",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"type",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"isOperationMethod",
"(",
"method",
... | Registers operations for the class. | [
"Registers",
"operations",
"for",
"the",
"class",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L266-L273 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.isOperationMethod | private boolean isOperationMethod(Method method) {
Class<?>[] paramTypes = method.getParameterTypes();
return paramTypes.length == 1 && paramTypes[0] == Commit.class;
} | java | private boolean isOperationMethod(Method method) {
Class<?>[] paramTypes = method.getParameterTypes();
return paramTypes.length == 1 && paramTypes[0] == Commit.class;
} | [
"private",
"boolean",
"isOperationMethod",
"(",
"Method",
"method",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"paramTypes",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"return",
"paramTypes",
".",
"length",
"==",
"1",
"&&",
"paramTypes",
"[",... | Returns a boolean value indicating whether the given method is an operation method. | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"whether",
"the",
"given",
"method",
"is",
"an",
"operation",
"method",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L278-L281 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.registerMethod | private void registerMethod(Method method) {
Type genericType = method.getGenericParameterTypes()[0];
Class<?> argumentType = resolveArgument(genericType);
if (argumentType != null && Operation.class.isAssignableFrom(argumentType)) {
registerMethod(argumentType, method);
}
} | java | private void registerMethod(Method method) {
Type genericType = method.getGenericParameterTypes()[0];
Class<?> argumentType = resolveArgument(genericType);
if (argumentType != null && Operation.class.isAssignableFrom(argumentType)) {
registerMethod(argumentType, method);
}
} | [
"private",
"void",
"registerMethod",
"(",
"Method",
"method",
")",
"{",
"Type",
"genericType",
"=",
"method",
".",
"getGenericParameterTypes",
"(",
")",
"[",
"0",
"]",
";",
"Class",
"<",
"?",
">",
"argumentType",
"=",
"resolveArgument",
"(",
"genericType",
"... | Registers an operation for the given method. | [
"Registers",
"an",
"operation",
"for",
"the",
"given",
"method",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L286-L292 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.resolveArgument | private Class<?> resolveArgument(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
return resolveClass(paramType.getActualTypeArguments()[0]);
} else if (type instanceof TypeVariable) {
return resolveClass(type);
} else if (type i... | java | private Class<?> resolveArgument(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
return resolveClass(paramType.getActualTypeArguments()[0]);
} else if (type instanceof TypeVariable) {
return resolveClass(type);
} else if (type i... | [
"private",
"Class",
"<",
"?",
">",
"resolveArgument",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
"{",
"ParameterizedType",
"paramType",
"=",
"(",
"ParameterizedType",
")",
"type",
";",
"return",
"resolveClass",
"(... | Resolves the generic argument for the given type. | [
"Resolves",
"the",
"generic",
"argument",
"for",
"the",
"given",
"type",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L297-L308 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.resolveClass | private Class<?> resolveClass(Type type) {
if (type instanceof Class) {
return (Class<?>) type;
} else if (type instanceof ParameterizedType) {
return resolveClass(((ParameterizedType) type).getRawType());
} else if (type instanceof WildcardType) {
Type[] bounds = ((WildcardType) type).get... | java | private Class<?> resolveClass(Type type) {
if (type instanceof Class) {
return (Class<?>) type;
} else if (type instanceof ParameterizedType) {
return resolveClass(((ParameterizedType) type).getRawType());
} else if (type instanceof WildcardType) {
Type[] bounds = ((WildcardType) type).get... | [
"private",
"Class",
"<",
"?",
">",
"resolveClass",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
")",
"{",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"}",
"else",
"if",
"(",
"type",
"instanceof",
"Parameterize... | Resolves the generic class for the given type. | [
"Resolves",
"the",
"generic",
"class",
"for",
"the",
"given",
"type",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L313-L325 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.registerMethod | private void registerMethod(Class<?> type, Method method) {
Class<?> returnType = method.getReturnType();
if (returnType == void.class || returnType == Void.class) {
registerVoidMethod(type, method);
} else {
registerValueMethod(type, method);
}
} | java | private void registerMethod(Class<?> type, Method method) {
Class<?> returnType = method.getReturnType();
if (returnType == void.class || returnType == Void.class) {
registerVoidMethod(type, method);
} else {
registerValueMethod(type, method);
}
} | [
"private",
"void",
"registerMethod",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Method",
"method",
")",
"{",
"Class",
"<",
"?",
">",
"returnType",
"=",
"method",
".",
"getReturnType",
"(",
")",
";",
"if",
"(",
"returnType",
"==",
"void",
".",
"class",
... | Registers the given method for the given operation type. | [
"Registers",
"the",
"given",
"method",
"for",
"the",
"given",
"operation",
"type",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L330-L337 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.registerVoidMethod | @SuppressWarnings("unchecked")
private void registerVoidMethod(Class type, Method method) {
executor.register(type, wrapVoidMethod(method));
} | java | @SuppressWarnings("unchecked")
private void registerVoidMethod(Class type, Method method) {
executor.register(type, wrapVoidMethod(method));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"registerVoidMethod",
"(",
"Class",
"type",
",",
"Method",
"method",
")",
"{",
"executor",
".",
"register",
"(",
"type",
",",
"wrapVoidMethod",
"(",
"method",
")",
")",
";",
"}"
] | Registers an operation with a void return value. | [
"Registers",
"an",
"operation",
"with",
"a",
"void",
"return",
"value",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L342-L345 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.wrapVoidMethod | private Consumer wrapVoidMethod(Method method) {
return c -> {
try {
method.invoke(this, c);
} catch (InvocationTargetException e) {
throw new CommandException(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
};
} | java | private Consumer wrapVoidMethod(Method method) {
return c -> {
try {
method.invoke(this, c);
} catch (InvocationTargetException e) {
throw new CommandException(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
};
} | [
"private",
"Consumer",
"wrapVoidMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"c",
"->",
"{",
"try",
"{",
"method",
".",
"invoke",
"(",
"this",
",",
"c",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"... | Wraps a void method. | [
"Wraps",
"a",
"void",
"method",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L350-L360 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.registerValueMethod | @SuppressWarnings("unchecked")
private void registerValueMethod(Class type, Method method) {
executor.register(type, wrapValueMethod(method));
} | java | @SuppressWarnings("unchecked")
private void registerValueMethod(Class type, Method method) {
executor.register(type, wrapValueMethod(method));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"registerValueMethod",
"(",
"Class",
"type",
",",
"Method",
"method",
")",
"{",
"executor",
".",
"register",
"(",
"type",
",",
"wrapValueMethod",
"(",
"method",
")",
")",
";",
"}"
] | Registers an operation with a non-void return value. | [
"Registers",
"an",
"operation",
"with",
"a",
"non",
"-",
"void",
"return",
"value",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L365-L368 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/StateMachine.java | StateMachine.wrapValueMethod | private Function wrapValueMethod(Method method) {
return c -> {
try {
return method.invoke(this, c);
} catch (InvocationTargetException e) {
throw new CommandException(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
};
} | java | private Function wrapValueMethod(Method method) {
return c -> {
try {
return method.invoke(this, c);
} catch (InvocationTargetException e) {
throw new CommandException(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
};
} | [
"private",
"Function",
"wrapValueMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"c",
"->",
"{",
"try",
"{",
"return",
"method",
".",
"invoke",
"(",
"this",
",",
"c",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",... | Wraps a value method. | [
"Wraps",
"a",
"value",
"method",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/StateMachine.java#L373-L383 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/SegmentFile.java | SegmentFile.id | public long id() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR, file.getName().lastIndexOf(PART_SEPARATOR) - 1) + 1, file.getName().lastIndexOf(PART_SEPARATOR)));
} | java | public long id() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR, file.getName().lastIndexOf(PART_SEPARATOR) - 1) + 1, file.getName().lastIndexOf(PART_SEPARATOR)));
} | [
"public",
"long",
"id",
"(",
")",
"{",
"return",
"Long",
".",
"valueOf",
"(",
"file",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"file",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"PART_SEPARATOR",
",",
"file",
".",
"getName",
"(",
")",... | Returns the segment identifier. | [
"Returns",
"the",
"segment",
"identifier",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/SegmentFile.java#L89-L91 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/SegmentFile.java | SegmentFile.version | public long version() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR) + 1, file.getName().lastIndexOf(EXTENSION_SEPARATOR)));
} | java | public long version() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR) + 1, file.getName().lastIndexOf(EXTENSION_SEPARATOR)));
} | [
"public",
"long",
"version",
"(",
")",
"{",
"return",
"Long",
".",
"valueOf",
"(",
"file",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"file",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"PART_SEPARATOR",
")",
"+",
"1",
",",
"file",
".",
... | Returns the segment version. | [
"Returns",
"the",
"segment",
"version",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/SegmentFile.java#L96-L98 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java | DefaultCopycatClient.setState | private void setState(State state) {
if (this.state != state) {
this.state = state;
LOGGER.debug("State changed: {}", state);
changeListeners.forEach(l -> l.accept(state));
}
} | java | private void setState(State state) {
if (this.state != state) {
this.state = state;
LOGGER.debug("State changed: {}", state);
changeListeners.forEach(l -> l.accept(state));
}
} | [
"private",
"void",
"setState",
"(",
"State",
"state",
")",
"{",
"if",
"(",
"this",
".",
"state",
"!=",
"state",
")",
"{",
"this",
".",
"state",
"=",
"state",
";",
"LOGGER",
".",
"debug",
"(",
"\"State changed: {}\"",
",",
"state",
")",
";",
"changeList... | Updates the client state. | [
"Updates",
"the",
"client",
"state",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java#L92-L98 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java | DefaultCopycatClient.newSession | private ClientSession newSession() {
ClientSession session = new ClientSession(clientId, transport.client(), selector, ioContext, connectionStrategy, sessionTimeout,
unstabilityTimeout
);
// Update the session change listener.
if (changeListener != null)
... | java | private ClientSession newSession() {
ClientSession session = new ClientSession(clientId, transport.client(), selector, ioContext, connectionStrategy, sessionTimeout,
unstabilityTimeout
);
// Update the session change listener.
if (changeListener != null)
... | [
"private",
"ClientSession",
"newSession",
"(",
")",
"{",
"ClientSession",
"session",
"=",
"new",
"ClientSession",
"(",
"clientId",
",",
"transport",
".",
"client",
"(",
")",
",",
"selector",
",",
"ioContext",
",",
"connectionStrategy",
",",
"sessionTimeout",
","... | Creates a new child session. | [
"Creates",
"a",
"new",
"child",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java#L129-L142 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java | DefaultCopycatClient.onStateChange | private void onStateChange(Session.State state) {
switch (state) {
// When the session is opened, transition the state to CONNECTED.
case OPEN:
setState(State.CONNECTED);
break;
// When the session becomes unstable, transition the state to SUSPENDED.
case UNSTABLE:
se... | java | private void onStateChange(Session.State state) {
switch (state) {
// When the session is opened, transition the state to CONNECTED.
case OPEN:
setState(State.CONNECTED);
break;
// When the session becomes unstable, transition the state to SUSPENDED.
case UNSTABLE:
se... | [
"private",
"void",
"onStateChange",
"(",
"Session",
".",
"State",
"state",
")",
"{",
"switch",
"(",
"state",
")",
"{",
"// When the session is opened, transition the state to CONNECTED.",
"case",
"OPEN",
":",
"setState",
"(",
"State",
".",
"CONNECTED",
")",
";",
"... | Handles a session state change. | [
"Handles",
"a",
"session",
"state",
"change",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java#L147-L173 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java | DefaultCopycatClient.kill | public synchronized CompletableFuture<Void> kill() {
if (state == State.CLOSED)
return CompletableFuture.completedFuture(null);
if (closeFuture == null) {
closeFuture = session.kill()
.whenComplete((result, error) -> {
setState(State.CLOSED);
CompletableFuture.runAsync((... | java | public synchronized CompletableFuture<Void> kill() {
if (state == State.CLOSED)
return CompletableFuture.completedFuture(null);
if (closeFuture == null) {
closeFuture = session.kill()
.whenComplete((result, error) -> {
setState(State.CLOSED);
CompletableFuture.runAsync((... | [
"public",
"synchronized",
"CompletableFuture",
"<",
"Void",
">",
"kill",
"(",
")",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"CLOSED",
")",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"null",
")",
";",
"if",
"(",
"closeFuture",
"==",
"nu... | Kills the client.
@return A completable future to be completed once the client's session has been killed. | [
"Kills",
"the",
"client",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/DefaultCopycatClient.java#L306-L322 | train |
atomix/copycat | examples/value-client/src/main/java/io/atomix/copycat/examples/ValueClientExample.java | ValueClientExample.main | public static void main(String[] args) throws Exception {
if (args.length < 1)
throw new IllegalArgumentException("must supply a set of host:port tuples");
// Build a list of all member addresses to which to connect.
List<Address> members = new ArrayList<>();
for (String arg : args) {
Strin... | java | public static void main(String[] args) throws Exception {
if (args.length < 1)
throw new IllegalArgumentException("must supply a set of host:port tuples");
// Build a list of all member addresses to which to connect.
List<Address> members = new ArrayList<>();
for (String arg : args) {
Strin... | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"<",
"1",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"must supply a set of host:port tuples\"",
")",
";",
"// B... | Starts the client. | [
"Starts",
"the",
"client",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/examples/value-client/src/main/java/io/atomix/copycat/examples/ValueClientExample.java#L46-L80 | train |
atomix/copycat | examples/value-client/src/main/java/io/atomix/copycat/examples/ValueClientExample.java | ValueClientExample.recursiveSet | private static void recursiveSet(CopycatClient client) {
client.submit(new SetCommand(UUID.randomUUID().toString())).whenComplete((result, error) -> {
client.context().schedule(Duration.ofSeconds(5), () -> recursiveSet(client));
});
} | java | private static void recursiveSet(CopycatClient client) {
client.submit(new SetCommand(UUID.randomUUID().toString())).whenComplete((result, error) -> {
client.context().schedule(Duration.ofSeconds(5), () -> recursiveSet(client));
});
} | [
"private",
"static",
"void",
"recursiveSet",
"(",
"CopycatClient",
"client",
")",
"{",
"client",
".",
"submit",
"(",
"new",
"SetCommand",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
".",
"whenComplete",
"(",
"(",
"resul... | Recursively sets state machine values. | [
"Recursively",
"sets",
"state",
"machine",
"values",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/examples/value-client/src/main/java/io/atomix/copycat/examples/ValueClientExample.java#L85-L89 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineExecutor.java | ServerStateMachineExecutor.init | void init(long index, Instant instant, ServerStateMachineContext.Type type) {
context.update(index, instant, type);
} | java | void init(long index, Instant instant, ServerStateMachineContext.Type type) {
context.update(index, instant, type);
} | [
"void",
"init",
"(",
"long",
"index",
",",
"Instant",
"instant",
",",
"ServerStateMachineContext",
".",
"Type",
"type",
")",
"{",
"context",
".",
"update",
"(",
"index",
",",
"instant",
",",
"type",
")",
";",
"}"
] | Initializes the execution of a task. | [
"Initializes",
"the",
"execution",
"of",
"a",
"task",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineExecutor.java#L103-L105 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineExecutor.java | ServerStateMachineExecutor.executeOperation | @SuppressWarnings("unchecked")
<T extends Operation<U>, U> U executeOperation(Commit commit) {
// If the commit operation is a no-op command, complete the operation.
if (commit.operation() instanceof NoOpCommand) {
commit.close();
return null;
}
// Get the function registered for the oper... | java | @SuppressWarnings("unchecked")
<T extends Operation<U>, U> U executeOperation(Commit commit) {
// If the commit operation is a no-op command, complete the operation.
if (commit.operation() instanceof NoOpCommand) {
commit.close();
return null;
}
// Get the function registered for the oper... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"<",
"T",
"extends",
"Operation",
"<",
"U",
">",
",",
"U",
">",
"U",
"executeOperation",
"(",
"Commit",
"commit",
")",
"{",
"// If the commit operation is a no-op command, complete the operation.",
"if",
"(",
"comm... | Executes an operation. | [
"Executes",
"an",
"operation",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineExecutor.java#L110-L150 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/index/SearchableOffsetIndex.java | SearchableOffsetIndex.findAfter | private long findAfter(long offset) {
if (size == 0) {
return -1;
}
int low = 0;
int high = size-1;
while (low <= high) {
int mid = low + ((high - low) / 2);
long i = buffer.readLong(mid * ENTRY_SIZE);
if (i < offset) {
low = mid + 1;
} else if (i > offset) ... | java | private long findAfter(long offset) {
if (size == 0) {
return -1;
}
int low = 0;
int high = size-1;
while (low <= high) {
int mid = low + ((high - low) / 2);
long i = buffer.readLong(mid * ENTRY_SIZE);
if (i < offset) {
low = mid + 1;
} else if (i > offset) ... | [
"private",
"long",
"findAfter",
"(",
"long",
"offset",
")",
"{",
"if",
"(",
"size",
"==",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"size",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"high",
... | Returns the real offset for the given relative offset. | [
"Returns",
"the",
"real",
"offset",
"for",
"the",
"given",
"relative",
"offset",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/index/SearchableOffsetIndex.java#L139-L161 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotFile.java | SnapshotFile.index | public long index() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR, file.getName().lastIndexOf(PART_SEPARATOR) - 1) + 1, file.getName().lastIndexOf(PART_SEPARATOR)));
} | java | public long index() {
return Long.valueOf(file.getName().substring(file.getName().lastIndexOf(PART_SEPARATOR, file.getName().lastIndexOf(PART_SEPARATOR) - 1) + 1, file.getName().lastIndexOf(PART_SEPARATOR)));
} | [
"public",
"long",
"index",
"(",
")",
"{",
"return",
"Long",
".",
"valueOf",
"(",
"file",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"file",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"PART_SEPARATOR",
",",
"file",
".",
"getName",
"(",
"... | Returns the snapshot index.
@return The snapshot index. | [
"Returns",
"the",
"snapshot",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotFile.java#L94-L96 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java | AddressSelector.reset | public AddressSelector reset() {
if (selectionsIterator != null) {
this.selections = strategy.selectConnections(leader, new ArrayList<>(servers));
this.selectionsIterator = null;
}
return this;
} | java | public AddressSelector reset() {
if (selectionsIterator != null) {
this.selections = strategy.selectConnections(leader, new ArrayList<>(servers));
this.selectionsIterator = null;
}
return this;
} | [
"public",
"AddressSelector",
"reset",
"(",
")",
"{",
"if",
"(",
"selectionsIterator",
"!=",
"null",
")",
"{",
"this",
".",
"selections",
"=",
"strategy",
".",
"selectConnections",
"(",
"leader",
",",
"new",
"ArrayList",
"<>",
"(",
"servers",
")",
")",
";",... | Resets the addresses.
@return The address selector. | [
"Resets",
"the",
"addresses",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java#L103-L109 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java | AddressSelector.reset | public AddressSelector reset(Address leader, Collection<Address> servers) {
if (changed(leader, servers)) {
this.leader = leader;
this.servers = servers;
this.selections = strategy.selectConnections(leader, new ArrayList<>(servers));
this.selectionsIterator = null;
}
return this;
} | java | public AddressSelector reset(Address leader, Collection<Address> servers) {
if (changed(leader, servers)) {
this.leader = leader;
this.servers = servers;
this.selections = strategy.selectConnections(leader, new ArrayList<>(servers));
this.selectionsIterator = null;
}
return this;
} | [
"public",
"AddressSelector",
"reset",
"(",
"Address",
"leader",
",",
"Collection",
"<",
"Address",
">",
"servers",
")",
"{",
"if",
"(",
"changed",
"(",
"leader",
",",
"servers",
")",
")",
"{",
"this",
".",
"leader",
"=",
"leader",
";",
"this",
".",
"se... | Resets the connection addresses.
@param servers The collection of server addresses.
@return The address selector. | [
"Resets",
"the",
"connection",
"addresses",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java#L117-L125 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java | AddressSelector.matches | private boolean matches(Collection<Address> left, Collection<Address> right) {
if (left.size() != right.size())
return false;
for (Address address : left) {
if (!right.contains(address)) {
return false;
}
}
return true;
} | java | private boolean matches(Collection<Address> left, Collection<Address> right) {
if (left.size() != right.size())
return false;
for (Address address : left) {
if (!right.contains(address)) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"matches",
"(",
"Collection",
"<",
"Address",
">",
"left",
",",
"Collection",
"<",
"Address",
">",
"right",
")",
"{",
"if",
"(",
"left",
".",
"size",
"(",
")",
"!=",
"right",
".",
"size",
"(",
")",
")",
"return",
"false",
";",
... | Returns a boolean value indicating whether the servers in the first list match the servers in the second list. | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"whether",
"the",
"servers",
"in",
"the",
"first",
"list",
"match",
"the",
"servers",
"in",
"the",
"second",
"list",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/util/AddressSelector.java#L150-L160 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java | Compactor.withDefaultCompactionMode | public Compactor withDefaultCompactionMode(Compaction.Mode mode) {
Assert.notNull(mode, "mode");
Assert.argNot(mode, mode == Compaction.Mode.DEFAULT, "DEFAULT cannot be the default compaction mode");
this.defaultCompactionMode = mode;
return this;
} | java | public Compactor withDefaultCompactionMode(Compaction.Mode mode) {
Assert.notNull(mode, "mode");
Assert.argNot(mode, mode == Compaction.Mode.DEFAULT, "DEFAULT cannot be the default compaction mode");
this.defaultCompactionMode = mode;
return this;
} | [
"public",
"Compactor",
"withDefaultCompactionMode",
"(",
"Compaction",
".",
"Mode",
"mode",
")",
"{",
"Assert",
".",
"notNull",
"(",
"mode",
",",
"\"mode\"",
")",
";",
"Assert",
".",
"argNot",
"(",
"mode",
",",
"mode",
"==",
"Compaction",
".",
"Mode",
".",... | Sets the default compaction mode.
@param mode The default compaction mode.
@return The compactor.
@throws NullPointerException if the compaction mode is {@code null}
@throws IllegalArgumentException if the compaction mode is {@link Compaction.Mode#DEFAULT} | [
"Sets",
"the",
"default",
"compaction",
"mode",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java#L82-L87 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java | Compactor.minorIndex | public Compactor minorIndex(long index) {
this.minorIndex = Math.max(this.minorIndex, index);
Segment segment = segments.segment(minorIndex);
if (segment != null) {
compactIndex = segment.firstIndex();
}
return this;
} | java | public Compactor minorIndex(long index) {
this.minorIndex = Math.max(this.minorIndex, index);
Segment segment = segments.segment(minorIndex);
if (segment != null) {
compactIndex = segment.firstIndex();
}
return this;
} | [
"public",
"Compactor",
"minorIndex",
"(",
"long",
"index",
")",
"{",
"this",
".",
"minorIndex",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"minorIndex",
",",
"index",
")",
";",
"Segment",
"segment",
"=",
"segments",
".",
"segment",
"(",
"minorIndex",
")"... | Sets the maximum compaction index for minor compaction.
@param index The maximum compaction index for minor compaction.
@return The log compactor. | [
"Sets",
"the",
"maximum",
"compaction",
"index",
"for",
"minor",
"compaction",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java#L104-L111 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java | Compactor.compact | private synchronized CompletableFuture<Void> compact(Compaction compaction, CompletableFuture<Void> future, ThreadContext context) {
CompactionManager manager = compaction.manager(this);
AtomicInteger counter = new AtomicInteger();
Collection<CompactionTask> tasks = manager.buildTasks(storage, segments);
... | java | private synchronized CompletableFuture<Void> compact(Compaction compaction, CompletableFuture<Void> future, ThreadContext context) {
CompactionManager manager = compaction.manager(this);
AtomicInteger counter = new AtomicInteger();
Collection<CompactionTask> tasks = manager.buildTasks(storage, segments);
... | [
"private",
"synchronized",
"CompletableFuture",
"<",
"Void",
">",
"compact",
"(",
"Compaction",
"compaction",
",",
"CompletableFuture",
"<",
"Void",
">",
"future",
",",
"ThreadContext",
"context",
")",
"{",
"CompactionManager",
"manager",
"=",
"compaction",
".",
"... | Compacts the log. | [
"Compacts",
"the",
"log",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/Compactor.java#L201-L227 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerCommit.java | ServerCommit.reset | void reset(OperationEntry<?> entry, ServerSessionContext session, long timestamp) {
if (references.compareAndSet(0, 1)) {
this.index = entry.getIndex();
this.session = session;
this.instant = Instant.ofEpochMilli(timestamp);
this.operation = entry.getOperation();
session.acquire();
... | java | void reset(OperationEntry<?> entry, ServerSessionContext session, long timestamp) {
if (references.compareAndSet(0, 1)) {
this.index = entry.getIndex();
this.session = session;
this.instant = Instant.ofEpochMilli(timestamp);
this.operation = entry.getOperation();
session.acquire();
... | [
"void",
"reset",
"(",
"OperationEntry",
"<",
"?",
">",
"entry",
",",
"ServerSessionContext",
"session",
",",
"long",
"timestamp",
")",
"{",
"if",
"(",
"references",
".",
"compareAndSet",
"(",
"0",
",",
"1",
")",
")",
"{",
"this",
".",
"index",
"=",
"en... | Resets the commit.
@param entry The entry. | [
"Resets",
"the",
"commit",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerCommit.java#L53-L64 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerCommit.java | ServerCommit.cleanup | private void cleanup() {
if (operation instanceof Command && log.isOpen()) {
try {
log.release(index);
} catch (IllegalStateException e) {
}
}
session.release();
index = 0;
session = null;
instant = null;
operation = null;
pool.release(this);
} | java | private void cleanup() {
if (operation instanceof Command && log.isOpen()) {
try {
log.release(index);
} catch (IllegalStateException e) {
}
}
session.release();
index = 0;
session = null;
instant = null;
operation = null;
pool.release(this);
} | [
"private",
"void",
"cleanup",
"(",
")",
"{",
"if",
"(",
"operation",
"instanceof",
"Command",
"&&",
"log",
".",
"isOpen",
"(",
")",
")",
"{",
"try",
"{",
"log",
".",
"release",
"(",
"index",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
... | Cleans up the commit. | [
"Cleans",
"up",
"the",
"commit",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerCommit.java#L135-L151 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/CopycatServer.java | CopycatServer.listen | private CompletableFuture<Void> listen() {
CompletableFuture<Void> future = new CompletableFuture<>();
context.getThreadContext().executor().execute(() -> {
internalServer.listen(cluster().member().serverAddress(), context::connectServer).whenComplete((internalResult, internalError) -> {
if (inter... | java | private CompletableFuture<Void> listen() {
CompletableFuture<Void> future = new CompletableFuture<>();
context.getThreadContext().executor().execute(() -> {
internalServer.listen(cluster().member().serverAddress(), context::connectServer).whenComplete((internalResult, internalError) -> {
if (inter... | [
"private",
"CompletableFuture",
"<",
"Void",
">",
"listen",
"(",
")",
"{",
"CompletableFuture",
"<",
"Void",
">",
"future",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"context",
".",
"getThreadContext",
"(",
")",
".",
"executor",
"(",
")",
".",
... | Starts listening the server. | [
"Starts",
"listening",
"the",
"server",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/CopycatServer.java#L694-L716 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.buildIndex | private void buildIndex() {
// Read the current buffer position.
long position = buffer.mark().position();
// Read the first entry length.
int length = buffer.readInt();
// While the length is non-zero...
while (length != 0) {
// Read the full entry into memory.
buffer.read(memory.... | java | private void buildIndex() {
// Read the current buffer position.
long position = buffer.mark().position();
// Read the first entry length.
int length = buffer.readInt();
// While the length is non-zero...
while (length != 0) {
// Read the full entry into memory.
buffer.read(memory.... | [
"private",
"void",
"buildIndex",
"(",
")",
"{",
"// Read the current buffer position.",
"long",
"position",
"=",
"buffer",
".",
"mark",
"(",
")",
".",
"position",
"(",
")",
";",
"// Read the first entry length.",
"int",
"length",
"=",
"buffer",
".",
"readInt",
"... | Builds the index from the segment bytes. | [
"Builds",
"the",
"index",
"from",
"the",
"segment",
"bytes",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L97-L151 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.lastIndex | public long lastIndex() {
assertSegmentOpen();
return !isEmpty() ? offsetIndex.lastOffset() + descriptor.index() + skip : descriptor.index() - 1;
} | java | public long lastIndex() {
assertSegmentOpen();
return !isEmpty() ? offsetIndex.lastOffset() + descriptor.index() + skip : descriptor.index() - 1;
} | [
"public",
"long",
"lastIndex",
"(",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"return",
"!",
"isEmpty",
"(",
")",
"?",
"offsetIndex",
".",
"lastOffset",
"(",
")",
"+",
"descriptor",
".",
"index",
"(",
")",
"+",
"skip",
":",
"descriptor",
".",
"inde... | Returns the index of the last entry in the segment.
@return The index of the last entry in the segment or {@code 0} if the segment is empty.
@throws IllegalStateException if the segment is not open | [
"Returns",
"the",
"index",
"of",
"the",
"last",
"entry",
"in",
"the",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L284-L287 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.checkRange | private void checkRange(long index) {
Assert.indexNot(isEmpty(), "segment is empty");
Assert.indexNot(index < firstIndex(), index + " is less than the first index in the segment");
Assert.indexNot(index > lastIndex(), index + " is greater than the last index in the segment");
} | java | private void checkRange(long index) {
Assert.indexNot(isEmpty(), "segment is empty");
Assert.indexNot(index < firstIndex(), index + " is less than the first index in the segment");
Assert.indexNot(index > lastIndex(), index + " is greater than the last index in the segment");
} | [
"private",
"void",
"checkRange",
"(",
"long",
"index",
")",
"{",
"Assert",
".",
"indexNot",
"(",
"isEmpty",
"(",
")",
",",
"\"segment is empty\"",
")",
";",
"Assert",
".",
"indexNot",
"(",
"index",
"<",
"firstIndex",
"(",
")",
",",
"index",
"+",
"\" is l... | Checks the range of the given index.
@throws IndexOutOfBoundsException if the {@code index} is invalid for the segment | [
"Checks",
"the",
"range",
"of",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L324-L328 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.append | public long append(Entry entry) {
Assert.notNull(entry, "entry");
Assert.stateNot(isFull(), "segment is full");
long index = nextIndex();
Assert.index(index == entry.getIndex(), "inconsistent index: %s", entry.getIndex());
// Calculate the offset of the entry.
long offset = relativeOffset(inde... | java | public long append(Entry entry) {
Assert.notNull(entry, "entry");
Assert.stateNot(isFull(), "segment is full");
long index = nextIndex();
Assert.index(index == entry.getIndex(), "inconsistent index: %s", entry.getIndex());
// Calculate the offset of the entry.
long offset = relativeOffset(inde... | [
"public",
"long",
"append",
"(",
"Entry",
"entry",
")",
"{",
"Assert",
".",
"notNull",
"(",
"entry",
",",
"\"entry\"",
")",
";",
"Assert",
".",
"stateNot",
"(",
"isFull",
"(",
")",
",",
"\"segment is full\"",
")",
";",
"long",
"index",
"=",
"nextIndex",
... | Commits an entry to the segment.
@throws NullPointerException if {@code entry} is null
@throws IllegalStateException if the segment is full
@throws IndexOutOfBoundsException if the {@code entry} index does not match the next index | [
"Commits",
"an",
"entry",
"to",
"the",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L337-L416 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.term | public long term(long index) {
assertSegmentOpen();
checkRange(index);
// Get the offset of the index within this segment.
long offset = relativeOffset(index);
// Look up the term for the offset in the term index.
return termIndex.lookup(offset);
} | java | public long term(long index) {
assertSegmentOpen();
checkRange(index);
// Get the offset of the index within this segment.
long offset = relativeOffset(index);
// Look up the term for the offset in the term index.
return termIndex.lookup(offset);
} | [
"public",
"long",
"term",
"(",
"long",
"index",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"checkRange",
"(",
"index",
")",
";",
"// Get the offset of the index within this segment.",
"long",
"offset",
"=",
"relativeOffset",
"(",
"index",
")",
";",
"// Look up ... | Reads the term for the entry at the given index.
@param index The index for which to read the term.
@return The term for the given index.
@throws IllegalStateException if the segment is not open or {@code index} is inconsistent | [
"Reads",
"the",
"term",
"for",
"the",
"entry",
"at",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L425-L434 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.get | public synchronized <T extends Entry> T get(long index) {
assertSegmentOpen();
checkRange(index);
// Get the offset of the index within this segment.
long offset = relativeOffset(index);
// Get the start position of the entry from the memory index.
long position = offsetIndex.position(offset);... | java | public synchronized <T extends Entry> T get(long index) {
assertSegmentOpen();
checkRange(index);
// Get the offset of the index within this segment.
long offset = relativeOffset(index);
// Get the start position of the entry from the memory index.
long position = offsetIndex.position(offset);... | [
"public",
"synchronized",
"<",
"T",
"extends",
"Entry",
">",
"T",
"get",
"(",
"long",
"index",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"checkRange",
"(",
"index",
")",
";",
"// Get the offset of the index within this segment.",
"long",
"offset",
"=",
"rela... | Reads the entry at the given index.
@param index The index from which to read the entry.
@return The entry at the given index.
@throws IllegalStateException if the segment is not open or {@code index} is inconsistent with the entry | [
"Reads",
"the",
"entry",
"at",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L443-L493 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.contains | public boolean contains(long index) {
assertSegmentOpen();
if (!validIndex(index))
return false;
// Check the memory index first for performance reasons.
long offset = relativeOffset(index);
return offsetIndex.contains(offset);
} | java | public boolean contains(long index) {
assertSegmentOpen();
if (!validIndex(index))
return false;
// Check the memory index first for performance reasons.
long offset = relativeOffset(index);
return offsetIndex.contains(offset);
} | [
"public",
"boolean",
"contains",
"(",
"long",
"index",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"if",
"(",
"!",
"validIndex",
"(",
"index",
")",
")",
"return",
"false",
";",
"// Check the memory index first for performance reasons.",
"long",
"offset",
"=",
... | Returns a boolean value indicating whether the entry at the given index is active.
@param index The index to check.
@return Indicates whether the entry at the given index is active.
@throws IllegalStateException if the segment is not open | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"whether",
"the",
"entry",
"at",
"the",
"given",
"index",
"is",
"active",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L514-L523 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.release | public boolean release(long index) {
assertSegmentOpen();
long offset = offsetIndex.find(relativeOffset(index));
return offset != -1 && offsetPredicate.release(offset);
} | java | public boolean release(long index) {
assertSegmentOpen();
long offset = offsetIndex.find(relativeOffset(index));
return offset != -1 && offsetPredicate.release(offset);
} | [
"public",
"boolean",
"release",
"(",
"long",
"index",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"long",
"offset",
"=",
"offsetIndex",
".",
"find",
"(",
"relativeOffset",
"(",
"index",
")",
")",
";",
"return",
"offset",
"!=",
"-",
"1",
"&&",
"offsetPr... | Releases an entry from the segment.
@param index The index of the entry to release.
@return Indicates whether the entry was newly released from the segment.
@throws IllegalStateException if the segment is not open | [
"Releases",
"an",
"entry",
"from",
"the",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L532-L536 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/Segment.java | Segment.truncate | public Segment truncate(long index) {
assertSegmentOpen();
Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
long offset = relativeOffset(index);
long lastOffset = offsetIndex.lastOffset();
long diff = Math.abs(lastOffset - offset);
skip = Math.max(skip - diff, 0... | java | public Segment truncate(long index) {
assertSegmentOpen();
Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
long offset = relativeOffset(index);
long lastOffset = offsetIndex.lastOffset();
long diff = Math.abs(lastOffset - offset);
skip = Math.max(skip - diff, 0... | [
"public",
"Segment",
"truncate",
"(",
"long",
"index",
")",
"{",
"assertSegmentOpen",
"(",
")",
";",
"Assert",
".",
"index",
"(",
"index",
">=",
"manager",
".",
"commitIndex",
"(",
")",
",",
"\"cannot truncate committed index\"",
")",
";",
"long",
"offset",
... | Truncates entries after the given index.
@param index The index after which to remove entries.
@return The segment.
@throws IllegalStateException if the segment is not open | [
"Truncates",
"entries",
"after",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/Segment.java#L590-L608 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java | ServerStateMachineContext.update | void update(long index, Instant instant, Type type) {
this.index = index;
this.type = type;
clock.set(instant);
} | java | void update(long index, Instant instant, Type type) {
this.index = index;
this.type = type;
clock.set(instant);
} | [
"void",
"update",
"(",
"long",
"index",
",",
"Instant",
"instant",
",",
"Type",
"type",
")",
"{",
"this",
".",
"index",
"=",
"index",
";",
"this",
".",
"type",
"=",
"type",
";",
"clock",
".",
"set",
"(",
"instant",
")",
";",
"}"
] | Updates the state machine context. | [
"Updates",
"the",
"state",
"machine",
"context",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java#L53-L57 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java | ServerStateMachineContext.commit | void commit() {
long index = this.index;
for (ServerSessionContext session : sessions.sessions.values()) {
session.commit(index);
}
} | java | void commit() {
long index = this.index;
for (ServerSessionContext session : sessions.sessions.values()) {
session.commit(index);
}
} | [
"void",
"commit",
"(",
")",
"{",
"long",
"index",
"=",
"this",
".",
"index",
";",
"for",
"(",
"ServerSessionContext",
"session",
":",
"sessions",
".",
"sessions",
".",
"values",
"(",
")",
")",
"{",
"session",
".",
"commit",
"(",
"index",
")",
";",
"}... | Commits the state machine index. | [
"Commits",
"the",
"state",
"machine",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachineContext.java#L62-L67 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.onStateChange | public Listener<CopycatServer.State> onStateChange(Consumer<CopycatServer.State> listener) {
return stateChangeListeners.add(listener);
} | java | public Listener<CopycatServer.State> onStateChange(Consumer<CopycatServer.State> listener) {
return stateChangeListeners.add(listener);
} | [
"public",
"Listener",
"<",
"CopycatServer",
".",
"State",
">",
"onStateChange",
"(",
"Consumer",
"<",
"CopycatServer",
".",
"State",
">",
"listener",
")",
"{",
"return",
"stateChangeListeners",
".",
"add",
"(",
"listener",
")",
";",
"}"
] | Registers a state change listener.
@param listener The state change listener.
@return The listener context. | [
"Registers",
"a",
"state",
"change",
"listener",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L112-L114 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.setGlobalIndex | ServerContext setGlobalIndex(long globalIndex) {
Assert.argNot(globalIndex < 0, "global index must be positive");
this.globalIndex = Math.max(this.globalIndex, globalIndex);
log.compactor().majorIndex(this.globalIndex - 1);
return this;
} | java | ServerContext setGlobalIndex(long globalIndex) {
Assert.argNot(globalIndex < 0, "global index must be positive");
this.globalIndex = Math.max(this.globalIndex, globalIndex);
log.compactor().majorIndex(this.globalIndex - 1);
return this;
} | [
"ServerContext",
"setGlobalIndex",
"(",
"long",
"globalIndex",
")",
"{",
"Assert",
".",
"argNot",
"(",
"globalIndex",
"<",
"0",
",",
"\"global index must be positive\"",
")",
";",
"this",
".",
"globalIndex",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"globalIn... | Sets the global index.
@param globalIndex The global index.
@return The Raft context. | [
"Sets",
"the",
"global",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L396-L401 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.reset | ServerContext reset() {
// Delete the existing log.
if (log != null) {
log.close();
storage.deleteLog(name);
}
// Delete the existing snapshot store.
if (snapshot != null) {
snapshot.close();
storage.deleteSnapshotStore(name);
}
// Open the log.
log = storage.op... | java | ServerContext reset() {
// Delete the existing log.
if (log != null) {
log.close();
storage.deleteLog(name);
}
// Delete the existing snapshot store.
if (snapshot != null) {
snapshot.close();
storage.deleteSnapshotStore(name);
}
// Open the log.
log = storage.op... | [
"ServerContext",
"reset",
"(",
")",
"{",
"// Delete the existing log.",
"if",
"(",
"log",
"!=",
"null",
")",
"{",
"log",
".",
"close",
"(",
")",
";",
"storage",
".",
"deleteLog",
"(",
"name",
")",
";",
"}",
"// Delete the existing snapshot store.",
"if",
"("... | Resets the state log.
@return The server context. | [
"Resets",
"the",
"state",
"log",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L462-L495 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.connectClient | public void connectClient(Connection connection) {
threadContext.checkThread();
// Note we do not use method references here because the "state" variable changes over time.
// We have to use lambdas to ensure the request handler points to the current state.
connection.handler(RegisterRequest.class, (Fu... | java | public void connectClient(Connection connection) {
threadContext.checkThread();
// Note we do not use method references here because the "state" variable changes over time.
// We have to use lambdas to ensure the request handler points to the current state.
connection.handler(RegisterRequest.class, (Fu... | [
"public",
"void",
"connectClient",
"(",
"Connection",
"connection",
")",
"{",
"threadContext",
".",
"checkThread",
"(",
")",
";",
"// Note we do not use method references here because the \"state\" variable changes over time.",
"// We have to use lambdas to ensure the request handler p... | Handles a connection from a client. | [
"Handles",
"a",
"connection",
"from",
"a",
"client",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L516-L530 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.connectServer | public void connectServer(Connection connection) {
threadContext.checkThread();
// Handlers for all request types are registered since requests can be proxied between servers.
// Note we do not use method references here because the "state" variable changes over time.
// We have to use lambdas to ensur... | java | public void connectServer(Connection connection) {
threadContext.checkThread();
// Handlers for all request types are registered since requests can be proxied between servers.
// Note we do not use method references here because the "state" variable changes over time.
// We have to use lambdas to ensur... | [
"public",
"void",
"connectServer",
"(",
"Connection",
"connection",
")",
"{",
"threadContext",
".",
"checkThread",
"(",
")",
";",
"// Handlers for all request types are registered since requests can be proxied between servers.",
"// Note we do not use method references here because the... | Handles a connection from another server. | [
"Handles",
"a",
"connection",
"from",
"another",
"server",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L535-L558 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerContext.java | ServerContext.delete | public void delete() {
// Delete the log.
storage.deleteLog(name);
// Delete the snapshot store.
storage.deleteSnapshotStore(name);
// Delete the metadata store.
storage.deleteMetaStore(name);
} | java | public void delete() {
// Delete the log.
storage.deleteLog(name);
// Delete the snapshot store.
storage.deleteSnapshotStore(name);
// Delete the metadata store.
storage.deleteMetaStore(name);
} | [
"public",
"void",
"delete",
"(",
")",
"{",
"// Delete the log.",
"storage",
".",
"deleteLog",
"(",
"name",
")",
";",
"// Delete the snapshot store.",
"storage",
".",
"deleteSnapshotStore",
"(",
"name",
")",
";",
"// Delete the metadata store.",
"storage",
".",
"dele... | Deletes the server context. | [
"Deletes",
"the",
"server",
"context",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerContext.java#L661-L670 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java | ConnectionManager.getConnection | public CompletableFuture<Connection> getConnection(Address address) {
Connection connection = connections.get(address);
return connection == null ? createConnection(address) : CompletableFuture.completedFuture(connection);
} | java | public CompletableFuture<Connection> getConnection(Address address) {
Connection connection = connections.get(address);
return connection == null ? createConnection(address) : CompletableFuture.completedFuture(connection);
} | [
"public",
"CompletableFuture",
"<",
"Connection",
">",
"getConnection",
"(",
"Address",
"address",
")",
"{",
"Connection",
"connection",
"=",
"connections",
".",
"get",
"(",
"address",
")",
";",
"return",
"connection",
"==",
"null",
"?",
"createConnection",
"(",... | Returns the connection for the given member.
@param address The member for which to get the connection.
@return A completable future to be called once the connection is received. | [
"Returns",
"the",
"connection",
"for",
"the",
"given",
"member",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L46-L49 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java | ConnectionManager.resetConnection | public void resetConnection(Address address) {
Connection connection = connections.remove(address);
if (connection != null) {
connection.close();
}
} | java | public void resetConnection(Address address) {
Connection connection = connections.remove(address);
if (connection != null) {
connection.close();
}
} | [
"public",
"void",
"resetConnection",
"(",
"Address",
"address",
")",
"{",
"Connection",
"connection",
"=",
"connections",
".",
"remove",
"(",
"address",
")",
";",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"connection",
".",
"close",
"(",
")",
";",
... | Resets the connection to the given address.
@param address The address for which to reset the connection. | [
"Resets",
"the",
"connection",
"to",
"the",
"given",
"address",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L56-L61 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java | ConnectionManager.createConnection | private CompletableFuture<Connection> createConnection(Address address) {
return connectionFutures.computeIfAbsent(address, a -> {
CompletableFuture<Connection> future = client.connect(address).thenApply(connection -> {
connection.onClose(c -> connections.remove(address, c));
connections.put(a... | java | private CompletableFuture<Connection> createConnection(Address address) {
return connectionFutures.computeIfAbsent(address, a -> {
CompletableFuture<Connection> future = client.connect(address).thenApply(connection -> {
connection.onClose(c -> connections.remove(address, c));
connections.put(a... | [
"private",
"CompletableFuture",
"<",
"Connection",
">",
"createConnection",
"(",
"Address",
"address",
")",
"{",
"return",
"connectionFutures",
".",
"computeIfAbsent",
"(",
"address",
",",
"a",
"->",
"{",
"CompletableFuture",
"<",
"Connection",
">",
"future",
"=",... | Creates a connection for the given member.
@param address The member for which to create the connection.
@return A completable future to be called once the connection has been created. | [
"Creates",
"a",
"connection",
"for",
"the",
"given",
"member",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L69-L79 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java | ConnectionManager.close | public CompletableFuture<Void> close() {
CompletableFuture[] futures = new CompletableFuture[connections.size()];
for (CompletableFuture<Connection> future : this.connectionFutures.values()) {
future.cancel(false);
}
int i = 0;
for (Connection connection : connections.values()) {
futur... | java | public CompletableFuture<Void> close() {
CompletableFuture[] futures = new CompletableFuture[connections.size()];
for (CompletableFuture<Connection> future : this.connectionFutures.values()) {
future.cancel(false);
}
int i = 0;
for (Connection connection : connections.values()) {
futur... | [
"public",
"CompletableFuture",
"<",
"Void",
">",
"close",
"(",
")",
"{",
"CompletableFuture",
"[",
"]",
"futures",
"=",
"new",
"CompletableFuture",
"[",
"connections",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"CompletableFuture",
"<",
"Connection",
">",
... | Closes the connection manager.
@return A completable future to be completed once the connection manager is closed. | [
"Closes",
"the",
"connection",
"manager",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ConnectionManager.java#L86-L99 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java | MinorCompactionTask.compactEntries | private void compactEntries(Segment segment, Segment compactSegment) {
for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
checkEntry(i, segment, compactSegment);
}
} | java | private void compactEntries(Segment segment, Segment compactSegment) {
for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
checkEntry(i, segment, compactSegment);
}
} | [
"private",
"void",
"compactEntries",
"(",
"Segment",
"segment",
",",
"Segment",
"compactSegment",
")",
"{",
"for",
"(",
"long",
"i",
"=",
"segment",
".",
"firstIndex",
"(",
")",
";",
"i",
"<=",
"segment",
".",
"lastIndex",
"(",
")",
";",
"i",
"++",
")"... | Compacts entries from the given segment, rewriting them to the compact segment.
@param segment The segment to compact.
@param compactSegment The compact segment. | [
"Compacts",
"entries",
"from",
"the",
"given",
"segment",
"rewriting",
"them",
"to",
"the",
"compact",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L99-L103 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java | MinorCompactionTask.checkEntry | private void checkEntry(long index, Segment segment, Segment compactSegment) {
try (Entry entry = segment.get(index)) {
// If an entry was found, only remove the entry from the segment if it's not a tombstone that has been released.
if (entry != null) {
checkEntry(index, entry, segment, compactS... | java | private void checkEntry(long index, Segment segment, Segment compactSegment) {
try (Entry entry = segment.get(index)) {
// If an entry was found, only remove the entry from the segment if it's not a tombstone that has been released.
if (entry != null) {
checkEntry(index, entry, segment, compactS... | [
"private",
"void",
"checkEntry",
"(",
"long",
"index",
",",
"Segment",
"segment",
",",
"Segment",
"compactSegment",
")",
"{",
"try",
"(",
"Entry",
"entry",
"=",
"segment",
".",
"get",
"(",
"index",
")",
")",
"{",
"// If an entry was found, only remove the entry ... | Compacts the entry at the given index.
@param index The index at which to compact the entry.
@param segment The segment to compact.
@param compactSegment The segment to which to write the compacted segment. | [
"Compacts",
"the",
"entry",
"at",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L112-L121 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java | MinorCompactionTask.checkEntry | private void checkEntry(long index, Entry entry, Segment segment, Segment compactSegment) {
// Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction
// mode to the entry.
Compaction.Mode mode = entry.getCompactionMode();
if (mode == Compaction.Mode.DEFAULT) {
... | java | private void checkEntry(long index, Entry entry, Segment segment, Segment compactSegment) {
// Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction
// mode to the entry.
Compaction.Mode mode = entry.getCompactionMode();
if (mode == Compaction.Mode.DEFAULT) {
... | [
"private",
"void",
"checkEntry",
"(",
"long",
"index",
",",
"Entry",
"entry",
",",
"Segment",
"segment",
",",
"Segment",
"compactSegment",
")",
"{",
"// Get the entry compaction mode. If the compaction mode is DEFAULT apply the default compaction",
"// mode to the entry.",
"Com... | Compacts a command entry from a segment. | [
"Compacts",
"a",
"command",
"entry",
"from",
"a",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L126-L175 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java | MinorCompactionTask.transferEntry | private void transferEntry(long index, Entry entry, Segment compactSegment) {
compactSegment.append(entry);
// If the entry was released in the prior segment, mark it as released in the compact segment.
if (!segment.isLive(index)) {
compactSegment.release(index);
}
} | java | private void transferEntry(long index, Entry entry, Segment compactSegment) {
compactSegment.append(entry);
// If the entry was released in the prior segment, mark it as released in the compact segment.
if (!segment.isLive(index)) {
compactSegment.release(index);
}
} | [
"private",
"void",
"transferEntry",
"(",
"long",
"index",
",",
"Entry",
"entry",
",",
"Segment",
"compactSegment",
")",
"{",
"compactSegment",
".",
"append",
"(",
"entry",
")",
";",
"// If the entry was released in the prior segment, mark it as released in the compact segme... | Transfers an entry to the given compact segment. | [
"Transfers",
"an",
"entry",
"to",
"the",
"given",
"compact",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L188-L195 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java | MinorCompactionTask.mergeReleasedEntries | private void mergeReleasedEntries(Segment segment, Segment compactSegment) {
for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
if (!segment.isLive(i)) {
compactSegment.release(i);
}
}
} | java | private void mergeReleasedEntries(Segment segment, Segment compactSegment) {
for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
if (!segment.isLive(i)) {
compactSegment.release(i);
}
}
} | [
"private",
"void",
"mergeReleasedEntries",
"(",
"Segment",
"segment",
",",
"Segment",
"compactSegment",
")",
"{",
"for",
"(",
"long",
"i",
"=",
"segment",
".",
"firstIndex",
"(",
")",
";",
"i",
"<=",
"segment",
".",
"lastIndex",
"(",
")",
";",
"i",
"++",... | Updates the new compact segment with entries that were released from the given segment during compaction. | [
"Updates",
"the",
"new",
"compact",
"segment",
"with",
"entries",
"that",
"were",
"released",
"from",
"the",
"given",
"segment",
"during",
"compaction",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MinorCompactionTask.java#L200-L206 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java | SnapshotStore.open | private void open() {
for (Snapshot snapshot : loadSnapshots()) {
snapshots.put(snapshot.index(), snapshot);
}
if (!snapshots.isEmpty()) {
currentSnapshot = snapshots.lastEntry().getValue();
}
} | java | private void open() {
for (Snapshot snapshot : loadSnapshots()) {
snapshots.put(snapshot.index(), snapshot);
}
if (!snapshots.isEmpty()) {
currentSnapshot = snapshots.lastEntry().getValue();
}
} | [
"private",
"void",
"open",
"(",
")",
"{",
"for",
"(",
"Snapshot",
"snapshot",
":",
"loadSnapshots",
"(",
")",
")",
"{",
"snapshots",
".",
"put",
"(",
"snapshot",
".",
"index",
"(",
")",
",",
"snapshot",
")",
";",
"}",
"if",
"(",
"!",
"snapshots",
"... | Opens the snapshot manager. | [
"Opens",
"the",
"snapshot",
"manager",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java#L91-L99 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java | SnapshotStore.createMemorySnapshot | private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) {
HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE);
Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this);
LOGGER.debug("Created memory snapshot: {}", snapshot);
return snap... | java | private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) {
HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE);
Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this);
LOGGER.debug("Created memory snapshot: {}", snapshot);
return snap... | [
"private",
"Snapshot",
"createMemorySnapshot",
"(",
"SnapshotDescriptor",
"descriptor",
")",
"{",
"HeapBuffer",
"buffer",
"=",
"HeapBuffer",
".",
"allocate",
"(",
"SnapshotDescriptor",
".",
"BYTES",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"Snapshot",
"snapshot",... | Creates a memory snapshot. | [
"Creates",
"a",
"memory",
"snapshot",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/snapshot/SnapshotStore.java#L212-L217 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.getPrevEntry | @SuppressWarnings("unused")
protected Entry getPrevEntry(MemberState member) {
long prevIndex = Math.min(member.getNextIndex() - 1, context.getLog().lastIndex());
while (prevIndex > 0) {
Entry entry = context.getLog().get(prevIndex);
if (entry != null) {
return entry;
}
prevInd... | java | @SuppressWarnings("unused")
protected Entry getPrevEntry(MemberState member) {
long prevIndex = Math.min(member.getNextIndex() - 1, context.getLog().lastIndex());
while (prevIndex > 0) {
Entry entry = context.getLog().get(prevIndex);
if (entry != null) {
return entry;
}
prevInd... | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"protected",
"Entry",
"getPrevEntry",
"(",
"MemberState",
"member",
")",
"{",
"long",
"prevIndex",
"=",
"Math",
".",
"min",
"(",
"member",
".",
"getNextIndex",
"(",
")",
"-",
"1",
",",
"context",
".",
"getLo... | Gets the previous entry. | [
"Gets",
"the",
"previous",
"entry",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L152-L163 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.sendAppendRequest | protected void sendAppendRequest(Connection connection, MemberState member, AppendRequest request) {
long timestamp = System.nanoTime();
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().address());
connection.<AppendRequest, AppendResponse>sendAndRe... | java | protected void sendAppendRequest(Connection connection, MemberState member, AppendRequest request) {
long timestamp = System.nanoTime();
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().address());
connection.<AppendRequest, AppendResponse>sendAndRe... | [
"protected",
"void",
"sendAppendRequest",
"(",
"Connection",
"connection",
",",
"MemberState",
"member",
",",
"AppendRequest",
"request",
")",
"{",
"long",
"timestamp",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"logger",
".",
"trace",
"(",
"\"{} - Sending {... | Sends a commit message. | [
"Sends",
"a",
"commit",
"message",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L192-L220 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.updateNextIndex | protected void updateNextIndex(MemberState member, AppendRequest request) {
// If the match index was set, update the next index to be greater than the match index if necessary.
if (!request.entries().isEmpty()) {
member.setNextIndex(request.entries().get(request.entries().size()-1).getIndex()+1);
}
... | java | protected void updateNextIndex(MemberState member, AppendRequest request) {
// If the match index was set, update the next index to be greater than the match index if necessary.
if (!request.entries().isEmpty()) {
member.setNextIndex(request.entries().get(request.entries().size()-1).getIndex()+1);
}
... | [
"protected",
"void",
"updateNextIndex",
"(",
"MemberState",
"member",
",",
"AppendRequest",
"request",
")",
"{",
"// If the match index was set, update the next index to be greater than the match index if necessary.",
"if",
"(",
"!",
"request",
".",
"entries",
"(",
")",
".",
... | Updates the next index when the match index is updated. | [
"Updates",
"the",
"next",
"index",
"when",
"the",
"match",
"index",
"is",
"updated",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L336-L341 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.sendConfigureRequest | protected void sendConfigureRequest(Connection connection, MemberState member, ConfigureRequest request) {
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress());
connection.<ConfigureRequest, ConfigureResponse>sendAndReceive(request).whenComp... | java | protected void sendConfigureRequest(Connection connection, MemberState member, ConfigureRequest request) {
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress());
connection.<ConfigureRequest, ConfigureResponse>sendAndReceive(request).whenComp... | [
"protected",
"void",
"sendConfigureRequest",
"(",
"Connection",
"connection",
",",
"MemberState",
"member",
",",
"ConfigureRequest",
"request",
")",
"{",
"logger",
".",
"trace",
"(",
"\"{} - Sending {} to {}\"",
",",
"context",
".",
"getCluster",
"(",
")",
".",
"m... | Sends a configuration message. | [
"Sends",
"a",
"configuration",
"message",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L406-L424 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.sendInstallRequest | protected void sendInstallRequest(Connection connection, MemberState member, InstallRequest request) {
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress());
connection.<InstallRequest, InstallResponse>sendAndReceive(request).whenComplete((re... | java | protected void sendInstallRequest(Connection connection, MemberState member, InstallRequest request) {
logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress());
connection.<InstallRequest, InstallResponse>sendAndReceive(request).whenComplete((re... | [
"protected",
"void",
"sendInstallRequest",
"(",
"Connection",
"connection",
",",
"MemberState",
"member",
",",
"InstallRequest",
"request",
")",
"{",
"logger",
".",
"trace",
"(",
"\"{} - Sending {} to {}\"",
",",
"context",
".",
"getCluster",
"(",
")",
".",
"membe... | Sends a snapshot message. | [
"Sends",
"a",
"snapshot",
"message",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L539-L559 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.handleInstallRequestFailure | protected void handleInstallRequestFailure(MemberState member, InstallRequest request, Throwable error) {
// Log the failed attempt to contact the member.
failAttempt(member, error);
} | java | protected void handleInstallRequestFailure(MemberState member, InstallRequest request, Throwable error) {
// Log the failed attempt to contact the member.
failAttempt(member, error);
} | [
"protected",
"void",
"handleInstallRequestFailure",
"(",
"MemberState",
"member",
",",
"InstallRequest",
"request",
",",
"Throwable",
"error",
")",
"{",
"// Log the failed attempt to contact the member.",
"failAttempt",
"(",
"member",
",",
"error",
")",
";",
"}"
] | Handles an install request failure. | [
"Handles",
"an",
"install",
"request",
"failure",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L564-L567 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.handleInstallResponseFailure | protected void handleInstallResponseFailure(MemberState member, InstallRequest request, Throwable error) {
// Reset the member's snapshot index and offset to resend the snapshot from the start
// once a connection to the member is re-established.
member.setNextSnapshotIndex(0).setNextSnapshotOffset(0);
... | java | protected void handleInstallResponseFailure(MemberState member, InstallRequest request, Throwable error) {
// Reset the member's snapshot index and offset to resend the snapshot from the start
// once a connection to the member is re-established.
member.setNextSnapshotIndex(0).setNextSnapshotOffset(0);
... | [
"protected",
"void",
"handleInstallResponseFailure",
"(",
"MemberState",
"member",
",",
"InstallRequest",
"request",
",",
"Throwable",
"error",
")",
"{",
"// Reset the member's snapshot index and offset to resend the snapshot from the start",
"// once a connection to the member is re-e... | Handles an install response failure. | [
"Handles",
"an",
"install",
"response",
"failure",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L572-L579 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java | EntryBuffer.append | public EntryBuffer append(Entry entry) {
int offset = offset(entry.getIndex());
Entry oldEntry = buffer[offset];
buffer[offset] = entry.acquire();
if (oldEntry != null) {
oldEntry.release();
}
return this;
} | java | public EntryBuffer append(Entry entry) {
int offset = offset(entry.getIndex());
Entry oldEntry = buffer[offset];
buffer[offset] = entry.acquire();
if (oldEntry != null) {
oldEntry.release();
}
return this;
} | [
"public",
"EntryBuffer",
"append",
"(",
"Entry",
"entry",
")",
"{",
"int",
"offset",
"=",
"offset",
"(",
"entry",
".",
"getIndex",
"(",
")",
")",
";",
"Entry",
"oldEntry",
"=",
"buffer",
"[",
"offset",
"]",
";",
"buffer",
"[",
"offset",
"]",
"=",
"en... | Appends an entry to the buffer.
@param entry The entry to append.
@return The entry buffer. | [
"Appends",
"an",
"entry",
"to",
"the",
"buffer",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L38-L46 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java | EntryBuffer.get | @SuppressWarnings("unchecked")
public <T extends Entry> T get(long index) {
Entry entry = buffer[offset(index)];
return entry != null && entry.getIndex() == index ? (T) entry.acquire() : null;
} | java | @SuppressWarnings("unchecked")
public <T extends Entry> T get(long index) {
Entry entry = buffer[offset(index)];
return entry != null && entry.getIndex() == index ? (T) entry.acquire() : null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
"extends",
"Entry",
">",
"T",
"get",
"(",
"long",
"index",
")",
"{",
"Entry",
"entry",
"=",
"buffer",
"[",
"offset",
"(",
"index",
")",
"]",
";",
"return",
"entry",
"!=",
"null",
... | Looks up an entry in the buffer.
@param index The entry index.
@param <T> The entry type.
@return The entry or {@code null} if the entry is not present in the index. | [
"Looks",
"up",
"an",
"entry",
"in",
"the",
"buffer",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L55-L59 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java | EntryBuffer.clear | public EntryBuffer clear() {
for (int i = 0; i < buffer.length; i++) {
buffer[i] = null;
}
return this;
} | java | public EntryBuffer clear() {
for (int i = 0; i < buffer.length; i++) {
buffer[i] = null;
}
return this;
} | [
"public",
"EntryBuffer",
"clear",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"buffer",
".",
"length",
";",
"i",
"++",
")",
"{",
"buffer",
"[",
"i",
"]",
"=",
"null",
";",
"}",
"return",
"this",
";",
"}"
] | Clears the buffer and resets the index to the given index.
@return The entry buffer. | [
"Clears",
"the",
"buffer",
"and",
"resets",
"the",
"index",
"to",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L66-L71 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java | EntryBuffer.offset | private int offset(long index) {
int offset = (int) (index % buffer.length);
if (offset < 0) {
offset += buffer.length;
}
return offset;
} | java | private int offset(long index) {
int offset = (int) (index % buffer.length);
if (offset < 0) {
offset += buffer.length;
}
return offset;
} | [
"private",
"int",
"offset",
"(",
"long",
"index",
")",
"{",
"int",
"offset",
"=",
"(",
"int",
")",
"(",
"index",
"%",
"buffer",
".",
"length",
")",
";",
"if",
"(",
"offset",
"<",
"0",
")",
"{",
"offset",
"+=",
"buffer",
".",
"length",
";",
"}",
... | Returns the buffer index for the given offset. | [
"Returns",
"the",
"buffer",
"index",
"for",
"the",
"given",
"offset",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/EntryBuffer.java#L76-L82 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSessionState.java | ClientSessionState.onStateChange | public Listener<Session.State> onStateChange(Consumer<Session.State> callback) {
Listener<Session.State> listener = new Listener<Session.State>() {
@Override
public void accept(Session.State state) {
callback.accept(state);
}
@Override
public void close() {
changeListen... | java | public Listener<Session.State> onStateChange(Consumer<Session.State> callback) {
Listener<Session.State> listener = new Listener<Session.State>() {
@Override
public void accept(Session.State state) {
callback.accept(state);
}
@Override
public void close() {
changeListen... | [
"public",
"Listener",
"<",
"Session",
".",
"State",
">",
"onStateChange",
"(",
"Consumer",
"<",
"Session",
".",
"State",
">",
"callback",
")",
"{",
"Listener",
"<",
"Session",
".",
"State",
">",
"listener",
"=",
"new",
"Listener",
"<",
"Session",
".",
"S... | Registers a state change listener on the session manager.
@param callback The state change listener callback.
@return The state change listener. | [
"Registers",
"a",
"state",
"change",
"listener",
"on",
"the",
"session",
"manager",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSessionState.java#L142-L155 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java | TermIndex.term | public synchronized long term() {
Map.Entry<Long, Long> entry = terms.lastEntry();
return entry != null ? entry.getValue() : 0;
} | java | public synchronized long term() {
Map.Entry<Long, Long> entry = terms.lastEntry();
return entry != null ? entry.getValue() : 0;
} | [
"public",
"synchronized",
"long",
"term",
"(",
")",
"{",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Long",
">",
"entry",
"=",
"terms",
".",
"lastEntry",
"(",
")",
";",
"return",
"entry",
"!=",
"null",
"?",
"entry",
".",
"getValue",
"(",
")",
":",
"0",... | Returns the highest term in the index.
@return The highest term in the index. | [
"Returns",
"the",
"highest",
"term",
"in",
"the",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L45-L48 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java | TermIndex.index | public synchronized void index(long offset, long term) {
if (lookup(offset) != term) {
terms.put(offset, term);
}
} | java | public synchronized void index(long offset, long term) {
if (lookup(offset) != term) {
terms.put(offset, term);
}
} | [
"public",
"synchronized",
"void",
"index",
"(",
"long",
"offset",
",",
"long",
"term",
")",
"{",
"if",
"(",
"lookup",
"(",
"offset",
")",
"!=",
"term",
")",
"{",
"terms",
".",
"put",
"(",
"offset",
",",
"term",
")",
";",
"}",
"}"
] | Indexes the given offset with the given term.
@param offset The offset to index.
@param term The term to index. | [
"Indexes",
"the",
"given",
"offset",
"with",
"the",
"given",
"term",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L56-L60 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java | TermIndex.lookup | public synchronized long lookup(long offset) {
Map.Entry<Long, Long> entry = terms.floorEntry(offset);
return entry != null ? entry.getValue() : 0;
} | java | public synchronized long lookup(long offset) {
Map.Entry<Long, Long> entry = terms.floorEntry(offset);
return entry != null ? entry.getValue() : 0;
} | [
"public",
"synchronized",
"long",
"lookup",
"(",
"long",
"offset",
")",
"{",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Long",
">",
"entry",
"=",
"terms",
".",
"floorEntry",
"(",
"offset",
")",
";",
"return",
"entry",
"!=",
"null",
"?",
"entry",
".",
"g... | Looks up the term for the given offset.
@param offset The offset for which to look up the term.
@return The term for the entry at the given offset. | [
"Looks",
"up",
"the",
"term",
"for",
"the",
"given",
"offset",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/TermIndex.java#L68-L71 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/util/OffsetPredicate.java | OffsetPredicate.release | public boolean release(long offset) {
Assert.argNot(offset < 0, "offset must be positive");
if (bits.size() <= offset) {
while (bits.size() <= offset) {
bits.resize(bits.size() * 2);
}
}
return bits.set(offset);
} | java | public boolean release(long offset) {
Assert.argNot(offset < 0, "offset must be positive");
if (bits.size() <= offset) {
while (bits.size() <= offset) {
bits.resize(bits.size() * 2);
}
}
return bits.set(offset);
} | [
"public",
"boolean",
"release",
"(",
"long",
"offset",
")",
"{",
"Assert",
".",
"argNot",
"(",
"offset",
"<",
"0",
",",
"\"offset must be positive\"",
")",
";",
"if",
"(",
"bits",
".",
"size",
"(",
")",
"<=",
"offset",
")",
"{",
"while",
"(",
"bits",
... | Releases an offset from the segment.
@param offset The offset to release.
@return Indicates whether the offset was newly released. | [
"Releases",
"an",
"offset",
"from",
"the",
"segment",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/util/OffsetPredicate.java#L62-L70 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSession.java | ClientSession.submit | public <T> CompletableFuture<T> submit(Operation<T> operation) {
if (operation instanceof Query) {
return submit((Query<T>) operation);
} else if (operation instanceof Command) {
return submit((Command<T>) operation);
} else {
throw new UnsupportedOperationException("unknown operation type... | java | public <T> CompletableFuture<T> submit(Operation<T> operation) {
if (operation instanceof Query) {
return submit((Query<T>) operation);
} else if (operation instanceof Command) {
return submit((Command<T>) operation);
} else {
throw new UnsupportedOperationException("unknown operation type... | [
"public",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"submit",
"(",
"Operation",
"<",
"T",
">",
"operation",
")",
"{",
"if",
"(",
"operation",
"instanceof",
"Query",
")",
"{",
"return",
"submit",
"(",
"(",
"Query",
"<",
"T",
">",
")",
"operat... | Submits an operation to the session.
@param operation The operation to submit.
@param <T> The operation result type.
@return A completable future to be completed with the operation result. | [
"Submits",
"an",
"operation",
"to",
"the",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L97-L105 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSession.java | ClientSession.submit | public <T> CompletableFuture<T> submit(Command<T> command) {
State state = state();
if (state == State.CLOSED || state == State.EXPIRED) {
return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
}
return submitter.submit(command);
} | java | public <T> CompletableFuture<T> submit(Command<T> command) {
State state = state();
if (state == State.CLOSED || state == State.EXPIRED) {
return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
}
return submitter.submit(command);
} | [
"public",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"submit",
"(",
"Command",
"<",
"T",
">",
"command",
")",
"{",
"State",
"state",
"=",
"state",
"(",
")",
";",
"if",
"(",
"state",
"==",
"State",
".",
"CLOSED",
"||",
"state",
"==",
"State"... | Submits a command to the session.
@param command The command to submit.
@param <T> The command result type.
@return A completable future to be completed with the command result. | [
"Submits",
"a",
"command",
"to",
"the",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L114-L120 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSession.java | ClientSession.submit | public <T> CompletableFuture<T> submit(Query<T> query) {
State state = state();
if (state == State.CLOSED || state == State.EXPIRED) {
return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
}
return submitter.submit(query);
} | java | public <T> CompletableFuture<T> submit(Query<T> query) {
State state = state();
if (state == State.CLOSED || state == State.EXPIRED) {
return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
}
return submitter.submit(query);
} | [
"public",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"submit",
"(",
"Query",
"<",
"T",
">",
"query",
")",
"{",
"State",
"state",
"=",
"state",
"(",
")",
";",
"if",
"(",
"state",
"==",
"State",
".",
"CLOSED",
"||",
"state",
"==",
"State",
... | Submits a query to the session.
@param query The query to submit.
@param <T> The query result type.
@return A completable future to be completed with the query result. | [
"Submits",
"a",
"query",
"to",
"the",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L129-L135 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSession.java | ClientSession.kill | public CompletableFuture<Void> kill() {
return submitter.close()
.thenCompose(v -> listener.close())
.thenCompose(v -> manager.kill())
.thenCompose(v -> connection.close());
} | java | public CompletableFuture<Void> kill() {
return submitter.close()
.thenCompose(v -> listener.close())
.thenCompose(v -> manager.kill())
.thenCompose(v -> connection.close());
} | [
"public",
"CompletableFuture",
"<",
"Void",
">",
"kill",
"(",
")",
"{",
"return",
"submitter",
".",
"close",
"(",
")",
".",
"thenCompose",
"(",
"v",
"->",
"listener",
".",
"close",
"(",
")",
")",
".",
"thenCompose",
"(",
"v",
"->",
"manager",
".",
"k... | Kills the session.
@return A completable future to be completed once the session has been killed. | [
"Kills",
"the",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSession.java#L221-L226 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.calculateLastCompleted | private long calculateLastCompleted(long index) {
// Calculate the last completed index as the lowest index acknowledged by all clients.
long lastCompleted = index;
for (ServerSessionContext session : executor.context().sessions().sessions.values()) {
lastCompleted = Math.min(lastCompleted, session.ge... | java | private long calculateLastCompleted(long index) {
// Calculate the last completed index as the lowest index acknowledged by all clients.
long lastCompleted = index;
for (ServerSessionContext session : executor.context().sessions().sessions.values()) {
lastCompleted = Math.min(lastCompleted, session.ge... | [
"private",
"long",
"calculateLastCompleted",
"(",
"long",
"index",
")",
"{",
"// Calculate the last completed index as the lowest index acknowledged by all clients.",
"long",
"lastCompleted",
"=",
"index",
";",
"for",
"(",
"ServerSessionContext",
"session",
":",
"executor",
"... | Calculates the last completed session event index. | [
"Calculates",
"the",
"last",
"completed",
"session",
"event",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L238-L245 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.setLastCompleted | private void setLastCompleted(long lastCompleted) {
if (!log.isOpen())
return;
this.lastCompleted = Math.max(this.lastCompleted, lastCompleted);
// Update the log compaction minor index.
log.compactor().minorIndex(this.lastCompleted);
completeSnapshot();
} | java | private void setLastCompleted(long lastCompleted) {
if (!log.isOpen())
return;
this.lastCompleted = Math.max(this.lastCompleted, lastCompleted);
// Update the log compaction minor index.
log.compactor().minorIndex(this.lastCompleted);
completeSnapshot();
} | [
"private",
"void",
"setLastCompleted",
"(",
"long",
"lastCompleted",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isOpen",
"(",
")",
")",
"return",
";",
"this",
".",
"lastCompleted",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"lastCompleted",
",",
"lastComplet... | Updates the last completed event index based on a commit at the given index. | [
"Updates",
"the",
"last",
"completed",
"event",
"index",
"based",
"on",
"a",
"commit",
"at",
"the",
"given",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L250-L260 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.keepAliveSession | private void keepAliveSession(long index, long timestamp, long commandSequence, long eventIndex, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
... | java | private void keepAliveSession(long index, long timestamp, long commandSequence, long eventIndex, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
... | [
"private",
"void",
"keepAliveSession",
"(",
"long",
"index",
",",
"long",
"timestamp",
",",
"long",
"commandSequence",
",",
"long",
"eventIndex",
",",
"ServerSessionContext",
"session",
",",
"CompletableFuture",
"<",
"Void",
">",
"future",
",",
"ThreadContext",
"c... | Applies a keep alive for a session. | [
"Applies",
"a",
"keep",
"alive",
"for",
"a",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L548-L580 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.sequenceCommand | private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
Result result = session.ge... | java | private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
Result result = session.ge... | [
"private",
"void",
"sequenceCommand",
"(",
"long",
"sequence",
",",
"ServerSessionContext",
"session",
",",
"CompletableFuture",
"<",
"Result",
">",
"future",
",",
"ThreadContext",
"context",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isOpen",
"(",
")",
")",
"{"... | Sequences a command according to the command sequence number. | [
"Sequences",
"a",
"command",
"according",
"to",
"the",
"command",
"sequence",
"number",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L817-L828 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.executeCommand | private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
... | java | private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
... | [
"private",
"void",
"executeCommand",
"(",
"long",
"index",
",",
"long",
"sequence",
",",
"long",
"timestamp",
",",
"ServerCommit",
"commit",
",",
"ServerSessionContext",
"session",
",",
"CompletableFuture",
"<",
"Result",
">",
"future",
",",
"ThreadContext",
"cont... | Executes a state machine command. | [
"Executes",
"a",
"state",
"machine",
"command",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L833-L874 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java | ServerStateMachine.executeQuery | private void executeQuery(ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
// If the session is al... | java | private void executeQuery(ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
// If the session is al... | [
"private",
"void",
"executeQuery",
"(",
"ServerCommit",
"commit",
",",
"ServerSessionContext",
"session",
",",
"CompletableFuture",
"<",
"Result",
">",
"future",
",",
"ThreadContext",
"context",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isOpen",
"(",
")",
")",
... | Executes a state machine query. | [
"Executes",
"a",
"state",
"machine",
"query",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L919-L945 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/LeaderState.java | LeaderState.query | private CompletableFuture<QueryResponse> query(QueryEntry entry) {
Query.ConsistencyLevel consistency = entry.getQuery().consistency();
if (consistency == null)
return queryLinearizable(entry);
switch (consistency) {
case SEQUENTIAL:
return queryLocal(entry);
case LINEARIZABLE_LEA... | java | private CompletableFuture<QueryResponse> query(QueryEntry entry) {
Query.ConsistencyLevel consistency = entry.getQuery().consistency();
if (consistency == null)
return queryLinearizable(entry);
switch (consistency) {
case SEQUENTIAL:
return queryLocal(entry);
case LINEARIZABLE_LEA... | [
"private",
"CompletableFuture",
"<",
"QueryResponse",
">",
"query",
"(",
"QueryEntry",
"entry",
")",
"{",
"Query",
".",
"ConsistencyLevel",
"consistency",
"=",
"entry",
".",
"getQuery",
"(",
")",
".",
"consistency",
"(",
")",
";",
"if",
"(",
"consistency",
"... | Applies the given query entry to the state machine according to the query's consistency level. | [
"Applies",
"the",
"given",
"query",
"entry",
"to",
"the",
"state",
"machine",
"according",
"to",
"the",
"query",
"s",
"consistency",
"level",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L567-L582 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/LeaderState.java | LeaderState.sequenceAndApply | private CompletableFuture<QueryResponse> sequenceAndApply(QueryEntry entry) {
// Get the client's server session. If the session doesn't exist, return an unknown session error.
ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession());
if (sessio... | java | private CompletableFuture<QueryResponse> sequenceAndApply(QueryEntry entry) {
// Get the client's server session. If the session doesn't exist, return an unknown session error.
ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession());
if (sessio... | [
"private",
"CompletableFuture",
"<",
"QueryResponse",
">",
"sequenceAndApply",
"(",
"QueryEntry",
"entry",
")",
"{",
"// Get the client's server session. If the session doesn't exist, return an unknown session error.",
"ServerSessionContext",
"session",
"=",
"context",
".",
"getSta... | Sequences and applies the given query entry. | [
"Sequences",
"and",
"applies",
"the",
"given",
"query",
"entry",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L613-L635 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/LeaderState.java | LeaderState.cancelAppendTimer | private void cancelAppendTimer() {
if (appendTimer != null) {
LOGGER.trace("{} - Cancelling append timer", context.getCluster().member().address());
appendTimer.cancel();
}
} | java | private void cancelAppendTimer() {
if (appendTimer != null) {
LOGGER.trace("{} - Cancelling append timer", context.getCluster().member().address());
appendTimer.cancel();
}
} | [
"private",
"void",
"cancelAppendTimer",
"(",
")",
"{",
"if",
"(",
"appendTimer",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"{} - Cancelling append timer\"",
",",
"context",
".",
"getCluster",
"(",
")",
".",
"member",
"(",
")",
".",
"address",
... | Cancels the append timer. | [
"Cancels",
"the",
"append",
"timer",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderState.java#L861-L866 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java | MajorCompactionManager.getCompactableGroups | public List<List<Segment>> getCompactableGroups(Storage storage, SegmentManager manager) {
List<List<Segment>> compact = new ArrayList<>();
List<Segment> segments = null;
for (Segment segment : getCompactableSegments(manager)) {
// If this is the first segment in a segments list, add the segment.
... | java | public List<List<Segment>> getCompactableGroups(Storage storage, SegmentManager manager) {
List<List<Segment>> compact = new ArrayList<>();
List<Segment> segments = null;
for (Segment segment : getCompactableSegments(manager)) {
// If this is the first segment in a segments list, add the segment.
... | [
"public",
"List",
"<",
"List",
"<",
"Segment",
">",
">",
"getCompactableGroups",
"(",
"Storage",
"storage",
",",
"SegmentManager",
"manager",
")",
"{",
"List",
"<",
"List",
"<",
"Segment",
">>",
"compact",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"L... | Returns a list of segments lists to compact, where segments are grouped according to how they will be merged during
compaction. | [
"Returns",
"a",
"list",
"of",
"segments",
"lists",
"to",
"compact",
"where",
"segments",
"are",
"grouped",
"according",
"to",
"how",
"they",
"will",
"be",
"merged",
"during",
"compaction",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java#L62-L89 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java | MajorCompactionManager.getCompactableSegments | private List<Segment> getCompactableSegments(SegmentManager manager) {
List<Segment> segments = new ArrayList<>(manager.segments().size());
Iterator<Segment> iterator = manager.segments().iterator();
Segment segment = iterator.next();
while (iterator.hasNext()) {
Segment nextSegment = iterator.nex... | java | private List<Segment> getCompactableSegments(SegmentManager manager) {
List<Segment> segments = new ArrayList<>(manager.segments().size());
Iterator<Segment> iterator = manager.segments().iterator();
Segment segment = iterator.next();
while (iterator.hasNext()) {
Segment nextSegment = iterator.nex... | [
"private",
"List",
"<",
"Segment",
">",
"getCompactableSegments",
"(",
"SegmentManager",
"manager",
")",
"{",
"List",
"<",
"Segment",
">",
"segments",
"=",
"new",
"ArrayList",
"<>",
"(",
"manager",
".",
"segments",
"(",
")",
".",
"size",
"(",
")",
")",
"... | Returns a list of compactable log segments.
@param manager The segment manager.
@return A list of compactable log segments. | [
"Returns",
"a",
"list",
"of",
"compactable",
"log",
"segments",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/storage/compaction/MajorCompactionManager.java#L97-L116 | train |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/session/ClientSessionSubmitter.java | ClientSessionSubmitter.close | public CompletableFuture<Void> close() {
for (OperationAttempt attempt : new ArrayList<>(attempts.values())) {
attempt.fail(new ClosedSessionException("session closed"));
}
attempts.clear();
return CompletableFuture.completedFuture(null);
} | java | public CompletableFuture<Void> close() {
for (OperationAttempt attempt : new ArrayList<>(attempts.values())) {
attempt.fail(new ClosedSessionException("session closed"));
}
attempts.clear();
return CompletableFuture.completedFuture(null);
} | [
"public",
"CompletableFuture",
"<",
"Void",
">",
"close",
"(",
")",
"{",
"for",
"(",
"OperationAttempt",
"attempt",
":",
"new",
"ArrayList",
"<>",
"(",
"attempts",
".",
"values",
"(",
")",
")",
")",
"{",
"attempt",
".",
"fail",
"(",
"new",
"ClosedSession... | Closes the submitter.
@return A completable future to be completed with a list of pending operations. | [
"Closes",
"the",
"submitter",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/session/ClientSessionSubmitter.java#L211-L217 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerMember.java | ServerMember.update | ServerMember update(Status status, Instant time) {
if (this.status != status) {
this.status = Assert.notNull(status, "status");
if (time.isAfter(updated)) {
this.updated = Assert.notNull(time, "time");
}
if (statusChangeListeners != null) {
statusChangeListeners.accept(status... | java | ServerMember update(Status status, Instant time) {
if (this.status != status) {
this.status = Assert.notNull(status, "status");
if (time.isAfter(updated)) {
this.updated = Assert.notNull(time, "time");
}
if (statusChangeListeners != null) {
statusChangeListeners.accept(status... | [
"ServerMember",
"update",
"(",
"Status",
"status",
",",
"Instant",
"time",
")",
"{",
"if",
"(",
"this",
".",
"status",
"!=",
"status",
")",
"{",
"this",
".",
"status",
"=",
"Assert",
".",
"notNull",
"(",
"status",
",",
"\"status\"",
")",
";",
"if",
"... | Updates the member status.
@param status The member status.
@return The member. | [
"Updates",
"the",
"member",
"status",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerMember.java#L180-L191 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerMember.java | ServerMember.update | ServerMember update(Address clientAddress, Instant time) {
if (clientAddress != null) {
this.clientAddress = clientAddress;
if (time.isAfter(updated)) {
this.updated = Assert.notNull(time, "time");
}
}
return this;
} | java | ServerMember update(Address clientAddress, Instant time) {
if (clientAddress != null) {
this.clientAddress = clientAddress;
if (time.isAfter(updated)) {
this.updated = Assert.notNull(time, "time");
}
}
return this;
} | [
"ServerMember",
"update",
"(",
"Address",
"clientAddress",
",",
"Instant",
"time",
")",
"{",
"if",
"(",
"clientAddress",
"!=",
"null",
")",
"{",
"this",
".",
"clientAddress",
"=",
"clientAddress",
";",
"if",
"(",
"time",
".",
"isAfter",
"(",
"updated",
")"... | Updates the member client address.
@param clientAddress The member client address.
@return The member. | [
"Updates",
"the",
"member",
"client",
"address",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerMember.java#L199-L207 | train |
atomix/copycat | examples/value-state-machine/src/main/java/io/atomix/copycat/examples/ValueStateMachine.java | ValueStateMachine.delete | private void delete(Commit<DeleteCommand> commit) {
try {
if (value != null) {
value.close();
value = null;
}
} finally {
commit.close();
}
} | java | private void delete(Commit<DeleteCommand> commit) {
try {
if (value != null) {
value.close();
value = null;
}
} finally {
commit.close();
}
} | [
"private",
"void",
"delete",
"(",
"Commit",
"<",
"DeleteCommand",
">",
"commit",
")",
"{",
"try",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"value",
".",
"close",
"(",
")",
";",
"value",
"=",
"null",
";",
"}",
"}",
"finally",
"{",
"commit",
... | Deletes the value. | [
"Deletes",
"the",
"value",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/examples/value-state-machine/src/main/java/io/atomix/copycat/examples/ValueStateMachine.java#L70-L79 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java | ServerSessionContext.release | void release() {
long references = --this.references;
if (!state.active() && references == 0) {
context.sessions().unregisterSession(id);
log.release(id);
if (closeIndex > 0) {
log.release(closeIndex);
}
}
} | java | void release() {
long references = --this.references;
if (!state.active() && references == 0) {
context.sessions().unregisterSession(id);
log.release(id);
if (closeIndex > 0) {
log.release(closeIndex);
}
}
} | [
"void",
"release",
"(",
")",
"{",
"long",
"references",
"=",
"--",
"this",
".",
"references",
";",
"if",
"(",
"!",
"state",
".",
"active",
"(",
")",
"&&",
"references",
"==",
"0",
")",
"{",
"context",
".",
"sessions",
"(",
")",
".",
"unregisterSessio... | Releases a reference to the session. | [
"Releases",
"a",
"reference",
"to",
"the",
"session",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L131-L140 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java | ServerSessionContext.setKeepAliveIndex | ServerSessionContext setKeepAliveIndex(long keepAliveIndex) {
long previousKeepAliveIndex = this.keepAliveIndex;
this.keepAliveIndex = keepAliveIndex;
if (previousKeepAliveIndex > 0) {
log.release(previousKeepAliveIndex);
}
return this;
} | java | ServerSessionContext setKeepAliveIndex(long keepAliveIndex) {
long previousKeepAliveIndex = this.keepAliveIndex;
this.keepAliveIndex = keepAliveIndex;
if (previousKeepAliveIndex > 0) {
log.release(previousKeepAliveIndex);
}
return this;
} | [
"ServerSessionContext",
"setKeepAliveIndex",
"(",
"long",
"keepAliveIndex",
")",
"{",
"long",
"previousKeepAliveIndex",
"=",
"this",
".",
"keepAliveIndex",
";",
"this",
".",
"keepAliveIndex",
"=",
"keepAliveIndex",
";",
"if",
"(",
"previousKeepAliveIndex",
">",
"0",
... | Sets the current session keep alive index.
@param keepAliveIndex The current session keep alive index.
@return The server session. | [
"Sets",
"the",
"current",
"session",
"keep",
"alive",
"index",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L195-L202 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java | ServerSessionContext.setRequestSequence | boolean setRequestSequence(long requestSequence) {
if (requestSequence == this.requestSequence + 1) {
this.requestSequence = requestSequence;
return true;
} else if (requestSequence <= this.requestSequence) {
return true;
}
return false;
} | java | boolean setRequestSequence(long requestSequence) {
if (requestSequence == this.requestSequence + 1) {
this.requestSequence = requestSequence;
return true;
} else if (requestSequence <= this.requestSequence) {
return true;
}
return false;
} | [
"boolean",
"setRequestSequence",
"(",
"long",
"requestSequence",
")",
"{",
"if",
"(",
"requestSequence",
"==",
"this",
".",
"requestSequence",
"+",
"1",
")",
"{",
"this",
".",
"requestSequence",
"=",
"requestSequence",
";",
"return",
"true",
";",
"}",
"else",
... | Checks and sets the current request sequence number.
@param requestSequence The request sequence number to set.
@return Indicates whether the given {@code requestSequence} number is the next sequence number. | [
"Checks",
"and",
"sets",
"the",
"current",
"request",
"sequence",
"number",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L219-L227 | train |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java | ServerSessionContext.resendEvents | ServerSessionContext resendEvents(long index) {
clearEvents(index);
for (EventHolder event : events) {
sendEvent(event);
}
return this;
} | java | ServerSessionContext resendEvents(long index) {
clearEvents(index);
for (EventHolder event : events) {
sendEvent(event);
}
return this;
} | [
"ServerSessionContext",
"resendEvents",
"(",
"long",
"index",
")",
"{",
"clearEvents",
"(",
"index",
")",
";",
"for",
"(",
"EventHolder",
"event",
":",
"events",
")",
"{",
"sendEvent",
"(",
"event",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Resends events from the given sequence.
@param index The index from which to resend events.
@return The server session. | [
"Resends",
"events",
"from",
"the",
"given",
"sequence",
"."
] | c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10 | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerSessionContext.java#L495-L501 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.