id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
15,300
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.setActiveMigration
|
void setActiveMigration() {
InternalPartitionServiceImpl partitionService = getService();
MigrationManager migrationManager = partitionService.getMigrationManager();
MigrationInfo currentActiveMigration = migrationManager.setActiveMigration(migrationInfo);
if (currentActiveMigration != null) {
if (migrationInfo.equals(currentActiveMigration)) {
migrationInfo = currentActiveMigration;
return;
}
throw new RetryableHazelcastException("Cannot set active migration to " + migrationInfo
+ ". Current active migration is " + currentActiveMigration);
}
PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
if (!partitionStateManager.trySetMigratingFlag(migrationInfo.getPartitionId())) {
throw new RetryableHazelcastException("Cannot set migrating flag, "
+ "probably previous migration's finalization is not completed yet.");
}
}
|
java
|
void setActiveMigration() {
InternalPartitionServiceImpl partitionService = getService();
MigrationManager migrationManager = partitionService.getMigrationManager();
MigrationInfo currentActiveMigration = migrationManager.setActiveMigration(migrationInfo);
if (currentActiveMigration != null) {
if (migrationInfo.equals(currentActiveMigration)) {
migrationInfo = currentActiveMigration;
return;
}
throw new RetryableHazelcastException("Cannot set active migration to " + migrationInfo
+ ". Current active migration is " + currentActiveMigration);
}
PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
if (!partitionStateManager.trySetMigratingFlag(migrationInfo.getPartitionId())) {
throw new RetryableHazelcastException("Cannot set migrating flag, "
+ "probably previous migration's finalization is not completed yet.");
}
}
|
[
"void",
"setActiveMigration",
"(",
")",
"{",
"InternalPartitionServiceImpl",
"partitionService",
"=",
"getService",
"(",
")",
";",
"MigrationManager",
"migrationManager",
"=",
"partitionService",
".",
"getMigrationManager",
"(",
")",
";",
"MigrationInfo",
"currentActiveMigration",
"=",
"migrationManager",
".",
"setActiveMigration",
"(",
"migrationInfo",
")",
";",
"if",
"(",
"currentActiveMigration",
"!=",
"null",
")",
"{",
"if",
"(",
"migrationInfo",
".",
"equals",
"(",
"currentActiveMigration",
")",
")",
"{",
"migrationInfo",
"=",
"currentActiveMigration",
";",
"return",
";",
"}",
"throw",
"new",
"RetryableHazelcastException",
"(",
"\"Cannot set active migration to \"",
"+",
"migrationInfo",
"+",
"\". Current active migration is \"",
"+",
"currentActiveMigration",
")",
";",
"}",
"PartitionStateManager",
"partitionStateManager",
"=",
"partitionService",
".",
"getPartitionStateManager",
"(",
")",
";",
"if",
"(",
"!",
"partitionStateManager",
".",
"trySetMigratingFlag",
"(",
"migrationInfo",
".",
"getPartitionId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"RetryableHazelcastException",
"(",
"\"Cannot set migrating flag, \"",
"+",
"\"probably previous migration's finalization is not completed yet.\"",
")",
";",
"}",
"}"
] |
Sets the active migration and the partition migration flag.
|
[
"Sets",
"the",
"active",
"migration",
"and",
"the",
"partition",
"migration",
"flag",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L201-L219
|
15,301
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/aggregation/impl/AbstractAggregator.java
|
AbstractAggregator.extract
|
@SuppressWarnings("unchecked")
private <T> T extract(I input) {
if (attributePath == null) {
if (input instanceof Map.Entry) {
return (T) ((Map.Entry) input).getValue();
}
} else if (input instanceof Extractable) {
return (T) ((Extractable) input).getAttributeValue(attributePath);
}
throw new IllegalArgumentException("Can't extract " + attributePath + " from the given input");
}
|
java
|
@SuppressWarnings("unchecked")
private <T> T extract(I input) {
if (attributePath == null) {
if (input instanceof Map.Entry) {
return (T) ((Map.Entry) input).getValue();
}
} else if (input instanceof Extractable) {
return (T) ((Extractable) input).getAttributeValue(attributePath);
}
throw new IllegalArgumentException("Can't extract " + attributePath + " from the given input");
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"T",
"extract",
"(",
"I",
"input",
")",
"{",
"if",
"(",
"attributePath",
"==",
"null",
")",
"{",
"if",
"(",
"input",
"instanceof",
"Map",
".",
"Entry",
")",
"{",
"return",
"(",
"T",
")",
"(",
"(",
"Map",
".",
"Entry",
")",
"input",
")",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"Extractable",
")",
"{",
"return",
"(",
"T",
")",
"(",
"(",
"Extractable",
")",
"input",
")",
".",
"getAttributeValue",
"(",
"attributePath",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't extract \"",
"+",
"attributePath",
"+",
"\" from the given input\"",
")",
";",
"}"
] |
Extract the value of the given attributePath from the given entry.
|
[
"Extract",
"the",
"value",
"of",
"the",
"given",
"attributePath",
"from",
"the",
"given",
"entry",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/aggregation/impl/AbstractAggregator.java#L85-L95
|
15,302
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java
|
Invocation.initInvocationTarget
|
final void initInvocationTarget() throws Exception {
Member previousTargetMember = targetMember;
T target = getInvocationTarget();
if (target == null) {
remote = false;
throw newTargetNullException();
}
targetMember = toTargetMember(target);
if (targetMember != null) {
targetAddress = targetMember.getAddress();
} else {
targetAddress = toTargetAddress(target);
}
memberListVersion = context.clusterService.getMemberListVersion();
if (targetMember == null) {
if (previousTargetMember != null) {
// If a target member was found earlier but current target member is null
// then it means a member left.
throw new MemberLeftException(previousTargetMember);
}
if (!(isJoinOperation(op) || isWanReplicationOperation(op))) {
throw new TargetNotMemberException(target, op.getPartitionId(), op.getClass().getName(), op.getServiceName());
}
}
if (op instanceof TargetAware) {
((TargetAware) op).setTarget(targetAddress);
}
remote = !context.thisAddress.equals(targetAddress);
}
|
java
|
final void initInvocationTarget() throws Exception {
Member previousTargetMember = targetMember;
T target = getInvocationTarget();
if (target == null) {
remote = false;
throw newTargetNullException();
}
targetMember = toTargetMember(target);
if (targetMember != null) {
targetAddress = targetMember.getAddress();
} else {
targetAddress = toTargetAddress(target);
}
memberListVersion = context.clusterService.getMemberListVersion();
if (targetMember == null) {
if (previousTargetMember != null) {
// If a target member was found earlier but current target member is null
// then it means a member left.
throw new MemberLeftException(previousTargetMember);
}
if (!(isJoinOperation(op) || isWanReplicationOperation(op))) {
throw new TargetNotMemberException(target, op.getPartitionId(), op.getClass().getName(), op.getServiceName());
}
}
if (op instanceof TargetAware) {
((TargetAware) op).setTarget(targetAddress);
}
remote = !context.thisAddress.equals(targetAddress);
}
|
[
"final",
"void",
"initInvocationTarget",
"(",
")",
"throws",
"Exception",
"{",
"Member",
"previousTargetMember",
"=",
"targetMember",
";",
"T",
"target",
"=",
"getInvocationTarget",
"(",
")",
";",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"remote",
"=",
"false",
";",
"throw",
"newTargetNullException",
"(",
")",
";",
"}",
"targetMember",
"=",
"toTargetMember",
"(",
"target",
")",
";",
"if",
"(",
"targetMember",
"!=",
"null",
")",
"{",
"targetAddress",
"=",
"targetMember",
".",
"getAddress",
"(",
")",
";",
"}",
"else",
"{",
"targetAddress",
"=",
"toTargetAddress",
"(",
"target",
")",
";",
"}",
"memberListVersion",
"=",
"context",
".",
"clusterService",
".",
"getMemberListVersion",
"(",
")",
";",
"if",
"(",
"targetMember",
"==",
"null",
")",
"{",
"if",
"(",
"previousTargetMember",
"!=",
"null",
")",
"{",
"// If a target member was found earlier but current target member is null",
"// then it means a member left.",
"throw",
"new",
"MemberLeftException",
"(",
"previousTargetMember",
")",
";",
"}",
"if",
"(",
"!",
"(",
"isJoinOperation",
"(",
"op",
")",
"||",
"isWanReplicationOperation",
"(",
"op",
")",
")",
")",
"{",
"throw",
"new",
"TargetNotMemberException",
"(",
"target",
",",
"op",
".",
"getPartitionId",
"(",
")",
",",
"op",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"op",
".",
"getServiceName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"op",
"instanceof",
"TargetAware",
")",
"{",
"(",
"(",
"TargetAware",
")",
"op",
")",
".",
"setTarget",
"(",
"targetAddress",
")",
";",
"}",
"remote",
"=",
"!",
"context",
".",
"thisAddress",
".",
"equals",
"(",
"targetAddress",
")",
";",
"}"
] |
Initializes the invocation target.
@throws Exception if the initialization was a failure
|
[
"Initializes",
"the",
"invocation",
"target",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java#L284-L316
|
15,303
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java
|
Invocation.notifyBackupComplete
|
void notifyBackupComplete() {
int newBackupAcksCompleted = BACKUP_ACKS_RECEIVED.incrementAndGet(this);
Object pendingResponse = this.pendingResponse;
if (pendingResponse == VOID) {
// no pendingResponse has been set, so we are done since the invocation on the primary needs to complete first
return;
}
// if a pendingResponse is set, then the backupsAcksExpected has been set (so we can now safely read backupsAcksExpected)
int backupAcksExpected = this.backupsAcksExpected;
if (backupAcksExpected < newBackupAcksCompleted) {
// the backups have not yet completed, so we are done
return;
}
if (backupAcksExpected != newBackupAcksCompleted) {
// we managed to complete one backup, but we were not the one completing the last backup, so we are done
return;
}
// we are the lucky one since we just managed to complete the last backup for this invocation and since the
// pendingResponse is set, we can set it on the future
complete(pendingResponse);
}
|
java
|
void notifyBackupComplete() {
int newBackupAcksCompleted = BACKUP_ACKS_RECEIVED.incrementAndGet(this);
Object pendingResponse = this.pendingResponse;
if (pendingResponse == VOID) {
// no pendingResponse has been set, so we are done since the invocation on the primary needs to complete first
return;
}
// if a pendingResponse is set, then the backupsAcksExpected has been set (so we can now safely read backupsAcksExpected)
int backupAcksExpected = this.backupsAcksExpected;
if (backupAcksExpected < newBackupAcksCompleted) {
// the backups have not yet completed, so we are done
return;
}
if (backupAcksExpected != newBackupAcksCompleted) {
// we managed to complete one backup, but we were not the one completing the last backup, so we are done
return;
}
// we are the lucky one since we just managed to complete the last backup for this invocation and since the
// pendingResponse is set, we can set it on the future
complete(pendingResponse);
}
|
[
"void",
"notifyBackupComplete",
"(",
")",
"{",
"int",
"newBackupAcksCompleted",
"=",
"BACKUP_ACKS_RECEIVED",
".",
"incrementAndGet",
"(",
"this",
")",
";",
"Object",
"pendingResponse",
"=",
"this",
".",
"pendingResponse",
";",
"if",
"(",
"pendingResponse",
"==",
"VOID",
")",
"{",
"// no pendingResponse has been set, so we are done since the invocation on the primary needs to complete first",
"return",
";",
"}",
"// if a pendingResponse is set, then the backupsAcksExpected has been set (so we can now safely read backupsAcksExpected)",
"int",
"backupAcksExpected",
"=",
"this",
".",
"backupsAcksExpected",
";",
"if",
"(",
"backupAcksExpected",
"<",
"newBackupAcksCompleted",
")",
"{",
"// the backups have not yet completed, so we are done",
"return",
";",
"}",
"if",
"(",
"backupAcksExpected",
"!=",
"newBackupAcksCompleted",
")",
"{",
"// we managed to complete one backup, but we were not the one completing the last backup, so we are done",
"return",
";",
"}",
"// we are the lucky one since we just managed to complete the last backup for this invocation and since the",
"// pendingResponse is set, we can set it on the future",
"complete",
"(",
"pendingResponse",
")",
";",
"}"
] |
this method can be called concurrently
|
[
"this",
"method",
"can",
"be",
"called",
"concurrently"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java#L431-L455
|
15,304
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java
|
Invocation.detectAndHandleTimeout
|
boolean detectAndHandleTimeout(long heartbeatTimeoutMillis) {
if (skipTimeoutDetection()) {
return false;
}
HeartbeatTimeout heartbeatTimeout = detectTimeout(heartbeatTimeoutMillis);
if (heartbeatTimeout == TIMEOUT) {
complete(HEARTBEAT_TIMEOUT);
return true;
} else {
return false;
}
}
|
java
|
boolean detectAndHandleTimeout(long heartbeatTimeoutMillis) {
if (skipTimeoutDetection()) {
return false;
}
HeartbeatTimeout heartbeatTimeout = detectTimeout(heartbeatTimeoutMillis);
if (heartbeatTimeout == TIMEOUT) {
complete(HEARTBEAT_TIMEOUT);
return true;
} else {
return false;
}
}
|
[
"boolean",
"detectAndHandleTimeout",
"(",
"long",
"heartbeatTimeoutMillis",
")",
"{",
"if",
"(",
"skipTimeoutDetection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"HeartbeatTimeout",
"heartbeatTimeout",
"=",
"detectTimeout",
"(",
"heartbeatTimeoutMillis",
")",
";",
"if",
"(",
"heartbeatTimeout",
"==",
"TIMEOUT",
")",
"{",
"complete",
"(",
"HEARTBEAT_TIMEOUT",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Checks if this Invocation has received a heartbeat in time.
If the response is already set, or if a heartbeat has been received in time, then {@code false} is returned.
If no heartbeat has been received, then the future.set is called with HEARTBEAT_TIMEOUT and {@code true} is returned.
Gets called from the monitor-thread.
@return {@code true} if there is a timeout detected, {@code false} otherwise.
|
[
"Checks",
"if",
"this",
"Invocation",
"has",
"received",
"a",
"heartbeat",
"in",
"time",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java#L467-L480
|
15,305
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java
|
Invocation.detectAndHandleBackupTimeout
|
boolean detectAndHandleBackupTimeout(long timeoutMillis) {
// if the backups have completed, we are done; this also filters out all non backup-aware operations
// since the backupsAcksExpected will always be equal to the backupsAcksReceived
boolean backupsCompleted = backupsAcksExpected == backupsAcksReceived;
long responseReceivedMillis = pendingResponseReceivedMillis;
// if this has not yet expired (so has not been in the system for a too long period) we ignore it
long expirationTime = responseReceivedMillis + timeoutMillis;
boolean timeout = expirationTime > 0 && expirationTime < Clock.currentTimeMillis();
// if no response has yet been received, we we are done; we are only going to re-invoke an operation
// if the response of the primary has been received, but the backups have not replied
boolean responseReceived = pendingResponse != VOID;
if (backupsCompleted || !responseReceived || !timeout) {
return false;
}
if (shouldFailOnIndeterminateOperationState()) {
complete(new IndeterminateOperationStateException(this + " failed because backup acks missed."));
return true;
}
boolean targetDead = context.clusterService.getMember(targetAddress) == null;
if (targetDead) {
// the target doesn't exist, so we are going to re-invoke this invocation;
// the reason for the re-invocation is that otherwise it's possible to lose data,
// e.g. when a map.put() was done and the primary node has returned the response,
// but has not yet completed the backups and then the primary node fails;
// the consequence would be that the backups are never be made and the effects of the map.put() will never be visible,
// even though the future returned a value;
// so if we would complete the future, a response is sent even though its changes never made it into the system
resetAndReInvoke();
return false;
}
// the backups have not yet completed, but we are going to release the future anyway if a pendingResponse has been set
complete(pendingResponse);
return true;
}
|
java
|
boolean detectAndHandleBackupTimeout(long timeoutMillis) {
// if the backups have completed, we are done; this also filters out all non backup-aware operations
// since the backupsAcksExpected will always be equal to the backupsAcksReceived
boolean backupsCompleted = backupsAcksExpected == backupsAcksReceived;
long responseReceivedMillis = pendingResponseReceivedMillis;
// if this has not yet expired (so has not been in the system for a too long period) we ignore it
long expirationTime = responseReceivedMillis + timeoutMillis;
boolean timeout = expirationTime > 0 && expirationTime < Clock.currentTimeMillis();
// if no response has yet been received, we we are done; we are only going to re-invoke an operation
// if the response of the primary has been received, but the backups have not replied
boolean responseReceived = pendingResponse != VOID;
if (backupsCompleted || !responseReceived || !timeout) {
return false;
}
if (shouldFailOnIndeterminateOperationState()) {
complete(new IndeterminateOperationStateException(this + " failed because backup acks missed."));
return true;
}
boolean targetDead = context.clusterService.getMember(targetAddress) == null;
if (targetDead) {
// the target doesn't exist, so we are going to re-invoke this invocation;
// the reason for the re-invocation is that otherwise it's possible to lose data,
// e.g. when a map.put() was done and the primary node has returned the response,
// but has not yet completed the backups and then the primary node fails;
// the consequence would be that the backups are never be made and the effects of the map.put() will never be visible,
// even though the future returned a value;
// so if we would complete the future, a response is sent even though its changes never made it into the system
resetAndReInvoke();
return false;
}
// the backups have not yet completed, but we are going to release the future anyway if a pendingResponse has been set
complete(pendingResponse);
return true;
}
|
[
"boolean",
"detectAndHandleBackupTimeout",
"(",
"long",
"timeoutMillis",
")",
"{",
"// if the backups have completed, we are done; this also filters out all non backup-aware operations",
"// since the backupsAcksExpected will always be equal to the backupsAcksReceived",
"boolean",
"backupsCompleted",
"=",
"backupsAcksExpected",
"==",
"backupsAcksReceived",
";",
"long",
"responseReceivedMillis",
"=",
"pendingResponseReceivedMillis",
";",
"// if this has not yet expired (so has not been in the system for a too long period) we ignore it",
"long",
"expirationTime",
"=",
"responseReceivedMillis",
"+",
"timeoutMillis",
";",
"boolean",
"timeout",
"=",
"expirationTime",
">",
"0",
"&&",
"expirationTime",
"<",
"Clock",
".",
"currentTimeMillis",
"(",
")",
";",
"// if no response has yet been received, we we are done; we are only going to re-invoke an operation",
"// if the response of the primary has been received, but the backups have not replied",
"boolean",
"responseReceived",
"=",
"pendingResponse",
"!=",
"VOID",
";",
"if",
"(",
"backupsCompleted",
"||",
"!",
"responseReceived",
"||",
"!",
"timeout",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"shouldFailOnIndeterminateOperationState",
"(",
")",
")",
"{",
"complete",
"(",
"new",
"IndeterminateOperationStateException",
"(",
"this",
"+",
"\" failed because backup acks missed.\"",
")",
")",
";",
"return",
"true",
";",
"}",
"boolean",
"targetDead",
"=",
"context",
".",
"clusterService",
".",
"getMember",
"(",
"targetAddress",
")",
"==",
"null",
";",
"if",
"(",
"targetDead",
")",
"{",
"// the target doesn't exist, so we are going to re-invoke this invocation;",
"// the reason for the re-invocation is that otherwise it's possible to lose data,",
"// e.g. when a map.put() was done and the primary node has returned the response,",
"// but has not yet completed the backups and then the primary node fails;",
"// the consequence would be that the backups are never be made and the effects of the map.put() will never be visible,",
"// even though the future returned a value;",
"// so if we would complete the future, a response is sent even though its changes never made it into the system",
"resetAndReInvoke",
"(",
")",
";",
"return",
"false",
";",
"}",
"// the backups have not yet completed, but we are going to release the future anyway if a pendingResponse has been set",
"complete",
"(",
"pendingResponse",
")",
";",
"return",
"true",
";",
"}"
] |
gets called from the monitor-thread
|
[
"gets",
"called",
"from",
"the",
"monitor",
"-",
"thread"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/Invocation.java#L520-L559
|
15,306
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/usercodedeployment/UserCodeDeploymentService.java
|
UserCodeDeploymentService.handleClassNotFoundException
|
public Class<?> handleClassNotFoundException(String name)
throws ClassNotFoundException {
if (!enabled) {
throw new ClassNotFoundException("User Code Deployment is not enabled. Cannot find class " + name);
}
return locator.handleClassNotFoundException(name);
}
|
java
|
public Class<?> handleClassNotFoundException(String name)
throws ClassNotFoundException {
if (!enabled) {
throw new ClassNotFoundException("User Code Deployment is not enabled. Cannot find class " + name);
}
return locator.handleClassNotFoundException(name);
}
|
[
"public",
"Class",
"<",
"?",
">",
"handleClassNotFoundException",
"(",
"String",
"name",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"!",
"enabled",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"\"User Code Deployment is not enabled. Cannot find class \"",
"+",
"name",
")",
";",
"}",
"return",
"locator",
".",
"handleClassNotFoundException",
"(",
"name",
")",
";",
"}"
] |
called by User Code Deployment classloader on this member
|
[
"called",
"by",
"User",
"Code",
"Deployment",
"classloader",
"on",
"this",
"member"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/usercodedeployment/UserCodeDeploymentService.java#L84-L90
|
15,307
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/scheduler/SecondsBasedEntryTaskScheduler.java
|
SecondsBasedEntryTaskScheduler.get
|
@Override
public ScheduledEntry<K, V> get(K key) {
synchronized (mutex) {
if (scheduleType.equals(ScheduleType.FOR_EACH)) {
return getByCompositeKey(key);
}
Integer second = secondsOfKeys.get(key);
if (second != null) {
Map<Object, ScheduledEntry<K, V>> entries = scheduledEntries.get(second);
if (entries != null) {
return entries.get(key);
}
}
return null;
}
}
|
java
|
@Override
public ScheduledEntry<K, V> get(K key) {
synchronized (mutex) {
if (scheduleType.equals(ScheduleType.FOR_EACH)) {
return getByCompositeKey(key);
}
Integer second = secondsOfKeys.get(key);
if (second != null) {
Map<Object, ScheduledEntry<K, V>> entries = scheduledEntries.get(second);
if (entries != null) {
return entries.get(key);
}
}
return null;
}
}
|
[
"@",
"Override",
"public",
"ScheduledEntry",
"<",
"K",
",",
"V",
">",
"get",
"(",
"K",
"key",
")",
"{",
"synchronized",
"(",
"mutex",
")",
"{",
"if",
"(",
"scheduleType",
".",
"equals",
"(",
"ScheduleType",
".",
"FOR_EACH",
")",
")",
"{",
"return",
"getByCompositeKey",
"(",
"key",
")",
";",
"}",
"Integer",
"second",
"=",
"secondsOfKeys",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"second",
"!=",
"null",
")",
"{",
"Map",
"<",
"Object",
",",
"ScheduledEntry",
"<",
"K",
",",
"V",
">",
">",
"entries",
"=",
"scheduledEntries",
".",
"get",
"(",
"second",
")",
";",
"if",
"(",
"entries",
"!=",
"null",
")",
"{",
"return",
"entries",
".",
"get",
"(",
"key",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}"
] |
in the case of composite keys this method will return only one scheduled entry with no ordering guarantee
|
[
"in",
"the",
"case",
"of",
"composite",
"keys",
"this",
"method",
"will",
"return",
"only",
"one",
"scheduled",
"entry",
"with",
"no",
"ordering",
"guarantee"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/scheduler/SecondsBasedEntryTaskScheduler.java#L199-L214
|
15,308
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/quorum/impl/QuorumServiceImpl.java
|
QuorumServiceImpl.scanQuorums
|
private void scanQuorums() {
for (QuorumImpl quorum : quorums.values()) {
if (quorum.isHeartbeatAware()) {
this.heartbeatAware = true;
}
if (quorum.isPingAware()) {
this.pingAware = true;
}
}
}
|
java
|
private void scanQuorums() {
for (QuorumImpl quorum : quorums.values()) {
if (quorum.isHeartbeatAware()) {
this.heartbeatAware = true;
}
if (quorum.isPingAware()) {
this.pingAware = true;
}
}
}
|
[
"private",
"void",
"scanQuorums",
"(",
")",
"{",
"for",
"(",
"QuorumImpl",
"quorum",
":",
"quorums",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"quorum",
".",
"isHeartbeatAware",
"(",
")",
")",
"{",
"this",
".",
"heartbeatAware",
"=",
"true",
";",
"}",
"if",
"(",
"quorum",
".",
"isPingAware",
"(",
")",
")",
"{",
"this",
".",
"pingAware",
"=",
"true",
";",
"}",
"}",
"}"
] |
scan quorums for heartbeat-aware and ping-aware implementations and set corresponding flags
|
[
"scan",
"quorums",
"for",
"heartbeat",
"-",
"aware",
"and",
"ping",
"-",
"aware",
"implementations",
"and",
"set",
"corresponding",
"flags"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/quorum/impl/QuorumServiceImpl.java#L188-L197
|
15,309
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/InboundHandler.java
|
InboundHandler.initSrcBuffer
|
protected final void initSrcBuffer(int sizeBytes) {
ChannelOptions config = channel.options();
src = (S) newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
}
|
java
|
protected final void initSrcBuffer(int sizeBytes) {
ChannelOptions config = channel.options();
src = (S) newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
}
|
[
"protected",
"final",
"void",
"initSrcBuffer",
"(",
"int",
"sizeBytes",
")",
"{",
"ChannelOptions",
"config",
"=",
"channel",
".",
"options",
"(",
")",
";",
"src",
"=",
"(",
"S",
")",
"newByteBuffer",
"(",
"sizeBytes",
",",
"config",
".",
"getOption",
"(",
"DIRECT_BUF",
")",
")",
";",
"}"
] |
Initializes the src buffer. Should only be called by InboundHandler
implementations that have a ByteBuffer as source.
@param sizeBytes the size of the srcBuffer in bytes.
|
[
"Initializes",
"the",
"src",
"buffer",
".",
"Should",
"only",
"be",
"called",
"by",
"InboundHandler",
"implementations",
"that",
"have",
"a",
"ByteBuffer",
"as",
"source",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/InboundHandler.java#L75-L78
|
15,310
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractCacheService.java
|
AbstractCacheService.getQuorumName
|
@Override
public String getQuorumName(String cacheName) {
CacheConfig cacheConfig = getCacheConfig(cacheName);
if (cacheConfig == null) {
return null;
}
return cacheConfig.getQuorumName();
}
|
java
|
@Override
public String getQuorumName(String cacheName) {
CacheConfig cacheConfig = getCacheConfig(cacheName);
if (cacheConfig == null) {
return null;
}
return cacheConfig.getQuorumName();
}
|
[
"@",
"Override",
"public",
"String",
"getQuorumName",
"(",
"String",
"cacheName",
")",
"{",
"CacheConfig",
"cacheConfig",
"=",
"getCacheConfig",
"(",
"cacheName",
")",
";",
"if",
"(",
"cacheConfig",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"cacheConfig",
".",
"getQuorumName",
"(",
")",
";",
"}"
] |
Gets the name of the quorum associated with specified cache
@param cacheName name of the cache
@return name of the associated quorum
null if there is no associated quorum
|
[
"Gets",
"the",
"name",
"of",
"the",
"quorum",
"associated",
"with",
"specified",
"cache"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractCacheService.java#L778-L785
|
15,311
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java
|
RaftSemaphore.acquire
|
AcquireResult acquire(AcquireInvocationKey key, boolean wait) {
SemaphoreEndpoint endpoint = key.endpoint();
SessionSemaphoreState state = sessionStates.get(key.sessionId());
if (state != null && state.containsInvocation(endpoint.threadId(), key.invocationUid())) {
return new AcquireResult(key.permits(), Collections.<AcquireInvocationKey>emptyList());
}
Collection<AcquireInvocationKey> cancelled = cancelWaitKeys(endpoint, key.invocationUid());
if (!isAvailable(key.permits())) {
if (wait) {
addWaitKey(endpoint, key);
}
return new AcquireResult(0, cancelled);
}
assignPermitsToInvocation(endpoint, key.invocationUid(), key.permits());
return new AcquireResult(key.permits(), cancelled);
}
|
java
|
AcquireResult acquire(AcquireInvocationKey key, boolean wait) {
SemaphoreEndpoint endpoint = key.endpoint();
SessionSemaphoreState state = sessionStates.get(key.sessionId());
if (state != null && state.containsInvocation(endpoint.threadId(), key.invocationUid())) {
return new AcquireResult(key.permits(), Collections.<AcquireInvocationKey>emptyList());
}
Collection<AcquireInvocationKey> cancelled = cancelWaitKeys(endpoint, key.invocationUid());
if (!isAvailable(key.permits())) {
if (wait) {
addWaitKey(endpoint, key);
}
return new AcquireResult(0, cancelled);
}
assignPermitsToInvocation(endpoint, key.invocationUid(), key.permits());
return new AcquireResult(key.permits(), cancelled);
}
|
[
"AcquireResult",
"acquire",
"(",
"AcquireInvocationKey",
"key",
",",
"boolean",
"wait",
")",
"{",
"SemaphoreEndpoint",
"endpoint",
"=",
"key",
".",
"endpoint",
"(",
")",
";",
"SessionSemaphoreState",
"state",
"=",
"sessionStates",
".",
"get",
"(",
"key",
".",
"sessionId",
"(",
")",
")",
";",
"if",
"(",
"state",
"!=",
"null",
"&&",
"state",
".",
"containsInvocation",
"(",
"endpoint",
".",
"threadId",
"(",
")",
",",
"key",
".",
"invocationUid",
"(",
")",
")",
")",
"{",
"return",
"new",
"AcquireResult",
"(",
"key",
".",
"permits",
"(",
")",
",",
"Collections",
".",
"<",
"AcquireInvocationKey",
">",
"emptyList",
"(",
")",
")",
";",
"}",
"Collection",
"<",
"AcquireInvocationKey",
">",
"cancelled",
"=",
"cancelWaitKeys",
"(",
"endpoint",
",",
"key",
".",
"invocationUid",
"(",
")",
")",
";",
"if",
"(",
"!",
"isAvailable",
"(",
"key",
".",
"permits",
"(",
")",
")",
")",
"{",
"if",
"(",
"wait",
")",
"{",
"addWaitKey",
"(",
"endpoint",
",",
"key",
")",
";",
"}",
"return",
"new",
"AcquireResult",
"(",
"0",
",",
"cancelled",
")",
";",
"}",
"assignPermitsToInvocation",
"(",
"endpoint",
",",
"key",
".",
"invocationUid",
"(",
")",
",",
"key",
".",
"permits",
"(",
")",
")",
";",
"return",
"new",
"AcquireResult",
"(",
"key",
".",
"permits",
"(",
")",
",",
"cancelled",
")",
";",
"}"
] |
Assigns permits to the endpoint, if sufficient number of permits are
available. If there are no sufficient number of permits and the second
argument is true, a wait key is created and added to the wait queue.
Permits are not assigned if the acquire request is a retry of
a successful acquire request of a session-aware proxy. Permits are
assigned again if the acquire request is a retry of a successful acquire
request of a sessionless proxy. If the acquire request is a retry of
an endpoint that resides in the wait queue with the same invocation uid,
a duplicate wait key is added to the wait queue because cancelling
the previous wait key can cause the caller to fail. If the acquire
request is a new request of an endpoint that resides in the wait queue
with a different invocation uid, the existing wait key is cancelled
because it means the caller has stopped waiting for response of
the previous invocation.
|
[
"Assigns",
"permits",
"to",
"the",
"endpoint",
"if",
"sufficient",
"number",
"of",
"permits",
"are",
"available",
".",
"If",
"there",
"are",
"no",
"sufficient",
"number",
"of",
"permits",
"and",
"the",
"second",
"argument",
"is",
"true",
"a",
"wait",
"key",
"is",
"created",
"and",
"added",
"to",
"the",
"wait",
"queue",
".",
"Permits",
"are",
"not",
"assigned",
"if",
"the",
"acquire",
"request",
"is",
"a",
"retry",
"of",
"a",
"successful",
"acquire",
"request",
"of",
"a",
"session",
"-",
"aware",
"proxy",
".",
"Permits",
"are",
"assigned",
"again",
"if",
"the",
"acquire",
"request",
"is",
"a",
"retry",
"of",
"a",
"successful",
"acquire",
"request",
"of",
"a",
"sessionless",
"proxy",
".",
"If",
"the",
"acquire",
"request",
"is",
"a",
"retry",
"of",
"an",
"endpoint",
"that",
"resides",
"in",
"the",
"wait",
"queue",
"with",
"the",
"same",
"invocation",
"uid",
"a",
"duplicate",
"wait",
"key",
"is",
"added",
"to",
"the",
"wait",
"queue",
"because",
"cancelling",
"the",
"previous",
"wait",
"key",
"can",
"cause",
"the",
"caller",
"to",
"fail",
".",
"If",
"the",
"acquire",
"request",
"is",
"a",
"new",
"request",
"of",
"an",
"endpoint",
"that",
"resides",
"in",
"the",
"wait",
"queue",
"with",
"a",
"different",
"invocation",
"uid",
"the",
"existing",
"wait",
"key",
"is",
"cancelled",
"because",
"it",
"means",
"the",
"caller",
"has",
"stopped",
"waiting",
"for",
"response",
"of",
"the",
"previous",
"invocation",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java#L100-L120
|
15,312
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java
|
RaftSemaphore.change
|
ReleaseResult change(SemaphoreEndpoint endpoint, UUID invocationUid, int permits) {
if (permits == 0) {
return ReleaseResult.failed(Collections.<AcquireInvocationKey>emptyList());
}
Collection<AcquireInvocationKey> cancelled = cancelWaitKeys(endpoint, invocationUid);
long sessionId = endpoint.sessionId();
if (sessionId != NO_SESSION_ID) {
SessionSemaphoreState state = sessionStates.get(sessionId);
if (state == null) {
state = new SessionSemaphoreState();
sessionStates.put(sessionId, state);
}
long threadId = endpoint.threadId();
if (state.containsInvocation(threadId, invocationUid)) {
Collection<AcquireInvocationKey> c = Collections.emptyList();
return ReleaseResult.successful(c, c);
}
state.invocationRefUids.put(threadId, Tuple2.of(invocationUid, permits));
}
available += permits;
initialized = true;
Collection<AcquireInvocationKey> acquired =
permits > 0 ? assignPermitsToWaitKeys() : Collections.<AcquireInvocationKey>emptyList();
return ReleaseResult.successful(acquired, cancelled);
}
|
java
|
ReleaseResult change(SemaphoreEndpoint endpoint, UUID invocationUid, int permits) {
if (permits == 0) {
return ReleaseResult.failed(Collections.<AcquireInvocationKey>emptyList());
}
Collection<AcquireInvocationKey> cancelled = cancelWaitKeys(endpoint, invocationUid);
long sessionId = endpoint.sessionId();
if (sessionId != NO_SESSION_ID) {
SessionSemaphoreState state = sessionStates.get(sessionId);
if (state == null) {
state = new SessionSemaphoreState();
sessionStates.put(sessionId, state);
}
long threadId = endpoint.threadId();
if (state.containsInvocation(threadId, invocationUid)) {
Collection<AcquireInvocationKey> c = Collections.emptyList();
return ReleaseResult.successful(c, c);
}
state.invocationRefUids.put(threadId, Tuple2.of(invocationUid, permits));
}
available += permits;
initialized = true;
Collection<AcquireInvocationKey> acquired =
permits > 0 ? assignPermitsToWaitKeys() : Collections.<AcquireInvocationKey>emptyList();
return ReleaseResult.successful(acquired, cancelled);
}
|
[
"ReleaseResult",
"change",
"(",
"SemaphoreEndpoint",
"endpoint",
",",
"UUID",
"invocationUid",
",",
"int",
"permits",
")",
"{",
"if",
"(",
"permits",
"==",
"0",
")",
"{",
"return",
"ReleaseResult",
".",
"failed",
"(",
"Collections",
".",
"<",
"AcquireInvocationKey",
">",
"emptyList",
"(",
")",
")",
";",
"}",
"Collection",
"<",
"AcquireInvocationKey",
">",
"cancelled",
"=",
"cancelWaitKeys",
"(",
"endpoint",
",",
"invocationUid",
")",
";",
"long",
"sessionId",
"=",
"endpoint",
".",
"sessionId",
"(",
")",
";",
"if",
"(",
"sessionId",
"!=",
"NO_SESSION_ID",
")",
"{",
"SessionSemaphoreState",
"state",
"=",
"sessionStates",
".",
"get",
"(",
"sessionId",
")",
";",
"if",
"(",
"state",
"==",
"null",
")",
"{",
"state",
"=",
"new",
"SessionSemaphoreState",
"(",
")",
";",
"sessionStates",
".",
"put",
"(",
"sessionId",
",",
"state",
")",
";",
"}",
"long",
"threadId",
"=",
"endpoint",
".",
"threadId",
"(",
")",
";",
"if",
"(",
"state",
".",
"containsInvocation",
"(",
"threadId",
",",
"invocationUid",
")",
")",
"{",
"Collection",
"<",
"AcquireInvocationKey",
">",
"c",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"return",
"ReleaseResult",
".",
"successful",
"(",
"c",
",",
"c",
")",
";",
"}",
"state",
".",
"invocationRefUids",
".",
"put",
"(",
"threadId",
",",
"Tuple2",
".",
"of",
"(",
"invocationUid",
",",
"permits",
")",
")",
";",
"}",
"available",
"+=",
"permits",
";",
"initialized",
"=",
"true",
";",
"Collection",
"<",
"AcquireInvocationKey",
">",
"acquired",
"=",
"permits",
">",
"0",
"?",
"assignPermitsToWaitKeys",
"(",
")",
":",
"Collections",
".",
"<",
"AcquireInvocationKey",
">",
"emptyList",
"(",
")",
";",
"return",
"ReleaseResult",
".",
"successful",
"(",
"acquired",
",",
"cancelled",
")",
";",
"}"
] |
Changes the number of permits by adding the given permit value. Permits
are not changed if it is a retry of a previous successful change request
of a session-aware proxy. Permits are changed again if it is a retry of
a successful change request of a sessionless proxy. If number of permits
increase, new assignments can be done. Returns completed wait keys after
successful change if there are any. Returns cancelled wait keys of
the same endpoint if there are any.
|
[
"Changes",
"the",
"number",
"of",
"permits",
"by",
"adding",
"the",
"given",
"permit",
"value",
".",
"Permits",
"are",
"not",
"changed",
"if",
"it",
"is",
"a",
"retry",
"of",
"a",
"previous",
"successful",
"change",
"request",
"of",
"a",
"session",
"-",
"aware",
"proxy",
".",
"Permits",
"are",
"changed",
"again",
"if",
"it",
"is",
"a",
"retry",
"of",
"a",
"successful",
"change",
"request",
"of",
"a",
"sessionless",
"proxy",
".",
"If",
"number",
"of",
"permits",
"increase",
"new",
"assignments",
"can",
"be",
"done",
".",
"Returns",
"completed",
"wait",
"keys",
"after",
"successful",
"change",
"if",
"there",
"are",
"any",
".",
"Returns",
"cancelled",
"wait",
"keys",
"of",
"the",
"same",
"endpoint",
"if",
"there",
"are",
"any",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java#L265-L296
|
15,313
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java
|
RaftSemaphore.onSessionClose
|
@Override
protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
SessionSemaphoreState state = sessionStates.get(sessionId);
if (state != null) {
// remove the session after release() because release() checks existence of the session
if (state.acquiredPermits > 0) {
SemaphoreEndpoint endpoint = new SemaphoreEndpoint(sessionId, 0);
ReleaseResult result = release(endpoint, newUnsecureUUID(), state.acquiredPermits);
assert result.cancelled.isEmpty();
for (AcquireInvocationKey key : result.acquired) {
responses.put(key.commitIndex(), Boolean.TRUE);
}
}
sessionStates.remove(sessionId);
}
}
|
java
|
@Override
protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
SessionSemaphoreState state = sessionStates.get(sessionId);
if (state != null) {
// remove the session after release() because release() checks existence of the session
if (state.acquiredPermits > 0) {
SemaphoreEndpoint endpoint = new SemaphoreEndpoint(sessionId, 0);
ReleaseResult result = release(endpoint, newUnsecureUUID(), state.acquiredPermits);
assert result.cancelled.isEmpty();
for (AcquireInvocationKey key : result.acquired) {
responses.put(key.commitIndex(), Boolean.TRUE);
}
}
sessionStates.remove(sessionId);
}
}
|
[
"@",
"Override",
"protected",
"void",
"onSessionClose",
"(",
"long",
"sessionId",
",",
"Map",
"<",
"Long",
",",
"Object",
">",
"responses",
")",
"{",
"SessionSemaphoreState",
"state",
"=",
"sessionStates",
".",
"get",
"(",
"sessionId",
")",
";",
"if",
"(",
"state",
"!=",
"null",
")",
"{",
"// remove the session after release() because release() checks existence of the session",
"if",
"(",
"state",
".",
"acquiredPermits",
">",
"0",
")",
"{",
"SemaphoreEndpoint",
"endpoint",
"=",
"new",
"SemaphoreEndpoint",
"(",
"sessionId",
",",
"0",
")",
";",
"ReleaseResult",
"result",
"=",
"release",
"(",
"endpoint",
",",
"newUnsecureUUID",
"(",
")",
",",
"state",
".",
"acquiredPermits",
")",
";",
"assert",
"result",
".",
"cancelled",
".",
"isEmpty",
"(",
")",
";",
"for",
"(",
"AcquireInvocationKey",
"key",
":",
"result",
".",
"acquired",
")",
"{",
"responses",
".",
"put",
"(",
"key",
".",
"commitIndex",
"(",
")",
",",
"Boolean",
".",
"TRUE",
")",
";",
"}",
"}",
"sessionStates",
".",
"remove",
"(",
"sessionId",
")",
";",
"}",
"}"
] |
Releases permits of the closed session.
|
[
"Releases",
"permits",
"of",
"the",
"closed",
"session",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java#L301-L317
|
15,314
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/CapacityUtil.java
|
CapacityUtil.roundCapacity
|
public static long roundCapacity(long requestedCapacity) {
if (requestedCapacity > MAX_LONG_CAPACITY) {
throw new IllegalArgumentException(requestedCapacity + " is greater than max allowed capacity["
+ MAX_LONG_CAPACITY + "].");
}
return Math.max(MIN_CAPACITY, QuickMath.nextPowerOfTwo(requestedCapacity));
}
|
java
|
public static long roundCapacity(long requestedCapacity) {
if (requestedCapacity > MAX_LONG_CAPACITY) {
throw new IllegalArgumentException(requestedCapacity + " is greater than max allowed capacity["
+ MAX_LONG_CAPACITY + "].");
}
return Math.max(MIN_CAPACITY, QuickMath.nextPowerOfTwo(requestedCapacity));
}
|
[
"public",
"static",
"long",
"roundCapacity",
"(",
"long",
"requestedCapacity",
")",
"{",
"if",
"(",
"requestedCapacity",
">",
"MAX_LONG_CAPACITY",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"requestedCapacity",
"+",
"\" is greater than max allowed capacity[\"",
"+",
"MAX_LONG_CAPACITY",
"+",
"\"].\"",
")",
";",
"}",
"return",
"Math",
".",
"max",
"(",
"MIN_CAPACITY",
",",
"QuickMath",
".",
"nextPowerOfTwo",
"(",
"requestedCapacity",
")",
")",
";",
"}"
] |
Round the capacity to the next allowed value.
|
[
"Round",
"the",
"capacity",
"to",
"the",
"next",
"allowed",
"value",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/CapacityUtil.java#L47-L54
|
15,315
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/CapacityUtil.java
|
CapacityUtil.nextCapacity
|
public static int nextCapacity(int current) {
assert current > 0 && Long.bitCount(current) == 1 : "Capacity must be a power of two.";
if (current < MIN_CAPACITY / 2) {
current = MIN_CAPACITY / 2;
}
current <<= 1;
if (current < 0) {
throw new RuntimeException("Maximum capacity exceeded.");
}
return current;
}
|
java
|
public static int nextCapacity(int current) {
assert current > 0 && Long.bitCount(current) == 1 : "Capacity must be a power of two.";
if (current < MIN_CAPACITY / 2) {
current = MIN_CAPACITY / 2;
}
current <<= 1;
if (current < 0) {
throw new RuntimeException("Maximum capacity exceeded.");
}
return current;
}
|
[
"public",
"static",
"int",
"nextCapacity",
"(",
"int",
"current",
")",
"{",
"assert",
"current",
">",
"0",
"&&",
"Long",
".",
"bitCount",
"(",
"current",
")",
"==",
"1",
":",
"\"Capacity must be a power of two.\"",
";",
"if",
"(",
"current",
"<",
"MIN_CAPACITY",
"/",
"2",
")",
"{",
"current",
"=",
"MIN_CAPACITY",
"/",
"2",
";",
"}",
"current",
"<<=",
"1",
";",
"if",
"(",
"current",
"<",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Maximum capacity exceeded.\"",
")",
";",
"}",
"return",
"current",
";",
"}"
] |
Returns the next possible capacity, counting from the current buffers' size.
|
[
"Returns",
"the",
"next",
"possible",
"capacity",
"counting",
"from",
"the",
"current",
"buffers",
"size",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/CapacityUtil.java#L67-L79
|
15,316
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/flakeidgen/impl/FlakeIdGeneratorProxy.java
|
FlakeIdGeneratorProxy.getNodeId
|
int getNodeId(long nanoTime) {
// Check if it is a time to check for updated nodeId. We need to recheck, because if duplicate node ID
// is assigned during a network split, this will be resolved after a cluster merge.
// We throttle the calls to avoid contention due to the lock+unlock call in getMemberListJoinVersion().
int nodeId = this.nodeId;
if (nodeId != NODE_ID_OUT_OF_RANGE && nextNodeIdUpdate <= nanoTime) {
int newNodeId = getNodeEngine().getClusterService().getMemberListJoinVersion();
assert newNodeId >= 0 : "newNodeId=" + newNodeId;
newNodeId += nodeIdOffset;
nextNodeIdUpdate = nanoTime + NODE_ID_UPDATE_INTERVAL_NS;
if (newNodeId != nodeId) {
nodeId = newNodeId;
// If our node ID is out of range, assign NODE_ID_OUT_OF_RANGE to nodeId
if ((nodeId & -1 << BITS_NODE_ID) != 0) {
outOfRangeMembers.add(getNodeEngine().getClusterService().getLocalMember().getUuid());
logger.severe("Node ID is out of range (" + nodeId + "), this member won't be able to generate IDs. "
+ "Cluster restart is recommended.");
nodeId = NODE_ID_OUT_OF_RANGE;
}
// we ignore possible double initialization
this.nodeId = nodeId;
if (logger.isFineEnabled()) {
logger.fine("Node ID assigned to '" + name + "': " + nodeId);
}
}
}
return nodeId;
}
|
java
|
int getNodeId(long nanoTime) {
// Check if it is a time to check for updated nodeId. We need to recheck, because if duplicate node ID
// is assigned during a network split, this will be resolved after a cluster merge.
// We throttle the calls to avoid contention due to the lock+unlock call in getMemberListJoinVersion().
int nodeId = this.nodeId;
if (nodeId != NODE_ID_OUT_OF_RANGE && nextNodeIdUpdate <= nanoTime) {
int newNodeId = getNodeEngine().getClusterService().getMemberListJoinVersion();
assert newNodeId >= 0 : "newNodeId=" + newNodeId;
newNodeId += nodeIdOffset;
nextNodeIdUpdate = nanoTime + NODE_ID_UPDATE_INTERVAL_NS;
if (newNodeId != nodeId) {
nodeId = newNodeId;
// If our node ID is out of range, assign NODE_ID_OUT_OF_RANGE to nodeId
if ((nodeId & -1 << BITS_NODE_ID) != 0) {
outOfRangeMembers.add(getNodeEngine().getClusterService().getLocalMember().getUuid());
logger.severe("Node ID is out of range (" + nodeId + "), this member won't be able to generate IDs. "
+ "Cluster restart is recommended.");
nodeId = NODE_ID_OUT_OF_RANGE;
}
// we ignore possible double initialization
this.nodeId = nodeId;
if (logger.isFineEnabled()) {
logger.fine("Node ID assigned to '" + name + "': " + nodeId);
}
}
}
return nodeId;
}
|
[
"int",
"getNodeId",
"(",
"long",
"nanoTime",
")",
"{",
"// Check if it is a time to check for updated nodeId. We need to recheck, because if duplicate node ID",
"// is assigned during a network split, this will be resolved after a cluster merge.",
"// We throttle the calls to avoid contention due to the lock+unlock call in getMemberListJoinVersion().",
"int",
"nodeId",
"=",
"this",
".",
"nodeId",
";",
"if",
"(",
"nodeId",
"!=",
"NODE_ID_OUT_OF_RANGE",
"&&",
"nextNodeIdUpdate",
"<=",
"nanoTime",
")",
"{",
"int",
"newNodeId",
"=",
"getNodeEngine",
"(",
")",
".",
"getClusterService",
"(",
")",
".",
"getMemberListJoinVersion",
"(",
")",
";",
"assert",
"newNodeId",
">=",
"0",
":",
"\"newNodeId=\"",
"+",
"newNodeId",
";",
"newNodeId",
"+=",
"nodeIdOffset",
";",
"nextNodeIdUpdate",
"=",
"nanoTime",
"+",
"NODE_ID_UPDATE_INTERVAL_NS",
";",
"if",
"(",
"newNodeId",
"!=",
"nodeId",
")",
"{",
"nodeId",
"=",
"newNodeId",
";",
"// If our node ID is out of range, assign NODE_ID_OUT_OF_RANGE to nodeId",
"if",
"(",
"(",
"nodeId",
"&",
"-",
"1",
"<<",
"BITS_NODE_ID",
")",
"!=",
"0",
")",
"{",
"outOfRangeMembers",
".",
"add",
"(",
"getNodeEngine",
"(",
")",
".",
"getClusterService",
"(",
")",
".",
"getLocalMember",
"(",
")",
".",
"getUuid",
"(",
")",
")",
";",
"logger",
".",
"severe",
"(",
"\"Node ID is out of range (\"",
"+",
"nodeId",
"+",
"\"), this member won't be able to generate IDs. \"",
"+",
"\"Cluster restart is recommended.\"",
")",
";",
"nodeId",
"=",
"NODE_ID_OUT_OF_RANGE",
";",
"}",
"// we ignore possible double initialization",
"this",
".",
"nodeId",
"=",
"nodeId",
";",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Node ID assigned to '\"",
"+",
"name",
"+",
"\"': \"",
"+",
"nodeId",
")",
";",
"}",
"}",
"}",
"return",
"nodeId",
";",
"}"
] |
package-visible for tests
|
[
"package",
"-",
"visible",
"for",
"tests"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/flakeidgen/impl/FlakeIdGeneratorProxy.java#L216-L246
|
15,317
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/json/internal/JsonSchemaHelper.java
|
JsonSchemaHelper.createSchema
|
public static JsonSchemaNode createSchema(JsonParser parser) throws IOException {
JsonSchemaNode dummy = new JsonSchemaStructNode(null);
JsonSchemaStructNode parent = (JsonSchemaStructNode) dummy;
JsonToken currentToken = parser.nextToken();
int nameLocation = -1;
if (currentToken == null) {
return null;
}
while (currentToken != null) {
if (currentToken.isStructStart()) {
JsonSchemaStructNode structNode = new JsonSchemaStructNode(parent);
JsonSchemaNameValue nameValue = new JsonSchemaNameValue(nameLocation, structNode);
parent.addChild(nameValue);
parent = structNode;
nameLocation = -1;
} else if (currentToken == JsonToken.FIELD_NAME) {
nameLocation = (int) getTokenLocation(parser);
} else if (currentToken.isStructEnd()) {
parent = parent.getParent();
nameLocation = -1;
} else {
JsonSchemaTerminalNode terminalNode = new JsonSchemaTerminalNode(parent);
terminalNode.setValueStartLocation((int) getTokenLocation(parser));
JsonSchemaNameValue nameValue = new JsonSchemaNameValue(nameLocation, terminalNode);
parent.addChild(nameValue);
nameLocation = -1;
}
currentToken = parser.nextToken();
}
JsonSchemaNameValue nameValue = ((JsonSchemaStructNode) dummy).getChild(0);
if (nameValue == null) {
return null;
}
dummy = nameValue.getValue();
dummy.setParent(null);
return dummy;
}
|
java
|
public static JsonSchemaNode createSchema(JsonParser parser) throws IOException {
JsonSchemaNode dummy = new JsonSchemaStructNode(null);
JsonSchemaStructNode parent = (JsonSchemaStructNode) dummy;
JsonToken currentToken = parser.nextToken();
int nameLocation = -1;
if (currentToken == null) {
return null;
}
while (currentToken != null) {
if (currentToken.isStructStart()) {
JsonSchemaStructNode structNode = new JsonSchemaStructNode(parent);
JsonSchemaNameValue nameValue = new JsonSchemaNameValue(nameLocation, structNode);
parent.addChild(nameValue);
parent = structNode;
nameLocation = -1;
} else if (currentToken == JsonToken.FIELD_NAME) {
nameLocation = (int) getTokenLocation(parser);
} else if (currentToken.isStructEnd()) {
parent = parent.getParent();
nameLocation = -1;
} else {
JsonSchemaTerminalNode terminalNode = new JsonSchemaTerminalNode(parent);
terminalNode.setValueStartLocation((int) getTokenLocation(parser));
JsonSchemaNameValue nameValue = new JsonSchemaNameValue(nameLocation, terminalNode);
parent.addChild(nameValue);
nameLocation = -1;
}
currentToken = parser.nextToken();
}
JsonSchemaNameValue nameValue = ((JsonSchemaStructNode) dummy).getChild(0);
if (nameValue == null) {
return null;
}
dummy = nameValue.getValue();
dummy.setParent(null);
return dummy;
}
|
[
"public",
"static",
"JsonSchemaNode",
"createSchema",
"(",
"JsonParser",
"parser",
")",
"throws",
"IOException",
"{",
"JsonSchemaNode",
"dummy",
"=",
"new",
"JsonSchemaStructNode",
"(",
"null",
")",
";",
"JsonSchemaStructNode",
"parent",
"=",
"(",
"JsonSchemaStructNode",
")",
"dummy",
";",
"JsonToken",
"currentToken",
"=",
"parser",
".",
"nextToken",
"(",
")",
";",
"int",
"nameLocation",
"=",
"-",
"1",
";",
"if",
"(",
"currentToken",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"while",
"(",
"currentToken",
"!=",
"null",
")",
"{",
"if",
"(",
"currentToken",
".",
"isStructStart",
"(",
")",
")",
"{",
"JsonSchemaStructNode",
"structNode",
"=",
"new",
"JsonSchemaStructNode",
"(",
"parent",
")",
";",
"JsonSchemaNameValue",
"nameValue",
"=",
"new",
"JsonSchemaNameValue",
"(",
"nameLocation",
",",
"structNode",
")",
";",
"parent",
".",
"addChild",
"(",
"nameValue",
")",
";",
"parent",
"=",
"structNode",
";",
"nameLocation",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"currentToken",
"==",
"JsonToken",
".",
"FIELD_NAME",
")",
"{",
"nameLocation",
"=",
"(",
"int",
")",
"getTokenLocation",
"(",
"parser",
")",
";",
"}",
"else",
"if",
"(",
"currentToken",
".",
"isStructEnd",
"(",
")",
")",
"{",
"parent",
"=",
"parent",
".",
"getParent",
"(",
")",
";",
"nameLocation",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"JsonSchemaTerminalNode",
"terminalNode",
"=",
"new",
"JsonSchemaTerminalNode",
"(",
"parent",
")",
";",
"terminalNode",
".",
"setValueStartLocation",
"(",
"(",
"int",
")",
"getTokenLocation",
"(",
"parser",
")",
")",
";",
"JsonSchemaNameValue",
"nameValue",
"=",
"new",
"JsonSchemaNameValue",
"(",
"nameLocation",
",",
"terminalNode",
")",
";",
"parent",
".",
"addChild",
"(",
"nameValue",
")",
";",
"nameLocation",
"=",
"-",
"1",
";",
"}",
"currentToken",
"=",
"parser",
".",
"nextToken",
"(",
")",
";",
"}",
"JsonSchemaNameValue",
"nameValue",
"=",
"(",
"(",
"JsonSchemaStructNode",
")",
"dummy",
")",
".",
"getChild",
"(",
"0",
")",
";",
"if",
"(",
"nameValue",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"dummy",
"=",
"nameValue",
".",
"getValue",
"(",
")",
";",
"dummy",
".",
"setParent",
"(",
"null",
")",
";",
"return",
"dummy",
";",
"}"
] |
Creates a description out of a JsonValue. The parser must be
pointing to the start of the input.
@param parser
@return
@throws IOException
|
[
"Creates",
"a",
"description",
"out",
"of",
"a",
"JsonValue",
".",
"The",
"parser",
"must",
"be",
"pointing",
"to",
"the",
"start",
"of",
"the",
"input",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/json/internal/JsonSchemaHelper.java#L164-L200
|
15,318
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/config/MergePolicyValidator.java
|
MergePolicyValidator.checkMapMergePolicyWhenStatisticsAreDisabled
|
private static void checkMapMergePolicyWhenStatisticsAreDisabled(String mergePolicyClass, List<Class> requiredMergeTypes) {
for (Class<?> requiredMergeType : requiredMergeTypes) {
if (MergingLastStoredTime.class.isAssignableFrom(requiredMergeType)
|| MergingExpirationTime.class.isAssignableFrom(requiredMergeType)) {
throw new InvalidConfigurationException("The merge policy " + mergePolicyClass
+ " requires the merge type " + requiredMergeType.getName()
+ ", which is just provided if the map statistics are enabled.");
}
}
}
|
java
|
private static void checkMapMergePolicyWhenStatisticsAreDisabled(String mergePolicyClass, List<Class> requiredMergeTypes) {
for (Class<?> requiredMergeType : requiredMergeTypes) {
if (MergingLastStoredTime.class.isAssignableFrom(requiredMergeType)
|| MergingExpirationTime.class.isAssignableFrom(requiredMergeType)) {
throw new InvalidConfigurationException("The merge policy " + mergePolicyClass
+ " requires the merge type " + requiredMergeType.getName()
+ ", which is just provided if the map statistics are enabled.");
}
}
}
|
[
"private",
"static",
"void",
"checkMapMergePolicyWhenStatisticsAreDisabled",
"(",
"String",
"mergePolicyClass",
",",
"List",
"<",
"Class",
">",
"requiredMergeTypes",
")",
"{",
"for",
"(",
"Class",
"<",
"?",
">",
"requiredMergeType",
":",
"requiredMergeTypes",
")",
"{",
"if",
"(",
"MergingLastStoredTime",
".",
"class",
".",
"isAssignableFrom",
"(",
"requiredMergeType",
")",
"||",
"MergingExpirationTime",
".",
"class",
".",
"isAssignableFrom",
"(",
"requiredMergeType",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"\"The merge policy \"",
"+",
"mergePolicyClass",
"+",
"\" requires the merge type \"",
"+",
"requiredMergeType",
".",
"getName",
"(",
")",
"+",
"\", which is just provided if the map statistics are enabled.\"",
")",
";",
"}",
"}",
"}"
] |
Checks if the configured merge policy requires merge types, which are just available if map statistics are enabled.
@param mergePolicyClass the name of the configured merge policy class
@param requiredMergeTypes the required merge types of the configured merge policy
|
[
"Checks",
"if",
"the",
"configured",
"merge",
"policy",
"requires",
"merge",
"types",
"which",
"are",
"just",
"available",
"if",
"map",
"statistics",
"are",
"enabled",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/config/MergePolicyValidator.java#L164-L173
|
15,319
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java
|
AbstractInvocationFuture.unwrap
|
protected Throwable unwrap(Throwable throwable) {
if (throwable instanceof ExecutionException && throwable.getCause() != null) {
return throwable.getCause();
}
return throwable;
}
|
java
|
protected Throwable unwrap(Throwable throwable) {
if (throwable instanceof ExecutionException && throwable.getCause() != null) {
return throwable.getCause();
}
return throwable;
}
|
[
"protected",
"Throwable",
"unwrap",
"(",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"instanceof",
"ExecutionException",
"&&",
"throwable",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"throwable",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"throwable",
";",
"}"
] |
this method should not be needed; but there is a difference between client and server how it handles async throwables
|
[
"this",
"method",
"should",
"not",
"be",
"needed",
";",
"but",
"there",
"is",
"a",
"difference",
"between",
"client",
"and",
"server",
"how",
"it",
"handles",
"async",
"throwables"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java#L271-L276
|
15,320
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java
|
AbstractInvocationFuture.complete
|
@Override
public final boolean complete(Object value) {
for (; ; ) {
final Object oldState = state;
if (isDone(oldState)) {
warnIfSuspiciousDoubleCompletion(oldState, value);
return false;
}
if (compareAndSetState(oldState, value)) {
onComplete();
unblockAll(oldState, defaultExecutor);
return true;
}
}
}
|
java
|
@Override
public final boolean complete(Object value) {
for (; ; ) {
final Object oldState = state;
if (isDone(oldState)) {
warnIfSuspiciousDoubleCompletion(oldState, value);
return false;
}
if (compareAndSetState(oldState, value)) {
onComplete();
unblockAll(oldState, defaultExecutor);
return true;
}
}
}
|
[
"@",
"Override",
"public",
"final",
"boolean",
"complete",
"(",
"Object",
"value",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"final",
"Object",
"oldState",
"=",
"state",
";",
"if",
"(",
"isDone",
"(",
"oldState",
")",
")",
"{",
"warnIfSuspiciousDoubleCompletion",
"(",
"oldState",
",",
"value",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"compareAndSetState",
"(",
"oldState",
",",
"value",
")",
")",
"{",
"onComplete",
"(",
")",
";",
"unblockAll",
"(",
"oldState",
",",
"defaultExecutor",
")",
";",
"return",
"true",
";",
"}",
"}",
"}"
] |
Can be called multiple times, but only the first answer will lead to the
future getting triggered. All subsequent complete calls are ignored.
@param value The type of response to offer.
@return <tt>true</tt> if offered response, either a final response or an
internal response, is set/applied, <tt>false</tt> otherwise. If <tt>false</tt>
is returned, that means offered response is ignored because a final response
is already set to this future.
|
[
"Can",
"be",
"called",
"multiple",
"times",
"but",
"only",
"the",
"first",
"answer",
"will",
"lead",
"to",
"the",
"future",
"getting",
"triggered",
".",
"All",
"subsequent",
"complete",
"calls",
"are",
"ignored",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java#L366-L380
|
15,321
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java
|
AbstractInvocationFuture.warnIfSuspiciousDoubleCompletion
|
private void warnIfSuspiciousDoubleCompletion(Object s0, Object s1) {
if (s0 != s1 && !(s0 instanceof CancellationException) && !(s1 instanceof CancellationException)) {
logger.warning(String.format("Future.complete(Object) on completed future. "
+ "Request: %s, current value: %s, offered value: %s",
invocationToString(), s0, s1));
}
}
|
java
|
private void warnIfSuspiciousDoubleCompletion(Object s0, Object s1) {
if (s0 != s1 && !(s0 instanceof CancellationException) && !(s1 instanceof CancellationException)) {
logger.warning(String.format("Future.complete(Object) on completed future. "
+ "Request: %s, current value: %s, offered value: %s",
invocationToString(), s0, s1));
}
}
|
[
"private",
"void",
"warnIfSuspiciousDoubleCompletion",
"(",
"Object",
"s0",
",",
"Object",
"s1",
")",
"{",
"if",
"(",
"s0",
"!=",
"s1",
"&&",
"!",
"(",
"s0",
"instanceof",
"CancellationException",
")",
"&&",
"!",
"(",
"s1",
"instanceof",
"CancellationException",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"String",
".",
"format",
"(",
"\"Future.complete(Object) on completed future. \"",
"+",
"\"Request: %s, current value: %s, offered value: %s\"",
",",
"invocationToString",
"(",
")",
",",
"s0",
",",
"s1",
")",
")",
";",
"}",
"}"
] |
received a response, but before it cleans up itself, it receives a HazelcastInstanceNotActiveException
|
[
"received",
"a",
"response",
"but",
"before",
"it",
"cleans",
"up",
"itself",
"it",
"receives",
"a",
"HazelcastInstanceNotActiveException"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/AbstractInvocationFuture.java#L388-L394
|
15,322
|
hazelcast/hazelcast
|
hazelcast-client/src/main/java/com/hazelcast/client/cache/impl/ClientCacheHelper.java
|
ClientCacheHelper.getCacheConfig
|
static <K, V> CacheConfig<K, V> getCacheConfig(HazelcastClientInstanceImpl client,
String cacheName, String simpleCacheName) {
ClientMessage request = CacheGetConfigCodec.encodeRequest(cacheName, simpleCacheName);
try {
int partitionId = client.getClientPartitionService().getPartitionId(cacheName);
ClientInvocation clientInvocation = new ClientInvocation(client, request, cacheName, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
ClientMessage responseMessage = future.get();
SerializationService serializationService = client.getSerializationService();
return deserializeCacheConfig(client, responseMessage, serializationService, clientInvocation);
} catch (Exception e) {
throw rethrow(e);
}
}
|
java
|
static <K, V> CacheConfig<K, V> getCacheConfig(HazelcastClientInstanceImpl client,
String cacheName, String simpleCacheName) {
ClientMessage request = CacheGetConfigCodec.encodeRequest(cacheName, simpleCacheName);
try {
int partitionId = client.getClientPartitionService().getPartitionId(cacheName);
ClientInvocation clientInvocation = new ClientInvocation(client, request, cacheName, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
ClientMessage responseMessage = future.get();
SerializationService serializationService = client.getSerializationService();
return deserializeCacheConfig(client, responseMessage, serializationService, clientInvocation);
} catch (Exception e) {
throw rethrow(e);
}
}
|
[
"static",
"<",
"K",
",",
"V",
">",
"CacheConfig",
"<",
"K",
",",
"V",
">",
"getCacheConfig",
"(",
"HazelcastClientInstanceImpl",
"client",
",",
"String",
"cacheName",
",",
"String",
"simpleCacheName",
")",
"{",
"ClientMessage",
"request",
"=",
"CacheGetConfigCodec",
".",
"encodeRequest",
"(",
"cacheName",
",",
"simpleCacheName",
")",
";",
"try",
"{",
"int",
"partitionId",
"=",
"client",
".",
"getClientPartitionService",
"(",
")",
".",
"getPartitionId",
"(",
"cacheName",
")",
";",
"ClientInvocation",
"clientInvocation",
"=",
"new",
"ClientInvocation",
"(",
"client",
",",
"request",
",",
"cacheName",
",",
"partitionId",
")",
";",
"Future",
"<",
"ClientMessage",
">",
"future",
"=",
"clientInvocation",
".",
"invoke",
"(",
")",
";",
"ClientMessage",
"responseMessage",
"=",
"future",
".",
"get",
"(",
")",
";",
"SerializationService",
"serializationService",
"=",
"client",
".",
"getSerializationService",
"(",
")",
";",
"return",
"deserializeCacheConfig",
"(",
"client",
",",
"responseMessage",
",",
"serializationService",
",",
"clientInvocation",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"rethrow",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets the cache configuration from the server.
@param client the client instance which will send the operation to server
@param cacheName full cache name with prefixes
@param simpleCacheName pure cache name without any prefix
@param <K> type of the key of the cache
@param <V> type of the value of the cache
@return the cache configuration if it can be found
|
[
"Gets",
"the",
"cache",
"configuration",
"from",
"the",
"server",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/cache/impl/ClientCacheHelper.java#L68-L82
|
15,323
|
hazelcast/hazelcast
|
hazelcast-client/src/main/java/com/hazelcast/client/cache/impl/ClientCacheHelper.java
|
ClientCacheHelper.createCacheConfig
|
static <K, V> CacheConfig<K, V> createCacheConfig(HazelcastClientInstanceImpl client,
CacheConfig<K, V> newCacheConfig) {
try {
String nameWithPrefix = newCacheConfig.getNameWithPrefix();
int partitionId = client.getClientPartitionService().getPartitionId(nameWithPrefix);
Object resolvedConfig = resolveCacheConfigWithRetry(client, newCacheConfig, partitionId);
Data configData = client.getSerializationService().toData(resolvedConfig);
ClientMessage request = CacheCreateConfigCodec.encodeRequest(configData, true);
ClientInvocation clientInvocation = new ClientInvocation(client, request, nameWithPrefix, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
final ClientMessage response = future.get();
final Data data = CacheCreateConfigCodec.decodeResponse(response).response;
return resolveCacheConfig(client, clientInvocation, data);
} catch (Exception e) {
throw rethrow(e);
}
}
|
java
|
static <K, V> CacheConfig<K, V> createCacheConfig(HazelcastClientInstanceImpl client,
CacheConfig<K, V> newCacheConfig) {
try {
String nameWithPrefix = newCacheConfig.getNameWithPrefix();
int partitionId = client.getClientPartitionService().getPartitionId(nameWithPrefix);
Object resolvedConfig = resolveCacheConfigWithRetry(client, newCacheConfig, partitionId);
Data configData = client.getSerializationService().toData(resolvedConfig);
ClientMessage request = CacheCreateConfigCodec.encodeRequest(configData, true);
ClientInvocation clientInvocation = new ClientInvocation(client, request, nameWithPrefix, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
final ClientMessage response = future.get();
final Data data = CacheCreateConfigCodec.decodeResponse(response).response;
return resolveCacheConfig(client, clientInvocation, data);
} catch (Exception e) {
throw rethrow(e);
}
}
|
[
"static",
"<",
"K",
",",
"V",
">",
"CacheConfig",
"<",
"K",
",",
"V",
">",
"createCacheConfig",
"(",
"HazelcastClientInstanceImpl",
"client",
",",
"CacheConfig",
"<",
"K",
",",
"V",
">",
"newCacheConfig",
")",
"{",
"try",
"{",
"String",
"nameWithPrefix",
"=",
"newCacheConfig",
".",
"getNameWithPrefix",
"(",
")",
";",
"int",
"partitionId",
"=",
"client",
".",
"getClientPartitionService",
"(",
")",
".",
"getPartitionId",
"(",
"nameWithPrefix",
")",
";",
"Object",
"resolvedConfig",
"=",
"resolveCacheConfigWithRetry",
"(",
"client",
",",
"newCacheConfig",
",",
"partitionId",
")",
";",
"Data",
"configData",
"=",
"client",
".",
"getSerializationService",
"(",
")",
".",
"toData",
"(",
"resolvedConfig",
")",
";",
"ClientMessage",
"request",
"=",
"CacheCreateConfigCodec",
".",
"encodeRequest",
"(",
"configData",
",",
"true",
")",
";",
"ClientInvocation",
"clientInvocation",
"=",
"new",
"ClientInvocation",
"(",
"client",
",",
"request",
",",
"nameWithPrefix",
",",
"partitionId",
")",
";",
"Future",
"<",
"ClientMessage",
">",
"future",
"=",
"clientInvocation",
".",
"invoke",
"(",
")",
";",
"final",
"ClientMessage",
"response",
"=",
"future",
".",
"get",
"(",
")",
";",
"final",
"Data",
"data",
"=",
"CacheCreateConfigCodec",
".",
"decodeResponse",
"(",
"response",
")",
".",
"response",
";",
"return",
"resolveCacheConfig",
"(",
"client",
",",
"clientInvocation",
",",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"rethrow",
"(",
"e",
")",
";",
"}",
"}"
] |
Creates a new cache configuration on Hazelcast members.
@param client the client instance which will send the operation to server
@param newCacheConfig the cache configuration to be sent to server
@param <K> type of the key of the cache
@param <V> type of the value of the cache
@return the created cache configuration
@see com.hazelcast.cache.impl.operation.CacheCreateConfigOperation
|
[
"Creates",
"a",
"new",
"cache",
"configuration",
"on",
"Hazelcast",
"members",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/cache/impl/ClientCacheHelper.java#L114-L132
|
15,324
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java
|
PortableUtils.validateAndGetArrayQuantifierFromCurrentToken
|
static int validateAndGetArrayQuantifierFromCurrentToken(String token, String fullPath) {
String quantifier = extractArgumentsFromAttributeName(token);
if (quantifier == null) {
throw new IllegalArgumentException("Malformed quantifier in " + fullPath);
}
int index = Integer.parseInt(quantifier);
if (index < 0) {
throw new IllegalArgumentException("Array index " + index + " cannot be negative in " + fullPath);
}
return index;
}
|
java
|
static int validateAndGetArrayQuantifierFromCurrentToken(String token, String fullPath) {
String quantifier = extractArgumentsFromAttributeName(token);
if (quantifier == null) {
throw new IllegalArgumentException("Malformed quantifier in " + fullPath);
}
int index = Integer.parseInt(quantifier);
if (index < 0) {
throw new IllegalArgumentException("Array index " + index + " cannot be negative in " + fullPath);
}
return index;
}
|
[
"static",
"int",
"validateAndGetArrayQuantifierFromCurrentToken",
"(",
"String",
"token",
",",
"String",
"fullPath",
")",
"{",
"String",
"quantifier",
"=",
"extractArgumentsFromAttributeName",
"(",
"token",
")",
";",
"if",
"(",
"quantifier",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Malformed quantifier in \"",
"+",
"fullPath",
")",
";",
"}",
"int",
"index",
"=",
"Integer",
".",
"parseInt",
"(",
"quantifier",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Array index \"",
"+",
"index",
"+",
"\" cannot be negative in \"",
"+",
"fullPath",
")",
";",
"}",
"return",
"index",
";",
"}"
] |
Extracts and validates the quantifier from the given path token
@param token token from which the quantifier is retrieved
@param fullPath fullPath to which the token belongs - just for output
@return validated quantifier
|
[
"Extracts",
"and",
"validates",
"the",
"quantifier",
"from",
"the",
"given",
"path",
"token"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java#L44-L54
|
15,325
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java
|
PortableUtils.getPortableArrayCellPosition
|
static int getPortableArrayCellPosition(BufferObjectDataInput in, int streamPosition, int cellIndex)
throws IOException {
return in.readInt(streamPosition + cellIndex * Bits.INT_SIZE_IN_BYTES);
}
|
java
|
static int getPortableArrayCellPosition(BufferObjectDataInput in, int streamPosition, int cellIndex)
throws IOException {
return in.readInt(streamPosition + cellIndex * Bits.INT_SIZE_IN_BYTES);
}
|
[
"static",
"int",
"getPortableArrayCellPosition",
"(",
"BufferObjectDataInput",
"in",
",",
"int",
"streamPosition",
",",
"int",
"cellIndex",
")",
"throws",
"IOException",
"{",
"return",
"in",
".",
"readInt",
"(",
"streamPosition",
"+",
"cellIndex",
"*",
"Bits",
".",
"INT_SIZE_IN_BYTES",
")",
";",
"}"
] |
Calculates and reads the position of the Portable object stored in a Portable array under the given index.
@param in data input stream
@param streamPosition streamPosition to begin the reading from
@param cellIndex index of the cell
@return the position of the given portable object in the stream
@throws IOException on any stream errors
|
[
"Calculates",
"and",
"reads",
"the",
"position",
"of",
"the",
"Portable",
"object",
"stored",
"in",
"a",
"Portable",
"array",
"under",
"the",
"given",
"index",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java#L65-L68
|
15,326
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java
|
PortableUtils.getStreamPositionOfTheField
|
static int getStreamPositionOfTheField(FieldDefinition fd, BufferObjectDataInput in, int offset) throws IOException {
int pos = in.readInt(offset + fd.getIndex() * Bits.INT_SIZE_IN_BYTES);
short len = in.readShort(pos);
// name + len + type
return pos + Bits.SHORT_SIZE_IN_BYTES + len + 1;
}
|
java
|
static int getStreamPositionOfTheField(FieldDefinition fd, BufferObjectDataInput in, int offset) throws IOException {
int pos = in.readInt(offset + fd.getIndex() * Bits.INT_SIZE_IN_BYTES);
short len = in.readShort(pos);
// name + len + type
return pos + Bits.SHORT_SIZE_IN_BYTES + len + 1;
}
|
[
"static",
"int",
"getStreamPositionOfTheField",
"(",
"FieldDefinition",
"fd",
",",
"BufferObjectDataInput",
"in",
",",
"int",
"offset",
")",
"throws",
"IOException",
"{",
"int",
"pos",
"=",
"in",
".",
"readInt",
"(",
"offset",
"+",
"fd",
".",
"getIndex",
"(",
")",
"*",
"Bits",
".",
"INT_SIZE_IN_BYTES",
")",
";",
"short",
"len",
"=",
"in",
".",
"readShort",
"(",
"pos",
")",
";",
"// name + len + type",
"return",
"pos",
"+",
"Bits",
".",
"SHORT_SIZE_IN_BYTES",
"+",
"len",
"+",
"1",
";",
"}"
] |
Calculates the position of the given field in the portable byte stream
@param fd given field definition
@param in data input stream
@param offset offset to use while stream reading
@return position of the given field
@throws IOException on any stream errors
|
[
"Calculates",
"the",
"position",
"of",
"the",
"given",
"field",
"in",
"the",
"portable",
"byte",
"stream"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java#L79-L84
|
15,327
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java
|
PortableUtils.getArrayLengthOfTheField
|
static int getArrayLengthOfTheField(FieldDefinition fd, BufferObjectDataInput in, int offset) throws IOException {
int originalPos = in.position();
try {
int pos = getStreamPositionOfTheField(fd, in, offset);
in.position(pos);
return in.readInt();
} finally {
in.position(originalPos);
}
}
|
java
|
static int getArrayLengthOfTheField(FieldDefinition fd, BufferObjectDataInput in, int offset) throws IOException {
int originalPos = in.position();
try {
int pos = getStreamPositionOfTheField(fd, in, offset);
in.position(pos);
return in.readInt();
} finally {
in.position(originalPos);
}
}
|
[
"static",
"int",
"getArrayLengthOfTheField",
"(",
"FieldDefinition",
"fd",
",",
"BufferObjectDataInput",
"in",
",",
"int",
"offset",
")",
"throws",
"IOException",
"{",
"int",
"originalPos",
"=",
"in",
".",
"position",
"(",
")",
";",
"try",
"{",
"int",
"pos",
"=",
"getStreamPositionOfTheField",
"(",
"fd",
",",
"in",
",",
"offset",
")",
";",
"in",
".",
"position",
"(",
"pos",
")",
";",
"return",
"in",
".",
"readInt",
"(",
")",
";",
"}",
"finally",
"{",
"in",
".",
"position",
"(",
"originalPos",
")",
";",
"}",
"}"
] |
Reads the length of the given array.
It does not validate if the current position is actually an array - has to be taken care of by the caller.
@param fd field of the array
@param in data input stream
@param offset offset to use while stream reading
@return length of the array
@throws IOException on any stream errors
|
[
"Reads",
"the",
"length",
"of",
"the",
"given",
"array",
".",
"It",
"does",
"not",
"validate",
"if",
"the",
"current",
"position",
"is",
"actually",
"an",
"array",
"-",
"has",
"to",
"be",
"taken",
"care",
"of",
"by",
"the",
"caller",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java#L96-L105
|
15,328
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java
|
PortableUtils.validateFactoryAndClass
|
static void validateFactoryAndClass(FieldDefinition fd, int factoryId, int classId, String fullPath) {
if (factoryId != fd.getFactoryId()) {
throw new IllegalArgumentException("Invalid factoryId! Expected: "
+ fd.getFactoryId() + ", Current: " + factoryId + " in path " + fullPath);
}
if (classId != fd.getClassId()) {
throw new IllegalArgumentException("Invalid classId! Expected: "
+ fd.getClassId() + ", Current: " + classId + " in path " + fullPath);
}
}
|
java
|
static void validateFactoryAndClass(FieldDefinition fd, int factoryId, int classId, String fullPath) {
if (factoryId != fd.getFactoryId()) {
throw new IllegalArgumentException("Invalid factoryId! Expected: "
+ fd.getFactoryId() + ", Current: " + factoryId + " in path " + fullPath);
}
if (classId != fd.getClassId()) {
throw new IllegalArgumentException("Invalid classId! Expected: "
+ fd.getClassId() + ", Current: " + classId + " in path " + fullPath);
}
}
|
[
"static",
"void",
"validateFactoryAndClass",
"(",
"FieldDefinition",
"fd",
",",
"int",
"factoryId",
",",
"int",
"classId",
",",
"String",
"fullPath",
")",
"{",
"if",
"(",
"factoryId",
"!=",
"fd",
".",
"getFactoryId",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid factoryId! Expected: \"",
"+",
"fd",
".",
"getFactoryId",
"(",
")",
"+",
"\", Current: \"",
"+",
"factoryId",
"+",
"\" in path \"",
"+",
"fullPath",
")",
";",
"}",
"if",
"(",
"classId",
"!=",
"fd",
".",
"getClassId",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid classId! Expected: \"",
"+",
"fd",
".",
"getClassId",
"(",
")",
"+",
"\", Current: \"",
"+",
"classId",
"+",
"\" in path \"",
"+",
"fullPath",
")",
";",
"}",
"}"
] |
Validates if the given factoryId and classId match the ones from the fieldDefinition
@param fd given fieldDefinition to validate against
@param factoryId given factoryId to validate
@param classId given factoryId to validate
@param fullPath full path - just for output
|
[
"Validates",
"if",
"the",
"given",
"factoryId",
"and",
"classId",
"match",
"the",
"ones",
"from",
"the",
"fieldDefinition"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableUtils.java#L168-L177
|
15,329
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/AliasedDiscoveryConfigUtils.java
|
AliasedDiscoveryConfigUtils.map
|
public static List<DiscoveryStrategyConfig> map(List<AliasedDiscoveryConfig<?>> aliasedDiscoveryConfigs) {
List<DiscoveryStrategyConfig> result = new ArrayList<DiscoveryStrategyConfig>();
for (AliasedDiscoveryConfig config : aliasedDiscoveryConfigs) {
if (config.isEnabled()) {
result.add(createDiscoveryStrategyConfig(config));
}
}
return result;
}
|
java
|
public static List<DiscoveryStrategyConfig> map(List<AliasedDiscoveryConfig<?>> aliasedDiscoveryConfigs) {
List<DiscoveryStrategyConfig> result = new ArrayList<DiscoveryStrategyConfig>();
for (AliasedDiscoveryConfig config : aliasedDiscoveryConfigs) {
if (config.isEnabled()) {
result.add(createDiscoveryStrategyConfig(config));
}
}
return result;
}
|
[
"public",
"static",
"List",
"<",
"DiscoveryStrategyConfig",
">",
"map",
"(",
"List",
"<",
"AliasedDiscoveryConfig",
"<",
"?",
">",
">",
"aliasedDiscoveryConfigs",
")",
"{",
"List",
"<",
"DiscoveryStrategyConfig",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"DiscoveryStrategyConfig",
">",
"(",
")",
";",
"for",
"(",
"AliasedDiscoveryConfig",
"config",
":",
"aliasedDiscoveryConfigs",
")",
"{",
"if",
"(",
"config",
".",
"isEnabled",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"createDiscoveryStrategyConfig",
"(",
"config",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Maps aliased discovery strategy configs into discovery strategy configs.
|
[
"Maps",
"aliased",
"discovery",
"strategy",
"configs",
"into",
"discovery",
"strategy",
"configs",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/AliasedDiscoveryConfigUtils.java#L74-L82
|
15,330
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/JoinConfig.java
|
JoinConfig.verify
|
@SuppressWarnings("checkstyle:npathcomplexity")
public void verify() {
int countEnabled = 0;
if (getTcpIpConfig().isEnabled()) {
countEnabled++;
}
if (getMulticastConfig().isEnabled()) {
countEnabled++;
}
if (getAwsConfig().isEnabled()) {
countEnabled++;
}
if (getGcpConfig().isEnabled()) {
countEnabled++;
}
if (getAzureConfig().isEnabled()) {
countEnabled++;
}
if (getKubernetesConfig().isEnabled()) {
countEnabled++;
}
if (getEurekaConfig().isEnabled()) {
countEnabled++;
}
if (countEnabled > 1) {
throw new InvalidConfigurationException("Multiple join configuration cannot be enabled at the same time. Enable only "
+ "one of: TCP/IP, Multicast, AWS, GCP, Azure, Kubernetes, or Eureka");
}
verifyDiscoveryProviderConfig();
}
|
java
|
@SuppressWarnings("checkstyle:npathcomplexity")
public void verify() {
int countEnabled = 0;
if (getTcpIpConfig().isEnabled()) {
countEnabled++;
}
if (getMulticastConfig().isEnabled()) {
countEnabled++;
}
if (getAwsConfig().isEnabled()) {
countEnabled++;
}
if (getGcpConfig().isEnabled()) {
countEnabled++;
}
if (getAzureConfig().isEnabled()) {
countEnabled++;
}
if (getKubernetesConfig().isEnabled()) {
countEnabled++;
}
if (getEurekaConfig().isEnabled()) {
countEnabled++;
}
if (countEnabled > 1) {
throw new InvalidConfigurationException("Multiple join configuration cannot be enabled at the same time. Enable only "
+ "one of: TCP/IP, Multicast, AWS, GCP, Azure, Kubernetes, or Eureka");
}
verifyDiscoveryProviderConfig();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"checkstyle:npathcomplexity\"",
")",
"public",
"void",
"verify",
"(",
")",
"{",
"int",
"countEnabled",
"=",
"0",
";",
"if",
"(",
"getTcpIpConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getMulticastConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getAwsConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getGcpConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getAzureConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getKubernetesConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"getEurekaConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"countEnabled",
"++",
";",
"}",
"if",
"(",
"countEnabled",
">",
"1",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"\"Multiple join configuration cannot be enabled at the same time. Enable only \"",
"+",
"\"one of: TCP/IP, Multicast, AWS, GCP, Azure, Kubernetes, or Eureka\"",
")",
";",
"}",
"verifyDiscoveryProviderConfig",
"(",
")",
";",
"}"
] |
Verifies this JoinConfig is valid. At most a single joiner should be active.
@throws IllegalStateException when the join config is not valid
|
[
"Verifies",
"this",
"JoinConfig",
"is",
"valid",
".",
"At",
"most",
"a",
"single",
"joiner",
"should",
"be",
"active",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/JoinConfig.java#L181-L212
|
15,331
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/JoinConfig.java
|
JoinConfig.verifyDiscoveryProviderConfig
|
private void verifyDiscoveryProviderConfig() {
Collection<DiscoveryStrategyConfig> discoveryStrategyConfigs = discoveryConfig.getDiscoveryStrategyConfigs();
if (discoveryStrategyConfigs.size() > 0) {
if (getMulticastConfig().isEnabled()) {
throw new InvalidConfigurationException(
"Multicast and DiscoveryProviders join can't be enabled at the same time");
}
}
}
|
java
|
private void verifyDiscoveryProviderConfig() {
Collection<DiscoveryStrategyConfig> discoveryStrategyConfigs = discoveryConfig.getDiscoveryStrategyConfigs();
if (discoveryStrategyConfigs.size() > 0) {
if (getMulticastConfig().isEnabled()) {
throw new InvalidConfigurationException(
"Multicast and DiscoveryProviders join can't be enabled at the same time");
}
}
}
|
[
"private",
"void",
"verifyDiscoveryProviderConfig",
"(",
")",
"{",
"Collection",
"<",
"DiscoveryStrategyConfig",
">",
"discoveryStrategyConfigs",
"=",
"discoveryConfig",
".",
"getDiscoveryStrategyConfigs",
"(",
")",
";",
"if",
"(",
"discoveryStrategyConfigs",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"getMulticastConfig",
"(",
")",
".",
"isEnabled",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"\"Multicast and DiscoveryProviders join can't be enabled at the same time\"",
")",
";",
"}",
"}",
"}"
] |
Verifies this JoinConfig is valid. When Discovery SPI enabled other discovery
methods should be disabled
@throws IllegalStateException when the join config is not valid
|
[
"Verifies",
"this",
"JoinConfig",
"is",
"valid",
".",
"When",
"Discovery",
"SPI",
"enabled",
"other",
"discovery",
"methods",
"should",
"be",
"disabled"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/JoinConfig.java#L220-L228
|
15,332
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/MapServiceContextImpl.java
|
MapServiceContextImpl.removeAllRecordStoresOfAllMaps
|
protected void removeAllRecordStoresOfAllMaps(boolean onShutdown, boolean onRecordStoreDestroy) {
for (PartitionContainer partitionContainer : partitionContainers) {
if (partitionContainer != null) {
removeRecordStoresFromPartitionMatchingWith(allRecordStores(),
partitionContainer.getPartitionId(), onShutdown, onRecordStoreDestroy);
}
}
}
|
java
|
protected void removeAllRecordStoresOfAllMaps(boolean onShutdown, boolean onRecordStoreDestroy) {
for (PartitionContainer partitionContainer : partitionContainers) {
if (partitionContainer != null) {
removeRecordStoresFromPartitionMatchingWith(allRecordStores(),
partitionContainer.getPartitionId(), onShutdown, onRecordStoreDestroy);
}
}
}
|
[
"protected",
"void",
"removeAllRecordStoresOfAllMaps",
"(",
"boolean",
"onShutdown",
",",
"boolean",
"onRecordStoreDestroy",
")",
"{",
"for",
"(",
"PartitionContainer",
"partitionContainer",
":",
"partitionContainers",
")",
"{",
"if",
"(",
"partitionContainer",
"!=",
"null",
")",
"{",
"removeRecordStoresFromPartitionMatchingWith",
"(",
"allRecordStores",
"(",
")",
",",
"partitionContainer",
".",
"getPartitionId",
"(",
")",
",",
"onShutdown",
",",
"onRecordStoreDestroy",
")",
";",
"}",
"}",
"}"
] |
Removes all record stores from all partitions.
Calls {@link #removeRecordStoresFromPartitionMatchingWith} internally and
@param onShutdown {@code true} if this method is called during map service shutdown,
otherwise set {@code false}
@param onRecordStoreDestroy {@code true} if this method is called during to destroy record store,
otherwise set {@code false}
|
[
"Removes",
"all",
"record",
"stores",
"from",
"all",
"partitions",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapServiceContextImpl.java#L314-L321
|
15,333
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/MXBeanUtil.java
|
MXBeanUtil.unregisterCacheObject
|
public static void unregisterCacheObject(String cacheManagerName, String name, boolean stats) {
synchronized (mBeanServer) {
ObjectName objectName = calculateObjectName(cacheManagerName, name, stats);
Set<ObjectName> registeredObjectNames = mBeanServer.queryNames(objectName, null);
if (isRegistered(cacheManagerName, name, stats)) {
//should just be one
for (ObjectName registeredObjectName : registeredObjectNames) {
try {
mBeanServer.unregisterMBean(registeredObjectName);
} catch (InstanceNotFoundException e) {
// it can happen that the instance that we want to unregister isn't found. So lets ignore it
// https://github.com/hazelcast/hazelcast/issues/11055
ignore(e);
} catch (Exception e) {
throw new CacheException("Error unregistering object instance " + registeredObjectName
+ ". Error was " + e.getMessage(), e);
}
}
}
}
}
|
java
|
public static void unregisterCacheObject(String cacheManagerName, String name, boolean stats) {
synchronized (mBeanServer) {
ObjectName objectName = calculateObjectName(cacheManagerName, name, stats);
Set<ObjectName> registeredObjectNames = mBeanServer.queryNames(objectName, null);
if (isRegistered(cacheManagerName, name, stats)) {
//should just be one
for (ObjectName registeredObjectName : registeredObjectNames) {
try {
mBeanServer.unregisterMBean(registeredObjectName);
} catch (InstanceNotFoundException e) {
// it can happen that the instance that we want to unregister isn't found. So lets ignore it
// https://github.com/hazelcast/hazelcast/issues/11055
ignore(e);
} catch (Exception e) {
throw new CacheException("Error unregistering object instance " + registeredObjectName
+ ". Error was " + e.getMessage(), e);
}
}
}
}
}
|
[
"public",
"static",
"void",
"unregisterCacheObject",
"(",
"String",
"cacheManagerName",
",",
"String",
"name",
",",
"boolean",
"stats",
")",
"{",
"synchronized",
"(",
"mBeanServer",
")",
"{",
"ObjectName",
"objectName",
"=",
"calculateObjectName",
"(",
"cacheManagerName",
",",
"name",
",",
"stats",
")",
";",
"Set",
"<",
"ObjectName",
">",
"registeredObjectNames",
"=",
"mBeanServer",
".",
"queryNames",
"(",
"objectName",
",",
"null",
")",
";",
"if",
"(",
"isRegistered",
"(",
"cacheManagerName",
",",
"name",
",",
"stats",
")",
")",
"{",
"//should just be one",
"for",
"(",
"ObjectName",
"registeredObjectName",
":",
"registeredObjectNames",
")",
"{",
"try",
"{",
"mBeanServer",
".",
"unregisterMBean",
"(",
"registeredObjectName",
")",
";",
"}",
"catch",
"(",
"InstanceNotFoundException",
"e",
")",
"{",
"// it can happen that the instance that we want to unregister isn't found. So lets ignore it",
"// https://github.com/hazelcast/hazelcast/issues/11055",
"ignore",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CacheException",
"(",
"\"Error unregistering object instance \"",
"+",
"registeredObjectName",
"+",
"\". Error was \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
UnRegisters the mxbean if registered already.
@param cacheManagerName name generated by URI and classloader.
@param name cache name.
@param stats is mxbean, a statistics mxbean.
|
[
"UnRegisters",
"the",
"mxbean",
"if",
"registered",
"already",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/MXBeanUtil.java#L79-L99
|
15,334
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/MessageFlyweight.java
|
MessageFlyweight.set
|
public MessageFlyweight set(boolean value) {
buffer.putByte(index + offset, (byte) (value ? 1 : 0));
index += Bits.BYTE_SIZE_IN_BYTES;
return this;
}
|
java
|
public MessageFlyweight set(boolean value) {
buffer.putByte(index + offset, (byte) (value ? 1 : 0));
index += Bits.BYTE_SIZE_IN_BYTES;
return this;
}
|
[
"public",
"MessageFlyweight",
"set",
"(",
"boolean",
"value",
")",
"{",
"buffer",
".",
"putByte",
"(",
"index",
"+",
"offset",
",",
"(",
"byte",
")",
"(",
"value",
"?",
"1",
":",
"0",
")",
")",
";",
"index",
"+=",
"Bits",
".",
"BYTE_SIZE_IN_BYTES",
";",
"return",
"this",
";",
"}"
] |
region SET Overloads
|
[
"region",
"SET",
"Overloads"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/MessageFlyweight.java#L76-L80
|
15,335
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/MessageFlyweight.java
|
MessageFlyweight.getBoolean
|
public boolean getBoolean() {
byte result = buffer.getByte(index + offset);
index += Bits.BYTE_SIZE_IN_BYTES;
return result != 0;
}
|
java
|
public boolean getBoolean() {
byte result = buffer.getByte(index + offset);
index += Bits.BYTE_SIZE_IN_BYTES;
return result != 0;
}
|
[
"public",
"boolean",
"getBoolean",
"(",
")",
"{",
"byte",
"result",
"=",
"buffer",
".",
"getByte",
"(",
"index",
"+",
"offset",
")",
";",
"index",
"+=",
"Bits",
".",
"BYTE_SIZE_IN_BYTES",
";",
"return",
"result",
"!=",
"0",
";",
"}"
] |
region GET Overloads
|
[
"region",
"GET",
"Overloads"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/MessageFlyweight.java#L137-L141
|
15,336
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/OperatingSystemMXBeanSupport.java
|
OperatingSystemMXBeanSupport.readLongAttribute
|
public static long readLongAttribute(String attributeName, long defaultValue) {
try {
String methodName = "get" + attributeName;
OperatingSystemMXBean systemMXBean = OPERATING_SYSTEM_MX_BEAN;
Method method = systemMXBean.getClass().getMethod(methodName);
method.setAccessible(true);
Object value = method.invoke(systemMXBean);
if (value == null) {
return defaultValue;
}
if (value instanceof Long) {
return (Long) value;
}
if (value instanceof Double) {
double v = (Double) value;
return Math.round(v * PERCENTAGE_MULTIPLIER);
}
if (value instanceof Number) {
return ((Number) value).longValue();
}
} catch (RuntimeException re) {
throw re;
} catch (Exception ignored) {
ignore(ignored);
}
return defaultValue;
}
|
java
|
public static long readLongAttribute(String attributeName, long defaultValue) {
try {
String methodName = "get" + attributeName;
OperatingSystemMXBean systemMXBean = OPERATING_SYSTEM_MX_BEAN;
Method method = systemMXBean.getClass().getMethod(methodName);
method.setAccessible(true);
Object value = method.invoke(systemMXBean);
if (value == null) {
return defaultValue;
}
if (value instanceof Long) {
return (Long) value;
}
if (value instanceof Double) {
double v = (Double) value;
return Math.round(v * PERCENTAGE_MULTIPLIER);
}
if (value instanceof Number) {
return ((Number) value).longValue();
}
} catch (RuntimeException re) {
throw re;
} catch (Exception ignored) {
ignore(ignored);
}
return defaultValue;
}
|
[
"public",
"static",
"long",
"readLongAttribute",
"(",
"String",
"attributeName",
",",
"long",
"defaultValue",
")",
"{",
"try",
"{",
"String",
"methodName",
"=",
"\"get\"",
"+",
"attributeName",
";",
"OperatingSystemMXBean",
"systemMXBean",
"=",
"OPERATING_SYSTEM_MX_BEAN",
";",
"Method",
"method",
"=",
"systemMXBean",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodName",
")",
";",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"Object",
"value",
"=",
"method",
".",
"invoke",
"(",
"systemMXBean",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Long",
")",
"{",
"return",
"(",
"Long",
")",
"value",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Double",
")",
"{",
"double",
"v",
"=",
"(",
"Double",
")",
"value",
";",
"return",
"Math",
".",
"round",
"(",
"v",
"*",
"PERCENTAGE_MULTIPLIER",
")",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"value",
")",
".",
"longValue",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"RuntimeException",
"re",
")",
"{",
"throw",
"re",
";",
"}",
"catch",
"(",
"Exception",
"ignored",
")",
"{",
"ignore",
"(",
"ignored",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] |
Reads a long attribute from OperatingSystemMXBean.
@param attributeName name of the attribute
@param defaultValue default value if the attribute value is null
@return value of the attribute
|
[
"Reads",
"a",
"long",
"attribute",
"from",
"OperatingSystemMXBean",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/OperatingSystemMXBeanSupport.java#L43-L74
|
15,337
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java
|
MigrationManager.addCompletedMigration
|
boolean addCompletedMigration(MigrationInfo migrationInfo) {
if (migrationInfo.getStatus() != MigrationStatus.SUCCESS
&& migrationInfo.getStatus() != MigrationStatus.FAILED) {
throw new IllegalArgumentException("Migration doesn't seem completed: " + migrationInfo);
}
if (migrationInfo.getInitialPartitionVersion() <= 0 || migrationInfo.getPartitionVersionIncrement() <= 0) {
throw new IllegalArgumentException("Partition state versions are not set: " + migrationInfo);
}
partitionServiceLock.lock();
try {
boolean added = completedMigrations.add(migrationInfo);
if (added) {
stats.incrementCompletedMigrations();
}
return added;
} finally {
partitionServiceLock.unlock();
}
}
|
java
|
boolean addCompletedMigration(MigrationInfo migrationInfo) {
if (migrationInfo.getStatus() != MigrationStatus.SUCCESS
&& migrationInfo.getStatus() != MigrationStatus.FAILED) {
throw new IllegalArgumentException("Migration doesn't seem completed: " + migrationInfo);
}
if (migrationInfo.getInitialPartitionVersion() <= 0 || migrationInfo.getPartitionVersionIncrement() <= 0) {
throw new IllegalArgumentException("Partition state versions are not set: " + migrationInfo);
}
partitionServiceLock.lock();
try {
boolean added = completedMigrations.add(migrationInfo);
if (added) {
stats.incrementCompletedMigrations();
}
return added;
} finally {
partitionServiceLock.unlock();
}
}
|
[
"boolean",
"addCompletedMigration",
"(",
"MigrationInfo",
"migrationInfo",
")",
"{",
"if",
"(",
"migrationInfo",
".",
"getStatus",
"(",
")",
"!=",
"MigrationStatus",
".",
"SUCCESS",
"&&",
"migrationInfo",
".",
"getStatus",
"(",
")",
"!=",
"MigrationStatus",
".",
"FAILED",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Migration doesn't seem completed: \"",
"+",
"migrationInfo",
")",
";",
"}",
"if",
"(",
"migrationInfo",
".",
"getInitialPartitionVersion",
"(",
")",
"<=",
"0",
"||",
"migrationInfo",
".",
"getPartitionVersionIncrement",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Partition state versions are not set: \"",
"+",
"migrationInfo",
")",
";",
"}",
"partitionServiceLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"boolean",
"added",
"=",
"completedMigrations",
".",
"add",
"(",
"migrationInfo",
")",
";",
"if",
"(",
"added",
")",
"{",
"stats",
".",
"incrementCompletedMigrations",
"(",
")",
";",
"}",
"return",
"added",
";",
"}",
"finally",
"{",
"partitionServiceLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Adds the migration to the set of completed migrations and increases the completed migration counter.
Acquires the partition service lock to update the migrations.
@param migrationInfo the completed migration
@return {@code true} if the migration has been added or {@code false} if this migration is already in the completed set
@throws IllegalArgumentException if the migration is not completed
|
[
"Adds",
"the",
"migration",
"to",
"the",
"set",
"of",
"completed",
"migrations",
"and",
"increases",
"the",
"completed",
"migration",
"counter",
".",
"Acquires",
"the",
"partition",
"service",
"lock",
"to",
"update",
"the",
"migrations",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java#L432-L452
|
15,338
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java
|
MigrationManager.evictCompletedMigrations
|
private void evictCompletedMigrations(Collection<MigrationInfo> migrations) {
partitionServiceLock.lock();
try {
completedMigrations.removeAll(migrations);
} finally {
partitionServiceLock.unlock();
}
}
|
java
|
private void evictCompletedMigrations(Collection<MigrationInfo> migrations) {
partitionServiceLock.lock();
try {
completedMigrations.removeAll(migrations);
} finally {
partitionServiceLock.unlock();
}
}
|
[
"private",
"void",
"evictCompletedMigrations",
"(",
"Collection",
"<",
"MigrationInfo",
">",
"migrations",
")",
"{",
"partitionServiceLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"completedMigrations",
".",
"removeAll",
"(",
"migrations",
")",
";",
"}",
"finally",
"{",
"partitionServiceLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Evicts completed migrations from the list
@param migrations completed migrations to evict
|
[
"Evicts",
"completed",
"migrations",
"from",
"the",
"list"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java#L469-L476
|
15,339
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java
|
MigrationManager.triggerControlTask
|
void triggerControlTask() {
migrationQueue.clear();
if (!node.getClusterService().isJoined()) {
logger.fine("Node is not joined, will not trigger ControlTask");
return;
}
if (!node.isMaster()) {
logger.fine("Node is not master, will not trigger ControlTask");
return;
}
migrationQueue.add(new ControlTask());
if (logger.isFinestEnabled()) {
logger.finest("Migration queue is cleared and control task is scheduled");
}
}
|
java
|
void triggerControlTask() {
migrationQueue.clear();
if (!node.getClusterService().isJoined()) {
logger.fine("Node is not joined, will not trigger ControlTask");
return;
}
if (!node.isMaster()) {
logger.fine("Node is not master, will not trigger ControlTask");
return;
}
migrationQueue.add(new ControlTask());
if (logger.isFinestEnabled()) {
logger.finest("Migration queue is cleared and control task is scheduled");
}
}
|
[
"void",
"triggerControlTask",
"(",
")",
"{",
"migrationQueue",
".",
"clear",
"(",
")",
";",
"if",
"(",
"!",
"node",
".",
"getClusterService",
"(",
")",
".",
"isJoined",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Node is not joined, will not trigger ControlTask\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"node",
".",
"isMaster",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Node is not master, will not trigger ControlTask\"",
")",
";",
"return",
";",
"}",
"migrationQueue",
".",
"add",
"(",
"new",
"ControlTask",
"(",
")",
")",
";",
"if",
"(",
"logger",
".",
"isFinestEnabled",
"(",
")",
")",
"{",
"logger",
".",
"finest",
"(",
"\"Migration queue is cleared and control task is scheduled\"",
")",
";",
"}",
"}"
] |
Clears the migration queue and triggers the control task. Called on the master node.
|
[
"Clears",
"the",
"migration",
"queue",
"and",
"triggers",
"the",
"control",
"task",
".",
"Called",
"on",
"the",
"master",
"node",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java#L479-L493
|
15,340
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java
|
MigrationManager.applyMigration
|
void applyMigration(InternalPartitionImpl partition, MigrationInfo migrationInfo) {
final PartitionReplica[] members = Arrays.copyOf(partition.getReplicas(), InternalPartition.MAX_REPLICA_COUNT);
if (migrationInfo.getSourceCurrentReplicaIndex() > -1) {
members[migrationInfo.getSourceCurrentReplicaIndex()] = null;
}
if (migrationInfo.getDestinationCurrentReplicaIndex() > -1) {
members[migrationInfo.getDestinationCurrentReplicaIndex()] = null;
}
members[migrationInfo.getDestinationNewReplicaIndex()] = migrationInfo.getDestination();
if (migrationInfo.getSourceNewReplicaIndex() > -1) {
members[migrationInfo.getSourceNewReplicaIndex()] = migrationInfo.getSource();
}
partition.setReplicas(members);
}
|
java
|
void applyMigration(InternalPartitionImpl partition, MigrationInfo migrationInfo) {
final PartitionReplica[] members = Arrays.copyOf(partition.getReplicas(), InternalPartition.MAX_REPLICA_COUNT);
if (migrationInfo.getSourceCurrentReplicaIndex() > -1) {
members[migrationInfo.getSourceCurrentReplicaIndex()] = null;
}
if (migrationInfo.getDestinationCurrentReplicaIndex() > -1) {
members[migrationInfo.getDestinationCurrentReplicaIndex()] = null;
}
members[migrationInfo.getDestinationNewReplicaIndex()] = migrationInfo.getDestination();
if (migrationInfo.getSourceNewReplicaIndex() > -1) {
members[migrationInfo.getSourceNewReplicaIndex()] = migrationInfo.getSource();
}
partition.setReplicas(members);
}
|
[
"void",
"applyMigration",
"(",
"InternalPartitionImpl",
"partition",
",",
"MigrationInfo",
"migrationInfo",
")",
"{",
"final",
"PartitionReplica",
"[",
"]",
"members",
"=",
"Arrays",
".",
"copyOf",
"(",
"partition",
".",
"getReplicas",
"(",
")",
",",
"InternalPartition",
".",
"MAX_REPLICA_COUNT",
")",
";",
"if",
"(",
"migrationInfo",
".",
"getSourceCurrentReplicaIndex",
"(",
")",
">",
"-",
"1",
")",
"{",
"members",
"[",
"migrationInfo",
".",
"getSourceCurrentReplicaIndex",
"(",
")",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"migrationInfo",
".",
"getDestinationCurrentReplicaIndex",
"(",
")",
">",
"-",
"1",
")",
"{",
"members",
"[",
"migrationInfo",
".",
"getDestinationCurrentReplicaIndex",
"(",
")",
"]",
"=",
"null",
";",
"}",
"members",
"[",
"migrationInfo",
".",
"getDestinationNewReplicaIndex",
"(",
")",
"]",
"=",
"migrationInfo",
".",
"getDestination",
"(",
")",
";",
"if",
"(",
"migrationInfo",
".",
"getSourceNewReplicaIndex",
"(",
")",
">",
"-",
"1",
")",
"{",
"members",
"[",
"migrationInfo",
".",
"getSourceNewReplicaIndex",
"(",
")",
"]",
"=",
"migrationInfo",
".",
"getSource",
"(",
")",
";",
"}",
"partition",
".",
"setReplicas",
"(",
"members",
")",
";",
"}"
] |
Mutates the partition state and applies the migration.
|
[
"Mutates",
"the",
"partition",
"state",
"and",
"applies",
"the",
"migration",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/MigrationManager.java#L580-L593
|
15,341
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/nio/SelectorOptimizer.java
|
SelectorOptimizer.newSelector
|
static Selector newSelector(ILogger logger) {
checkNotNull(logger, "logger");
Selector selector;
try {
selector = Selector.open();
} catch (IOException e) {
throw new HazelcastException("Failed to open a Selector", e);
}
boolean optimize = Boolean.parseBoolean(System.getProperty("hazelcast.io.optimizeselector", "true"));
if (optimize) {
optimize(selector, logger);
}
return selector;
}
|
java
|
static Selector newSelector(ILogger logger) {
checkNotNull(logger, "logger");
Selector selector;
try {
selector = Selector.open();
} catch (IOException e) {
throw new HazelcastException("Failed to open a Selector", e);
}
boolean optimize = Boolean.parseBoolean(System.getProperty("hazelcast.io.optimizeselector", "true"));
if (optimize) {
optimize(selector, logger);
}
return selector;
}
|
[
"static",
"Selector",
"newSelector",
"(",
"ILogger",
"logger",
")",
"{",
"checkNotNull",
"(",
"logger",
",",
"\"logger\"",
")",
";",
"Selector",
"selector",
";",
"try",
"{",
"selector",
"=",
"Selector",
".",
"open",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"\"Failed to open a Selector\"",
",",
"e",
")",
";",
"}",
"boolean",
"optimize",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"System",
".",
"getProperty",
"(",
"\"hazelcast.io.optimizeselector\"",
",",
"\"true\"",
")",
")",
";",
"if",
"(",
"optimize",
")",
"{",
"optimize",
"(",
"selector",
",",
"logger",
")",
";",
"}",
"return",
"selector",
";",
"}"
] |
Creates a new Selector and will optimize it if possible.
@param logger the logger used for the optimization process.
@return the created Selector.
@throws NullPointerException if logger is null.
|
[
"Creates",
"a",
"new",
"Selector",
"and",
"will",
"optimize",
"it",
"if",
"possible",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/nio/SelectorOptimizer.java#L55-L70
|
15,342
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/nio/SelectorOptimizer.java
|
SelectorOptimizer.optimize
|
static SelectionKeysSet optimize(Selector selector, ILogger logger) {
checkNotNull(selector, "selector");
checkNotNull(logger, "logger");
try {
SelectionKeysSet set = new SelectionKeysSet();
Class<?> selectorImplClass = findOptimizableSelectorClass(selector);
if (selectorImplClass == null) {
return null;
}
Field selectedKeysField = selectorImplClass.getDeclaredField("selectedKeys");
selectedKeysField.setAccessible(true);
Field publicSelectedKeysField = selectorImplClass.getDeclaredField("publicSelectedKeys");
publicSelectedKeysField.setAccessible(true);
selectedKeysField.set(selector, set);
publicSelectedKeysField.set(selector, set);
logger.finest("Optimized Selector: " + selector.getClass().getName());
return set;
} catch (Throwable t) {
// we don't want to print at warning level because it could very well be that the target JVM doesn't
// support this optimization. That is why we print on finest
logger.finest("Failed to optimize Selector: " + selector.getClass().getName(), t);
return null;
}
}
|
java
|
static SelectionKeysSet optimize(Selector selector, ILogger logger) {
checkNotNull(selector, "selector");
checkNotNull(logger, "logger");
try {
SelectionKeysSet set = new SelectionKeysSet();
Class<?> selectorImplClass = findOptimizableSelectorClass(selector);
if (selectorImplClass == null) {
return null;
}
Field selectedKeysField = selectorImplClass.getDeclaredField("selectedKeys");
selectedKeysField.setAccessible(true);
Field publicSelectedKeysField = selectorImplClass.getDeclaredField("publicSelectedKeys");
publicSelectedKeysField.setAccessible(true);
selectedKeysField.set(selector, set);
publicSelectedKeysField.set(selector, set);
logger.finest("Optimized Selector: " + selector.getClass().getName());
return set;
} catch (Throwable t) {
// we don't want to print at warning level because it could very well be that the target JVM doesn't
// support this optimization. That is why we print on finest
logger.finest("Failed to optimize Selector: " + selector.getClass().getName(), t);
return null;
}
}
|
[
"static",
"SelectionKeysSet",
"optimize",
"(",
"Selector",
"selector",
",",
"ILogger",
"logger",
")",
"{",
"checkNotNull",
"(",
"selector",
",",
"\"selector\"",
")",
";",
"checkNotNull",
"(",
"logger",
",",
"\"logger\"",
")",
";",
"try",
"{",
"SelectionKeysSet",
"set",
"=",
"new",
"SelectionKeysSet",
"(",
")",
";",
"Class",
"<",
"?",
">",
"selectorImplClass",
"=",
"findOptimizableSelectorClass",
"(",
"selector",
")",
";",
"if",
"(",
"selectorImplClass",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Field",
"selectedKeysField",
"=",
"selectorImplClass",
".",
"getDeclaredField",
"(",
"\"selectedKeys\"",
")",
";",
"selectedKeysField",
".",
"setAccessible",
"(",
"true",
")",
";",
"Field",
"publicSelectedKeysField",
"=",
"selectorImplClass",
".",
"getDeclaredField",
"(",
"\"publicSelectedKeys\"",
")",
";",
"publicSelectedKeysField",
".",
"setAccessible",
"(",
"true",
")",
";",
"selectedKeysField",
".",
"set",
"(",
"selector",
",",
"set",
")",
";",
"publicSelectedKeysField",
".",
"set",
"(",
"selector",
",",
"set",
")",
";",
"logger",
".",
"finest",
"(",
"\"Optimized Selector: \"",
"+",
"selector",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"return",
"set",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// we don't want to print at warning level because it could very well be that the target JVM doesn't",
"// support this optimization. That is why we print on finest",
"logger",
".",
"finest",
"(",
"\"Failed to optimize Selector: \"",
"+",
"selector",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"t",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Tries to optimize the provided Selector.
@param selector the selector to optimize
@return an FastSelectionKeySet if the optimization was a success, null otherwise.
@throws NullPointerException if selector or logger is null.
|
[
"Tries",
"to",
"optimize",
"the",
"provided",
"Selector",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/nio/SelectorOptimizer.java#L79-L108
|
15,343
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/DefaultQueryCache.java
|
DefaultQueryCache.isTryRecoverSucceeded
|
private boolean isTryRecoverSucceeded(ConcurrentMap<Integer, Long> brokenSequences) {
int numberOfBrokenSequences = brokenSequences.size();
InvokerWrapper invokerWrapper = context.getInvokerWrapper();
SubscriberContext subscriberContext = context.getSubscriberContext();
SubscriberContextSupport subscriberContextSupport = subscriberContext.getSubscriberContextSupport();
List<Future<Object>> futures = new ArrayList<>(numberOfBrokenSequences);
for (Map.Entry<Integer, Long> entry : brokenSequences.entrySet()) {
Integer partitionId = entry.getKey();
Long sequence = entry.getValue();
Object recoveryOperation
= subscriberContextSupport.createRecoveryOperation(mapName, cacheId, sequence, partitionId);
Future<Object> future
= (Future<Object>)
invokerWrapper.invokeOnPartitionOwner(recoveryOperation, partitionId);
futures.add(future);
}
Collection<Object> results = FutureUtil.returnWithDeadline(futures, 1, MINUTES);
int successCount = 0;
for (Object object : results) {
Boolean resolvedResponse = subscriberContextSupport.resolveResponseForRecoveryOperation(object);
if (TRUE.equals(resolvedResponse)) {
successCount++;
}
}
return successCount == numberOfBrokenSequences;
}
|
java
|
private boolean isTryRecoverSucceeded(ConcurrentMap<Integer, Long> brokenSequences) {
int numberOfBrokenSequences = brokenSequences.size();
InvokerWrapper invokerWrapper = context.getInvokerWrapper();
SubscriberContext subscriberContext = context.getSubscriberContext();
SubscriberContextSupport subscriberContextSupport = subscriberContext.getSubscriberContextSupport();
List<Future<Object>> futures = new ArrayList<>(numberOfBrokenSequences);
for (Map.Entry<Integer, Long> entry : brokenSequences.entrySet()) {
Integer partitionId = entry.getKey();
Long sequence = entry.getValue();
Object recoveryOperation
= subscriberContextSupport.createRecoveryOperation(mapName, cacheId, sequence, partitionId);
Future<Object> future
= (Future<Object>)
invokerWrapper.invokeOnPartitionOwner(recoveryOperation, partitionId);
futures.add(future);
}
Collection<Object> results = FutureUtil.returnWithDeadline(futures, 1, MINUTES);
int successCount = 0;
for (Object object : results) {
Boolean resolvedResponse = subscriberContextSupport.resolveResponseForRecoveryOperation(object);
if (TRUE.equals(resolvedResponse)) {
successCount++;
}
}
return successCount == numberOfBrokenSequences;
}
|
[
"private",
"boolean",
"isTryRecoverSucceeded",
"(",
"ConcurrentMap",
"<",
"Integer",
",",
"Long",
">",
"brokenSequences",
")",
"{",
"int",
"numberOfBrokenSequences",
"=",
"brokenSequences",
".",
"size",
"(",
")",
";",
"InvokerWrapper",
"invokerWrapper",
"=",
"context",
".",
"getInvokerWrapper",
"(",
")",
";",
"SubscriberContext",
"subscriberContext",
"=",
"context",
".",
"getSubscriberContext",
"(",
")",
";",
"SubscriberContextSupport",
"subscriberContextSupport",
"=",
"subscriberContext",
".",
"getSubscriberContextSupport",
"(",
")",
";",
"List",
"<",
"Future",
"<",
"Object",
">",
">",
"futures",
"=",
"new",
"ArrayList",
"<>",
"(",
"numberOfBrokenSequences",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"Long",
">",
"entry",
":",
"brokenSequences",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"partitionId",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Long",
"sequence",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"Object",
"recoveryOperation",
"=",
"subscriberContextSupport",
".",
"createRecoveryOperation",
"(",
"mapName",
",",
"cacheId",
",",
"sequence",
",",
"partitionId",
")",
";",
"Future",
"<",
"Object",
">",
"future",
"=",
"(",
"Future",
"<",
"Object",
">",
")",
"invokerWrapper",
".",
"invokeOnPartitionOwner",
"(",
"recoveryOperation",
",",
"partitionId",
")",
";",
"futures",
".",
"add",
"(",
"future",
")",
";",
"}",
"Collection",
"<",
"Object",
">",
"results",
"=",
"FutureUtil",
".",
"returnWithDeadline",
"(",
"futures",
",",
"1",
",",
"MINUTES",
")",
";",
"int",
"successCount",
"=",
"0",
";",
"for",
"(",
"Object",
"object",
":",
"results",
")",
"{",
"Boolean",
"resolvedResponse",
"=",
"subscriberContextSupport",
".",
"resolveResponseForRecoveryOperation",
"(",
"object",
")",
";",
"if",
"(",
"TRUE",
".",
"equals",
"(",
"resolvedResponse",
")",
")",
"{",
"successCount",
"++",
";",
"}",
"}",
"return",
"successCount",
"==",
"numberOfBrokenSequences",
";",
"}"
] |
This tries to reset cursor position of the accumulator to the supplied sequence,
if that sequence is still there, it will be succeeded, otherwise query cache content stays inconsistent.
|
[
"This",
"tries",
"to",
"reset",
"cursor",
"position",
"of",
"the",
"accumulator",
"to",
"the",
"supplied",
"sequence",
"if",
"that",
"sequence",
"is",
"still",
"there",
"it",
"will",
"be",
"succeeded",
"otherwise",
"query",
"cache",
"content",
"stays",
"inconsistent",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/DefaultQueryCache.java#L146-L173
|
15,344
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/fd/PhiAccrualFailureDetector.java
|
PhiAccrualFailureDetector.firstHeartbeat
|
@SuppressWarnings("checkstyle:magicnumber")
private void firstHeartbeat(long firstHeartbeatEstimateMillis) {
long stdDeviationMillis = firstHeartbeatEstimateMillis / 4;
heartbeatHistory.add(firstHeartbeatEstimateMillis - stdDeviationMillis);
heartbeatHistory.add(firstHeartbeatEstimateMillis + stdDeviationMillis);
}
|
java
|
@SuppressWarnings("checkstyle:magicnumber")
private void firstHeartbeat(long firstHeartbeatEstimateMillis) {
long stdDeviationMillis = firstHeartbeatEstimateMillis / 4;
heartbeatHistory.add(firstHeartbeatEstimateMillis - stdDeviationMillis);
heartbeatHistory.add(firstHeartbeatEstimateMillis + stdDeviationMillis);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"private",
"void",
"firstHeartbeat",
"(",
"long",
"firstHeartbeatEstimateMillis",
")",
"{",
"long",
"stdDeviationMillis",
"=",
"firstHeartbeatEstimateMillis",
"/",
"4",
";",
"heartbeatHistory",
".",
"add",
"(",
"firstHeartbeatEstimateMillis",
"-",
"stdDeviationMillis",
")",
";",
"heartbeatHistory",
".",
"add",
"(",
"firstHeartbeatEstimateMillis",
"+",
"stdDeviationMillis",
")",
";",
"}"
] |
bootstrap with 2 entries with rather high standard deviation
|
[
"bootstrap",
"with",
"2",
"entries",
"with",
"rather",
"high",
"standard",
"deviation"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/fd/PhiAccrualFailureDetector.java#L92-L97
|
15,345
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/fd/PhiAccrualFailureDetector.java
|
PhiAccrualFailureDetector.phi
|
private double phi(long timestampMillis) {
long timeDiffMillis;
double meanMillis;
double stdDeviationMillis;
synchronized (heartbeatHistory) {
long lastTimestampMillis = lastHeartbeatMillis;
if (lastTimestampMillis == NO_HEARTBEAT_TIMESTAMP) {
return 0.0;
}
timeDiffMillis = timestampMillis - lastTimestampMillis;
meanMillis = heartbeatHistory.mean();
stdDeviationMillis = ensureValidStdDeviation(heartbeatHistory.stdDeviation());
}
return phi(timeDiffMillis, meanMillis + acceptableHeartbeatPauseMillis, stdDeviationMillis);
}
|
java
|
private double phi(long timestampMillis) {
long timeDiffMillis;
double meanMillis;
double stdDeviationMillis;
synchronized (heartbeatHistory) {
long lastTimestampMillis = lastHeartbeatMillis;
if (lastTimestampMillis == NO_HEARTBEAT_TIMESTAMP) {
return 0.0;
}
timeDiffMillis = timestampMillis - lastTimestampMillis;
meanMillis = heartbeatHistory.mean();
stdDeviationMillis = ensureValidStdDeviation(heartbeatHistory.stdDeviation());
}
return phi(timeDiffMillis, meanMillis + acceptableHeartbeatPauseMillis, stdDeviationMillis);
}
|
[
"private",
"double",
"phi",
"(",
"long",
"timestampMillis",
")",
"{",
"long",
"timeDiffMillis",
";",
"double",
"meanMillis",
";",
"double",
"stdDeviationMillis",
";",
"synchronized",
"(",
"heartbeatHistory",
")",
"{",
"long",
"lastTimestampMillis",
"=",
"lastHeartbeatMillis",
";",
"if",
"(",
"lastTimestampMillis",
"==",
"NO_HEARTBEAT_TIMESTAMP",
")",
"{",
"return",
"0.0",
";",
"}",
"timeDiffMillis",
"=",
"timestampMillis",
"-",
"lastTimestampMillis",
";",
"meanMillis",
"=",
"heartbeatHistory",
".",
"mean",
"(",
")",
";",
"stdDeviationMillis",
"=",
"ensureValidStdDeviation",
"(",
"heartbeatHistory",
".",
"stdDeviation",
"(",
")",
")",
";",
"}",
"return",
"phi",
"(",
"timeDiffMillis",
",",
"meanMillis",
"+",
"acceptableHeartbeatPauseMillis",
",",
"stdDeviationMillis",
")",
";",
"}"
] |
The suspicion level of the accrual failure detector.
If a connection does not have any records in failure detector then it is
considered healthy.
|
[
"The",
"suspicion",
"level",
"of",
"the",
"accrual",
"failure",
"detector",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/fd/PhiAccrualFailureDetector.java#L109-L126
|
15,346
|
hazelcast/hazelcast
|
hazelcast-build-utils/src/main/java/com/hazelcast/buildutils/ElementParser.java
|
ElementParser.parseDelimitedString
|
public static List<String> parseDelimitedString(String value, char delimiter, boolean trim) {
if (value == null) {
value = "";
}
List<String> list = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
int expecting = (CHAR | DELIMITER | START_QUOTE);
for (int i = 0; i < value.length(); i++) {
char character = value.charAt(i);
boolean isEscaped = isEscaped(value, i);
boolean isDelimiter = isDelimiter(delimiter, character, isEscaped);
boolean isQuote = isQuote(character, isEscaped);
if (isDelimiter && ((expecting & DELIMITER) > 0)) {
addPart(list, sb, trim);
sb.delete(0, sb.length());
expecting = (CHAR | DELIMITER | START_QUOTE);
} else if (isQuote && ((expecting & START_QUOTE) > 0)) {
sb.append(character);
expecting = CHAR | END_QUOTE;
} else if (isQuote && ((expecting & END_QUOTE) > 0)) {
sb.append(character);
expecting = (CHAR | START_QUOTE | DELIMITER);
} else if ((expecting & CHAR) > 0) {
sb.append(character);
} else {
String message = String.format("Invalid delimited string [%s] for delimiter: %s", value, delimiter);
throw new IllegalArgumentException(message);
}
}
if (sb.length() > 0) {
addPart(list, sb, trim);
}
return list;
}
|
java
|
public static List<String> parseDelimitedString(String value, char delimiter, boolean trim) {
if (value == null) {
value = "";
}
List<String> list = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
int expecting = (CHAR | DELIMITER | START_QUOTE);
for (int i = 0; i < value.length(); i++) {
char character = value.charAt(i);
boolean isEscaped = isEscaped(value, i);
boolean isDelimiter = isDelimiter(delimiter, character, isEscaped);
boolean isQuote = isQuote(character, isEscaped);
if (isDelimiter && ((expecting & DELIMITER) > 0)) {
addPart(list, sb, trim);
sb.delete(0, sb.length());
expecting = (CHAR | DELIMITER | START_QUOTE);
} else if (isQuote && ((expecting & START_QUOTE) > 0)) {
sb.append(character);
expecting = CHAR | END_QUOTE;
} else if (isQuote && ((expecting & END_QUOTE) > 0)) {
sb.append(character);
expecting = (CHAR | START_QUOTE | DELIMITER);
} else if ((expecting & CHAR) > 0) {
sb.append(character);
} else {
String message = String.format("Invalid delimited string [%s] for delimiter: %s", value, delimiter);
throw new IllegalArgumentException(message);
}
}
if (sb.length() > 0) {
addPart(list, sb, trim);
}
return list;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"parseDelimitedString",
"(",
"String",
"value",
",",
"char",
"delimiter",
",",
"boolean",
"trim",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"\"\"",
";",
"}",
"List",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"expecting",
"=",
"(",
"CHAR",
"|",
"DELIMITER",
"|",
"START_QUOTE",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"character",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"boolean",
"isEscaped",
"=",
"isEscaped",
"(",
"value",
",",
"i",
")",
";",
"boolean",
"isDelimiter",
"=",
"isDelimiter",
"(",
"delimiter",
",",
"character",
",",
"isEscaped",
")",
";",
"boolean",
"isQuote",
"=",
"isQuote",
"(",
"character",
",",
"isEscaped",
")",
";",
"if",
"(",
"isDelimiter",
"&&",
"(",
"(",
"expecting",
"&",
"DELIMITER",
")",
">",
"0",
")",
")",
"{",
"addPart",
"(",
"list",
",",
"sb",
",",
"trim",
")",
";",
"sb",
".",
"delete",
"(",
"0",
",",
"sb",
".",
"length",
"(",
")",
")",
";",
"expecting",
"=",
"(",
"CHAR",
"|",
"DELIMITER",
"|",
"START_QUOTE",
")",
";",
"}",
"else",
"if",
"(",
"isQuote",
"&&",
"(",
"(",
"expecting",
"&",
"START_QUOTE",
")",
">",
"0",
")",
")",
"{",
"sb",
".",
"append",
"(",
"character",
")",
";",
"expecting",
"=",
"CHAR",
"|",
"END_QUOTE",
";",
"}",
"else",
"if",
"(",
"isQuote",
"&&",
"(",
"(",
"expecting",
"&",
"END_QUOTE",
")",
">",
"0",
")",
")",
"{",
"sb",
".",
"append",
"(",
"character",
")",
";",
"expecting",
"=",
"(",
"CHAR",
"|",
"START_QUOTE",
"|",
"DELIMITER",
")",
";",
"}",
"else",
"if",
"(",
"(",
"expecting",
"&",
"CHAR",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"character",
")",
";",
"}",
"else",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Invalid delimited string [%s] for delimiter: %s\"",
",",
"value",
",",
"delimiter",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"}",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"addPart",
"(",
"list",
",",
"sb",
",",
"trim",
")",
";",
"}",
"return",
"list",
";",
"}"
] |
Parses delimited string and returns an array containing the tokens. This parser obeys quotes, so the delimiter character
will be ignored if it is inside of a quote. This method assumes that the quote character is not included in the set of
delimiter characters.
@param value the delimited string to parse.
@param delimiter the characters delimiting the tokens.
@param trim whether to trim the parts.
@return an array of string tokens or null if there were no tokens.
|
[
"Parses",
"delimited",
"string",
"and",
"returns",
"an",
"array",
"containing",
"the",
"tokens",
".",
"This",
"parser",
"obeys",
"quotes",
"so",
"the",
"delimiter",
"character",
"will",
"be",
"ignored",
"if",
"it",
"is",
"inside",
"of",
"a",
"quote",
".",
"This",
"method",
"assumes",
"that",
"the",
"quote",
"character",
"is",
"not",
"included",
"in",
"the",
"set",
"of",
"delimiter",
"characters",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-build-utils/src/main/java/com/hazelcast/buildutils/ElementParser.java#L53-L92
|
15,347
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateResults
|
public static void validateResults(Map<Integer, Object> results) {
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
ExceptionUtil.sneakyThrow((Throwable) response);
}
}
}
}
|
java
|
public static void validateResults(Map<Integer, Object> results) {
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
ExceptionUtil.sneakyThrow((Throwable) response);
}
}
}
}
|
[
"public",
"static",
"void",
"validateResults",
"(",
"Map",
"<",
"Integer",
",",
"Object",
">",
"results",
")",
"{",
"for",
"(",
"Object",
"result",
":",
"results",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"result",
"!=",
"null",
"&&",
"result",
"instanceof",
"CacheClearResponse",
")",
"{",
"Object",
"response",
"=",
"(",
"(",
"CacheClearResponse",
")",
"result",
")",
".",
"getResponse",
"(",
")",
";",
"if",
"(",
"response",
"instanceof",
"Throwable",
")",
"{",
"ExceptionUtil",
".",
"sneakyThrow",
"(",
"(",
"Throwable",
")",
"response",
")",
";",
"}",
"}",
"}",
"}"
] |
Cache clear response validator, loop on results to validate that no exception exists on the result map.
Throws the first exception in the map.
@param results map of {@link CacheClearResponse}.
|
[
"Cache",
"clear",
"response",
"validator",
"loop",
"on",
"results",
"to",
"validate",
"that",
"no",
"exception",
"exists",
"on",
"the",
"result",
"map",
".",
"Throws",
"the",
"first",
"exception",
"in",
"the",
"map",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L52-L61
|
15,348
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateNotNull
|
public static <K, V> void validateNotNull(K key, V value) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
}
|
java
|
public static <K, V> void validateNotNull(K key, V value) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"validateNotNull",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"checkNotNull",
"(",
"key",
",",
"NULL_KEY_IS_NOT_ALLOWED",
")",
";",
"checkNotNull",
"(",
"value",
",",
"NULL_VALUE_IS_NOT_ALLOWED",
")",
";",
"}"
] |
Validates that key, value pair are both not null.
@param key the key to be validated.
@param <K> the type of key.
@param value the value to be validated.
@param <V> the type of value.
@throws java.lang.NullPointerException if key or value is null.
|
[
"Validates",
"that",
"key",
"value",
"pair",
"are",
"both",
"not",
"null",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L87-L90
|
15,349
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateNotNull
|
public static <K, V> void validateNotNull(K key, V value1, V value2) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(value1, NULL_VALUE_IS_NOT_ALLOWED);
checkNotNull(value2, NULL_VALUE_IS_NOT_ALLOWED);
}
|
java
|
public static <K, V> void validateNotNull(K key, V value1, V value2) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(value1, NULL_VALUE_IS_NOT_ALLOWED);
checkNotNull(value2, NULL_VALUE_IS_NOT_ALLOWED);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"validateNotNull",
"(",
"K",
"key",
",",
"V",
"value1",
",",
"V",
"value2",
")",
"{",
"checkNotNull",
"(",
"key",
",",
"NULL_KEY_IS_NOT_ALLOWED",
")",
";",
"checkNotNull",
"(",
"value1",
",",
"NULL_VALUE_IS_NOT_ALLOWED",
")",
";",
"checkNotNull",
"(",
"value2",
",",
"NULL_VALUE_IS_NOT_ALLOWED",
")",
";",
"}"
] |
Validates that key and multi values are not null.
@param key the key to be validated.
@param value1 first value to be validated.
@param value2 second value to be validated.
@param <K> the type of key.
@param <V> the type of value.
@throws java.lang.NullPointerException if key or any value is null.
|
[
"Validates",
"that",
"key",
"and",
"multi",
"values",
"are",
"not",
"null",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L102-L106
|
15,350
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateNotNull
|
public static <K, V> void validateNotNull(Map<? extends K, ? extends V> map) {
checkNotNull(map, "map is null");
boolean containsNullKey = false;
boolean containsNullValue = false;
// we catch possible NPE since the Map implementation could not support null values
// TODO: is it possible to validate a map more efficiently without try-catch blocks?
try {
containsNullKey = map.containsKey(null);
} catch (NullPointerException e) {
// ignore if null key is not allowed for this map
ignore(e);
}
try {
containsNullValue = map.containsValue(null);
} catch (NullPointerException e) {
// ignore if null value is not allowed for this map
ignore(e);
}
if (containsNullKey) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (containsNullValue) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
}
|
java
|
public static <K, V> void validateNotNull(Map<? extends K, ? extends V> map) {
checkNotNull(map, "map is null");
boolean containsNullKey = false;
boolean containsNullValue = false;
// we catch possible NPE since the Map implementation could not support null values
// TODO: is it possible to validate a map more efficiently without try-catch blocks?
try {
containsNullKey = map.containsKey(null);
} catch (NullPointerException e) {
// ignore if null key is not allowed for this map
ignore(e);
}
try {
containsNullValue = map.containsValue(null);
} catch (NullPointerException e) {
// ignore if null value is not allowed for this map
ignore(e);
}
if (containsNullKey) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (containsNullValue) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"validateNotNull",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"map",
")",
"{",
"checkNotNull",
"(",
"map",
",",
"\"map is null\"",
")",
";",
"boolean",
"containsNullKey",
"=",
"false",
";",
"boolean",
"containsNullValue",
"=",
"false",
";",
"// we catch possible NPE since the Map implementation could not support null values",
"// TODO: is it possible to validate a map more efficiently without try-catch blocks?",
"try",
"{",
"containsNullKey",
"=",
"map",
".",
"containsKey",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"// ignore if null key is not allowed for this map",
"ignore",
"(",
"e",
")",
";",
"}",
"try",
"{",
"containsNullValue",
"=",
"map",
".",
"containsValue",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"// ignore if null value is not allowed for this map",
"ignore",
"(",
"e",
")",
";",
"}",
"if",
"(",
"containsNullKey",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"NULL_KEY_IS_NOT_ALLOWED",
")",
";",
"}",
"if",
"(",
"containsNullValue",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"NULL_VALUE_IS_NOT_ALLOWED",
")",
";",
"}",
"}"
] |
This validator ensures that no key or value is null in the provided map.
@param map the map to be validated.
@param <K> the type of key.
@param <V> the type of value.
@throws java.lang.NullPointerException if provided map contains a null key or value in the map.
|
[
"This",
"validator",
"ensures",
"that",
"no",
"key",
"or",
"value",
"is",
"null",
"in",
"the",
"provided",
"map",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L129-L154
|
15,351
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateConfiguredTypes
|
public static <K> void validateConfiguredTypes(CacheConfig cacheConfig, K key) throws ClassCastException {
Class keyType = cacheConfig.getKeyType();
validateConfiguredKeyType(keyType, key);
}
|
java
|
public static <K> void validateConfiguredTypes(CacheConfig cacheConfig, K key) throws ClassCastException {
Class keyType = cacheConfig.getKeyType();
validateConfiguredKeyType(keyType, key);
}
|
[
"public",
"static",
"<",
"K",
">",
"void",
"validateConfiguredTypes",
"(",
"CacheConfig",
"cacheConfig",
",",
"K",
"key",
")",
"throws",
"ClassCastException",
"{",
"Class",
"keyType",
"=",
"cacheConfig",
".",
"getKeyType",
"(",
")",
";",
"validateConfiguredKeyType",
"(",
"keyType",
",",
"key",
")",
";",
"}"
] |
Validates that the configured key matches the provided key.
@param cacheConfig Cache configuration.
@param key the key to be validated with its type.
@param <K> the type of key.
@throws ClassCastException if the provided key does not match with configured type.
|
[
"Validates",
"that",
"the",
"configured",
"key",
"matches",
"the",
"provided",
"key",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L164-L167
|
15,352
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateConfiguredTypes
|
public static <K, V> void validateConfiguredTypes(CacheConfig cacheConfig, K key, V value) throws ClassCastException {
Class keyType = cacheConfig.getKeyType();
Class valueType = cacheConfig.getValueType();
validateConfiguredKeyType(keyType, key);
validateConfiguredValueType(valueType, value);
}
|
java
|
public static <K, V> void validateConfiguredTypes(CacheConfig cacheConfig, K key, V value) throws ClassCastException {
Class keyType = cacheConfig.getKeyType();
Class valueType = cacheConfig.getValueType();
validateConfiguredKeyType(keyType, key);
validateConfiguredValueType(valueType, value);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"validateConfiguredTypes",
"(",
"CacheConfig",
"cacheConfig",
",",
"K",
"key",
",",
"V",
"value",
")",
"throws",
"ClassCastException",
"{",
"Class",
"keyType",
"=",
"cacheConfig",
".",
"getKeyType",
"(",
")",
";",
"Class",
"valueType",
"=",
"cacheConfig",
".",
"getValueType",
"(",
")",
";",
"validateConfiguredKeyType",
"(",
"keyType",
",",
"key",
")",
";",
"validateConfiguredValueType",
"(",
"valueType",
",",
"value",
")",
";",
"}"
] |
Validates the configured key and value types matches the provided key, value types.
@param cacheConfig Cache configuration.
@param key the key to be validated.
@param <K> the type of key.
@param value the value to be validated.
@param <V> the type of value.
@throws ClassCastException if the provided key or value do not match with configured types.
|
[
"Validates",
"the",
"configured",
"key",
"and",
"value",
"types",
"matches",
"the",
"provided",
"key",
"value",
"types",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L179-L184
|
15,353
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateConfiguredKeyType
|
public static <K> void validateConfiguredKeyType(Class<K> keyType, K key) throws ClassCastException {
if (Object.class != keyType) {
// means that type checks is required
if (!keyType.isAssignableFrom(key.getClass())) {
throw new ClassCastException("Key '" + key + "' is not assignable to " + keyType);
}
}
}
|
java
|
public static <K> void validateConfiguredKeyType(Class<K> keyType, K key) throws ClassCastException {
if (Object.class != keyType) {
// means that type checks is required
if (!keyType.isAssignableFrom(key.getClass())) {
throw new ClassCastException("Key '" + key + "' is not assignable to " + keyType);
}
}
}
|
[
"public",
"static",
"<",
"K",
">",
"void",
"validateConfiguredKeyType",
"(",
"Class",
"<",
"K",
">",
"keyType",
",",
"K",
"key",
")",
"throws",
"ClassCastException",
"{",
"if",
"(",
"Object",
".",
"class",
"!=",
"keyType",
")",
"{",
"// means that type checks is required",
"if",
"(",
"!",
"keyType",
".",
"isAssignableFrom",
"(",
"key",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"\"Key '\"",
"+",
"key",
"+",
"\"' is not assignable to \"",
"+",
"keyType",
")",
";",
"}",
"}",
"}"
] |
Validates the key with key type.
@param keyType key class.
@param key key to be validated.
@param <K> the type of key.
@throws ClassCastException if the provided key do not match with keyType.
|
[
"Validates",
"the",
"key",
"with",
"key",
"type",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L214-L221
|
15,354
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateConfiguredValueType
|
public static <V> void validateConfiguredValueType(Class<V> valueType, V value) throws ClassCastException {
if (Object.class != valueType) {
// means that type checks is required
if (!valueType.isAssignableFrom(value.getClass())) {
throw new ClassCastException("Value '" + value + "' is not assignable to " + valueType);
}
}
}
|
java
|
public static <V> void validateConfiguredValueType(Class<V> valueType, V value) throws ClassCastException {
if (Object.class != valueType) {
// means that type checks is required
if (!valueType.isAssignableFrom(value.getClass())) {
throw new ClassCastException("Value '" + value + "' is not assignable to " + valueType);
}
}
}
|
[
"public",
"static",
"<",
"V",
">",
"void",
"validateConfiguredValueType",
"(",
"Class",
"<",
"V",
">",
"valueType",
",",
"V",
"value",
")",
"throws",
"ClassCastException",
"{",
"if",
"(",
"Object",
".",
"class",
"!=",
"valueType",
")",
"{",
"// means that type checks is required",
"if",
"(",
"!",
"valueType",
".",
"isAssignableFrom",
"(",
"value",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"\"Value '\"",
"+",
"value",
"+",
"\"' is not assignable to \"",
"+",
"valueType",
")",
";",
"}",
"}",
"}"
] |
Validates the value with value type.
@param valueType value class.
@param value value to be validated.
@param <V> the type of value.
@throws ClassCastException if the provided value do not match with valueType.
|
[
"Validates",
"the",
"value",
"with",
"value",
"type",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L231-L238
|
15,355
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/concurrent/lock/LockResourceImpl.java
|
LockResourceImpl.extendLeaseTime
|
boolean extendLeaseTime(String caller, long threadId, long leaseTime) {
if (!isLockedBy(caller, threadId)) {
return false;
}
this.blockReads = true;
if (expirationTime < Long.MAX_VALUE) {
setExpirationTime(expirationTime - Clock.currentTimeMillis() + leaseTime);
}
return true;
}
|
java
|
boolean extendLeaseTime(String caller, long threadId, long leaseTime) {
if (!isLockedBy(caller, threadId)) {
return false;
}
this.blockReads = true;
if (expirationTime < Long.MAX_VALUE) {
setExpirationTime(expirationTime - Clock.currentTimeMillis() + leaseTime);
}
return true;
}
|
[
"boolean",
"extendLeaseTime",
"(",
"String",
"caller",
",",
"long",
"threadId",
",",
"long",
"leaseTime",
")",
"{",
"if",
"(",
"!",
"isLockedBy",
"(",
"caller",
",",
"threadId",
")",
")",
"{",
"return",
"false",
";",
"}",
"this",
".",
"blockReads",
"=",
"true",
";",
"if",
"(",
"expirationTime",
"<",
"Long",
".",
"MAX_VALUE",
")",
"{",
"setExpirationTime",
"(",
"expirationTime",
"-",
"Clock",
".",
"currentTimeMillis",
"(",
")",
"+",
"leaseTime",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
This method is used to extend the already locked resource in the prepare phase of the transactions.
It also marks the resource true to block reads.
@param caller
@param threadId
@param leaseTime
@return
|
[
"This",
"method",
"is",
"used",
"to",
"extend",
"the",
"already",
"locked",
"resource",
"in",
"the",
"prepare",
"phase",
"of",
"the",
"transactions",
".",
"It",
"also",
"marks",
"the",
"resource",
"true",
"to",
"block",
"reads",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/concurrent/lock/LockResourceImpl.java#L122-L131
|
15,356
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePathCursor.java
|
PortablePathCursor.init
|
void init(String path) {
this.path = checkHasText(path, "path cannot be null or empty");
this.index = 0;
this.offset = 0;
this.nextSplit = StringUtil.indexOf(path, '.', 0);
this.token = null;
if (nextSplit == 0) {
throw new IllegalArgumentException("The path cannot begin with a dot: " + path);
}
}
|
java
|
void init(String path) {
this.path = checkHasText(path, "path cannot be null or empty");
this.index = 0;
this.offset = 0;
this.nextSplit = StringUtil.indexOf(path, '.', 0);
this.token = null;
if (nextSplit == 0) {
throw new IllegalArgumentException("The path cannot begin with a dot: " + path);
}
}
|
[
"void",
"init",
"(",
"String",
"path",
")",
"{",
"this",
".",
"path",
"=",
"checkHasText",
"(",
"path",
",",
"\"path cannot be null or empty\"",
")",
";",
"this",
".",
"index",
"=",
"0",
";",
"this",
".",
"offset",
"=",
"0",
";",
"this",
".",
"nextSplit",
"=",
"StringUtil",
".",
"indexOf",
"(",
"path",
",",
"'",
"'",
",",
"0",
")",
";",
"this",
".",
"token",
"=",
"null",
";",
"if",
"(",
"nextSplit",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The path cannot begin with a dot: \"",
"+",
"path",
")",
";",
"}",
"}"
] |
Inits the cursor with the given path and sets the current position to the first token.
@param path path to initialise the cursor with
|
[
"Inits",
"the",
"cursor",
"with",
"the",
"given",
"path",
"and",
"sets",
"the",
"current",
"position",
"to",
"the",
"first",
"token",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePathCursor.java#L44-L53
|
15,357
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/topic/impl/TopicProxySupport.java
|
TopicProxySupport.publishInternal
|
public void publishInternal(Object message) {
topicStats.incrementPublishes();
topicService.publishMessage(name, message, multithreaded);
}
|
java
|
public void publishInternal(Object message) {
topicStats.incrementPublishes();
topicService.publishMessage(name, message, multithreaded);
}
|
[
"public",
"void",
"publishInternal",
"(",
"Object",
"message",
")",
"{",
"topicStats",
".",
"incrementPublishes",
"(",
")",
";",
"topicService",
".",
"publishMessage",
"(",
"name",
",",
"message",
",",
"multithreaded",
")",
";",
"}"
] |
Publishes the message and increases the local statistics
for the number of published messages.
@param message the message to be published
|
[
"Publishes",
"the",
"message",
"and",
"increases",
"the",
"local",
"statistics",
"for",
"the",
"number",
"of",
"published",
"messages",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/topic/impl/TopicProxySupport.java#L95-L98
|
15,358
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/instance/DefaultNodeExtension.java
|
DefaultNodeExtension.getClusterOrNodeVersion
|
private Version getClusterOrNodeVersion() {
if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
return node.getClusterService().getClusterVersion();
} else {
String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
: node.getVersion().asVersion();
}
}
|
java
|
private Version getClusterOrNodeVersion() {
if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
return node.getClusterService().getClusterVersion();
} else {
String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
: node.getVersion().asVersion();
}
}
|
[
"private",
"Version",
"getClusterOrNodeVersion",
"(",
")",
"{",
"if",
"(",
"node",
".",
"getClusterService",
"(",
")",
"!=",
"null",
"&&",
"!",
"node",
".",
"getClusterService",
"(",
")",
".",
"getClusterVersion",
"(",
")",
".",
"isUnknown",
"(",
")",
")",
"{",
"return",
"node",
".",
"getClusterService",
"(",
")",
".",
"getClusterVersion",
"(",
")",
";",
"}",
"else",
"{",
"String",
"overriddenClusterVersion",
"=",
"node",
".",
"getProperties",
"(",
")",
".",
"getString",
"(",
"GroupProperty",
".",
"INIT_CLUSTER_VERSION",
")",
";",
"return",
"(",
"overriddenClusterVersion",
"!=",
"null",
")",
"?",
"MemberVersion",
".",
"of",
"(",
"overriddenClusterVersion",
")",
".",
"asVersion",
"(",
")",
":",
"node",
".",
"getVersion",
"(",
")",
".",
"asVersion",
"(",
")",
";",
"}",
"}"
] |
otherwise, if not overridden, use current node's codebase version
|
[
"otherwise",
"if",
"not",
"overridden",
"use",
"current",
"node",
"s",
"codebase",
"version"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/instance/DefaultNodeExtension.java#L424-L432
|
15,359
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/JsonParser.java
|
JsonParser.parse
|
public void parse(String string) {
if (string == null) {
throw new NullPointerException("string is null");
}
int bufferSize = Math.max(MIN_BUFFER_SIZE, Math.min(DEFAULT_BUFFER_SIZE, string.length()));
try {
parse(new StringReader(string), bufferSize);
} catch (IOException exception) {
// StringReader does not throw IOException
throw new RuntimeException(exception);
}
}
|
java
|
public void parse(String string) {
if (string == null) {
throw new NullPointerException("string is null");
}
int bufferSize = Math.max(MIN_BUFFER_SIZE, Math.min(DEFAULT_BUFFER_SIZE, string.length()));
try {
parse(new StringReader(string), bufferSize);
} catch (IOException exception) {
// StringReader does not throw IOException
throw new RuntimeException(exception);
}
}
|
[
"public",
"void",
"parse",
"(",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"string is null\"",
")",
";",
"}",
"int",
"bufferSize",
"=",
"Math",
".",
"max",
"(",
"MIN_BUFFER_SIZE",
",",
"Math",
".",
"min",
"(",
"DEFAULT_BUFFER_SIZE",
",",
"string",
".",
"length",
"(",
")",
")",
")",
";",
"try",
"{",
"parse",
"(",
"new",
"StringReader",
"(",
"string",
")",
",",
"bufferSize",
")",
";",
"}",
"catch",
"(",
"IOException",
"exception",
")",
"{",
"// StringReader does not throw IOException",
"throw",
"new",
"RuntimeException",
"(",
"exception",
")",
";",
"}",
"}"
] |
Parses the given input string. The input must contain a valid JSON value, optionally padded
with whitespace.
@param string
the input string, must be valid JSON
@throws ParseException
if the input is not valid JSON
|
[
"Parses",
"the",
"given",
"input",
"string",
".",
"The",
"input",
"must",
"contain",
"a",
"valid",
"JSON",
"value",
"optionally",
"padded",
"with",
"whitespace",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonParser.java#L85-L96
|
15,360
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/crdt/CRDTReplicationTask.java
|
CRDTReplicationTask.getNonLocalReplicaAddresses
|
private List<Member> getNonLocalReplicaAddresses() {
final Collection<Member> dataMembers = nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR);
final ArrayList<Member> nonLocalDataMembers = new ArrayList<Member>(dataMembers);
nonLocalDataMembers.remove(nodeEngine.getLocalMember());
return nonLocalDataMembers;
}
|
java
|
private List<Member> getNonLocalReplicaAddresses() {
final Collection<Member> dataMembers = nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR);
final ArrayList<Member> nonLocalDataMembers = new ArrayList<Member>(dataMembers);
nonLocalDataMembers.remove(nodeEngine.getLocalMember());
return nonLocalDataMembers;
}
|
[
"private",
"List",
"<",
"Member",
">",
"getNonLocalReplicaAddresses",
"(",
")",
"{",
"final",
"Collection",
"<",
"Member",
">",
"dataMembers",
"=",
"nodeEngine",
".",
"getClusterService",
"(",
")",
".",
"getMembers",
"(",
"DATA_MEMBER_SELECTOR",
")",
";",
"final",
"ArrayList",
"<",
"Member",
">",
"nonLocalDataMembers",
"=",
"new",
"ArrayList",
"<",
"Member",
">",
"(",
"dataMembers",
")",
";",
"nonLocalDataMembers",
".",
"remove",
"(",
"nodeEngine",
".",
"getLocalMember",
"(",
")",
")",
";",
"return",
"nonLocalDataMembers",
";",
"}"
] |
Return the list of non-local CRDT replicas in the cluster.
|
[
"Return",
"the",
"list",
"of",
"non",
"-",
"local",
"CRDT",
"replicas",
"in",
"the",
"cluster",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/crdt/CRDTReplicationTask.java#L79-L84
|
15,361
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/monitor/impl/LocalMapStatsImpl.java
|
LocalMapStatsImpl.setIndexStats
|
public void setIndexStats(Map<String, LocalIndexStatsImpl> indexStats) {
this.mutableIndexStats.clear();
if (indexStats != null) {
this.mutableIndexStats.putAll(indexStats);
}
}
|
java
|
public void setIndexStats(Map<String, LocalIndexStatsImpl> indexStats) {
this.mutableIndexStats.clear();
if (indexStats != null) {
this.mutableIndexStats.putAll(indexStats);
}
}
|
[
"public",
"void",
"setIndexStats",
"(",
"Map",
"<",
"String",
",",
"LocalIndexStatsImpl",
">",
"indexStats",
")",
"{",
"this",
".",
"mutableIndexStats",
".",
"clear",
"(",
")",
";",
"if",
"(",
"indexStats",
"!=",
"null",
")",
"{",
"this",
".",
"mutableIndexStats",
".",
"putAll",
"(",
"indexStats",
")",
";",
"}",
"}"
] |
Sets the per-index stats of this map stats to the given per-index stats.
@param indexStats the per-index stats to set.
|
[
"Sets",
"the",
"per",
"-",
"index",
"stats",
"of",
"this",
"map",
"stats",
"to",
"the",
"given",
"per",
"-",
"index",
"stats",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/monitor/impl/LocalMapStatsImpl.java#L396-L401
|
15,362
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/matcher/MatchingPointConfigPatternMatcher.java
|
MatchingPointConfigPatternMatcher.getMatchingPoint
|
private int getMatchingPoint(String pattern, String itemName) {
int index = pattern.indexOf('*');
if (index == -1) {
return -1;
}
String firstPart = pattern.substring(0, index);
if (!itemName.startsWith(firstPart)) {
return -1;
}
String secondPart = pattern.substring(index + 1);
if (!itemName.endsWith(secondPart)) {
return -1;
}
return firstPart.length() + secondPart.length();
}
|
java
|
private int getMatchingPoint(String pattern, String itemName) {
int index = pattern.indexOf('*');
if (index == -1) {
return -1;
}
String firstPart = pattern.substring(0, index);
if (!itemName.startsWith(firstPart)) {
return -1;
}
String secondPart = pattern.substring(index + 1);
if (!itemName.endsWith(secondPart)) {
return -1;
}
return firstPart.length() + secondPart.length();
}
|
[
"private",
"int",
"getMatchingPoint",
"(",
"String",
"pattern",
",",
"String",
"itemName",
")",
"{",
"int",
"index",
"=",
"pattern",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"String",
"firstPart",
"=",
"pattern",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"if",
"(",
"!",
"itemName",
".",
"startsWith",
"(",
"firstPart",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"String",
"secondPart",
"=",
"pattern",
".",
"substring",
"(",
"index",
"+",
"1",
")",
";",
"if",
"(",
"!",
"itemName",
".",
"endsWith",
"(",
"secondPart",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"firstPart",
".",
"length",
"(",
")",
"+",
"secondPart",
".",
"length",
"(",
")",
";",
"}"
] |
This method returns the higher value the better the matching is.
@param pattern configuration pattern to match with
@param itemName item name to match
@return -1 if name does not match at all, zero or positive otherwise
|
[
"This",
"method",
"returns",
"the",
"higher",
"value",
"the",
"better",
"the",
"matching",
"is",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/matcher/MatchingPointConfigPatternMatcher.java#L61-L78
|
15,363
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/matcher/LegacyMatchingPointConfigPatternMatcher.java
|
LegacyMatchingPointConfigPatternMatcher.getMatchingPoint
|
private int getMatchingPoint(String pattern, String itemName) {
int index = pattern.indexOf('*');
if (index == -1) {
return -1;
}
String firstPart = pattern.substring(0, index);
int indexFirstPart = itemName.indexOf(firstPart, 0);
if (indexFirstPart == -1) {
return -1;
}
String secondPart = pattern.substring(index + 1);
int indexSecondPart = itemName.indexOf(secondPart, index + 1);
if (indexSecondPart == -1) {
return -1;
}
return firstPart.length() + secondPart.length();
}
|
java
|
private int getMatchingPoint(String pattern, String itemName) {
int index = pattern.indexOf('*');
if (index == -1) {
return -1;
}
String firstPart = pattern.substring(0, index);
int indexFirstPart = itemName.indexOf(firstPart, 0);
if (indexFirstPart == -1) {
return -1;
}
String secondPart = pattern.substring(index + 1);
int indexSecondPart = itemName.indexOf(secondPart, index + 1);
if (indexSecondPart == -1) {
return -1;
}
return firstPart.length() + secondPart.length();
}
|
[
"private",
"int",
"getMatchingPoint",
"(",
"String",
"pattern",
",",
"String",
"itemName",
")",
"{",
"int",
"index",
"=",
"pattern",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"String",
"firstPart",
"=",
"pattern",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"int",
"indexFirstPart",
"=",
"itemName",
".",
"indexOf",
"(",
"firstPart",
",",
"0",
")",
";",
"if",
"(",
"indexFirstPart",
"==",
"-",
"1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"String",
"secondPart",
"=",
"pattern",
".",
"substring",
"(",
"index",
"+",
"1",
")",
";",
"int",
"indexSecondPart",
"=",
"itemName",
".",
"indexOf",
"(",
"secondPart",
",",
"index",
"+",
"1",
")",
";",
"if",
"(",
"indexSecondPart",
"==",
"-",
"1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"firstPart",
".",
"length",
"(",
")",
"+",
"secondPart",
".",
"length",
"(",
")",
";",
"}"
] |
This method returns higher values the better the matching is.
@param pattern configuration pattern to match with
@param itemName item name to match
@return -1 if name does not match at all, zero or positive otherwise
|
[
"This",
"method",
"returns",
"higher",
"values",
"the",
"better",
"the",
"matching",
"is",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/matcher/LegacyMatchingPointConfigPatternMatcher.java#L58-L77
|
15,364
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/getters/JsonGetterContextCache.java
|
JsonGetterContextCache.getContext
|
public JsonGetterContext getContext(String queryPath) {
JsonGetterContext context = internalCache.get(queryPath);
if (context != null) {
return context;
}
context = new JsonGetterContext(queryPath);
JsonGetterContext previousContextValue = internalCache.putIfAbsent(queryPath, context);
if (previousContextValue == null) {
cleanupIfNeccessary(context);
return context;
} else {
return previousContextValue;
}
}
|
java
|
public JsonGetterContext getContext(String queryPath) {
JsonGetterContext context = internalCache.get(queryPath);
if (context != null) {
return context;
}
context = new JsonGetterContext(queryPath);
JsonGetterContext previousContextValue = internalCache.putIfAbsent(queryPath, context);
if (previousContextValue == null) {
cleanupIfNeccessary(context);
return context;
} else {
return previousContextValue;
}
}
|
[
"public",
"JsonGetterContext",
"getContext",
"(",
"String",
"queryPath",
")",
"{",
"JsonGetterContext",
"context",
"=",
"internalCache",
".",
"get",
"(",
"queryPath",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"return",
"context",
";",
"}",
"context",
"=",
"new",
"JsonGetterContext",
"(",
"queryPath",
")",
";",
"JsonGetterContext",
"previousContextValue",
"=",
"internalCache",
".",
"putIfAbsent",
"(",
"queryPath",
",",
"context",
")",
";",
"if",
"(",
"previousContextValue",
"==",
"null",
")",
"{",
"cleanupIfNeccessary",
"(",
"context",
")",
";",
"return",
"context",
";",
"}",
"else",
"{",
"return",
"previousContextValue",
";",
"}",
"}"
] |
Returns an existing or newly created context for given query path.
If maximum cache size is reached, then some entries are evicted.
The newly created entry is not evicted.
@param queryPath
@return
|
[
"Returns",
"an",
"existing",
"or",
"newly",
"created",
"context",
"for",
"given",
"query",
"path",
".",
"If",
"maximum",
"cache",
"size",
"is",
"reached",
"then",
"some",
"entries",
"are",
"evicted",
".",
"The",
"newly",
"created",
"entry",
"is",
"not",
"evicted",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/JsonGetterContextCache.java#L42-L55
|
15,365
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java
|
LocalMapStatsProvider.addStatsOfNoDataIncludedMaps
|
private void addStatsOfNoDataIncludedMaps(Map statsPerMap) {
ProxyService proxyService = nodeEngine.getProxyService();
Collection<String> mapNames = proxyService.getDistributedObjectNames(SERVICE_NAME);
for (String mapName : mapNames) {
if (!statsPerMap.containsKey(mapName)) {
statsPerMap.put(mapName, EMPTY_LOCAL_MAP_STATS);
}
}
}
|
java
|
private void addStatsOfNoDataIncludedMaps(Map statsPerMap) {
ProxyService proxyService = nodeEngine.getProxyService();
Collection<String> mapNames = proxyService.getDistributedObjectNames(SERVICE_NAME);
for (String mapName : mapNames) {
if (!statsPerMap.containsKey(mapName)) {
statsPerMap.put(mapName, EMPTY_LOCAL_MAP_STATS);
}
}
}
|
[
"private",
"void",
"addStatsOfNoDataIncludedMaps",
"(",
"Map",
"statsPerMap",
")",
"{",
"ProxyService",
"proxyService",
"=",
"nodeEngine",
".",
"getProxyService",
"(",
")",
";",
"Collection",
"<",
"String",
">",
"mapNames",
"=",
"proxyService",
".",
"getDistributedObjectNames",
"(",
"SERVICE_NAME",
")",
";",
"for",
"(",
"String",
"mapName",
":",
"mapNames",
")",
"{",
"if",
"(",
"!",
"statsPerMap",
".",
"containsKey",
"(",
"mapName",
")",
")",
"{",
"statsPerMap",
".",
"put",
"(",
"mapName",
",",
"EMPTY_LOCAL_MAP_STATS",
")",
";",
"}",
"}",
"}"
] |
Some maps may have a proxy but no data has been put yet. Think of one created a proxy but not put any data in it.
By calling this method we are returning an empty stats object for those maps. This is helpful to monitor those kind
of maps.
|
[
"Some",
"maps",
"may",
"have",
"a",
"proxy",
"but",
"no",
"data",
"has",
"been",
"put",
"yet",
".",
"Think",
"of",
"one",
"created",
"a",
"proxy",
"but",
"not",
"put",
"any",
"data",
"in",
"it",
".",
"By",
"calling",
"this",
"method",
"we",
"are",
"returning",
"an",
"empty",
"stats",
"object",
"for",
"those",
"maps",
".",
"This",
"is",
"helpful",
"to",
"monitor",
"those",
"kind",
"of",
"maps",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java#L150-L158
|
15,366
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java
|
LocalMapStatsProvider.addReplicaStatsOf
|
private void addReplicaStatsOf(RecordStore recordStore, LocalMapOnDemandCalculatedStats onDemandStats) {
if (!hasRecords(recordStore)) {
return;
}
long backupEntryCount = 0;
long backupEntryMemoryCost = 0;
int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount();
for (int replicaNumber = 1; replicaNumber <= totalBackupCount; replicaNumber++) {
int partitionId = recordStore.getPartitionId();
Address replicaAddress = getReplicaAddress(partitionId, replicaNumber, totalBackupCount);
if (!isReplicaAvailable(replicaAddress, totalBackupCount)) {
printWarning(partitionId, replicaNumber);
continue;
}
if (isReplicaOnThisNode(replicaAddress)) {
backupEntryMemoryCost += recordStore.getOwnedEntryCost();
backupEntryCount += recordStore.size();
}
}
if (NATIVE != recordStore.getMapContainer().getMapConfig().getInMemoryFormat()) {
onDemandStats.incrementHeapCost(backupEntryMemoryCost);
}
onDemandStats.incrementBackupEntryMemoryCost(backupEntryMemoryCost);
onDemandStats.incrementBackupEntryCount(backupEntryCount);
onDemandStats.setBackupCount(recordStore.getMapContainer().getMapConfig().getTotalBackupCount());
}
|
java
|
private void addReplicaStatsOf(RecordStore recordStore, LocalMapOnDemandCalculatedStats onDemandStats) {
if (!hasRecords(recordStore)) {
return;
}
long backupEntryCount = 0;
long backupEntryMemoryCost = 0;
int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount();
for (int replicaNumber = 1; replicaNumber <= totalBackupCount; replicaNumber++) {
int partitionId = recordStore.getPartitionId();
Address replicaAddress = getReplicaAddress(partitionId, replicaNumber, totalBackupCount);
if (!isReplicaAvailable(replicaAddress, totalBackupCount)) {
printWarning(partitionId, replicaNumber);
continue;
}
if (isReplicaOnThisNode(replicaAddress)) {
backupEntryMemoryCost += recordStore.getOwnedEntryCost();
backupEntryCount += recordStore.size();
}
}
if (NATIVE != recordStore.getMapContainer().getMapConfig().getInMemoryFormat()) {
onDemandStats.incrementHeapCost(backupEntryMemoryCost);
}
onDemandStats.incrementBackupEntryMemoryCost(backupEntryMemoryCost);
onDemandStats.incrementBackupEntryCount(backupEntryCount);
onDemandStats.setBackupCount(recordStore.getMapContainer().getMapConfig().getTotalBackupCount());
}
|
[
"private",
"void",
"addReplicaStatsOf",
"(",
"RecordStore",
"recordStore",
",",
"LocalMapOnDemandCalculatedStats",
"onDemandStats",
")",
"{",
"if",
"(",
"!",
"hasRecords",
"(",
"recordStore",
")",
")",
"{",
"return",
";",
"}",
"long",
"backupEntryCount",
"=",
"0",
";",
"long",
"backupEntryMemoryCost",
"=",
"0",
";",
"int",
"totalBackupCount",
"=",
"recordStore",
".",
"getMapContainer",
"(",
")",
".",
"getTotalBackupCount",
"(",
")",
";",
"for",
"(",
"int",
"replicaNumber",
"=",
"1",
";",
"replicaNumber",
"<=",
"totalBackupCount",
";",
"replicaNumber",
"++",
")",
"{",
"int",
"partitionId",
"=",
"recordStore",
".",
"getPartitionId",
"(",
")",
";",
"Address",
"replicaAddress",
"=",
"getReplicaAddress",
"(",
"partitionId",
",",
"replicaNumber",
",",
"totalBackupCount",
")",
";",
"if",
"(",
"!",
"isReplicaAvailable",
"(",
"replicaAddress",
",",
"totalBackupCount",
")",
")",
"{",
"printWarning",
"(",
"partitionId",
",",
"replicaNumber",
")",
";",
"continue",
";",
"}",
"if",
"(",
"isReplicaOnThisNode",
"(",
"replicaAddress",
")",
")",
"{",
"backupEntryMemoryCost",
"+=",
"recordStore",
".",
"getOwnedEntryCost",
"(",
")",
";",
"backupEntryCount",
"+=",
"recordStore",
".",
"size",
"(",
")",
";",
"}",
"}",
"if",
"(",
"NATIVE",
"!=",
"recordStore",
".",
"getMapContainer",
"(",
")",
".",
"getMapConfig",
"(",
")",
".",
"getInMemoryFormat",
"(",
")",
")",
"{",
"onDemandStats",
".",
"incrementHeapCost",
"(",
"backupEntryMemoryCost",
")",
";",
"}",
"onDemandStats",
".",
"incrementBackupEntryMemoryCost",
"(",
"backupEntryMemoryCost",
")",
";",
"onDemandStats",
".",
"incrementBackupEntryCount",
"(",
"backupEntryCount",
")",
";",
"onDemandStats",
".",
"setBackupCount",
"(",
"recordStore",
".",
"getMapContainer",
"(",
")",
".",
"getMapConfig",
"(",
")",
".",
"getTotalBackupCount",
"(",
")",
")",
";",
"}"
] |
Calculates and adds replica partition stats.
|
[
"Calculates",
"and",
"adds",
"replica",
"partition",
"stats",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java#L224-L252
|
15,367
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java
|
LocalMapStatsProvider.getReplicaAddress
|
private Address getReplicaAddress(int partitionId, int replicaNumber, int backupCount) {
IPartition partition = partitionService.getPartition(partitionId);
Address replicaAddress = partition.getReplicaAddress(replicaNumber);
if (replicaAddress == null) {
replicaAddress = waitForReplicaAddress(replicaNumber, partition, backupCount);
}
return replicaAddress;
}
|
java
|
private Address getReplicaAddress(int partitionId, int replicaNumber, int backupCount) {
IPartition partition = partitionService.getPartition(partitionId);
Address replicaAddress = partition.getReplicaAddress(replicaNumber);
if (replicaAddress == null) {
replicaAddress = waitForReplicaAddress(replicaNumber, partition, backupCount);
}
return replicaAddress;
}
|
[
"private",
"Address",
"getReplicaAddress",
"(",
"int",
"partitionId",
",",
"int",
"replicaNumber",
",",
"int",
"backupCount",
")",
"{",
"IPartition",
"partition",
"=",
"partitionService",
".",
"getPartition",
"(",
"partitionId",
")",
";",
"Address",
"replicaAddress",
"=",
"partition",
".",
"getReplicaAddress",
"(",
"replicaNumber",
")",
";",
"if",
"(",
"replicaAddress",
"==",
"null",
")",
"{",
"replicaAddress",
"=",
"waitForReplicaAddress",
"(",
"replicaNumber",
",",
"partition",
",",
"backupCount",
")",
";",
"}",
"return",
"replicaAddress",
";",
"}"
] |
Gets replica address. Waits if necessary.
@see #waitForReplicaAddress
|
[
"Gets",
"replica",
"address",
".",
"Waits",
"if",
"necessary",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java#L275-L282
|
15,368
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java
|
LocalMapStatsProvider.waitForReplicaAddress
|
private Address waitForReplicaAddress(int replica, IPartition partition, int backupCount) {
int tryCount = RETRY_COUNT;
Address replicaAddress = null;
while (replicaAddress == null && partitionService.getMaxAllowedBackupCount() >= backupCount && tryCount-- > 0) {
sleep();
replicaAddress = partition.getReplicaAddress(replica);
}
return replicaAddress;
}
|
java
|
private Address waitForReplicaAddress(int replica, IPartition partition, int backupCount) {
int tryCount = RETRY_COUNT;
Address replicaAddress = null;
while (replicaAddress == null && partitionService.getMaxAllowedBackupCount() >= backupCount && tryCount-- > 0) {
sleep();
replicaAddress = partition.getReplicaAddress(replica);
}
return replicaAddress;
}
|
[
"private",
"Address",
"waitForReplicaAddress",
"(",
"int",
"replica",
",",
"IPartition",
"partition",
",",
"int",
"backupCount",
")",
"{",
"int",
"tryCount",
"=",
"RETRY_COUNT",
";",
"Address",
"replicaAddress",
"=",
"null",
";",
"while",
"(",
"replicaAddress",
"==",
"null",
"&&",
"partitionService",
".",
"getMaxAllowedBackupCount",
"(",
")",
">=",
"backupCount",
"&&",
"tryCount",
"--",
">",
"0",
")",
"{",
"sleep",
"(",
")",
";",
"replicaAddress",
"=",
"partition",
".",
"getReplicaAddress",
"(",
"replica",
")",
";",
"}",
"return",
"replicaAddress",
";",
"}"
] |
Waits partition table update to get replica address if current replica address is null.
|
[
"Waits",
"partition",
"table",
"update",
"to",
"get",
"replica",
"address",
"if",
"current",
"replica",
"address",
"is",
"null",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java#L287-L295
|
15,369
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyorSingleQueue.java
|
ConcurrentConveyorSingleQueue.concurrentConveyorSingleQueue
|
public static <E1> ConcurrentConveyorSingleQueue<E1> concurrentConveyorSingleQueue(
E1 submitterGoneItem, QueuedPipe<E1> queue
) {
return new ConcurrentConveyorSingleQueue<E1>(submitterGoneItem, queue);
}
|
java
|
public static <E1> ConcurrentConveyorSingleQueue<E1> concurrentConveyorSingleQueue(
E1 submitterGoneItem, QueuedPipe<E1> queue
) {
return new ConcurrentConveyorSingleQueue<E1>(submitterGoneItem, queue);
}
|
[
"public",
"static",
"<",
"E1",
">",
"ConcurrentConveyorSingleQueue",
"<",
"E1",
">",
"concurrentConveyorSingleQueue",
"(",
"E1",
"submitterGoneItem",
",",
"QueuedPipe",
"<",
"E1",
">",
"queue",
")",
"{",
"return",
"new",
"ConcurrentConveyorSingleQueue",
"<",
"E1",
">",
"(",
"submitterGoneItem",
",",
"queue",
")",
";",
"}"
] |
Creates a new concurrent conveyor with a single queue.
@param submitterGoneItem the object that a submitter thread can use to signal it's done submitting
@param queue the concurrent queue the conveyor will manage
|
[
"Creates",
"a",
"new",
"concurrent",
"conveyor",
"with",
"a",
"single",
"queue",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyorSingleQueue.java#L37-L41
|
15,370
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/transaction/impl/xa/XAService.java
|
XAService.prepareReplicationOperation
|
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
if (event.getReplicaIndex() > 1) {
return null;
}
List<XATransactionDTO> migrationData = new ArrayList<XATransactionDTO>();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
for (Map.Entry<SerializableXID, List<XATransaction>> entry : transactions.entrySet()) {
SerializableXID xid = entry.getKey();
int partitionId = partitionService.getPartitionId(xid);
List<XATransaction> xaTransactionList = entry.getValue();
for (XATransaction xaTransaction : xaTransactionList) {
if (partitionId == event.getPartitionId()) {
migrationData.add(new XATransactionDTO(xaTransaction));
}
}
}
if (migrationData.isEmpty()) {
return null;
} else {
return new XaReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
}
}
|
java
|
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
if (event.getReplicaIndex() > 1) {
return null;
}
List<XATransactionDTO> migrationData = new ArrayList<XATransactionDTO>();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
for (Map.Entry<SerializableXID, List<XATransaction>> entry : transactions.entrySet()) {
SerializableXID xid = entry.getKey();
int partitionId = partitionService.getPartitionId(xid);
List<XATransaction> xaTransactionList = entry.getValue();
for (XATransaction xaTransaction : xaTransactionList) {
if (partitionId == event.getPartitionId()) {
migrationData.add(new XATransactionDTO(xaTransaction));
}
}
}
if (migrationData.isEmpty()) {
return null;
} else {
return new XaReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
}
}
|
[
"@",
"Override",
"public",
"Operation",
"prepareReplicationOperation",
"(",
"PartitionReplicationEvent",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getReplicaIndex",
"(",
")",
">",
"1",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"XATransactionDTO",
">",
"migrationData",
"=",
"new",
"ArrayList",
"<",
"XATransactionDTO",
">",
"(",
")",
";",
"InternalPartitionService",
"partitionService",
"=",
"nodeEngine",
".",
"getPartitionService",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"SerializableXID",
",",
"List",
"<",
"XATransaction",
">",
">",
"entry",
":",
"transactions",
".",
"entrySet",
"(",
")",
")",
"{",
"SerializableXID",
"xid",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"int",
"partitionId",
"=",
"partitionService",
".",
"getPartitionId",
"(",
"xid",
")",
";",
"List",
"<",
"XATransaction",
">",
"xaTransactionList",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"for",
"(",
"XATransaction",
"xaTransaction",
":",
"xaTransactionList",
")",
"{",
"if",
"(",
"partitionId",
"==",
"event",
".",
"getPartitionId",
"(",
")",
")",
"{",
"migrationData",
".",
"add",
"(",
"new",
"XATransactionDTO",
"(",
"xaTransaction",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"migrationData",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"new",
"XaReplicationOperation",
"(",
"migrationData",
",",
"event",
".",
"getPartitionId",
"(",
")",
",",
"event",
".",
"getReplicaIndex",
"(",
")",
")",
";",
"}",
"}"
] |
Migration related methods
|
[
"Migration",
"related",
"methods"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/transaction/impl/xa/XAService.java#L109-L132
|
15,371
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/metrics/metricsets/OperatingSystemMetricSet.java
|
OperatingSystemMetricSet.getMethod
|
private static Method getMethod(Object source, String methodName, String name) {
try {
Method method = source.getClass().getMethod(methodName);
method.setAccessible(true);
return method;
} catch (Exception e) {
if (LOGGER.isFinestEnabled()) {
LOGGER.log(Level.FINEST,
"Unable to register OperatingSystemMXBean method " + methodName + " used for probe " + name, e);
}
return null;
}
}
|
java
|
private static Method getMethod(Object source, String methodName, String name) {
try {
Method method = source.getClass().getMethod(methodName);
method.setAccessible(true);
return method;
} catch (Exception e) {
if (LOGGER.isFinestEnabled()) {
LOGGER.log(Level.FINEST,
"Unable to register OperatingSystemMXBean method " + methodName + " used for probe " + name, e);
}
return null;
}
}
|
[
"private",
"static",
"Method",
"getMethod",
"(",
"Object",
"source",
",",
"String",
"methodName",
",",
"String",
"name",
")",
"{",
"try",
"{",
"Method",
"method",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodName",
")",
";",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"method",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isFinestEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINEST",
",",
"\"Unable to register OperatingSystemMXBean method \"",
"+",
"methodName",
"+",
"\" used for probe \"",
"+",
"name",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] |
Returns a method from the given source object.
@param source the source object.
@param methodName the name of the method to retrieve.
@param name the probe name
@return the method
|
[
"Returns",
"a",
"method",
"from",
"the",
"given",
"source",
"object",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/metrics/metricsets/OperatingSystemMetricSet.java#L109-L121
|
15,372
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/DiscoveryConfig.java
|
DiscoveryConfig.setDiscoveryStrategyConfigs
|
public void setDiscoveryStrategyConfigs(List<DiscoveryStrategyConfig> discoveryStrategyConfigs) {
this.discoveryStrategyConfigs = discoveryStrategyConfigs == null
? new ArrayList<DiscoveryStrategyConfig>(1)
: discoveryStrategyConfigs;
}
|
java
|
public void setDiscoveryStrategyConfigs(List<DiscoveryStrategyConfig> discoveryStrategyConfigs) {
this.discoveryStrategyConfigs = discoveryStrategyConfigs == null
? new ArrayList<DiscoveryStrategyConfig>(1)
: discoveryStrategyConfigs;
}
|
[
"public",
"void",
"setDiscoveryStrategyConfigs",
"(",
"List",
"<",
"DiscoveryStrategyConfig",
">",
"discoveryStrategyConfigs",
")",
"{",
"this",
".",
"discoveryStrategyConfigs",
"=",
"discoveryStrategyConfigs",
"==",
"null",
"?",
"new",
"ArrayList",
"<",
"DiscoveryStrategyConfig",
">",
"(",
"1",
")",
":",
"discoveryStrategyConfigs",
";",
"}"
] |
Sets the strategy configurations for this discovery config.
@param discoveryStrategyConfigs the strategy configurations
|
[
"Sets",
"the",
"strategy",
"configurations",
"for",
"this",
"discovery",
"config",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/DiscoveryConfig.java#L123-L127
|
15,373
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoaderUtil.java
|
MapKeyLoaderUtil.assignRole
|
static MapKeyLoader.Role assignRole(boolean isPartitionOwner, boolean isMapNamePartition,
boolean isMapNamePartitionFirstReplica) {
if (isMapNamePartition) {
if (isPartitionOwner) {
// map-name partition owner is the SENDER
return MapKeyLoader.Role.SENDER;
} else {
if (isMapNamePartitionFirstReplica) {
// first replica of the map-name partition is the SENDER_BACKUP
return MapKeyLoader.Role.SENDER_BACKUP;
} else {
// other replicas of the map-name partition do not have a role
return MapKeyLoader.Role.NONE;
}
}
} else {
// ordinary partition owners are RECEIVERs, otherwise no role
return isPartitionOwner ? MapKeyLoader.Role.RECEIVER : MapKeyLoader.Role.NONE;
}
}
|
java
|
static MapKeyLoader.Role assignRole(boolean isPartitionOwner, boolean isMapNamePartition,
boolean isMapNamePartitionFirstReplica) {
if (isMapNamePartition) {
if (isPartitionOwner) {
// map-name partition owner is the SENDER
return MapKeyLoader.Role.SENDER;
} else {
if (isMapNamePartitionFirstReplica) {
// first replica of the map-name partition is the SENDER_BACKUP
return MapKeyLoader.Role.SENDER_BACKUP;
} else {
// other replicas of the map-name partition do not have a role
return MapKeyLoader.Role.NONE;
}
}
} else {
// ordinary partition owners are RECEIVERs, otherwise no role
return isPartitionOwner ? MapKeyLoader.Role.RECEIVER : MapKeyLoader.Role.NONE;
}
}
|
[
"static",
"MapKeyLoader",
".",
"Role",
"assignRole",
"(",
"boolean",
"isPartitionOwner",
",",
"boolean",
"isMapNamePartition",
",",
"boolean",
"isMapNamePartitionFirstReplica",
")",
"{",
"if",
"(",
"isMapNamePartition",
")",
"{",
"if",
"(",
"isPartitionOwner",
")",
"{",
"// map-name partition owner is the SENDER",
"return",
"MapKeyLoader",
".",
"Role",
".",
"SENDER",
";",
"}",
"else",
"{",
"if",
"(",
"isMapNamePartitionFirstReplica",
")",
"{",
"// first replica of the map-name partition is the SENDER_BACKUP",
"return",
"MapKeyLoader",
".",
"Role",
".",
"SENDER_BACKUP",
";",
"}",
"else",
"{",
"// other replicas of the map-name partition do not have a role",
"return",
"MapKeyLoader",
".",
"Role",
".",
"NONE",
";",
"}",
"}",
"}",
"else",
"{",
"// ordinary partition owners are RECEIVERs, otherwise no role",
"return",
"isPartitionOwner",
"?",
"MapKeyLoader",
".",
"Role",
".",
"RECEIVER",
":",
"MapKeyLoader",
".",
"Role",
".",
"NONE",
";",
"}",
"}"
] |
Returns the role for the map key loader based on the passed parameters.
The partition owner of the map name partition is the sender.
The first replica of the map name partition is the sender backup.
Other partition owners are receivers and other partition replicas do
not have a role.
@param isPartitionOwner if this is the partition owner
@param isMapNamePartition if this is the partition containing the map name
@param isMapNamePartitionFirstReplica if this is the first replica for the partition
containing the map name
@return the map key loader role
|
[
"Returns",
"the",
"role",
"for",
"the",
"map",
"key",
"loader",
"based",
"on",
"the",
"passed",
"parameters",
".",
"The",
"partition",
"owner",
"of",
"the",
"map",
"name",
"partition",
"is",
"the",
"sender",
".",
"The",
"first",
"replica",
"of",
"the",
"map",
"name",
"partition",
"is",
"the",
"sender",
"backup",
".",
"Other",
"partition",
"owners",
"are",
"receivers",
"and",
"other",
"partition",
"replicas",
"do",
"not",
"have",
"a",
"role",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoaderUtil.java#L55-L74
|
15,374
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/predicates/PredicateUtils.java
|
PredicateUtils.parseOutCompositeIndexComponents
|
public static String[] parseOutCompositeIndexComponents(String name) {
String[] components = COMMA_PATTERN.split(name, -1);
if (components.length == 1) {
return null;
}
if (components.length > MAX_INDEX_COMPONENTS) {
throw new IllegalArgumentException("Too many composite index attributes: " + name);
}
Set<String> seenComponents = new HashSet<String>(components.length);
for (int i = 0; i < components.length; ++i) {
String component = PredicateUtils.canonicalizeAttribute(components[i]);
components[i] = component;
if (component.isEmpty()) {
throw new IllegalArgumentException("Empty composite index attribute: " + name);
}
if (!seenComponents.add(component)) {
throw new IllegalArgumentException("Duplicate composite index attribute: " + name);
}
}
return components;
}
|
java
|
public static String[] parseOutCompositeIndexComponents(String name) {
String[] components = COMMA_PATTERN.split(name, -1);
if (components.length == 1) {
return null;
}
if (components.length > MAX_INDEX_COMPONENTS) {
throw new IllegalArgumentException("Too many composite index attributes: " + name);
}
Set<String> seenComponents = new HashSet<String>(components.length);
for (int i = 0; i < components.length; ++i) {
String component = PredicateUtils.canonicalizeAttribute(components[i]);
components[i] = component;
if (component.isEmpty()) {
throw new IllegalArgumentException("Empty composite index attribute: " + name);
}
if (!seenComponents.add(component)) {
throw new IllegalArgumentException("Duplicate composite index attribute: " + name);
}
}
return components;
}
|
[
"public",
"static",
"String",
"[",
"]",
"parseOutCompositeIndexComponents",
"(",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"components",
"=",
"COMMA_PATTERN",
".",
"split",
"(",
"name",
",",
"-",
"1",
")",
";",
"if",
"(",
"components",
".",
"length",
"==",
"1",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"components",
".",
"length",
">",
"MAX_INDEX_COMPONENTS",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Too many composite index attributes: \"",
"+",
"name",
")",
";",
"}",
"Set",
"<",
"String",
">",
"seenComponents",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"components",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"components",
".",
"length",
";",
"++",
"i",
")",
"{",
"String",
"component",
"=",
"PredicateUtils",
".",
"canonicalizeAttribute",
"(",
"components",
"[",
"i",
"]",
")",
";",
"components",
"[",
"i",
"]",
"=",
"component",
";",
"if",
"(",
"component",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Empty composite index attribute: \"",
"+",
"name",
")",
";",
"}",
"if",
"(",
"!",
"seenComponents",
".",
"add",
"(",
"component",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Duplicate composite index attribute: \"",
"+",
"name",
")",
";",
"}",
"}",
"return",
"components",
";",
"}"
] |
Parses the given index name into components.
@param name the index name to parse.
@return the parsed components or {@code null} if the given index name
doesn't describe a composite index components.
@throws IllegalArgumentException if the given index name is empty.
@throws IllegalArgumentException if the given index name contains empty
components.
@throws IllegalArgumentException if the given index name contains
duplicate components.
@throws IllegalArgumentException if the given index name has more than
255 components.
@see #constructCanonicalCompositeIndexName
|
[
"Parses",
"the",
"given",
"index",
"name",
"into",
"components",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/predicates/PredicateUtils.java#L115-L140
|
15,375
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/diagnostics/Diagnostics.java
|
Diagnostics.getPlugin
|
@SuppressWarnings("unchecked")
public <P extends DiagnosticsPlugin> P getPlugin(Class<P> pluginClass) {
return (P) pluginsMap.get(pluginClass);
}
|
java
|
@SuppressWarnings("unchecked")
public <P extends DiagnosticsPlugin> P getPlugin(Class<P> pluginClass) {
return (P) pluginsMap.get(pluginClass);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"P",
"extends",
"DiagnosticsPlugin",
">",
"P",
"getPlugin",
"(",
"Class",
"<",
"P",
">",
"pluginClass",
")",
"{",
"return",
"(",
"P",
")",
"pluginsMap",
".",
"get",
"(",
"pluginClass",
")",
";",
"}"
] |
Gets the plugin for a given plugin class. This method should be used if
the plugin instance is required within some data-structure outside of the
Diagnostics.
@param pluginClass the class of the DiagnosticsPlugin
@param <P> type of the plugin
@return the DiagnosticsPlugin found, or {@code null} if not active
|
[
"Gets",
"the",
"plugin",
"for",
"a",
"given",
"plugin",
"class",
".",
"This",
"method",
"should",
"be",
"used",
"if",
"the",
"plugin",
"instance",
"is",
"required",
"within",
"some",
"data",
"-",
"structure",
"outside",
"of",
"the",
"Diagnostics",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/Diagnostics.java#L178-L181
|
15,376
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/InvocationRegistry.java
|
InvocationRegistry.register
|
public boolean register(Invocation invocation) {
final long callId;
boolean force = invocation.op.isUrgent() || invocation.isRetryCandidate();
try {
callId = force ? callIdSequence.forceNext() : callIdSequence.next();
} catch (HazelcastOverloadException e) {
throw new HazelcastOverloadException("Failed to start invocation due to overload: " + invocation, e);
}
try {
// fails with IllegalStateException if the operation is already active
setCallId(invocation.op, callId);
} catch (IllegalStateException e) {
callIdSequence.complete();
throw e;
}
invocations.put(callId, invocation);
if (!alive) {
invocation.notifyError(new HazelcastInstanceNotActiveException());
return false;
}
return true;
}
|
java
|
public boolean register(Invocation invocation) {
final long callId;
boolean force = invocation.op.isUrgent() || invocation.isRetryCandidate();
try {
callId = force ? callIdSequence.forceNext() : callIdSequence.next();
} catch (HazelcastOverloadException e) {
throw new HazelcastOverloadException("Failed to start invocation due to overload: " + invocation, e);
}
try {
// fails with IllegalStateException if the operation is already active
setCallId(invocation.op, callId);
} catch (IllegalStateException e) {
callIdSequence.complete();
throw e;
}
invocations.put(callId, invocation);
if (!alive) {
invocation.notifyError(new HazelcastInstanceNotActiveException());
return false;
}
return true;
}
|
[
"public",
"boolean",
"register",
"(",
"Invocation",
"invocation",
")",
"{",
"final",
"long",
"callId",
";",
"boolean",
"force",
"=",
"invocation",
".",
"op",
".",
"isUrgent",
"(",
")",
"||",
"invocation",
".",
"isRetryCandidate",
"(",
")",
";",
"try",
"{",
"callId",
"=",
"force",
"?",
"callIdSequence",
".",
"forceNext",
"(",
")",
":",
"callIdSequence",
".",
"next",
"(",
")",
";",
"}",
"catch",
"(",
"HazelcastOverloadException",
"e",
")",
"{",
"throw",
"new",
"HazelcastOverloadException",
"(",
"\"Failed to start invocation due to overload: \"",
"+",
"invocation",
",",
"e",
")",
";",
"}",
"try",
"{",
"// fails with IllegalStateException if the operation is already active",
"setCallId",
"(",
"invocation",
".",
"op",
",",
"callId",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"callIdSequence",
".",
"complete",
"(",
")",
";",
"throw",
"e",
";",
"}",
"invocations",
".",
"put",
"(",
"callId",
",",
"invocation",
")",
";",
"if",
"(",
"!",
"alive",
")",
"{",
"invocation",
".",
"notifyError",
"(",
"new",
"HazelcastInstanceNotActiveException",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Registers an invocation.
@param invocation The invocation to register.
@return {@code false} when InvocationRegistry is not alive and registration is not successful, {@code true} otherwise
|
[
"Registers",
"an",
"invocation",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/InvocationRegistry.java#L111-L132
|
15,377
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java
|
ActionConstants.getPermission
|
public static Permission getPermission(String name, String serviceName, String... actions) {
PermissionFactory permissionFactory = PERMISSION_FACTORY_MAP.get(serviceName);
if (permissionFactory == null) {
throw new IllegalArgumentException("No permissions found for service: " + serviceName);
}
return permissionFactory.create(name, actions);
}
|
java
|
public static Permission getPermission(String name, String serviceName, String... actions) {
PermissionFactory permissionFactory = PERMISSION_FACTORY_MAP.get(serviceName);
if (permissionFactory == null) {
throw new IllegalArgumentException("No permissions found for service: " + serviceName);
}
return permissionFactory.create(name, actions);
}
|
[
"public",
"static",
"Permission",
"getPermission",
"(",
"String",
"name",
",",
"String",
"serviceName",
",",
"String",
"...",
"actions",
")",
"{",
"PermissionFactory",
"permissionFactory",
"=",
"PERMISSION_FACTORY_MAP",
".",
"get",
"(",
"serviceName",
")",
";",
"if",
"(",
"permissionFactory",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No permissions found for service: \"",
"+",
"serviceName",
")",
";",
"}",
"return",
"permissionFactory",
".",
"create",
"(",
"name",
",",
"actions",
")",
";",
"}"
] |
Creates a permission
@param name
@param serviceName
@param actions
@return the created Permission
@throws java.lang.IllegalArgumentException if there is no service found with the given serviceName.
|
[
"Creates",
"a",
"permission"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java#L260-L267
|
15,378
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/AbstractJoiner.java
|
AbstractJoiner.sendSplitBrainJoinMessageAndCheckResponse
|
protected final SplitBrainMergeCheckResult sendSplitBrainJoinMessageAndCheckResponse(Address target,
SplitBrainJoinMessage request) {
SplitBrainJoinMessage response = sendSplitBrainJoinMessage(target, request);
return clusterService.getClusterJoinManager().shouldMerge(response);
}
|
java
|
protected final SplitBrainMergeCheckResult sendSplitBrainJoinMessageAndCheckResponse(Address target,
SplitBrainJoinMessage request) {
SplitBrainJoinMessage response = sendSplitBrainJoinMessage(target, request);
return clusterService.getClusterJoinManager().shouldMerge(response);
}
|
[
"protected",
"final",
"SplitBrainMergeCheckResult",
"sendSplitBrainJoinMessageAndCheckResponse",
"(",
"Address",
"target",
",",
"SplitBrainJoinMessage",
"request",
")",
"{",
"SplitBrainJoinMessage",
"response",
"=",
"sendSplitBrainJoinMessage",
"(",
"target",
",",
"request",
")",
";",
"return",
"clusterService",
".",
"getClusterJoinManager",
"(",
")",
".",
"shouldMerge",
"(",
"response",
")",
";",
"}"
] |
Sends a split brain join request to the target address and checks the response to see if this node should merge
to the target address.
|
[
"Sends",
"a",
"split",
"brain",
"join",
"request",
"to",
"the",
"target",
"address",
"and",
"checks",
"the",
"response",
"to",
"see",
"if",
"this",
"node",
"should",
"merge",
"to",
"the",
"target",
"address",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/AbstractJoiner.java#L227-L231
|
15,379
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/AbstractJoiner.java
|
AbstractJoiner.sendSplitBrainJoinMessage
|
private SplitBrainJoinMessage sendSplitBrainJoinMessage(Address target, SplitBrainJoinMessage request) {
if (logger.isFineEnabled()) {
logger.fine("Sending SplitBrainJoinMessage to " + target);
}
Connection conn = node.getEndpointManager(MEMBER).getOrConnect(target, true);
long timeout = SPLIT_BRAIN_CONN_TIMEOUT_MILLIS;
while (conn == null) {
timeout -= SPLIT_BRAIN_SLEEP_TIME_MILLIS;
if (timeout < 0) {
logger.fine("Returning null timeout<0, " + timeout);
return null;
}
try {
//noinspection BusyWait
Thread.sleep(SPLIT_BRAIN_SLEEP_TIME_MILLIS);
} catch (InterruptedException e) {
currentThread().interrupt();
return null;
}
conn = node.getEndpointManager(MEMBER).getConnection(target);
}
NodeEngine nodeEngine = node.nodeEngine;
Future future = nodeEngine.getOperationService().createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME,
new SplitBrainMergeValidationOp(request), target)
.setTryCount(1).invoke();
try {
return (SplitBrainJoinMessage) future.get(SPLIT_BRAIN_JOIN_CHECK_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (TimeoutException e) {
logger.fine("Timeout during join check!", e);
} catch (Exception e) {
logger.warning("Error during join check!", e);
}
return null;
}
|
java
|
private SplitBrainJoinMessage sendSplitBrainJoinMessage(Address target, SplitBrainJoinMessage request) {
if (logger.isFineEnabled()) {
logger.fine("Sending SplitBrainJoinMessage to " + target);
}
Connection conn = node.getEndpointManager(MEMBER).getOrConnect(target, true);
long timeout = SPLIT_BRAIN_CONN_TIMEOUT_MILLIS;
while (conn == null) {
timeout -= SPLIT_BRAIN_SLEEP_TIME_MILLIS;
if (timeout < 0) {
logger.fine("Returning null timeout<0, " + timeout);
return null;
}
try {
//noinspection BusyWait
Thread.sleep(SPLIT_BRAIN_SLEEP_TIME_MILLIS);
} catch (InterruptedException e) {
currentThread().interrupt();
return null;
}
conn = node.getEndpointManager(MEMBER).getConnection(target);
}
NodeEngine nodeEngine = node.nodeEngine;
Future future = nodeEngine.getOperationService().createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME,
new SplitBrainMergeValidationOp(request), target)
.setTryCount(1).invoke();
try {
return (SplitBrainJoinMessage) future.get(SPLIT_BRAIN_JOIN_CHECK_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (TimeoutException e) {
logger.fine("Timeout during join check!", e);
} catch (Exception e) {
logger.warning("Error during join check!", e);
}
return null;
}
|
[
"private",
"SplitBrainJoinMessage",
"sendSplitBrainJoinMessage",
"(",
"Address",
"target",
",",
"SplitBrainJoinMessage",
"request",
")",
"{",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Sending SplitBrainJoinMessage to \"",
"+",
"target",
")",
";",
"}",
"Connection",
"conn",
"=",
"node",
".",
"getEndpointManager",
"(",
"MEMBER",
")",
".",
"getOrConnect",
"(",
"target",
",",
"true",
")",
";",
"long",
"timeout",
"=",
"SPLIT_BRAIN_CONN_TIMEOUT_MILLIS",
";",
"while",
"(",
"conn",
"==",
"null",
")",
"{",
"timeout",
"-=",
"SPLIT_BRAIN_SLEEP_TIME_MILLIS",
";",
"if",
"(",
"timeout",
"<",
"0",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Returning null timeout<0, \"",
"+",
"timeout",
")",
";",
"return",
"null",
";",
"}",
"try",
"{",
"//noinspection BusyWait",
"Thread",
".",
"sleep",
"(",
"SPLIT_BRAIN_SLEEP_TIME_MILLIS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"return",
"null",
";",
"}",
"conn",
"=",
"node",
".",
"getEndpointManager",
"(",
"MEMBER",
")",
".",
"getConnection",
"(",
"target",
")",
";",
"}",
"NodeEngine",
"nodeEngine",
"=",
"node",
".",
"nodeEngine",
";",
"Future",
"future",
"=",
"nodeEngine",
".",
"getOperationService",
"(",
")",
".",
"createInvocationBuilder",
"(",
"ClusterServiceImpl",
".",
"SERVICE_NAME",
",",
"new",
"SplitBrainMergeValidationOp",
"(",
"request",
")",
",",
"target",
")",
".",
"setTryCount",
"(",
"1",
")",
".",
"invoke",
"(",
")",
";",
"try",
"{",
"return",
"(",
"SplitBrainJoinMessage",
")",
"future",
".",
"get",
"(",
"SPLIT_BRAIN_JOIN_CHECK_TIMEOUT_SECONDS",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Timeout during join check!\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warning",
"(",
"\"Error during join check!\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Sends a split brain join request to the target address and returns the response.
|
[
"Sends",
"a",
"split",
"brain",
"join",
"request",
"to",
"the",
"target",
"address",
"and",
"returns",
"the",
"response",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/AbstractJoiner.java#L236-L271
|
15,380
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java
|
ExpirationTimeSetter.setExpirationTimes
|
public static void setExpirationTimes(long operationTTLMillis, long operationMaxIdleMillis, Record record,
MapConfig mapConfig, boolean consultMapConfig) {
long ttlMillis = pickTTLMillis(operationTTLMillis, record.getTtl(), mapConfig, consultMapConfig);
long maxIdleMillis = pickMaxIdleMillis(operationMaxIdleMillis, record.getMaxIdle(), mapConfig, consultMapConfig);
record.setTtl(ttlMillis);
record.setMaxIdle(maxIdleMillis);
setExpirationTime(record);
}
|
java
|
public static void setExpirationTimes(long operationTTLMillis, long operationMaxIdleMillis, Record record,
MapConfig mapConfig, boolean consultMapConfig) {
long ttlMillis = pickTTLMillis(operationTTLMillis, record.getTtl(), mapConfig, consultMapConfig);
long maxIdleMillis = pickMaxIdleMillis(operationMaxIdleMillis, record.getMaxIdle(), mapConfig, consultMapConfig);
record.setTtl(ttlMillis);
record.setMaxIdle(maxIdleMillis);
setExpirationTime(record);
}
|
[
"public",
"static",
"void",
"setExpirationTimes",
"(",
"long",
"operationTTLMillis",
",",
"long",
"operationMaxIdleMillis",
",",
"Record",
"record",
",",
"MapConfig",
"mapConfig",
",",
"boolean",
"consultMapConfig",
")",
"{",
"long",
"ttlMillis",
"=",
"pickTTLMillis",
"(",
"operationTTLMillis",
",",
"record",
".",
"getTtl",
"(",
")",
",",
"mapConfig",
",",
"consultMapConfig",
")",
";",
"long",
"maxIdleMillis",
"=",
"pickMaxIdleMillis",
"(",
"operationMaxIdleMillis",
",",
"record",
".",
"getMaxIdle",
"(",
")",
",",
"mapConfig",
",",
"consultMapConfig",
")",
";",
"record",
".",
"setTtl",
"(",
"ttlMillis",
")",
";",
"record",
".",
"setMaxIdle",
"(",
"maxIdleMillis",
")",
";",
"setExpirationTime",
"(",
"record",
")",
";",
"}"
] |
Updates records TTL and expiration time.
@param operationTTLMillis user provided TTL during operation call like put with TTL
@param record record to be updated
@param mapConfig map config object
@param consultMapConfig give {@code true} if this update should consult map ttl configuration,
otherwise give {@code false} to indicate update
|
[
"Updates",
"records",
"TTL",
"and",
"expiration",
"time",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java#L102-L110
|
15,381
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java
|
ExpirationTimeSetter.pickTTLMillis
|
private static long pickTTLMillis(long operationTTLMillis, long existingTTLMillis, MapConfig mapConfig,
boolean consultMapConfig) {
// if user set operationTTLMillis when calling operation, use it
if (operationTTLMillis > 0) {
return checkedTime(operationTTLMillis);
}
// if this is the first creation of entry, try to get TTL from mapConfig
if (consultMapConfig && operationTTLMillis < 0 && mapConfig.getTimeToLiveSeconds() > 0) {
return checkedTime(SECONDS.toMillis(mapConfig.getTimeToLiveSeconds()));
}
// if operationTTLMillis < 0, keep previously set TTL on record
if (operationTTLMillis < 0) {
return checkedTime(existingTTLMillis);
}
// if we are here, entry should live forever
return Long.MAX_VALUE;
}
|
java
|
private static long pickTTLMillis(long operationTTLMillis, long existingTTLMillis, MapConfig mapConfig,
boolean consultMapConfig) {
// if user set operationTTLMillis when calling operation, use it
if (operationTTLMillis > 0) {
return checkedTime(operationTTLMillis);
}
// if this is the first creation of entry, try to get TTL from mapConfig
if (consultMapConfig && operationTTLMillis < 0 && mapConfig.getTimeToLiveSeconds() > 0) {
return checkedTime(SECONDS.toMillis(mapConfig.getTimeToLiveSeconds()));
}
// if operationTTLMillis < 0, keep previously set TTL on record
if (operationTTLMillis < 0) {
return checkedTime(existingTTLMillis);
}
// if we are here, entry should live forever
return Long.MAX_VALUE;
}
|
[
"private",
"static",
"long",
"pickTTLMillis",
"(",
"long",
"operationTTLMillis",
",",
"long",
"existingTTLMillis",
",",
"MapConfig",
"mapConfig",
",",
"boolean",
"consultMapConfig",
")",
"{",
"// if user set operationTTLMillis when calling operation, use it",
"if",
"(",
"operationTTLMillis",
">",
"0",
")",
"{",
"return",
"checkedTime",
"(",
"operationTTLMillis",
")",
";",
"}",
"// if this is the first creation of entry, try to get TTL from mapConfig",
"if",
"(",
"consultMapConfig",
"&&",
"operationTTLMillis",
"<",
"0",
"&&",
"mapConfig",
".",
"getTimeToLiveSeconds",
"(",
")",
">",
"0",
")",
"{",
"return",
"checkedTime",
"(",
"SECONDS",
".",
"toMillis",
"(",
"mapConfig",
".",
"getTimeToLiveSeconds",
"(",
")",
")",
")",
";",
"}",
"// if operationTTLMillis < 0, keep previously set TTL on record",
"if",
"(",
"operationTTLMillis",
"<",
"0",
")",
"{",
"return",
"checkedTime",
"(",
"existingTTLMillis",
")",
";",
"}",
"// if we are here, entry should live forever",
"return",
"Long",
".",
"MAX_VALUE",
";",
"}"
] |
Decides if TTL millis should to be set on record.
@param existingTTLMillis existing TTL on record
@param operationTTLMillis user provided TTL during operation call like put with TTL
@param mapConfig used to get configured TTL
@param consultMapConfig give {@code true} if this update should consult map ttl configuration,
otherwise give {@code false}
@return TTL value in millis to set to record
|
[
"Decides",
"if",
"TTL",
"millis",
"should",
"to",
"be",
"set",
"on",
"record",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java#L122-L141
|
15,382
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java
|
ExpirationTimeSetter.calculateExpirationWithDelay
|
public static long calculateExpirationWithDelay(long timeInMillis, long delayMillis, boolean backup) {
checkNotNegative(timeInMillis, "timeInMillis can't be negative");
if (backup) {
long delayedTime = timeInMillis + delayMillis;
// check for a potential long overflow
if (delayedTime < 0) {
return Long.MAX_VALUE;
} else {
return delayedTime;
}
}
return timeInMillis;
}
|
java
|
public static long calculateExpirationWithDelay(long timeInMillis, long delayMillis, boolean backup) {
checkNotNegative(timeInMillis, "timeInMillis can't be negative");
if (backup) {
long delayedTime = timeInMillis + delayMillis;
// check for a potential long overflow
if (delayedTime < 0) {
return Long.MAX_VALUE;
} else {
return delayedTime;
}
}
return timeInMillis;
}
|
[
"public",
"static",
"long",
"calculateExpirationWithDelay",
"(",
"long",
"timeInMillis",
",",
"long",
"delayMillis",
",",
"boolean",
"backup",
")",
"{",
"checkNotNegative",
"(",
"timeInMillis",
",",
"\"timeInMillis can't be negative\"",
")",
";",
"if",
"(",
"backup",
")",
"{",
"long",
"delayedTime",
"=",
"timeInMillis",
"+",
"delayMillis",
";",
"// check for a potential long overflow",
"if",
"(",
"delayedTime",
"<",
"0",
")",
"{",
"return",
"Long",
".",
"MAX_VALUE",
";",
"}",
"else",
"{",
"return",
"delayedTime",
";",
"}",
"}",
"return",
"timeInMillis",
";",
"}"
] |
On backup partitions, this method delays key's expiration.
|
[
"On",
"backup",
"partitions",
"this",
"method",
"delays",
"key",
"s",
"expiration",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/ExpirationTimeSetter.java#L167-L180
|
15,383
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java
|
RaftLock.acquire
|
AcquireResult acquire(LockInvocationKey key, boolean wait) {
LockEndpoint endpoint = key.endpoint();
UUID invocationUid = key.invocationUid();
RaftLockOwnershipState memorized = ownerInvocationRefUids.get(Tuple2.of(endpoint, invocationUid));
if (memorized != null) {
AcquireStatus status = memorized.isLocked() ? SUCCESSFUL : FAILED;
return new AcquireResult(status, memorized.getFence(), Collections.<LockInvocationKey>emptyList());
}
if (owner == null) {
owner = key;
}
if (endpoint.equals(owner.endpoint())) {
if (lockCount == lockCountLimit) {
ownerInvocationRefUids.put(Tuple2.of(endpoint, invocationUid), NOT_LOCKED);
return AcquireResult.failed(Collections.<LockInvocationKey>emptyList());
}
lockCount++;
ownerInvocationRefUids.put(Tuple2.of(endpoint, invocationUid), lockOwnershipState());
return AcquireResult.acquired(owner.commitIndex());
}
// we must cancel waits keys of previous invocation of the endpoint
// before adding a new wait key or even if we will not wait
Collection<LockInvocationKey> cancelledWaitKeys = cancelWaitKeys(endpoint, invocationUid);
if (wait) {
addWaitKey(endpoint, key);
return AcquireResult.waitKeyAdded(cancelledWaitKeys);
}
return AcquireResult.failed(cancelledWaitKeys);
}
|
java
|
AcquireResult acquire(LockInvocationKey key, boolean wait) {
LockEndpoint endpoint = key.endpoint();
UUID invocationUid = key.invocationUid();
RaftLockOwnershipState memorized = ownerInvocationRefUids.get(Tuple2.of(endpoint, invocationUid));
if (memorized != null) {
AcquireStatus status = memorized.isLocked() ? SUCCESSFUL : FAILED;
return new AcquireResult(status, memorized.getFence(), Collections.<LockInvocationKey>emptyList());
}
if (owner == null) {
owner = key;
}
if (endpoint.equals(owner.endpoint())) {
if (lockCount == lockCountLimit) {
ownerInvocationRefUids.put(Tuple2.of(endpoint, invocationUid), NOT_LOCKED);
return AcquireResult.failed(Collections.<LockInvocationKey>emptyList());
}
lockCount++;
ownerInvocationRefUids.put(Tuple2.of(endpoint, invocationUid), lockOwnershipState());
return AcquireResult.acquired(owner.commitIndex());
}
// we must cancel waits keys of previous invocation of the endpoint
// before adding a new wait key or even if we will not wait
Collection<LockInvocationKey> cancelledWaitKeys = cancelWaitKeys(endpoint, invocationUid);
if (wait) {
addWaitKey(endpoint, key);
return AcquireResult.waitKeyAdded(cancelledWaitKeys);
}
return AcquireResult.failed(cancelledWaitKeys);
}
|
[
"AcquireResult",
"acquire",
"(",
"LockInvocationKey",
"key",
",",
"boolean",
"wait",
")",
"{",
"LockEndpoint",
"endpoint",
"=",
"key",
".",
"endpoint",
"(",
")",
";",
"UUID",
"invocationUid",
"=",
"key",
".",
"invocationUid",
"(",
")",
";",
"RaftLockOwnershipState",
"memorized",
"=",
"ownerInvocationRefUids",
".",
"get",
"(",
"Tuple2",
".",
"of",
"(",
"endpoint",
",",
"invocationUid",
")",
")",
";",
"if",
"(",
"memorized",
"!=",
"null",
")",
"{",
"AcquireStatus",
"status",
"=",
"memorized",
".",
"isLocked",
"(",
")",
"?",
"SUCCESSFUL",
":",
"FAILED",
";",
"return",
"new",
"AcquireResult",
"(",
"status",
",",
"memorized",
".",
"getFence",
"(",
")",
",",
"Collections",
".",
"<",
"LockInvocationKey",
">",
"emptyList",
"(",
")",
")",
";",
"}",
"if",
"(",
"owner",
"==",
"null",
")",
"{",
"owner",
"=",
"key",
";",
"}",
"if",
"(",
"endpoint",
".",
"equals",
"(",
"owner",
".",
"endpoint",
"(",
")",
")",
")",
"{",
"if",
"(",
"lockCount",
"==",
"lockCountLimit",
")",
"{",
"ownerInvocationRefUids",
".",
"put",
"(",
"Tuple2",
".",
"of",
"(",
"endpoint",
",",
"invocationUid",
")",
",",
"NOT_LOCKED",
")",
";",
"return",
"AcquireResult",
".",
"failed",
"(",
"Collections",
".",
"<",
"LockInvocationKey",
">",
"emptyList",
"(",
")",
")",
";",
"}",
"lockCount",
"++",
";",
"ownerInvocationRefUids",
".",
"put",
"(",
"Tuple2",
".",
"of",
"(",
"endpoint",
",",
"invocationUid",
")",
",",
"lockOwnershipState",
"(",
")",
")",
";",
"return",
"AcquireResult",
".",
"acquired",
"(",
"owner",
".",
"commitIndex",
"(",
")",
")",
";",
"}",
"// we must cancel waits keys of previous invocation of the endpoint",
"// before adding a new wait key or even if we will not wait",
"Collection",
"<",
"LockInvocationKey",
">",
"cancelledWaitKeys",
"=",
"cancelWaitKeys",
"(",
"endpoint",
",",
"invocationUid",
")",
";",
"if",
"(",
"wait",
")",
"{",
"addWaitKey",
"(",
"endpoint",
",",
"key",
")",
";",
"return",
"AcquireResult",
".",
"waitKeyAdded",
"(",
"cancelledWaitKeys",
")",
";",
"}",
"return",
"AcquireResult",
".",
"failed",
"(",
"cancelledWaitKeys",
")",
";",
"}"
] |
Assigns the lock to the endpoint, if the lock is not held. Lock count is
incremented if the endpoint already holds the lock. If some other
endpoint holds the lock and the second argument is true, a wait key is
created and added to the wait queue. Lock count is not incremented if
the lock request is a retry of the lock holder. If the lock request is
a retry of a lock endpoint that resides in the wait queue with the same
invocation uid, a retry wait key wait key is attached to the original
wait key. If the lock request is a new request of a lock endpoint that
resides in the wait queue with a different invocation uid, the existing
wait key is cancelled because it means the caller has stopped waiting
for response of the previous invocation. If the invocation uid is same
with one of the previous invocations of the current lock owner,
memorized result of the previous invocation is returned.
|
[
"Assigns",
"the",
"lock",
"to",
"the",
"endpoint",
"if",
"the",
"lock",
"is",
"not",
"held",
".",
"Lock",
"count",
"is",
"incremented",
"if",
"the",
"endpoint",
"already",
"holds",
"the",
"lock",
".",
"If",
"some",
"other",
"endpoint",
"holds",
"the",
"lock",
"and",
"the",
"second",
"argument",
"is",
"true",
"a",
"wait",
"key",
"is",
"created",
"and",
"added",
"to",
"the",
"wait",
"queue",
".",
"Lock",
"count",
"is",
"not",
"incremented",
"if",
"the",
"lock",
"request",
"is",
"a",
"retry",
"of",
"the",
"lock",
"holder",
".",
"If",
"the",
"lock",
"request",
"is",
"a",
"retry",
"of",
"a",
"lock",
"endpoint",
"that",
"resides",
"in",
"the",
"wait",
"queue",
"with",
"the",
"same",
"invocation",
"uid",
"a",
"retry",
"wait",
"key",
"wait",
"key",
"is",
"attached",
"to",
"the",
"original",
"wait",
"key",
".",
"If",
"the",
"lock",
"request",
"is",
"a",
"new",
"request",
"of",
"a",
"lock",
"endpoint",
"that",
"resides",
"in",
"the",
"wait",
"queue",
"with",
"a",
"different",
"invocation",
"uid",
"the",
"existing",
"wait",
"key",
"is",
"cancelled",
"because",
"it",
"means",
"the",
"caller",
"has",
"stopped",
"waiting",
"for",
"response",
"of",
"the",
"previous",
"invocation",
".",
"If",
"the",
"invocation",
"uid",
"is",
"same",
"with",
"one",
"of",
"the",
"previous",
"invocations",
"of",
"the",
"current",
"lock",
"owner",
"memorized",
"result",
"of",
"the",
"previous",
"invocation",
"is",
"returned",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java#L95-L129
|
15,384
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java
|
RaftLock.onSessionClose
|
@Override
protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
removeInvocationRefUids(sessionId);
if (owner != null && owner.sessionId() == sessionId) {
ReleaseResult result = doRelease(owner.endpoint(), newUnsecureUUID(), lockCount);
for (LockInvocationKey key : result.completedWaitKeys()) {
responses.put(key.commitIndex(), result.ownership().getFence());
}
}
}
|
java
|
@Override
protected void onSessionClose(long sessionId, Map<Long, Object> responses) {
removeInvocationRefUids(sessionId);
if (owner != null && owner.sessionId() == sessionId) {
ReleaseResult result = doRelease(owner.endpoint(), newUnsecureUUID(), lockCount);
for (LockInvocationKey key : result.completedWaitKeys()) {
responses.put(key.commitIndex(), result.ownership().getFence());
}
}
}
|
[
"@",
"Override",
"protected",
"void",
"onSessionClose",
"(",
"long",
"sessionId",
",",
"Map",
"<",
"Long",
",",
"Object",
">",
"responses",
")",
"{",
"removeInvocationRefUids",
"(",
"sessionId",
")",
";",
"if",
"(",
"owner",
"!=",
"null",
"&&",
"owner",
".",
"sessionId",
"(",
")",
"==",
"sessionId",
")",
"{",
"ReleaseResult",
"result",
"=",
"doRelease",
"(",
"owner",
".",
"endpoint",
"(",
")",
",",
"newUnsecureUUID",
"(",
")",
",",
"lockCount",
")",
";",
"for",
"(",
"LockInvocationKey",
"key",
":",
"result",
".",
"completedWaitKeys",
"(",
")",
")",
"{",
"responses",
".",
"put",
"(",
"key",
".",
"commitIndex",
"(",
")",
",",
"result",
".",
"ownership",
"(",
")",
".",
"getFence",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Releases the lock if the current lock holder's session is closed.
|
[
"Releases",
"the",
"lock",
"if",
"the",
"current",
"lock",
"holder",
"s",
"session",
"is",
"closed",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java#L234-L244
|
15,385
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java
|
RaftLock.getActivelyAttachedSessions
|
@Override
protected Collection<Long> getActivelyAttachedSessions() {
return owner != null ? Collections.singleton(owner.sessionId()) : Collections.<Long>emptyList();
}
|
java
|
@Override
protected Collection<Long> getActivelyAttachedSessions() {
return owner != null ? Collections.singleton(owner.sessionId()) : Collections.<Long>emptyList();
}
|
[
"@",
"Override",
"protected",
"Collection",
"<",
"Long",
">",
"getActivelyAttachedSessions",
"(",
")",
"{",
"return",
"owner",
"!=",
"null",
"?",
"Collections",
".",
"singleton",
"(",
"owner",
".",
"sessionId",
"(",
")",
")",
":",
"Collections",
".",
"<",
"Long",
">",
"emptyList",
"(",
")",
";",
"}"
] |
Returns session id of the current lock holder or an empty collection if
the lock is not held
|
[
"Returns",
"session",
"id",
"of",
"the",
"current",
"lock",
"holder",
"or",
"an",
"empty",
"collection",
"if",
"the",
"lock",
"is",
"not",
"held"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java#L259-L262
|
15,386
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/replicatedmap/impl/record/AbstractReplicatedRecordStore.java
|
AbstractReplicatedRecordStore.containsKeyAndValue
|
private boolean containsKeyAndValue(Object key) {
ReplicatedRecord replicatedRecord = getStorage().get(marshall(key));
return replicatedRecord != null && replicatedRecord.getValue() != null;
}
|
java
|
private boolean containsKeyAndValue(Object key) {
ReplicatedRecord replicatedRecord = getStorage().get(marshall(key));
return replicatedRecord != null && replicatedRecord.getValue() != null;
}
|
[
"private",
"boolean",
"containsKeyAndValue",
"(",
"Object",
"key",
")",
"{",
"ReplicatedRecord",
"replicatedRecord",
"=",
"getStorage",
"(",
")",
".",
"get",
"(",
"marshall",
"(",
"key",
")",
")",
";",
"return",
"replicatedRecord",
"!=",
"null",
"&&",
"replicatedRecord",
".",
"getValue",
"(",
")",
"!=",
"null",
";",
"}"
] |
IMPORTANT >> Increments hit counter
|
[
"IMPORTANT",
">>",
"Increments",
"hit",
"counter"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/replicatedmap/impl/record/AbstractReplicatedRecordStore.java#L209-L212
|
15,387
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/ClientPartitionListenerService.java
|
ClientPartitionListenerService.getPartitions
|
public Collection<Map.Entry<Address, List<Integer>>> getPartitions(PartitionTableView partitionTableView) {
Map<Address, List<Integer>> partitionsMap = new HashMap<Address, List<Integer>>();
int partitionCount = partitionTableView.getLength();
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
PartitionReplica owner = partitionTableView.getReplica(partitionId, 0);
if (owner == null) {
partitionsMap.clear();
return partitionsMap.entrySet();
}
Address clientOwnerAddress = clientAddressOf(owner.address());
if (clientOwnerAddress == null) {
partitionsMap.clear();
return partitionsMap.entrySet();
}
List<Integer> indexes = partitionsMap.get(clientOwnerAddress);
if (indexes == null) {
indexes = new LinkedList<Integer>();
partitionsMap.put(clientOwnerAddress, indexes);
}
indexes.add(partitionId);
}
return partitionsMap.entrySet();
}
|
java
|
public Collection<Map.Entry<Address, List<Integer>>> getPartitions(PartitionTableView partitionTableView) {
Map<Address, List<Integer>> partitionsMap = new HashMap<Address, List<Integer>>();
int partitionCount = partitionTableView.getLength();
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
PartitionReplica owner = partitionTableView.getReplica(partitionId, 0);
if (owner == null) {
partitionsMap.clear();
return partitionsMap.entrySet();
}
Address clientOwnerAddress = clientAddressOf(owner.address());
if (clientOwnerAddress == null) {
partitionsMap.clear();
return partitionsMap.entrySet();
}
List<Integer> indexes = partitionsMap.get(clientOwnerAddress);
if (indexes == null) {
indexes = new LinkedList<Integer>();
partitionsMap.put(clientOwnerAddress, indexes);
}
indexes.add(partitionId);
}
return partitionsMap.entrySet();
}
|
[
"public",
"Collection",
"<",
"Map",
".",
"Entry",
"<",
"Address",
",",
"List",
"<",
"Integer",
">",
">",
">",
"getPartitions",
"(",
"PartitionTableView",
"partitionTableView",
")",
"{",
"Map",
"<",
"Address",
",",
"List",
"<",
"Integer",
">",
">",
"partitionsMap",
"=",
"new",
"HashMap",
"<",
"Address",
",",
"List",
"<",
"Integer",
">",
">",
"(",
")",
";",
"int",
"partitionCount",
"=",
"partitionTableView",
".",
"getLength",
"(",
")",
";",
"for",
"(",
"int",
"partitionId",
"=",
"0",
";",
"partitionId",
"<",
"partitionCount",
";",
"partitionId",
"++",
")",
"{",
"PartitionReplica",
"owner",
"=",
"partitionTableView",
".",
"getReplica",
"(",
"partitionId",
",",
"0",
")",
";",
"if",
"(",
"owner",
"==",
"null",
")",
"{",
"partitionsMap",
".",
"clear",
"(",
")",
";",
"return",
"partitionsMap",
".",
"entrySet",
"(",
")",
";",
"}",
"Address",
"clientOwnerAddress",
"=",
"clientAddressOf",
"(",
"owner",
".",
"address",
"(",
")",
")",
";",
"if",
"(",
"clientOwnerAddress",
"==",
"null",
")",
"{",
"partitionsMap",
".",
"clear",
"(",
")",
";",
"return",
"partitionsMap",
".",
"entrySet",
"(",
")",
";",
"}",
"List",
"<",
"Integer",
">",
"indexes",
"=",
"partitionsMap",
".",
"get",
"(",
"clientOwnerAddress",
")",
";",
"if",
"(",
"indexes",
"==",
"null",
")",
"{",
"indexes",
"=",
"new",
"LinkedList",
"<",
"Integer",
">",
"(",
")",
";",
"partitionsMap",
".",
"put",
"(",
"clientOwnerAddress",
",",
"indexes",
")",
";",
"}",
"indexes",
".",
"add",
"(",
"partitionId",
")",
";",
"}",
"return",
"partitionsMap",
".",
"entrySet",
"(",
")",
";",
"}"
] |
If any partition does not have an owner, this method returns empty collection
@param partitionTableView will be converted to address->partitions mapping
@return address->partitions mapping, where address is the client address of the member
|
[
"If",
"any",
"partition",
"does",
"not",
"have",
"an",
"owner",
"this",
"method",
"returns",
"empty",
"collection"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/ClientPartitionListenerService.java#L89-L113
|
15,388
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java
|
HashSlotArrayBase.migrateTo
|
public final void migrateTo(MemoryAllocator newMalloc) {
baseAddress = move(baseAddress, capacity(), malloc, newMalloc);
malloc = newMalloc;
auxMalloc = null;
}
|
java
|
public final void migrateTo(MemoryAllocator newMalloc) {
baseAddress = move(baseAddress, capacity(), malloc, newMalloc);
malloc = newMalloc;
auxMalloc = null;
}
|
[
"public",
"final",
"void",
"migrateTo",
"(",
"MemoryAllocator",
"newMalloc",
")",
"{",
"baseAddress",
"=",
"move",
"(",
"baseAddress",
",",
"capacity",
"(",
")",
",",
"malloc",
",",
"newMalloc",
")",
";",
"malloc",
"=",
"newMalloc",
";",
"auxMalloc",
"=",
"null",
";",
"}"
] |
Migrates the backing memory region to a new allocator, freeing the current region. Memory allocated by the
new allocator must be accessible by the same accessor as the current one.
|
[
"Migrates",
"the",
"backing",
"memory",
"region",
"to",
"a",
"new",
"allocator",
"freeing",
"the",
"current",
"region",
".",
"Memory",
"allocated",
"by",
"the",
"new",
"allocator",
"must",
"be",
"accessible",
"by",
"the",
"same",
"accessor",
"as",
"the",
"current",
"one",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java#L212-L216
|
15,389
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java
|
HashSlotArrayBase.ensure0
|
protected final SlotAssignmentResult ensure0(long key1, long key2) {
assertValid();
final long size = size();
if (size == expansionThreshold()) {
resizeTo(CapacityUtil.nextCapacity(capacity()));
}
long slot = keyHash(key1, key2) & mask();
while (isSlotAssigned(slot)) {
if (equal(key1OfSlot(slot), key2OfSlot(slot), key1, key2)) {
slotAssignmentResult.setAddress(valueAddrOfSlot(slot));
slotAssignmentResult.setNew(false);
return slotAssignmentResult;
}
slot = (slot + 1) & mask();
}
setSize(size + 1);
putKey(baseAddress, slot, key1, key2);
slotAssignmentResult.setAddress(valueAddrOfSlot(slot));
slotAssignmentResult.setNew(true);
return slotAssignmentResult;
}
|
java
|
protected final SlotAssignmentResult ensure0(long key1, long key2) {
assertValid();
final long size = size();
if (size == expansionThreshold()) {
resizeTo(CapacityUtil.nextCapacity(capacity()));
}
long slot = keyHash(key1, key2) & mask();
while (isSlotAssigned(slot)) {
if (equal(key1OfSlot(slot), key2OfSlot(slot), key1, key2)) {
slotAssignmentResult.setAddress(valueAddrOfSlot(slot));
slotAssignmentResult.setNew(false);
return slotAssignmentResult;
}
slot = (slot + 1) & mask();
}
setSize(size + 1);
putKey(baseAddress, slot, key1, key2);
slotAssignmentResult.setAddress(valueAddrOfSlot(slot));
slotAssignmentResult.setNew(true);
return slotAssignmentResult;
}
|
[
"protected",
"final",
"SlotAssignmentResult",
"ensure0",
"(",
"long",
"key1",
",",
"long",
"key2",
")",
"{",
"assertValid",
"(",
")",
";",
"final",
"long",
"size",
"=",
"size",
"(",
")",
";",
"if",
"(",
"size",
"==",
"expansionThreshold",
"(",
")",
")",
"{",
"resizeTo",
"(",
"CapacityUtil",
".",
"nextCapacity",
"(",
"capacity",
"(",
")",
")",
")",
";",
"}",
"long",
"slot",
"=",
"keyHash",
"(",
"key1",
",",
"key2",
")",
"&",
"mask",
"(",
")",
";",
"while",
"(",
"isSlotAssigned",
"(",
"slot",
")",
")",
"{",
"if",
"(",
"equal",
"(",
"key1OfSlot",
"(",
"slot",
")",
",",
"key2OfSlot",
"(",
"slot",
")",
",",
"key1",
",",
"key2",
")",
")",
"{",
"slotAssignmentResult",
".",
"setAddress",
"(",
"valueAddrOfSlot",
"(",
"slot",
")",
")",
";",
"slotAssignmentResult",
".",
"setNew",
"(",
"false",
")",
";",
"return",
"slotAssignmentResult",
";",
"}",
"slot",
"=",
"(",
"slot",
"+",
"1",
")",
"&",
"mask",
"(",
")",
";",
"}",
"setSize",
"(",
"size",
"+",
"1",
")",
";",
"putKey",
"(",
"baseAddress",
",",
"slot",
",",
"key1",
",",
"key2",
")",
";",
"slotAssignmentResult",
".",
"setAddress",
"(",
"valueAddrOfSlot",
"(",
"slot",
")",
")",
";",
"slotAssignmentResult",
".",
"setNew",
"(",
"true",
")",
";",
"return",
"slotAssignmentResult",
";",
"}"
] |
These protected final methods will be called from the subclasses
|
[
"These",
"protected",
"final",
"methods",
"will",
"be",
"called",
"from",
"the",
"subclasses"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java#L221-L241
|
15,390
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java
|
HashSlotArrayBase.resizeTo
|
protected void resizeTo(long newCapacity) {
final long oldCapacity = capacity();
final long oldAllocatedSize = HEADER_SIZE + oldCapacity * slotLength;
final MemoryAllocator oldMalloc;
final long oldAddress;
if (auxMalloc != null) {
final long size = size();
oldAddress = move(baseAddress, oldCapacity, malloc, auxMalloc);
oldMalloc = auxMalloc;
auxAllocateAndAdjustFields(oldAddress, size, oldCapacity, newCapacity);
} else {
oldMalloc = malloc;
oldAddress = baseAddress;
allocateArrayAndAdjustFields(size(), newCapacity);
}
rehash(oldCapacity, oldAddress);
oldMalloc.free(oldAddress - HEADER_SIZE, oldAllocatedSize);
}
|
java
|
protected void resizeTo(long newCapacity) {
final long oldCapacity = capacity();
final long oldAllocatedSize = HEADER_SIZE + oldCapacity * slotLength;
final MemoryAllocator oldMalloc;
final long oldAddress;
if (auxMalloc != null) {
final long size = size();
oldAddress = move(baseAddress, oldCapacity, malloc, auxMalloc);
oldMalloc = auxMalloc;
auxAllocateAndAdjustFields(oldAddress, size, oldCapacity, newCapacity);
} else {
oldMalloc = malloc;
oldAddress = baseAddress;
allocateArrayAndAdjustFields(size(), newCapacity);
}
rehash(oldCapacity, oldAddress);
oldMalloc.free(oldAddress - HEADER_SIZE, oldAllocatedSize);
}
|
[
"protected",
"void",
"resizeTo",
"(",
"long",
"newCapacity",
")",
"{",
"final",
"long",
"oldCapacity",
"=",
"capacity",
"(",
")",
";",
"final",
"long",
"oldAllocatedSize",
"=",
"HEADER_SIZE",
"+",
"oldCapacity",
"*",
"slotLength",
";",
"final",
"MemoryAllocator",
"oldMalloc",
";",
"final",
"long",
"oldAddress",
";",
"if",
"(",
"auxMalloc",
"!=",
"null",
")",
"{",
"final",
"long",
"size",
"=",
"size",
"(",
")",
";",
"oldAddress",
"=",
"move",
"(",
"baseAddress",
",",
"oldCapacity",
",",
"malloc",
",",
"auxMalloc",
")",
";",
"oldMalloc",
"=",
"auxMalloc",
";",
"auxAllocateAndAdjustFields",
"(",
"oldAddress",
",",
"size",
",",
"oldCapacity",
",",
"newCapacity",
")",
";",
"}",
"else",
"{",
"oldMalloc",
"=",
"malloc",
";",
"oldAddress",
"=",
"baseAddress",
";",
"allocateArrayAndAdjustFields",
"(",
"size",
"(",
")",
",",
"newCapacity",
")",
";",
"}",
"rehash",
"(",
"oldCapacity",
",",
"oldAddress",
")",
";",
"oldMalloc",
".",
"free",
"(",
"oldAddress",
"-",
"HEADER_SIZE",
",",
"oldAllocatedSize",
")",
";",
"}"
] |
Allocates a new slot array with the requested size and moves all the
assigned slots from the current array into the new one.
|
[
"Allocates",
"a",
"new",
"slot",
"array",
"with",
"the",
"requested",
"size",
"and",
"moves",
"all",
"the",
"assigned",
"slots",
"from",
"the",
"current",
"array",
"into",
"the",
"new",
"one",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java#L363-L380
|
15,391
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java
|
HashSlotArrayBase.move
|
private long move(long fromBaseAddress, long capacity, MemoryAllocator fromMalloc, MemoryAllocator toMalloc) {
final long allocatedSize = HEADER_SIZE + capacity * slotLength;
final long toBaseAddress = toMalloc.allocate(allocatedSize) + HEADER_SIZE;
mem.copyMemory(fromBaseAddress - HEADER_SIZE, toBaseAddress - HEADER_SIZE, allocatedSize);
fromMalloc.free(fromBaseAddress - HEADER_SIZE, allocatedSize);
return toBaseAddress;
}
|
java
|
private long move(long fromBaseAddress, long capacity, MemoryAllocator fromMalloc, MemoryAllocator toMalloc) {
final long allocatedSize = HEADER_SIZE + capacity * slotLength;
final long toBaseAddress = toMalloc.allocate(allocatedSize) + HEADER_SIZE;
mem.copyMemory(fromBaseAddress - HEADER_SIZE, toBaseAddress - HEADER_SIZE, allocatedSize);
fromMalloc.free(fromBaseAddress - HEADER_SIZE, allocatedSize);
return toBaseAddress;
}
|
[
"private",
"long",
"move",
"(",
"long",
"fromBaseAddress",
",",
"long",
"capacity",
",",
"MemoryAllocator",
"fromMalloc",
",",
"MemoryAllocator",
"toMalloc",
")",
"{",
"final",
"long",
"allocatedSize",
"=",
"HEADER_SIZE",
"+",
"capacity",
"*",
"slotLength",
";",
"final",
"long",
"toBaseAddress",
"=",
"toMalloc",
".",
"allocate",
"(",
"allocatedSize",
")",
"+",
"HEADER_SIZE",
";",
"mem",
".",
"copyMemory",
"(",
"fromBaseAddress",
"-",
"HEADER_SIZE",
",",
"toBaseAddress",
"-",
"HEADER_SIZE",
",",
"allocatedSize",
")",
";",
"fromMalloc",
".",
"free",
"(",
"fromBaseAddress",
"-",
"HEADER_SIZE",
",",
"allocatedSize",
")",
";",
"return",
"toBaseAddress",
";",
"}"
] |
Copies a block from one allocator to another, then frees the source block.
|
[
"Copies",
"a",
"block",
"from",
"one",
"allocator",
"to",
"another",
"then",
"frees",
"the",
"source",
"block",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/hashslot/impl/HashSlotArrayBase.java#L473-L479
|
15,392
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java
|
CacheStatisticsImpl.addGetTimeNanos
|
public void addGetTimeNanos(long duration) {
for (;;) {
long nanos = getCacheTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (GET_CACHE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (GET_CACHE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
java
|
public void addGetTimeNanos(long duration) {
for (;;) {
long nanos = getCacheTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (GET_CACHE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (GET_CACHE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
[
"public",
"void",
"addGetTimeNanos",
"(",
"long",
"duration",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"long",
"nanos",
"=",
"getCacheTimeTakenNanos",
";",
"if",
"(",
"nanos",
"<=",
"Long",
".",
"MAX_VALUE",
"-",
"duration",
")",
"{",
"if",
"(",
"GET_CACHE_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"nanos",
"+",
"duration",
")",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"//counter full. Just reset.",
"if",
"(",
"GET_CACHE_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"duration",
")",
")",
"{",
"clear",
"(",
")",
";",
"return",
";",
"}",
"}",
"}",
"}"
] |
Increments the getCache time accumulator.
@param duration the time taken in nanoseconds.
|
[
"Increments",
"the",
"getCache",
"time",
"accumulator",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java#L368-L383
|
15,393
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java
|
CacheStatisticsImpl.addPutTimeNanos
|
public void addPutTimeNanos(long duration) {
for (;;) {
long nanos = putTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (PUT_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (PUT_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
java
|
public void addPutTimeNanos(long duration) {
for (;;) {
long nanos = putTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (PUT_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (PUT_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
[
"public",
"void",
"addPutTimeNanos",
"(",
"long",
"duration",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"long",
"nanos",
"=",
"putTimeTakenNanos",
";",
"if",
"(",
"nanos",
"<=",
"Long",
".",
"MAX_VALUE",
"-",
"duration",
")",
"{",
"if",
"(",
"PUT_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"nanos",
"+",
"duration",
")",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"//counter full. Just reset.",
"if",
"(",
"PUT_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"duration",
")",
")",
"{",
"clear",
"(",
")",
";",
"return",
";",
"}",
"}",
"}",
"}"
] |
Increments the put time accumulator.
@param duration the time taken in nanoseconds.
|
[
"Increments",
"the",
"put",
"time",
"accumulator",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java#L390-L405
|
15,394
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java
|
CacheStatisticsImpl.addRemoveTimeNanos
|
public void addRemoveTimeNanos(long duration) {
for (;;) {
long nanos = removeTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (REMOVE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (REMOVE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
java
|
public void addRemoveTimeNanos(long duration) {
for (;;) {
long nanos = removeTimeTakenNanos;
if (nanos <= Long.MAX_VALUE - duration) {
if (REMOVE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, nanos + duration)) {
return;
}
} else {
//counter full. Just reset.
if (REMOVE_TIME_TAKEN_NANOS.compareAndSet(this, nanos, duration)) {
clear();
return;
}
}
}
}
|
[
"public",
"void",
"addRemoveTimeNanos",
"(",
"long",
"duration",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"long",
"nanos",
"=",
"removeTimeTakenNanos",
";",
"if",
"(",
"nanos",
"<=",
"Long",
".",
"MAX_VALUE",
"-",
"duration",
")",
"{",
"if",
"(",
"REMOVE_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"nanos",
"+",
"duration",
")",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"//counter full. Just reset.",
"if",
"(",
"REMOVE_TIME_TAKEN_NANOS",
".",
"compareAndSet",
"(",
"this",
",",
"nanos",
",",
"duration",
")",
")",
"{",
"clear",
"(",
")",
";",
"return",
";",
"}",
"}",
"}",
"}"
] |
Increments the remove time accumulator.
@param duration the time taken in nanoseconds.
|
[
"Increments",
"the",
"remove",
"time",
"accumulator",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheStatisticsImpl.java#L412-L427
|
15,395
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/JVMUtil.java
|
JVMUtil.isObjectLayoutCompressedOopsOrNull
|
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
static Boolean isObjectLayoutCompressedOopsOrNull() {
if (!UNSAFE_AVAILABLE) {
return null;
}
Integer referenceSize = ReferenceSizeEstimator.getReferenceSizeOrNull();
if (referenceSize == null) {
return null;
}
// when reference size does not equal address size then it's safe to assume references are compressed
return referenceSize != UNSAFE.addressSize();
}
|
java
|
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
static Boolean isObjectLayoutCompressedOopsOrNull() {
if (!UNSAFE_AVAILABLE) {
return null;
}
Integer referenceSize = ReferenceSizeEstimator.getReferenceSizeOrNull();
if (referenceSize == null) {
return null;
}
// when reference size does not equal address size then it's safe to assume references are compressed
return referenceSize != UNSAFE.addressSize();
}
|
[
"@",
"SuppressFBWarnings",
"(",
"\"NP_BOOLEAN_RETURN_NULL\"",
")",
"static",
"Boolean",
"isObjectLayoutCompressedOopsOrNull",
"(",
")",
"{",
"if",
"(",
"!",
"UNSAFE_AVAILABLE",
")",
"{",
"return",
"null",
";",
"}",
"Integer",
"referenceSize",
"=",
"ReferenceSizeEstimator",
".",
"getReferenceSizeOrNull",
"(",
")",
";",
"if",
"(",
"referenceSize",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// when reference size does not equal address size then it's safe to assume references are compressed",
"return",
"referenceSize",
"!=",
"UNSAFE",
".",
"addressSize",
"(",
")",
";",
"}"
] |
Fallback when checking CompressedOopsEnabled.
|
[
"Fallback",
"when",
"checking",
"CompressedOopsEnabled",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JVMUtil.java#L90-L103
|
15,396
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
|
PortablePositionNavigator.navigateToPathTokenWithoutQuantifier
|
private static PortablePosition navigateToPathTokenWithoutQuantifier(
PortableNavigatorContext ctx, PortablePathCursor path) throws IOException {
if (path.isLastToken()) {
// if it's a token that's on the last position we calculate its direct access position and return it for
// reading in the value reader.
return createPositionForReadAccess(ctx, path);
} else {
// if it's not a token that's on the last position in the path we advance the position to the next token
// we also adjust the context, since advancing means that we are in the context of other
// (and possibly different) portable type.
if (!navigateContextToNextPortableTokenFromPortableField(ctx)) {
// we return null if we didn't manage to advance from the current token to the next one.
// For example: it may happen if the current token points to a null object.
return nilNotLeafPosition();
}
}
return null;
}
|
java
|
private static PortablePosition navigateToPathTokenWithoutQuantifier(
PortableNavigatorContext ctx, PortablePathCursor path) throws IOException {
if (path.isLastToken()) {
// if it's a token that's on the last position we calculate its direct access position and return it for
// reading in the value reader.
return createPositionForReadAccess(ctx, path);
} else {
// if it's not a token that's on the last position in the path we advance the position to the next token
// we also adjust the context, since advancing means that we are in the context of other
// (and possibly different) portable type.
if (!navigateContextToNextPortableTokenFromPortableField(ctx)) {
// we return null if we didn't manage to advance from the current token to the next one.
// For example: it may happen if the current token points to a null object.
return nilNotLeafPosition();
}
}
return null;
}
|
[
"private",
"static",
"PortablePosition",
"navigateToPathTokenWithoutQuantifier",
"(",
"PortableNavigatorContext",
"ctx",
",",
"PortablePathCursor",
"path",
")",
"throws",
"IOException",
"{",
"if",
"(",
"path",
".",
"isLastToken",
"(",
")",
")",
"{",
"// if it's a token that's on the last position we calculate its direct access position and return it for",
"// reading in the value reader.",
"return",
"createPositionForReadAccess",
"(",
"ctx",
",",
"path",
")",
";",
"}",
"else",
"{",
"// if it's not a token that's on the last position in the path we advance the position to the next token",
"// we also adjust the context, since advancing means that we are in the context of other",
"// (and possibly different) portable type.",
"if",
"(",
"!",
"navigateContextToNextPortableTokenFromPortableField",
"(",
"ctx",
")",
")",
"{",
"// we return null if we didn't manage to advance from the current token to the next one.",
"// For example: it may happen if the current token points to a null object.",
"return",
"nilNotLeafPosition",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Token without quantifier. It means it's just a simple field, not an array.
|
[
"Token",
"without",
"quantifier",
".",
"It",
"means",
"it",
"s",
"just",
"a",
"simple",
"field",
"not",
"an",
"array",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L170-L187
|
15,397
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
|
PortablePositionNavigator.navigateToPathTokenWithAnyQuantifierInPortableArray
|
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPortableArray(
PortableNavigatorContext ctx, PortablePathCursor path, NavigationFrame frame) throws IOException {
// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]
if (frame == null) {
// first we check if array null or empty
int len = getArrayLengthOfTheField(ctx);
PortablePosition result = doValidateArrayLengthForAnyQuantifier(len, path.isLastToken());
if (result != null) {
return result;
}
// then we populate frames for cell[1 to length-1]
ctx.populateAnyNavigationFrames(path.index(), len);
// pursue navigation to index 0, return result if last token
int cellIndex = 0;
result = doNavigateToPortableArrayCell(ctx, path, cellIndex);
if (result != null) {
return result;
}
} else {
// pursue navigation to index given by the frame, return result if last token
// no validation since it index in-bound has been validated while the navigation frames have been populated
PortablePosition result = doNavigateToPortableArrayCell(ctx, path, frame.arrayIndex);
if (result != null) {
return result;
}
}
return null;
}
|
java
|
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPortableArray(
PortableNavigatorContext ctx, PortablePathCursor path, NavigationFrame frame) throws IOException {
// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]
if (frame == null) {
// first we check if array null or empty
int len = getArrayLengthOfTheField(ctx);
PortablePosition result = doValidateArrayLengthForAnyQuantifier(len, path.isLastToken());
if (result != null) {
return result;
}
// then we populate frames for cell[1 to length-1]
ctx.populateAnyNavigationFrames(path.index(), len);
// pursue navigation to index 0, return result if last token
int cellIndex = 0;
result = doNavigateToPortableArrayCell(ctx, path, cellIndex);
if (result != null) {
return result;
}
} else {
// pursue navigation to index given by the frame, return result if last token
// no validation since it index in-bound has been validated while the navigation frames have been populated
PortablePosition result = doNavigateToPortableArrayCell(ctx, path, frame.arrayIndex);
if (result != null) {
return result;
}
}
return null;
}
|
[
"private",
"static",
"PortablePosition",
"navigateToPathTokenWithAnyQuantifierInPortableArray",
"(",
"PortableNavigatorContext",
"ctx",
",",
"PortablePathCursor",
"path",
",",
"NavigationFrame",
"frame",
")",
"throws",
"IOException",
"{",
"// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]",
"if",
"(",
"frame",
"==",
"null",
")",
"{",
"// first we check if array null or empty",
"int",
"len",
"=",
"getArrayLengthOfTheField",
"(",
"ctx",
")",
";",
"PortablePosition",
"result",
"=",
"doValidateArrayLengthForAnyQuantifier",
"(",
"len",
",",
"path",
".",
"isLastToken",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"// then we populate frames for cell[1 to length-1]",
"ctx",
".",
"populateAnyNavigationFrames",
"(",
"path",
".",
"index",
"(",
")",
",",
"len",
")",
";",
"// pursue navigation to index 0, return result if last token",
"int",
"cellIndex",
"=",
"0",
";",
"result",
"=",
"doNavigateToPortableArrayCell",
"(",
"ctx",
",",
"path",
",",
"cellIndex",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"else",
"{",
"// pursue navigation to index given by the frame, return result if last token",
"// no validation since it index in-bound has been validated while the navigation frames have been populated",
"PortablePosition",
"result",
"=",
"doNavigateToPortableArrayCell",
"(",
"ctx",
",",
"path",
",",
"frame",
".",
"arrayIndex",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
navigation in PORTABLE array
|
[
"navigation",
"in",
"PORTABLE",
"array"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L248-L277
|
15,398
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
|
PortablePositionNavigator.navigateToPathTokenWithAnyQuantifierInPrimitiveArray
|
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPrimitiveArray(
PortableNavigatorContext ctx, PortablePathCursor path, NavigationFrame frame) throws IOException {
// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]
if (frame == null) {
if (path.isLastToken()) {
// first we check if array null or empty
int len = getArrayLengthOfTheField(ctx);
PortablePosition result = doValidateArrayLengthForAnyQuantifier(len, path.isLastToken());
if (result != null) {
return result;
}
// then we populate frames for cell[1 to length-1]
ctx.populateAnyNavigationFrames(path.index(), len);
// finally, we return the cell's position for reading -> cell[0]
return createPositionForReadAccess(ctx, path, 0);
}
// primitive array cell has to be a last token, there's no furhter navigation from there.
throw createWrongUseOfAnyOperationException(ctx, path.path());
} else {
if (path.isLastToken()) {
return createPositionForReadAccess(ctx, path, frame.arrayIndex);
}
throw createWrongUseOfAnyOperationException(ctx, path.path());
}
}
|
java
|
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPrimitiveArray(
PortableNavigatorContext ctx, PortablePathCursor path, NavigationFrame frame) throws IOException {
// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]
if (frame == null) {
if (path.isLastToken()) {
// first we check if array null or empty
int len = getArrayLengthOfTheField(ctx);
PortablePosition result = doValidateArrayLengthForAnyQuantifier(len, path.isLastToken());
if (result != null) {
return result;
}
// then we populate frames for cell[1 to length-1]
ctx.populateAnyNavigationFrames(path.index(), len);
// finally, we return the cell's position for reading -> cell[0]
return createPositionForReadAccess(ctx, path, 0);
}
// primitive array cell has to be a last token, there's no furhter navigation from there.
throw createWrongUseOfAnyOperationException(ctx, path.path());
} else {
if (path.isLastToken()) {
return createPositionForReadAccess(ctx, path, frame.arrayIndex);
}
throw createWrongUseOfAnyOperationException(ctx, path.path());
}
}
|
[
"private",
"static",
"PortablePosition",
"navigateToPathTokenWithAnyQuantifierInPrimitiveArray",
"(",
"PortableNavigatorContext",
"ctx",
",",
"PortablePathCursor",
"path",
",",
"NavigationFrame",
"frame",
")",
"throws",
"IOException",
"{",
"// if no frame, we're pursuing the cell[0] case and populating the frames for cell[1 to length-1]",
"if",
"(",
"frame",
"==",
"null",
")",
"{",
"if",
"(",
"path",
".",
"isLastToken",
"(",
")",
")",
"{",
"// first we check if array null or empty",
"int",
"len",
"=",
"getArrayLengthOfTheField",
"(",
"ctx",
")",
";",
"PortablePosition",
"result",
"=",
"doValidateArrayLengthForAnyQuantifier",
"(",
"len",
",",
"path",
".",
"isLastToken",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"// then we populate frames for cell[1 to length-1]",
"ctx",
".",
"populateAnyNavigationFrames",
"(",
"path",
".",
"index",
"(",
")",
",",
"len",
")",
";",
"// finally, we return the cell's position for reading -> cell[0]",
"return",
"createPositionForReadAccess",
"(",
"ctx",
",",
"path",
",",
"0",
")",
";",
"}",
"// primitive array cell has to be a last token, there's no furhter navigation from there.",
"throw",
"createWrongUseOfAnyOperationException",
"(",
"ctx",
",",
"path",
".",
"path",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"path",
".",
"isLastToken",
"(",
")",
")",
"{",
"return",
"createPositionForReadAccess",
"(",
"ctx",
",",
"path",
",",
"frame",
".",
"arrayIndex",
")",
";",
"}",
"throw",
"createWrongUseOfAnyOperationException",
"(",
"ctx",
",",
"path",
".",
"path",
"(",
")",
")",
";",
"}",
"}"
] |
navigation in PRIMITIVE array
|
[
"navigation",
"in",
"PRIMITIVE",
"array"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L301-L327
|
15,399
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
|
PortablePositionNavigator.navigateContextToNextPortableTokenFromPortableField
|
private static boolean navigateContextToNextPortableTokenFromPortableField(PortableNavigatorContext ctx)
throws IOException {
BufferObjectDataInput in = ctx.getIn();
// find the field position that's stored in the fieldDefinition int the context and navigate to it
int pos = getStreamPositionOfTheField(ctx);
in.position(pos);
// check if it's null, if so return false indicating that the navigation has failed
boolean isNull = in.readBoolean();
if (isNull) {
return false;
}
// read factory and class ID and validate if it's the same as expected in the fieldDefinition
int factoryId = in.readInt();
int classId = in.readInt();
int versionId = in.readInt();
// initialise context with the given portable field for further navigation
ctx.advanceContextToNextPortableToken(factoryId, classId, versionId);
return true;
}
|
java
|
private static boolean navigateContextToNextPortableTokenFromPortableField(PortableNavigatorContext ctx)
throws IOException {
BufferObjectDataInput in = ctx.getIn();
// find the field position that's stored in the fieldDefinition int the context and navigate to it
int pos = getStreamPositionOfTheField(ctx);
in.position(pos);
// check if it's null, if so return false indicating that the navigation has failed
boolean isNull = in.readBoolean();
if (isNull) {
return false;
}
// read factory and class ID and validate if it's the same as expected in the fieldDefinition
int factoryId = in.readInt();
int classId = in.readInt();
int versionId = in.readInt();
// initialise context with the given portable field for further navigation
ctx.advanceContextToNextPortableToken(factoryId, classId, versionId);
return true;
}
|
[
"private",
"static",
"boolean",
"navigateContextToNextPortableTokenFromPortableField",
"(",
"PortableNavigatorContext",
"ctx",
")",
"throws",
"IOException",
"{",
"BufferObjectDataInput",
"in",
"=",
"ctx",
".",
"getIn",
"(",
")",
";",
"// find the field position that's stored in the fieldDefinition int the context and navigate to it",
"int",
"pos",
"=",
"getStreamPositionOfTheField",
"(",
"ctx",
")",
";",
"in",
".",
"position",
"(",
"pos",
")",
";",
"// check if it's null, if so return false indicating that the navigation has failed",
"boolean",
"isNull",
"=",
"in",
".",
"readBoolean",
"(",
")",
";",
"if",
"(",
"isNull",
")",
"{",
"return",
"false",
";",
"}",
"// read factory and class ID and validate if it's the same as expected in the fieldDefinition",
"int",
"factoryId",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"int",
"classId",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"int",
"versionId",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"// initialise context with the given portable field for further navigation",
"ctx",
".",
"advanceContextToNextPortableToken",
"(",
"factoryId",
",",
"classId",
",",
"versionId",
")",
";",
"return",
"true",
";",
"}"
] |
returns true if managed to advance, false if advance failed due to null field
|
[
"returns",
"true",
"if",
"managed",
"to",
"advance",
"false",
"if",
"advance",
"failed",
"due",
"to",
"null",
"field"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L362-L384
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.