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,200
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/jmx/InstanceMBean.java
|
InstanceMBean.registerWanPublisherMBeans
|
private void registerWanPublisherMBeans(WanReplicationService wanReplicationService) {
final Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
if (wanStats == null) {
return;
}
for (Entry<String, LocalWanStats> replicationStatsEntry : wanStats.entrySet()) {
final String wanReplicationName = replicationStatsEntry.getKey();
final LocalWanStats localWanStats = replicationStatsEntry.getValue();
final Map<String, LocalWanPublisherStats> publisherStats = localWanStats.getLocalWanPublisherStats();
for (String targetGroupName : publisherStats.keySet()) {
register(new WanPublisherMBean(wanReplicationService, wanReplicationName, targetGroupName, service));
}
}
}
|
java
|
private void registerWanPublisherMBeans(WanReplicationService wanReplicationService) {
final Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
if (wanStats == null) {
return;
}
for (Entry<String, LocalWanStats> replicationStatsEntry : wanStats.entrySet()) {
final String wanReplicationName = replicationStatsEntry.getKey();
final LocalWanStats localWanStats = replicationStatsEntry.getValue();
final Map<String, LocalWanPublisherStats> publisherStats = localWanStats.getLocalWanPublisherStats();
for (String targetGroupName : publisherStats.keySet()) {
register(new WanPublisherMBean(wanReplicationService, wanReplicationName, targetGroupName, service));
}
}
}
|
[
"private",
"void",
"registerWanPublisherMBeans",
"(",
"WanReplicationService",
"wanReplicationService",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"LocalWanStats",
">",
"wanStats",
"=",
"wanReplicationService",
".",
"getStats",
"(",
")",
";",
"if",
"(",
"wanStats",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"LocalWanStats",
">",
"replicationStatsEntry",
":",
"wanStats",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"wanReplicationName",
"=",
"replicationStatsEntry",
".",
"getKey",
"(",
")",
";",
"final",
"LocalWanStats",
"localWanStats",
"=",
"replicationStatsEntry",
".",
"getValue",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"LocalWanPublisherStats",
">",
"publisherStats",
"=",
"localWanStats",
".",
"getLocalWanPublisherStats",
"(",
")",
";",
"for",
"(",
"String",
"targetGroupName",
":",
"publisherStats",
".",
"keySet",
"(",
")",
")",
"{",
"register",
"(",
"new",
"WanPublisherMBean",
"(",
"wanReplicationService",
",",
"wanReplicationName",
",",
"targetGroupName",
",",
"service",
")",
")",
";",
"}",
"}",
"}"
] |
Registers managed beans for all WAN publishers, if any.
@param wanReplicationService the WAN replication service
|
[
"Registers",
"managed",
"beans",
"for",
"all",
"WAN",
"publishers",
"if",
"any",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/jmx/InstanceMBean.java#L89-L104
|
15,201
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java
|
BiInt2ObjectMap.remove
|
public V remove(final int keyPartA, final int keyPartB) {
final long key = compoundKey(keyPartA, keyPartB);
return map.remove(key);
}
|
java
|
public V remove(final int keyPartA, final int keyPartB) {
final long key = compoundKey(keyPartA, keyPartB);
return map.remove(key);
}
|
[
"public",
"V",
"remove",
"(",
"final",
"int",
"keyPartA",
",",
"final",
"int",
"keyPartB",
")",
"{",
"final",
"long",
"key",
"=",
"compoundKey",
"(",
"keyPartA",
",",
"keyPartB",
")",
";",
"return",
"map",
".",
"remove",
"(",
"key",
")",
";",
"}"
] |
Remove a value from the map and return the value.
@param keyPartA for the key
@param keyPartB for the key
@return the previous value if found otherwise null
|
[
"Remove",
"a",
"value",
"from",
"the",
"map",
"and",
"return",
"the",
"value",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java#L122-L126
|
15,202
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java
|
BiInt2ObjectMap.forEach
|
public void forEach(final EntryConsumer<V> consumer) {
for (Map.Entry<Long, V> entry : map.entrySet()) {
Long compoundKey = entry.getKey();
final int keyPartA = (int) (compoundKey >>> Integer.SIZE);
final int keyPartB = (int) (compoundKey & LOWER_INT_MASK);
consumer.accept(keyPartA, keyPartB, entry.getValue());
}
}
|
java
|
public void forEach(final EntryConsumer<V> consumer) {
for (Map.Entry<Long, V> entry : map.entrySet()) {
Long compoundKey = entry.getKey();
final int keyPartA = (int) (compoundKey >>> Integer.SIZE);
final int keyPartB = (int) (compoundKey & LOWER_INT_MASK);
consumer.accept(keyPartA, keyPartB, entry.getValue());
}
}
|
[
"public",
"void",
"forEach",
"(",
"final",
"EntryConsumer",
"<",
"V",
">",
"consumer",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"V",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Long",
"compoundKey",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"int",
"keyPartA",
"=",
"(",
"int",
")",
"(",
"compoundKey",
">>>",
"Integer",
".",
"SIZE",
")",
";",
"final",
"int",
"keyPartB",
"=",
"(",
"int",
")",
"(",
"compoundKey",
"&",
"LOWER_INT_MASK",
")",
";",
"consumer",
".",
"accept",
"(",
"keyPartA",
",",
"keyPartB",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Iterate over the entries of the map
@param consumer to apply to each entry in the map
|
[
"Iterate",
"over",
"the",
"entries",
"of",
"the",
"map"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java#L133-L140
|
15,203
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java
|
BiInt2ObjectMap.forEach
|
public void forEach(final Consumer<V> consumer) {
for (Map.Entry<Long, V> entry : map.entrySet()) {
consumer.accept(entry.getValue());
}
}
|
java
|
public void forEach(final Consumer<V> consumer) {
for (Map.Entry<Long, V> entry : map.entrySet()) {
consumer.accept(entry.getValue());
}
}
|
[
"public",
"void",
"forEach",
"(",
"final",
"Consumer",
"<",
"V",
">",
"consumer",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"V",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"consumer",
".",
"accept",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Iterate over the values in the map
@param consumer to apply to each value in the map
|
[
"Iterate",
"over",
"the",
"values",
"in",
"the",
"map"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/BiInt2ObjectMap.java#L147-L151
|
15,204
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java
|
SuffixModifierUtils.removeModifierSuffix
|
public static String removeModifierSuffix(String fullName) {
int indexOfFirstOpeningToken = fullName.indexOf(MODIFIER_OPENING_TOKEN);
if (indexOfFirstOpeningToken == -1) {
return fullName;
}
int indexOfSecondOpeningToken = fullName.lastIndexOf(MODIFIER_OPENING_TOKEN);
if (indexOfSecondOpeningToken != indexOfFirstOpeningToken) {
throw new IllegalArgumentException("Attribute name '" + fullName
+ "' is not valid as it contains more than one " + MODIFIER_OPENING_TOKEN);
}
int indexOfFirstClosingToken = fullName.indexOf(MODIFIER_CLOSING_TOKEN);
if (indexOfFirstClosingToken != fullName.length() - 1) {
throw new IllegalArgumentException("Attribute name '" + fullName
+ "' is not valid as the last character is not " + MODIFIER_CLOSING_TOKEN);
}
return fullName.substring(0, indexOfFirstOpeningToken);
}
|
java
|
public static String removeModifierSuffix(String fullName) {
int indexOfFirstOpeningToken = fullName.indexOf(MODIFIER_OPENING_TOKEN);
if (indexOfFirstOpeningToken == -1) {
return fullName;
}
int indexOfSecondOpeningToken = fullName.lastIndexOf(MODIFIER_OPENING_TOKEN);
if (indexOfSecondOpeningToken != indexOfFirstOpeningToken) {
throw new IllegalArgumentException("Attribute name '" + fullName
+ "' is not valid as it contains more than one " + MODIFIER_OPENING_TOKEN);
}
int indexOfFirstClosingToken = fullName.indexOf(MODIFIER_CLOSING_TOKEN);
if (indexOfFirstClosingToken != fullName.length() - 1) {
throw new IllegalArgumentException("Attribute name '" + fullName
+ "' is not valid as the last character is not " + MODIFIER_CLOSING_TOKEN);
}
return fullName.substring(0, indexOfFirstOpeningToken);
}
|
[
"public",
"static",
"String",
"removeModifierSuffix",
"(",
"String",
"fullName",
")",
"{",
"int",
"indexOfFirstOpeningToken",
"=",
"fullName",
".",
"indexOf",
"(",
"MODIFIER_OPENING_TOKEN",
")",
";",
"if",
"(",
"indexOfFirstOpeningToken",
"==",
"-",
"1",
")",
"{",
"return",
"fullName",
";",
"}",
"int",
"indexOfSecondOpeningToken",
"=",
"fullName",
".",
"lastIndexOf",
"(",
"MODIFIER_OPENING_TOKEN",
")",
";",
"if",
"(",
"indexOfSecondOpeningToken",
"!=",
"indexOfFirstOpeningToken",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name '\"",
"+",
"fullName",
"+",
"\"' is not valid as it contains more than one \"",
"+",
"MODIFIER_OPENING_TOKEN",
")",
";",
"}",
"int",
"indexOfFirstClosingToken",
"=",
"fullName",
".",
"indexOf",
"(",
"MODIFIER_CLOSING_TOKEN",
")",
";",
"if",
"(",
"indexOfFirstClosingToken",
"!=",
"fullName",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name '\"",
"+",
"fullName",
"+",
"\"' is not valid as the last character is not \"",
"+",
"MODIFIER_CLOSING_TOKEN",
")",
";",
"}",
"return",
"fullName",
".",
"substring",
"(",
"0",
",",
"indexOfFirstOpeningToken",
")",
";",
"}"
] |
Remove modifier suffix from given fullName.
@param fullName
@return
|
[
"Remove",
"modifier",
"suffix",
"from",
"given",
"fullName",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java#L44-L61
|
15,205
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java
|
SuffixModifierUtils.getModifierSuffix
|
public static String getModifierSuffix(String fullName, String baseName) {
if (fullName.equals(baseName)) {
return null;
}
int indexOfOpeningBracket = fullName.indexOf(MODIFIER_OPENING_TOKEN);
return fullName.substring(indexOfOpeningBracket, fullName.length());
}
|
java
|
public static String getModifierSuffix(String fullName, String baseName) {
if (fullName.equals(baseName)) {
return null;
}
int indexOfOpeningBracket = fullName.indexOf(MODIFIER_OPENING_TOKEN);
return fullName.substring(indexOfOpeningBracket, fullName.length());
}
|
[
"public",
"static",
"String",
"getModifierSuffix",
"(",
"String",
"fullName",
",",
"String",
"baseName",
")",
"{",
"if",
"(",
"fullName",
".",
"equals",
"(",
"baseName",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"indexOfOpeningBracket",
"=",
"fullName",
".",
"indexOf",
"(",
"MODIFIER_OPENING_TOKEN",
")",
";",
"return",
"fullName",
".",
"substring",
"(",
"indexOfOpeningBracket",
",",
"fullName",
".",
"length",
"(",
")",
")",
";",
"}"
] |
Get modifier suffix if fullName contains any otherwise returns null.
In contains no validation of input parameters as it assumes the validation
has been already done by {@link #removeModifierSuffix(String)}
@param fullName
@param baseName as returned by {@link #removeModifierSuffix(String)}
@return modifier suffix or null if no suffix is present
|
[
"Get",
"modifier",
"suffix",
"if",
"fullName",
"contains",
"any",
"otherwise",
"returns",
"null",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java#L74-L80
|
15,206
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/ObjectDataInputStream.java
|
ObjectDataInputStream.readDataAsObject
|
@Override
public <T> T readDataAsObject() throws IOException {
Data data = readData();
return data == null ? null : (T) serializationService.toObject(data);
}
|
java
|
@Override
public <T> T readDataAsObject() throws IOException {
Data data = readData();
return data == null ? null : (T) serializationService.toObject(data);
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"readDataAsObject",
"(",
")",
"throws",
"IOException",
"{",
"Data",
"data",
"=",
"readData",
"(",
")",
";",
"return",
"data",
"==",
"null",
"?",
"null",
":",
"(",
"T",
")",
"serializationService",
".",
"toObject",
"(",
"data",
")",
";",
"}"
] |
a future optimization would be to skip the construction of the Data object.
|
[
"a",
"future",
"optimization",
"would",
"be",
"to",
"skip",
"the",
"construction",
"of",
"the",
"Data",
"object",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/ObjectDataInputStream.java#L339-L343
|
15,207
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java
|
ClusterJoinManager.isValidJoinMessage
|
private boolean isValidJoinMessage(JoinMessage joinMessage) {
try {
return validateJoinMessage(joinMessage);
} catch (ConfigMismatchException e) {
throw e;
} catch (Exception e) {
return false;
}
}
|
java
|
private boolean isValidJoinMessage(JoinMessage joinMessage) {
try {
return validateJoinMessage(joinMessage);
} catch (ConfigMismatchException e) {
throw e;
} catch (Exception e) {
return false;
}
}
|
[
"private",
"boolean",
"isValidJoinMessage",
"(",
"JoinMessage",
"joinMessage",
")",
"{",
"try",
"{",
"return",
"validateJoinMessage",
"(",
"joinMessage",
")",
";",
"}",
"catch",
"(",
"ConfigMismatchException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
rethrows only on ConfigMismatchException; in case of other exception, returns false.
|
[
"rethrows",
"only",
"on",
"ConfigMismatchException",
";",
"in",
"case",
"of",
"other",
"exception",
"returns",
"false",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java#L208-L216
|
15,208
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java
|
ClusterJoinManager.handleMasterResponse
|
public void handleMasterResponse(Address masterAddress, Address callerAddress) {
clusterServiceLock.lock();
try {
if (logger.isFineEnabled()) {
logger.fine(format("Handling master response %s from %s", masterAddress, callerAddress));
}
if (clusterService.isJoined()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring master response %s from %s, this node is already joined",
masterAddress, callerAddress));
}
return;
}
if (node.getThisAddress().equals(masterAddress)) {
logger.warning("Received my address as master address from " + callerAddress);
return;
}
Address currentMaster = clusterService.getMasterAddress();
if (currentMaster == null || currentMaster.equals(masterAddress)) {
setMasterAndJoin(masterAddress);
return;
}
if (currentMaster.equals(callerAddress)) {
logger.warning(format("Setting master to %s since %s says it is not master anymore", masterAddress,
currentMaster));
setMasterAndJoin(masterAddress);
return;
}
Connection conn = node.getEndpointManager(MEMBER).getConnection(currentMaster);
if (conn != null && conn.isAlive()) {
logger.info(format("Ignoring master response %s from %s since this node has an active master %s",
masterAddress, callerAddress, currentMaster));
sendJoinRequest(currentMaster, true);
} else {
logger.warning(format("Ambiguous master response! Received master response %s from %s. "
+ "This node has a master %s, but does not have an active connection to it. "
+ "Master field will be unset now.",
masterAddress, callerAddress, currentMaster));
clusterService.setMasterAddress(null);
}
} finally {
clusterServiceLock.unlock();
}
}
|
java
|
public void handleMasterResponse(Address masterAddress, Address callerAddress) {
clusterServiceLock.lock();
try {
if (logger.isFineEnabled()) {
logger.fine(format("Handling master response %s from %s", masterAddress, callerAddress));
}
if (clusterService.isJoined()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring master response %s from %s, this node is already joined",
masterAddress, callerAddress));
}
return;
}
if (node.getThisAddress().equals(masterAddress)) {
logger.warning("Received my address as master address from " + callerAddress);
return;
}
Address currentMaster = clusterService.getMasterAddress();
if (currentMaster == null || currentMaster.equals(masterAddress)) {
setMasterAndJoin(masterAddress);
return;
}
if (currentMaster.equals(callerAddress)) {
logger.warning(format("Setting master to %s since %s says it is not master anymore", masterAddress,
currentMaster));
setMasterAndJoin(masterAddress);
return;
}
Connection conn = node.getEndpointManager(MEMBER).getConnection(currentMaster);
if (conn != null && conn.isAlive()) {
logger.info(format("Ignoring master response %s from %s since this node has an active master %s",
masterAddress, callerAddress, currentMaster));
sendJoinRequest(currentMaster, true);
} else {
logger.warning(format("Ambiguous master response! Received master response %s from %s. "
+ "This node has a master %s, but does not have an active connection to it. "
+ "Master field will be unset now.",
masterAddress, callerAddress, currentMaster));
clusterService.setMasterAddress(null);
}
} finally {
clusterServiceLock.unlock();
}
}
|
[
"public",
"void",
"handleMasterResponse",
"(",
"Address",
"masterAddress",
",",
"Address",
"callerAddress",
")",
"{",
"clusterServiceLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"format",
"(",
"\"Handling master response %s from %s\"",
",",
"masterAddress",
",",
"callerAddress",
")",
")",
";",
"}",
"if",
"(",
"clusterService",
".",
"isJoined",
"(",
")",
")",
"{",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"format",
"(",
"\"Ignoring master response %s from %s, this node is already joined\"",
",",
"masterAddress",
",",
"callerAddress",
")",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"node",
".",
"getThisAddress",
"(",
")",
".",
"equals",
"(",
"masterAddress",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"\"Received my address as master address from \"",
"+",
"callerAddress",
")",
";",
"return",
";",
"}",
"Address",
"currentMaster",
"=",
"clusterService",
".",
"getMasterAddress",
"(",
")",
";",
"if",
"(",
"currentMaster",
"==",
"null",
"||",
"currentMaster",
".",
"equals",
"(",
"masterAddress",
")",
")",
"{",
"setMasterAndJoin",
"(",
"masterAddress",
")",
";",
"return",
";",
"}",
"if",
"(",
"currentMaster",
".",
"equals",
"(",
"callerAddress",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"format",
"(",
"\"Setting master to %s since %s says it is not master anymore\"",
",",
"masterAddress",
",",
"currentMaster",
")",
")",
";",
"setMasterAndJoin",
"(",
"masterAddress",
")",
";",
"return",
";",
"}",
"Connection",
"conn",
"=",
"node",
".",
"getEndpointManager",
"(",
"MEMBER",
")",
".",
"getConnection",
"(",
"currentMaster",
")",
";",
"if",
"(",
"conn",
"!=",
"null",
"&&",
"conn",
".",
"isAlive",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"format",
"(",
"\"Ignoring master response %s from %s since this node has an active master %s\"",
",",
"masterAddress",
",",
"callerAddress",
",",
"currentMaster",
")",
")",
";",
"sendJoinRequest",
"(",
"currentMaster",
",",
"true",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warning",
"(",
"format",
"(",
"\"Ambiguous master response! Received master response %s from %s. \"",
"+",
"\"This node has a master %s, but does not have an active connection to it. \"",
"+",
"\"Master field will be unset now.\"",
",",
"masterAddress",
",",
"callerAddress",
",",
"currentMaster",
")",
")",
";",
"clusterService",
".",
"setMasterAddress",
"(",
"null",
")",
";",
"}",
"}",
"finally",
"{",
"clusterServiceLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Set master address, if required.
@param masterAddress address of cluster's master, as provided in {@link MasterResponseOp}
@param callerAddress address of node that sent the {@link MasterResponseOp}
@see MasterResponseOp
|
[
"Set",
"master",
"address",
"if",
"required",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java#L490-L538
|
15,209
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java
|
ClusterJoinManager.shouldMergeTo
|
private boolean shouldMergeTo(Address thisAddress, Address targetAddress) {
String thisAddressStr = "[" + thisAddress.getHost() + "]:" + thisAddress.getPort();
String targetAddressStr = "[" + targetAddress.getHost() + "]:" + targetAddress.getPort();
if (thisAddressStr.equals(targetAddressStr)) {
throw new IllegalArgumentException("Addresses should be different! This: "
+ thisAddress + ", Target: " + targetAddress);
}
// Since strings are guaranteed to be different, result will always be non-zero.
int result = thisAddressStr.compareTo(targetAddressStr);
return result > 0;
}
|
java
|
private boolean shouldMergeTo(Address thisAddress, Address targetAddress) {
String thisAddressStr = "[" + thisAddress.getHost() + "]:" + thisAddress.getPort();
String targetAddressStr = "[" + targetAddress.getHost() + "]:" + targetAddress.getPort();
if (thisAddressStr.equals(targetAddressStr)) {
throw new IllegalArgumentException("Addresses should be different! This: "
+ thisAddress + ", Target: " + targetAddress);
}
// Since strings are guaranteed to be different, result will always be non-zero.
int result = thisAddressStr.compareTo(targetAddressStr);
return result > 0;
}
|
[
"private",
"boolean",
"shouldMergeTo",
"(",
"Address",
"thisAddress",
",",
"Address",
"targetAddress",
")",
"{",
"String",
"thisAddressStr",
"=",
"\"[\"",
"+",
"thisAddress",
".",
"getHost",
"(",
")",
"+",
"\"]:\"",
"+",
"thisAddress",
".",
"getPort",
"(",
")",
";",
"String",
"targetAddressStr",
"=",
"\"[\"",
"+",
"targetAddress",
".",
"getHost",
"(",
")",
"+",
"\"]:\"",
"+",
"targetAddress",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"thisAddressStr",
".",
"equals",
"(",
"targetAddressStr",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Addresses should be different! This: \"",
"+",
"thisAddress",
"+",
"\", Target: \"",
"+",
"targetAddress",
")",
";",
"}",
"// Since strings are guaranteed to be different, result will always be non-zero.",
"int",
"result",
"=",
"thisAddressStr",
".",
"compareTo",
"(",
"targetAddressStr",
")",
";",
"return",
"result",
">",
"0",
";",
"}"
] |
Determines whether this address should merge to target address and called when two sides are equal on all aspects.
This is a pure function that must produce always the same output when called with the same parameters.
This logic should not be changed, otherwise compatibility will be broken.
@param thisAddress this address
@param targetAddress target address
@return true if this address should merge to target, false otherwise
|
[
"Determines",
"whether",
"this",
"address",
"should",
"merge",
"to",
"target",
"address",
"and",
"called",
"when",
"two",
"sides",
"are",
"equal",
"on",
"all",
"aspects",
".",
"This",
"is",
"a",
"pure",
"function",
"that",
"must",
"produce",
"always",
"the",
"same",
"output",
"when",
"called",
"with",
"the",
"same",
"parameters",
".",
"This",
"logic",
"should",
"not",
"be",
"changed",
"otherwise",
"compatibility",
"will",
"be",
"broken",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterJoinManager.java#L910-L922
|
15,210
|
hazelcast/hazelcast
|
hazelcast-spring/src/main/java/com/hazelcast/spring/transaction/HazelcastTransactionManager.java
|
HazelcastTransactionManager.getTransactionContext
|
public static TransactionContext getTransactionContext(HazelcastInstance hazelcastInstance) {
TransactionContextHolder transactionContextHolder =
(TransactionContextHolder) TransactionSynchronizationManager.getResource(hazelcastInstance);
if (transactionContextHolder == null) {
throw new NoTransactionException("No TransactionContext with actual transaction available for current thread");
}
return transactionContextHolder.getContext();
}
|
java
|
public static TransactionContext getTransactionContext(HazelcastInstance hazelcastInstance) {
TransactionContextHolder transactionContextHolder =
(TransactionContextHolder) TransactionSynchronizationManager.getResource(hazelcastInstance);
if (transactionContextHolder == null) {
throw new NoTransactionException("No TransactionContext with actual transaction available for current thread");
}
return transactionContextHolder.getContext();
}
|
[
"public",
"static",
"TransactionContext",
"getTransactionContext",
"(",
"HazelcastInstance",
"hazelcastInstance",
")",
"{",
"TransactionContextHolder",
"transactionContextHolder",
"=",
"(",
"TransactionContextHolder",
")",
"TransactionSynchronizationManager",
".",
"getResource",
"(",
"hazelcastInstance",
")",
";",
"if",
"(",
"transactionContextHolder",
"==",
"null",
")",
"{",
"throw",
"new",
"NoTransactionException",
"(",
"\"No TransactionContext with actual transaction available for current thread\"",
")",
";",
"}",
"return",
"transactionContextHolder",
".",
"getContext",
"(",
")",
";",
"}"
] |
Returns the transaction context for the given Hazelcast instance bounded to the current thread.
@throws NoTransactionException if the transaction context cannot be found
|
[
"Returns",
"the",
"transaction",
"context",
"for",
"the",
"given",
"Hazelcast",
"instance",
"bounded",
"to",
"the",
"current",
"thread",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-spring/src/main/java/com/hazelcast/spring/transaction/HazelcastTransactionManager.java#L56-L63
|
15,211
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AbstractAddConfigMessageTask.java
|
AbstractAddConfigMessageTask.mergePolicyConfig
|
protected MergePolicyConfig mergePolicyConfig(boolean mergePolicyExist, String mergePolicy, int batchSize) {
if (mergePolicyExist) {
MergePolicyConfig config = new MergePolicyConfig(mergePolicy, batchSize);
return config;
}
return new MergePolicyConfig();
}
|
java
|
protected MergePolicyConfig mergePolicyConfig(boolean mergePolicyExist, String mergePolicy, int batchSize) {
if (mergePolicyExist) {
MergePolicyConfig config = new MergePolicyConfig(mergePolicy, batchSize);
return config;
}
return new MergePolicyConfig();
}
|
[
"protected",
"MergePolicyConfig",
"mergePolicyConfig",
"(",
"boolean",
"mergePolicyExist",
",",
"String",
"mergePolicy",
",",
"int",
"batchSize",
")",
"{",
"if",
"(",
"mergePolicyExist",
")",
"{",
"MergePolicyConfig",
"config",
"=",
"new",
"MergePolicyConfig",
"(",
"mergePolicy",
",",
"batchSize",
")",
";",
"return",
"config",
";",
"}",
"return",
"new",
"MergePolicyConfig",
"(",
")",
";",
"}"
] |
returns a MergePolicyConfig based on given parameters if these exist, or the default MergePolicyConfig
|
[
"returns",
"a",
"MergePolicyConfig",
"based",
"on",
"given",
"parameters",
"if",
"these",
"exist",
"or",
"the",
"default",
"MergePolicyConfig"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AbstractAddConfigMessageTask.java#L88-L94
|
15,212
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
|
RaftNodeImpl.start
|
public void start() {
if (!raftIntegration.isReady()) {
raftIntegration.schedule(new Runnable() {
@Override
public void run() {
start();
}
}, RAFT_NODE_INIT_DELAY_MILLIS, MILLISECONDS);
return;
}
if (logger.isFineEnabled()) {
logger.fine("Starting raft node: " + localMember + " for " + groupId
+ " with " + state.memberCount() + " members: " + state.members());
}
raftIntegration.execute(new PreVoteTask(this, 0));
scheduleLeaderFailureDetection();
}
|
java
|
public void start() {
if (!raftIntegration.isReady()) {
raftIntegration.schedule(new Runnable() {
@Override
public void run() {
start();
}
}, RAFT_NODE_INIT_DELAY_MILLIS, MILLISECONDS);
return;
}
if (logger.isFineEnabled()) {
logger.fine("Starting raft node: " + localMember + " for " + groupId
+ " with " + state.memberCount() + " members: " + state.members());
}
raftIntegration.execute(new PreVoteTask(this, 0));
scheduleLeaderFailureDetection();
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"!",
"raftIntegration",
".",
"isReady",
"(",
")",
")",
"{",
"raftIntegration",
".",
"schedule",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"start",
"(",
")",
";",
"}",
"}",
",",
"RAFT_NODE_INIT_DELAY_MILLIS",
",",
"MILLISECONDS",
")",
";",
"return",
";",
"}",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Starting raft node: \"",
"+",
"localMember",
"+",
"\" for \"",
"+",
"groupId",
"+",
"\" with \"",
"+",
"state",
".",
"memberCount",
"(",
")",
"+",
"\" members: \"",
"+",
"state",
".",
"members",
"(",
")",
")",
";",
"}",
"raftIntegration",
".",
"execute",
"(",
"new",
"PreVoteTask",
"(",
"this",
",",
"0",
")",
")",
";",
"scheduleLeaderFailureDetection",
"(",
")",
";",
"}"
] |
Starts the periodic tasks, such as voting, leader failure-detection, snapshot handling.
|
[
"Starts",
"the",
"periodic",
"tasks",
"such",
"as",
"voting",
"leader",
"failure",
"-",
"detection",
"snapshot",
"handling",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L197-L215
|
15,213
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
|
RaftNodeImpl.applyLogEntry
|
private void applyLogEntry(LogEntry entry) {
if (logger.isFineEnabled()) {
logger.fine("Processing " + entry);
}
Object response = null;
Object operation = entry.operation();
if (operation instanceof RaftGroupCmd) {
if (operation instanceof DestroyRaftGroupCmd) {
setStatus(TERMINATED);
} else if (operation instanceof UpdateRaftGroupMembersCmd) {
if (state.lastGroupMembers().index() < entry.index()) {
setStatus(UPDATING_GROUP_MEMBER_LIST);
UpdateRaftGroupMembersCmd op = (UpdateRaftGroupMembersCmd) operation;
updateGroupMembers(entry.index(), op.getMembers());
}
assert status == UPDATING_GROUP_MEMBER_LIST : "STATUS: " + status;
assert state.lastGroupMembers().index() == entry.index();
state.commitGroupMembers();
UpdateRaftGroupMembersCmd cmd = (UpdateRaftGroupMembersCmd) operation;
if (cmd.getMember().equals(localMember) && cmd.getMode() == MembershipChangeMode.REMOVE) {
setStatus(STEPPED_DOWN);
// If I am the leader, I may have some waiting futures whose operations are already committed
// but responses are not decided yet. When I leave the cluster after my shutdown, invocations
// of those futures will receive MemberLeftException and retry. However, if I have an invocation
// during the shutdown process, its future will not complete unless I notify it here.
// Although LeaderDemotedException is designed for another case, we use it here since
// invocations internally retry when they receive LeaderDemotedException.
invalidateFuturesUntil(entry.index() - 1, new LeaderDemotedException(localMember, null));
} else {
setStatus(ACTIVE);
}
response = entry.index();
} else {
response = new IllegalArgumentException("Invalid command: " + operation);
}
} else {
response = raftIntegration.runOperation(operation, entry.index());
}
if (response == PostponedResponse.INSTANCE) {
// postpone sending response
return;
}
completeFuture(entry.index(), response);
}
|
java
|
private void applyLogEntry(LogEntry entry) {
if (logger.isFineEnabled()) {
logger.fine("Processing " + entry);
}
Object response = null;
Object operation = entry.operation();
if (operation instanceof RaftGroupCmd) {
if (operation instanceof DestroyRaftGroupCmd) {
setStatus(TERMINATED);
} else if (operation instanceof UpdateRaftGroupMembersCmd) {
if (state.lastGroupMembers().index() < entry.index()) {
setStatus(UPDATING_GROUP_MEMBER_LIST);
UpdateRaftGroupMembersCmd op = (UpdateRaftGroupMembersCmd) operation;
updateGroupMembers(entry.index(), op.getMembers());
}
assert status == UPDATING_GROUP_MEMBER_LIST : "STATUS: " + status;
assert state.lastGroupMembers().index() == entry.index();
state.commitGroupMembers();
UpdateRaftGroupMembersCmd cmd = (UpdateRaftGroupMembersCmd) operation;
if (cmd.getMember().equals(localMember) && cmd.getMode() == MembershipChangeMode.REMOVE) {
setStatus(STEPPED_DOWN);
// If I am the leader, I may have some waiting futures whose operations are already committed
// but responses are not decided yet. When I leave the cluster after my shutdown, invocations
// of those futures will receive MemberLeftException and retry. However, if I have an invocation
// during the shutdown process, its future will not complete unless I notify it here.
// Although LeaderDemotedException is designed for another case, we use it here since
// invocations internally retry when they receive LeaderDemotedException.
invalidateFuturesUntil(entry.index() - 1, new LeaderDemotedException(localMember, null));
} else {
setStatus(ACTIVE);
}
response = entry.index();
} else {
response = new IllegalArgumentException("Invalid command: " + operation);
}
} else {
response = raftIntegration.runOperation(operation, entry.index());
}
if (response == PostponedResponse.INSTANCE) {
// postpone sending response
return;
}
completeFuture(entry.index(), response);
}
|
[
"private",
"void",
"applyLogEntry",
"(",
"LogEntry",
"entry",
")",
"{",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Processing \"",
"+",
"entry",
")",
";",
"}",
"Object",
"response",
"=",
"null",
";",
"Object",
"operation",
"=",
"entry",
".",
"operation",
"(",
")",
";",
"if",
"(",
"operation",
"instanceof",
"RaftGroupCmd",
")",
"{",
"if",
"(",
"operation",
"instanceof",
"DestroyRaftGroupCmd",
")",
"{",
"setStatus",
"(",
"TERMINATED",
")",
";",
"}",
"else",
"if",
"(",
"operation",
"instanceof",
"UpdateRaftGroupMembersCmd",
")",
"{",
"if",
"(",
"state",
".",
"lastGroupMembers",
"(",
")",
".",
"index",
"(",
")",
"<",
"entry",
".",
"index",
"(",
")",
")",
"{",
"setStatus",
"(",
"UPDATING_GROUP_MEMBER_LIST",
")",
";",
"UpdateRaftGroupMembersCmd",
"op",
"=",
"(",
"UpdateRaftGroupMembersCmd",
")",
"operation",
";",
"updateGroupMembers",
"(",
"entry",
".",
"index",
"(",
")",
",",
"op",
".",
"getMembers",
"(",
")",
")",
";",
"}",
"assert",
"status",
"==",
"UPDATING_GROUP_MEMBER_LIST",
":",
"\"STATUS: \"",
"+",
"status",
";",
"assert",
"state",
".",
"lastGroupMembers",
"(",
")",
".",
"index",
"(",
")",
"==",
"entry",
".",
"index",
"(",
")",
";",
"state",
".",
"commitGroupMembers",
"(",
")",
";",
"UpdateRaftGroupMembersCmd",
"cmd",
"=",
"(",
"UpdateRaftGroupMembersCmd",
")",
"operation",
";",
"if",
"(",
"cmd",
".",
"getMember",
"(",
")",
".",
"equals",
"(",
"localMember",
")",
"&&",
"cmd",
".",
"getMode",
"(",
")",
"==",
"MembershipChangeMode",
".",
"REMOVE",
")",
"{",
"setStatus",
"(",
"STEPPED_DOWN",
")",
";",
"// If I am the leader, I may have some waiting futures whose operations are already committed",
"// but responses are not decided yet. When I leave the cluster after my shutdown, invocations",
"// of those futures will receive MemberLeftException and retry. However, if I have an invocation",
"// during the shutdown process, its future will not complete unless I notify it here.",
"// Although LeaderDemotedException is designed for another case, we use it here since",
"// invocations internally retry when they receive LeaderDemotedException.",
"invalidateFuturesUntil",
"(",
"entry",
".",
"index",
"(",
")",
"-",
"1",
",",
"new",
"LeaderDemotedException",
"(",
"localMember",
",",
"null",
")",
")",
";",
"}",
"else",
"{",
"setStatus",
"(",
"ACTIVE",
")",
";",
"}",
"response",
"=",
"entry",
".",
"index",
"(",
")",
";",
"}",
"else",
"{",
"response",
"=",
"new",
"IllegalArgumentException",
"(",
"\"Invalid command: \"",
"+",
"operation",
")",
";",
"}",
"}",
"else",
"{",
"response",
"=",
"raftIntegration",
".",
"runOperation",
"(",
"operation",
",",
"entry",
".",
"index",
"(",
")",
")",
";",
"}",
"if",
"(",
"response",
"==",
"PostponedResponse",
".",
"INSTANCE",
")",
"{",
"// postpone sending response",
"return",
";",
"}",
"completeFuture",
"(",
"entry",
".",
"index",
"(",
")",
",",
"response",
")",
";",
"}"
] |
Applies the log entry by executing operation attached and set execution result to
the related future if any available.
|
[
"Applies",
"the",
"log",
"entry",
"by",
"executing",
"operation",
"attached",
"and",
"set",
"execution",
"result",
"to",
"the",
"related",
"future",
"if",
"any",
"available",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L575-L622
|
15,214
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
|
RaftNodeImpl.runQueryOperation
|
public void runQueryOperation(Object operation, SimpleCompletableFuture resultFuture) {
long commitIndex = state.commitIndex();
Object result = raftIntegration.runOperation(operation, commitIndex);
resultFuture.setResult(result);
}
|
java
|
public void runQueryOperation(Object operation, SimpleCompletableFuture resultFuture) {
long commitIndex = state.commitIndex();
Object result = raftIntegration.runOperation(operation, commitIndex);
resultFuture.setResult(result);
}
|
[
"public",
"void",
"runQueryOperation",
"(",
"Object",
"operation",
",",
"SimpleCompletableFuture",
"resultFuture",
")",
"{",
"long",
"commitIndex",
"=",
"state",
".",
"commitIndex",
"(",
")",
";",
"Object",
"result",
"=",
"raftIntegration",
".",
"runOperation",
"(",
"operation",
",",
"commitIndex",
")",
";",
"resultFuture",
".",
"setResult",
"(",
"result",
")",
";",
"}"
] |
Executes query operation sets execution result to the future.
|
[
"Executes",
"query",
"operation",
"sets",
"execution",
"result",
"to",
"the",
"future",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L639-L643
|
15,215
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
|
RaftNodeImpl.installSnapshot
|
public boolean installSnapshot(SnapshotEntry snapshot) {
long commitIndex = state.commitIndex();
if (commitIndex > snapshot.index()) {
logger.info("Ignored stale " + snapshot + ", commit index at: " + commitIndex);
return false;
} else if (commitIndex == snapshot.index()) {
logger.info("Ignored " + snapshot + " since commit index is same.");
return true;
}
state.commitIndex(snapshot.index());
int truncated = state.log().setSnapshot(snapshot);
if (truncated > 0) {
logger.info(truncated + " entries are truncated to install " + snapshot);
}
raftIntegration.restoreSnapshot(snapshot.operation(), snapshot.index());
// If I am installing a snapshot, it means I am still present in the last member list,
// but it is possible that the last entry I appended before the snapshot could be a membership change.
// Because of this, I need to update my status.
// Nevertheless, I may not be present in the restored member list, which is ok.
setStatus(ACTIVE);
state.restoreGroupMembers(snapshot.groupMembersLogIndex(), snapshot.groupMembers());
printMemberState();
state.lastApplied(snapshot.index());
invalidateFuturesUntil(snapshot.index(), new StaleAppendRequestException(state.leader()));
logger.info(snapshot + " is installed.");
return true;
}
|
java
|
public boolean installSnapshot(SnapshotEntry snapshot) {
long commitIndex = state.commitIndex();
if (commitIndex > snapshot.index()) {
logger.info("Ignored stale " + snapshot + ", commit index at: " + commitIndex);
return false;
} else if (commitIndex == snapshot.index()) {
logger.info("Ignored " + snapshot + " since commit index is same.");
return true;
}
state.commitIndex(snapshot.index());
int truncated = state.log().setSnapshot(snapshot);
if (truncated > 0) {
logger.info(truncated + " entries are truncated to install " + snapshot);
}
raftIntegration.restoreSnapshot(snapshot.operation(), snapshot.index());
// If I am installing a snapshot, it means I am still present in the last member list,
// but it is possible that the last entry I appended before the snapshot could be a membership change.
// Because of this, I need to update my status.
// Nevertheless, I may not be present in the restored member list, which is ok.
setStatus(ACTIVE);
state.restoreGroupMembers(snapshot.groupMembersLogIndex(), snapshot.groupMembers());
printMemberState();
state.lastApplied(snapshot.index());
invalidateFuturesUntil(snapshot.index(), new StaleAppendRequestException(state.leader()));
logger.info(snapshot + " is installed.");
return true;
}
|
[
"public",
"boolean",
"installSnapshot",
"(",
"SnapshotEntry",
"snapshot",
")",
"{",
"long",
"commitIndex",
"=",
"state",
".",
"commitIndex",
"(",
")",
";",
"if",
"(",
"commitIndex",
">",
"snapshot",
".",
"index",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"Ignored stale \"",
"+",
"snapshot",
"+",
"\", commit index at: \"",
"+",
"commitIndex",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"commitIndex",
"==",
"snapshot",
".",
"index",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"Ignored \"",
"+",
"snapshot",
"+",
"\" since commit index is same.\"",
")",
";",
"return",
"true",
";",
"}",
"state",
".",
"commitIndex",
"(",
"snapshot",
".",
"index",
"(",
")",
")",
";",
"int",
"truncated",
"=",
"state",
".",
"log",
"(",
")",
".",
"setSnapshot",
"(",
"snapshot",
")",
";",
"if",
"(",
"truncated",
">",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"truncated",
"+",
"\" entries are truncated to install \"",
"+",
"snapshot",
")",
";",
"}",
"raftIntegration",
".",
"restoreSnapshot",
"(",
"snapshot",
".",
"operation",
"(",
")",
",",
"snapshot",
".",
"index",
"(",
")",
")",
";",
"// If I am installing a snapshot, it means I am still present in the last member list,",
"// but it is possible that the last entry I appended before the snapshot could be a membership change.",
"// Because of this, I need to update my status.",
"// Nevertheless, I may not be present in the restored member list, which is ok.",
"setStatus",
"(",
"ACTIVE",
")",
";",
"state",
".",
"restoreGroupMembers",
"(",
"snapshot",
".",
"groupMembersLogIndex",
"(",
")",
",",
"snapshot",
".",
"groupMembers",
"(",
")",
")",
";",
"printMemberState",
"(",
")",
";",
"state",
".",
"lastApplied",
"(",
"snapshot",
".",
"index",
"(",
")",
")",
";",
"invalidateFuturesUntil",
"(",
"snapshot",
".",
"index",
"(",
")",
",",
"new",
"StaleAppendRequestException",
"(",
"state",
".",
"leader",
"(",
")",
")",
")",
";",
"logger",
".",
"info",
"(",
"snapshot",
"+",
"\" is installed.\"",
")",
";",
"return",
"true",
";",
"}"
] |
Restores the snapshot sent by the leader if it's not applied before.
@return true if snapshot is restores, false otherwise.
|
[
"Restores",
"the",
"snapshot",
"sent",
"by",
"the",
"leader",
"if",
"it",
"s",
"not",
"applied",
"before",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L779-L811
|
15,216
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
|
RaftNodeImpl.updateGroupMembers
|
public void updateGroupMembers(long logIndex, Collection<Endpoint> members) {
state.updateGroupMembers(logIndex, members);
printMemberState();
}
|
java
|
public void updateGroupMembers(long logIndex, Collection<Endpoint> members) {
state.updateGroupMembers(logIndex, members);
printMemberState();
}
|
[
"public",
"void",
"updateGroupMembers",
"(",
"long",
"logIndex",
",",
"Collection",
"<",
"Endpoint",
">",
"members",
")",
"{",
"state",
".",
"updateGroupMembers",
"(",
"logIndex",
",",
"members",
")",
";",
"printMemberState",
"(",
")",
";",
"}"
] |
Updates Raft group members.
@see RaftState#updateGroupMembers(long, Collection)
|
[
"Updates",
"Raft",
"group",
"members",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L839-L842
|
15,217
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/SubscriberAccumulatorHandler.java
|
SubscriberAccumulatorHandler.pollRemovedCountHolders
|
private int pollRemovedCountHolders(AtomicReferenceArray<Queue<Integer>> removedCountHolders) {
int count = 0;
for (int i = 0; i < partitionCount; i++) {
Queue<Integer> removalCounts = removedCountHolders.get(i);
count += removalCounts.poll();
}
return count;
}
|
java
|
private int pollRemovedCountHolders(AtomicReferenceArray<Queue<Integer>> removedCountHolders) {
int count = 0;
for (int i = 0; i < partitionCount; i++) {
Queue<Integer> removalCounts = removedCountHolders.get(i);
count += removalCounts.poll();
}
return count;
}
|
[
"private",
"int",
"pollRemovedCountHolders",
"(",
"AtomicReferenceArray",
"<",
"Queue",
"<",
"Integer",
">",
">",
"removedCountHolders",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"partitionCount",
";",
"i",
"++",
")",
"{",
"Queue",
"<",
"Integer",
">",
"removalCounts",
"=",
"removedCountHolders",
".",
"get",
"(",
"i",
")",
";",
"count",
"+=",
"removalCounts",
".",
"poll",
"(",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
should be called when `noMissingMapWideEvent` `false`, otherwise polling can cause NPE
|
[
"should",
"be",
"called",
"when",
"noMissingMapWideEvent",
"false",
"otherwise",
"polling",
"can",
"cause",
"NPE"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/SubscriberAccumulatorHandler.java#L167-L174
|
15,218
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/getters/EvictableGetterCache.java
|
EvictableGetterCache.evictMap
|
private void evictMap(SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) {
map.purgeStaleEntries();
int mapSize = map.size();
if (mapSize - triggeringEvictionSize >= 0) {
for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) {
map.remove(entry.getEntryKey());
}
}
}
|
java
|
private void evictMap(SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) {
map.purgeStaleEntries();
int mapSize = map.size();
if (mapSize - triggeringEvictionSize >= 0) {
for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) {
map.remove(entry.getEntryKey());
}
}
}
|
[
"private",
"void",
"evictMap",
"(",
"SampleableConcurrentHashMap",
"<",
"?",
",",
"?",
">",
"map",
",",
"int",
"triggeringEvictionSize",
",",
"int",
"afterEvictionSize",
")",
"{",
"map",
".",
"purgeStaleEntries",
"(",
")",
";",
"int",
"mapSize",
"=",
"map",
".",
"size",
"(",
")",
";",
"if",
"(",
"mapSize",
"-",
"triggeringEvictionSize",
">=",
"0",
")",
"{",
"for",
"(",
"SampleableConcurrentHashMap",
".",
"SamplingEntry",
"entry",
":",
"map",
".",
"getRandomSamples",
"(",
"mapSize",
"-",
"afterEvictionSize",
")",
")",
"{",
"map",
".",
"remove",
"(",
"entry",
".",
"getEntryKey",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
It works on best effort basis. If multi-threaded calls involved it may evict all elements, but it's unlikely.
|
[
"It",
"works",
"on",
"best",
"effort",
"basis",
".",
"If",
"multi",
"-",
"threaded",
"calls",
"involved",
"it",
"may",
"evict",
"all",
"elements",
"but",
"it",
"s",
"unlikely",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/EvictableGetterCache.java#L79-L87
|
15,219
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/BoundedWriteBehindQueue.java
|
BoundedWriteBehindQueue.drainTo
|
@Override
public int drainTo(Collection<E> collection) {
int size = queue.drainTo(collection);
addCapacity(-size);
return size;
}
|
java
|
@Override
public int drainTo(Collection<E> collection) {
int size = queue.drainTo(collection);
addCapacity(-size);
return size;
}
|
[
"@",
"Override",
"public",
"int",
"drainTo",
"(",
"Collection",
"<",
"E",
">",
"collection",
")",
"{",
"int",
"size",
"=",
"queue",
".",
"drainTo",
"(",
"collection",
")",
";",
"addCapacity",
"(",
"-",
"size",
")",
";",
"return",
"size",
";",
"}"
] |
Removes all elements from this queue and adds them
to the given collection.
@return number of removed items from this queue.
|
[
"Removes",
"all",
"elements",
"from",
"this",
"queue",
"and",
"adds",
"them",
"to",
"the",
"given",
"collection",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/BoundedWriteBehindQueue.java#L108-L113
|
15,220
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/ToHeapDataConverter.java
|
ToHeapDataConverter.toHeapData
|
public static Data toHeapData(Data data) {
if (data == null || data instanceof HeapData) {
return data;
}
return new HeapData(data.toByteArray());
}
|
java
|
public static Data toHeapData(Data data) {
if (data == null || data instanceof HeapData) {
return data;
}
return new HeapData(data.toByteArray());
}
|
[
"public",
"static",
"Data",
"toHeapData",
"(",
"Data",
"data",
")",
"{",
"if",
"(",
"data",
"==",
"null",
"||",
"data",
"instanceof",
"HeapData",
")",
"{",
"return",
"data",
";",
"}",
"return",
"new",
"HeapData",
"(",
"data",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] |
Converts Data to HeapData. Useful for offheap conversion.
@param data
@return the onheap representation of data. If data is null, null is returned.
|
[
"Converts",
"Data",
"to",
"HeapData",
".",
"Useful",
"for",
"offheap",
"conversion",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/ToHeapDataConverter.java#L36-L41
|
15,221
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/record/CacheRecordHashMap.java
|
CacheRecordHashMap.setEntryCounting
|
@Override
public void setEntryCounting(boolean enable) {
if (enable) {
if (!entryCountingEnable) {
// It was disable before but now it will be enable.
// Therefore, we increase the entry count as size of records.
cacheContext.increaseEntryCount(size());
}
} else {
if (entryCountingEnable) {
// It was enable before but now it will be disable.
// Therefore, we decrease the entry count as size of records.
cacheContext.decreaseEntryCount(size());
}
}
this.entryCountingEnable = enable;
}
|
java
|
@Override
public void setEntryCounting(boolean enable) {
if (enable) {
if (!entryCountingEnable) {
// It was disable before but now it will be enable.
// Therefore, we increase the entry count as size of records.
cacheContext.increaseEntryCount(size());
}
} else {
if (entryCountingEnable) {
// It was enable before but now it will be disable.
// Therefore, we decrease the entry count as size of records.
cacheContext.decreaseEntryCount(size());
}
}
this.entryCountingEnable = enable;
}
|
[
"@",
"Override",
"public",
"void",
"setEntryCounting",
"(",
"boolean",
"enable",
")",
"{",
"if",
"(",
"enable",
")",
"{",
"if",
"(",
"!",
"entryCountingEnable",
")",
"{",
"// It was disable before but now it will be enable.",
"// Therefore, we increase the entry count as size of records.",
"cacheContext",
".",
"increaseEntryCount",
"(",
"size",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"entryCountingEnable",
")",
"{",
"// It was enable before but now it will be disable.",
"// Therefore, we decrease the entry count as size of records.",
"cacheContext",
".",
"decreaseEntryCount",
"(",
"size",
"(",
")",
")",
";",
"}",
"}",
"this",
".",
"entryCountingEnable",
"=",
"enable",
";",
"}"
] |
Called by only same partition thread. So there is no synchronization and visibility problem.
|
[
"Called",
"by",
"only",
"same",
"partition",
"thread",
".",
"So",
"there",
"is",
"no",
"synchronization",
"and",
"visibility",
"problem",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/record/CacheRecordHashMap.java#L56-L72
|
15,222
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterClockImpl.java
|
ClusterClockImpl.setClusterTimeDiff
|
void setClusterTimeDiff(long diff) {
if (logger.isFineEnabled()) {
logger.fine("Setting cluster time diff to " + diff + "ms.");
}
if (abs(diff) > abs(maxClusterTimeDiff)) {
maxClusterTimeDiff = diff;
}
this.clusterTimeDiff = diff;
}
|
java
|
void setClusterTimeDiff(long diff) {
if (logger.isFineEnabled()) {
logger.fine("Setting cluster time diff to " + diff + "ms.");
}
if (abs(diff) > abs(maxClusterTimeDiff)) {
maxClusterTimeDiff = diff;
}
this.clusterTimeDiff = diff;
}
|
[
"void",
"setClusterTimeDiff",
"(",
"long",
"diff",
")",
"{",
"if",
"(",
"logger",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Setting cluster time diff to \"",
"+",
"diff",
"+",
"\"ms.\"",
")",
";",
"}",
"if",
"(",
"abs",
"(",
"diff",
")",
">",
"abs",
"(",
"maxClusterTimeDiff",
")",
")",
"{",
"maxClusterTimeDiff",
"=",
"diff",
";",
"}",
"this",
".",
"clusterTimeDiff",
"=",
"diff",
";",
"}"
] |
Set the cluster time diff and records the maximum observed cluster time diff
|
[
"Set",
"the",
"cluster",
"time",
"diff",
"and",
"records",
"the",
"maximum",
"observed",
"cluster",
"time",
"diff"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ClusterClockImpl.java#L58-L68
|
15,223
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/maxsize/impl/EntryCountCacheEvictionChecker.java
|
EntryCountCacheEvictionChecker.calculateMaxPartitionSize
|
public static int calculateMaxPartitionSize(int maxEntryCount, int partitionCount) {
final double balancedPartitionSize = (double) maxEntryCount / (double) partitionCount;
final double approximatedStdDev = Math.sqrt(balancedPartitionSize);
int stdDevMultiplier;
if (maxEntryCount <= STD_DEV_OF_5_THRESHOLD) {
// Below 4.000 entry count, multiplying standard deviation with 5 gives better estimations
// as our experiments and test results.
stdDevMultiplier = STD_DEV_MULTIPLIER_5;
} else if (maxEntryCount > STD_DEV_OF_5_THRESHOLD
&& maxEntryCount <= MAX_ENTRY_COUNT_FOR_THRESHOLD_USAGE) {
// Above 4.000 entry count but below 1.000.000 entry count,
// multiplying standard deviation with 3 gives better estimations
// as our experiments and test results.
stdDevMultiplier = STD_DEV_MULTIPLIER_3;
} else {
// Over 1.000.000 entries, there is no need for using standard deviation
stdDevMultiplier = 0;
}
return (int) ((approximatedStdDev * stdDevMultiplier) + balancedPartitionSize);
}
|
java
|
public static int calculateMaxPartitionSize(int maxEntryCount, int partitionCount) {
final double balancedPartitionSize = (double) maxEntryCount / (double) partitionCount;
final double approximatedStdDev = Math.sqrt(balancedPartitionSize);
int stdDevMultiplier;
if (maxEntryCount <= STD_DEV_OF_5_THRESHOLD) {
// Below 4.000 entry count, multiplying standard deviation with 5 gives better estimations
// as our experiments and test results.
stdDevMultiplier = STD_DEV_MULTIPLIER_5;
} else if (maxEntryCount > STD_DEV_OF_5_THRESHOLD
&& maxEntryCount <= MAX_ENTRY_COUNT_FOR_THRESHOLD_USAGE) {
// Above 4.000 entry count but below 1.000.000 entry count,
// multiplying standard deviation with 3 gives better estimations
// as our experiments and test results.
stdDevMultiplier = STD_DEV_MULTIPLIER_3;
} else {
// Over 1.000.000 entries, there is no need for using standard deviation
stdDevMultiplier = 0;
}
return (int) ((approximatedStdDev * stdDevMultiplier) + balancedPartitionSize);
}
|
[
"public",
"static",
"int",
"calculateMaxPartitionSize",
"(",
"int",
"maxEntryCount",
",",
"int",
"partitionCount",
")",
"{",
"final",
"double",
"balancedPartitionSize",
"=",
"(",
"double",
")",
"maxEntryCount",
"/",
"(",
"double",
")",
"partitionCount",
";",
"final",
"double",
"approximatedStdDev",
"=",
"Math",
".",
"sqrt",
"(",
"balancedPartitionSize",
")",
";",
"int",
"stdDevMultiplier",
";",
"if",
"(",
"maxEntryCount",
"<=",
"STD_DEV_OF_5_THRESHOLD",
")",
"{",
"// Below 4.000 entry count, multiplying standard deviation with 5 gives better estimations",
"// as our experiments and test results.",
"stdDevMultiplier",
"=",
"STD_DEV_MULTIPLIER_5",
";",
"}",
"else",
"if",
"(",
"maxEntryCount",
">",
"STD_DEV_OF_5_THRESHOLD",
"&&",
"maxEntryCount",
"<=",
"MAX_ENTRY_COUNT_FOR_THRESHOLD_USAGE",
")",
"{",
"// Above 4.000 entry count but below 1.000.000 entry count,",
"// multiplying standard deviation with 3 gives better estimations",
"// as our experiments and test results.",
"stdDevMultiplier",
"=",
"STD_DEV_MULTIPLIER_3",
";",
"}",
"else",
"{",
"// Over 1.000.000 entries, there is no need for using standard deviation",
"stdDevMultiplier",
"=",
"0",
";",
"}",
"return",
"(",
"int",
")",
"(",
"(",
"approximatedStdDev",
"*",
"stdDevMultiplier",
")",
"+",
"balancedPartitionSize",
")",
";",
"}"
] |
for calculating the estimated max size.
|
[
"for",
"calculating",
"the",
"estimated",
"max",
"size",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/maxsize/impl/EntryCountCacheEvictionChecker.java#L45-L65
|
15,224
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/OperationRunnerImpl.java
|
OperationRunnerImpl.ensureQuorumPresent
|
private void ensureQuorumPresent(Operation op) {
QuorumServiceImpl quorumService = operationService.nodeEngine.getQuorumService();
quorumService.ensureQuorumPresent(op);
}
|
java
|
private void ensureQuorumPresent(Operation op) {
QuorumServiceImpl quorumService = operationService.nodeEngine.getQuorumService();
quorumService.ensureQuorumPresent(op);
}
|
[
"private",
"void",
"ensureQuorumPresent",
"(",
"Operation",
"op",
")",
"{",
"QuorumServiceImpl",
"quorumService",
"=",
"operationService",
".",
"nodeEngine",
".",
"getQuorumService",
"(",
")",
";",
"quorumService",
".",
"ensureQuorumPresent",
"(",
"op",
")",
";",
"}"
] |
Ensures that the quorum is present if the quorum is configured and the operation service is quorum aware.
@param op the operation for which the quorum must be checked for presence
@throws QuorumException if the operation requires a quorum and the quorum is not present
|
[
"Ensures",
"that",
"the",
"quorum",
"is",
"present",
"if",
"the",
"quorum",
"is",
"configured",
"and",
"the",
"operation",
"service",
"is",
"quorum",
"aware",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/OperationRunnerImpl.java#L285-L288
|
15,225
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/merge/AbstractContainerCollector.java
|
AbstractContainerCollector.run
|
public final void run() {
int partitionCount = partitionService.getPartitionCount();
latch = new CountDownLatch(partitionCount);
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
operationExecutor.execute(new CollectContainerRunnable(partitionId));
}
try {
latch.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
|
java
|
public final void run() {
int partitionCount = partitionService.getPartitionCount();
latch = new CountDownLatch(partitionCount);
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
operationExecutor.execute(new CollectContainerRunnable(partitionId));
}
try {
latch.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
|
[
"public",
"final",
"void",
"run",
"(",
")",
"{",
"int",
"partitionCount",
"=",
"partitionService",
".",
"getPartitionCount",
"(",
")",
";",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"partitionCount",
")",
";",
"for",
"(",
"int",
"partitionId",
"=",
"0",
";",
"partitionId",
"<",
"partitionCount",
";",
"partitionId",
"++",
")",
"{",
"operationExecutor",
".",
"execute",
"(",
"new",
"CollectContainerRunnable",
"(",
"partitionId",
")",
")",
";",
"}",
"try",
"{",
"latch",
".",
"await",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
] |
Collects the containers from the data structure in a thread-safe way.
|
[
"Collects",
"the",
"containers",
"from",
"the",
"data",
"structure",
"in",
"a",
"thread",
"-",
"safe",
"way",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/merge/AbstractContainerCollector.java#L89-L102
|
15,226
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/merge/AbstractContainerCollector.java
|
AbstractContainerCollector.destroy
|
public final void destroy() {
for (Collection<C> containers : containersByPartitionId.values()) {
for (C container : containers) {
destroy(container);
}
}
containersByPartitionId.clear();
onDestroy();
}
|
java
|
public final void destroy() {
for (Collection<C> containers : containersByPartitionId.values()) {
for (C container : containers) {
destroy(container);
}
}
containersByPartitionId.clear();
onDestroy();
}
|
[
"public",
"final",
"void",
"destroy",
"(",
")",
"{",
"for",
"(",
"Collection",
"<",
"C",
">",
"containers",
":",
"containersByPartitionId",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"C",
"container",
":",
"containers",
")",
"{",
"destroy",
"(",
"container",
")",
";",
"}",
"}",
"containersByPartitionId",
".",
"clear",
"(",
")",
";",
"onDestroy",
"(",
")",
";",
"}"
] |
Destroys all collected containers.
|
[
"Destroys",
"all",
"collected",
"containers",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/merge/AbstractContainerCollector.java#L116-L124
|
15,227
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/MapListenerFlagOperator.java
|
MapListenerFlagOperator.setAndGetAllListenerFlags
|
private static int setAndGetAllListenerFlags() {
int listenerFlags = 0;
EntryEventType[] values = EntryEventType.values();
for (EntryEventType eventType : values) {
listenerFlags = listenerFlags | eventType.getType();
}
return listenerFlags;
}
|
java
|
private static int setAndGetAllListenerFlags() {
int listenerFlags = 0;
EntryEventType[] values = EntryEventType.values();
for (EntryEventType eventType : values) {
listenerFlags = listenerFlags | eventType.getType();
}
return listenerFlags;
}
|
[
"private",
"static",
"int",
"setAndGetAllListenerFlags",
"(",
")",
"{",
"int",
"listenerFlags",
"=",
"0",
";",
"EntryEventType",
"[",
"]",
"values",
"=",
"EntryEventType",
".",
"values",
"(",
")",
";",
"for",
"(",
"EntryEventType",
"eventType",
":",
"values",
")",
"{",
"listenerFlags",
"=",
"listenerFlags",
"|",
"eventType",
".",
"getType",
"(",
")",
";",
"}",
"return",
"listenerFlags",
";",
"}"
] |
Sets and gets all listener flags.
|
[
"Sets",
"and",
"gets",
"all",
"listener",
"flags",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapListenerFlagOperator.java#L57-L64
|
15,228
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/scheduledexecutor/ScheduledExecutorTaskGetResultFromPartitionMessageTask.java
|
ScheduledExecutorTaskGetResultFromPartitionMessageTask.sendClientMessage
|
@Override
protected void sendClientMessage(Throwable throwable) {
if (throwable instanceof ScheduledTaskResult.ExecutionExceptionDecorator) {
super.sendClientMessage(throwable.getCause());
} else {
super.sendClientMessage(throwable);
}
}
|
java
|
@Override
protected void sendClientMessage(Throwable throwable) {
if (throwable instanceof ScheduledTaskResult.ExecutionExceptionDecorator) {
super.sendClientMessage(throwable.getCause());
} else {
super.sendClientMessage(throwable);
}
}
|
[
"@",
"Override",
"protected",
"void",
"sendClientMessage",
"(",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"instanceof",
"ScheduledTaskResult",
".",
"ExecutionExceptionDecorator",
")",
"{",
"super",
".",
"sendClientMessage",
"(",
"throwable",
".",
"getCause",
"(",
")",
")",
";",
"}",
"else",
"{",
"super",
".",
"sendClientMessage",
"(",
"throwable",
")",
";",
"}",
"}"
] |
Exceptions may be wrapped in ExecutionExceptionDecorator, the wrapped ExecutionException should be sent to
the client.
@param throwable
|
[
"Exceptions",
"may",
"be",
"wrapped",
"in",
"ExecutionExceptionDecorator",
"the",
"wrapped",
"ExecutionException",
"should",
"be",
"sent",
"to",
"the",
"client",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/scheduledexecutor/ScheduledExecutorTaskGetResultFromPartitionMessageTask.java#L92-L99
|
15,229
|
hazelcast/hazelcast
|
hazelcast-client/src/main/java/com/hazelcast/client/impl/clientside/FailoverClientConfigSupport.java
|
FailoverClientConfigSupport.checkValidAlternative
|
private static void checkValidAlternative(List<ClientConfig> alternativeClientConfigs) {
if (alternativeClientConfigs.isEmpty()) {
throw new InvalidConfigurationException("ClientFailoverConfig should have at least one client config.");
}
ClientConfig mainConfig = alternativeClientConfigs.get(0);
for (ClientConfig alternativeClientConfig : alternativeClientConfigs.subList(1, alternativeClientConfigs.size())) {
checkValidAlternative(mainConfig, alternativeClientConfig);
}
}
|
java
|
private static void checkValidAlternative(List<ClientConfig> alternativeClientConfigs) {
if (alternativeClientConfigs.isEmpty()) {
throw new InvalidConfigurationException("ClientFailoverConfig should have at least one client config.");
}
ClientConfig mainConfig = alternativeClientConfigs.get(0);
for (ClientConfig alternativeClientConfig : alternativeClientConfigs.subList(1, alternativeClientConfigs.size())) {
checkValidAlternative(mainConfig, alternativeClientConfig);
}
}
|
[
"private",
"static",
"void",
"checkValidAlternative",
"(",
"List",
"<",
"ClientConfig",
">",
"alternativeClientConfigs",
")",
"{",
"if",
"(",
"alternativeClientConfigs",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"\"ClientFailoverConfig should have at least one client config.\"",
")",
";",
"}",
"ClientConfig",
"mainConfig",
"=",
"alternativeClientConfigs",
".",
"get",
"(",
"0",
")",
";",
"for",
"(",
"ClientConfig",
"alternativeClientConfig",
":",
"alternativeClientConfigs",
".",
"subList",
"(",
"1",
",",
"alternativeClientConfigs",
".",
"size",
"(",
")",
")",
")",
"{",
"checkValidAlternative",
"(",
"mainConfig",
",",
"alternativeClientConfig",
")",
";",
"}",
"}"
] |
For a client to be valid alternative, all configurations should be equal except
GroupConfig
SecurityConfig
Discovery related parts of NetworkConfig
Credentials related configs
@param alternativeClientConfigs to check if they are valid alternative for a single client two switch between clusters
@throws InvalidConfigurationException when given configs are not valid
|
[
"For",
"a",
"client",
"to",
"be",
"valid",
"alternative",
"all",
"configurations",
"should",
"be",
"equal",
"except",
"GroupConfig",
"SecurityConfig",
"Discovery",
"related",
"parts",
"of",
"NetworkConfig",
"Credentials",
"related",
"configs"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/impl/clientside/FailoverClientConfigSupport.java#L162-L171
|
15,230
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/Json.java
|
Json.array
|
public static JsonArray array(String... strings) {
if (strings == null) {
throw new NullPointerException("values is null");
}
JsonArray array = new JsonArray();
for (String value : strings) {
array.add(value);
}
return array;
}
|
java
|
public static JsonArray array(String... strings) {
if (strings == null) {
throw new NullPointerException("values is null");
}
JsonArray array = new JsonArray();
for (String value : strings) {
array.add(value);
}
return array;
}
|
[
"public",
"static",
"JsonArray",
"array",
"(",
"String",
"...",
"strings",
")",
"{",
"if",
"(",
"strings",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"values is null\"",
")",
";",
"}",
"JsonArray",
"array",
"=",
"new",
"JsonArray",
"(",
")",
";",
"for",
"(",
"String",
"value",
":",
"strings",
")",
"{",
"array",
".",
"add",
"(",
"value",
")",
";",
"}",
"return",
"array",
";",
"}"
] |
Creates a new JsonArray that contains the JSON representations of the given strings.
@param strings
the strings to be included in the new JSON array
@return a new JSON array that contains the given strings
|
[
"Creates",
"a",
"new",
"JsonArray",
"that",
"contains",
"the",
"JSON",
"representations",
"of",
"the",
"given",
"strings",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/Json.java#L258-L267
|
15,231
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/Json.java
|
Json.parse
|
public static JsonValue parse(String string) {
if (string == null) {
throw new NullPointerException("string is null");
}
DefaultHandler handler = new DefaultHandler();
new JsonParser(handler).parse(string);
return handler.getValue();
}
|
java
|
public static JsonValue parse(String string) {
if (string == null) {
throw new NullPointerException("string is null");
}
DefaultHandler handler = new DefaultHandler();
new JsonParser(handler).parse(string);
return handler.getValue();
}
|
[
"public",
"static",
"JsonValue",
"parse",
"(",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"string is null\"",
")",
";",
"}",
"DefaultHandler",
"handler",
"=",
"new",
"DefaultHandler",
"(",
")",
";",
"new",
"JsonParser",
"(",
"handler",
")",
".",
"parse",
"(",
"string",
")",
";",
"return",
"handler",
".",
"getValue",
"(",
")",
";",
"}"
] |
Parses the given input string as JSON. The input must contain a valid JSON value, optionally
padded with whitespace.
@param string
the input string, must be valid JSON
@return a value that represents the parsed JSON
@throws ParseException
if the input is not valid JSON
|
[
"Parses",
"the",
"given",
"input",
"string",
"as",
"JSON",
".",
"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/Json.java#L289-L296
|
15,232
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/HashUtil.java
|
HashUtil.fastLongMix
|
public static long fastLongMix(long k) {
// phi = 2^64 / goldenRatio
final long phi = 0x9E3779B97F4A7C15L;
long h = k * phi;
h ^= h >>> 32;
return h ^ (h >>> 16);
}
|
java
|
public static long fastLongMix(long k) {
// phi = 2^64 / goldenRatio
final long phi = 0x9E3779B97F4A7C15L;
long h = k * phi;
h ^= h >>> 32;
return h ^ (h >>> 16);
}
|
[
"public",
"static",
"long",
"fastLongMix",
"(",
"long",
"k",
")",
"{",
"// phi = 2^64 / goldenRatio",
"final",
"long",
"phi",
"=",
"0x9E3779B97F4A7C15",
"",
"L",
";",
"long",
"h",
"=",
"k",
"*",
"phi",
";",
"h",
"^=",
"h",
">>>",
"32",
";",
"return",
"h",
"^",
"(",
"h",
">>>",
"16",
")",
";",
"}"
] |
Hash function based on Knuth's multiplicative method. This version is faster than using Murmur hash but provides
acceptable behavior.
@param k the long for which the hash will be calculated
@return the hash
|
[
"Hash",
"function",
"based",
"on",
"Knuth",
"s",
"multiplicative",
"method",
".",
"This",
"version",
"is",
"faster",
"than",
"using",
"Murmur",
"hash",
"but",
"provides",
"acceptable",
"behavior",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/HashUtil.java#L293-L299
|
15,233
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/MapMigrationAwareService.java
|
MapMigrationAwareService.flushAndRemoveQueryCaches
|
private void flushAndRemoveQueryCaches(PartitionMigrationEvent event) {
int partitionId = event.getPartitionId();
QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
PublisherContext publisherContext = queryCacheContext.getPublisherContext();
if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
flushAccumulator(publisherContext, partitionId);
removeAccumulator(publisherContext, partitionId);
return;
}
if (isLocalPromotion(event)) {
removeAccumulator(publisherContext, partitionId);
sendEndOfSequenceEvents(publisherContext, partitionId);
return;
}
}
|
java
|
private void flushAndRemoveQueryCaches(PartitionMigrationEvent event) {
int partitionId = event.getPartitionId();
QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
PublisherContext publisherContext = queryCacheContext.getPublisherContext();
if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
flushAccumulator(publisherContext, partitionId);
removeAccumulator(publisherContext, partitionId);
return;
}
if (isLocalPromotion(event)) {
removeAccumulator(publisherContext, partitionId);
sendEndOfSequenceEvents(publisherContext, partitionId);
return;
}
}
|
[
"private",
"void",
"flushAndRemoveQueryCaches",
"(",
"PartitionMigrationEvent",
"event",
")",
"{",
"int",
"partitionId",
"=",
"event",
".",
"getPartitionId",
"(",
")",
";",
"QueryCacheContext",
"queryCacheContext",
"=",
"mapServiceContext",
".",
"getQueryCacheContext",
"(",
")",
";",
"PublisherContext",
"publisherContext",
"=",
"queryCacheContext",
".",
"getPublisherContext",
"(",
")",
";",
"if",
"(",
"event",
".",
"getMigrationEndpoint",
"(",
")",
"==",
"MigrationEndpoint",
".",
"SOURCE",
")",
"{",
"flushAccumulator",
"(",
"publisherContext",
",",
"partitionId",
")",
";",
"removeAccumulator",
"(",
"publisherContext",
",",
"partitionId",
")",
";",
"return",
";",
"}",
"if",
"(",
"isLocalPromotion",
"(",
"event",
")",
")",
"{",
"removeAccumulator",
"(",
"publisherContext",
",",
"partitionId",
")",
";",
"sendEndOfSequenceEvents",
"(",
"publisherContext",
",",
"partitionId",
")",
";",
"return",
";",
"}",
"}"
] |
Flush and remove query cache on this source partition.
|
[
"Flush",
"and",
"remove",
"query",
"cache",
"on",
"this",
"source",
"partition",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapMigrationAwareService.java#L98-L114
|
15,234
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java
|
ItemCounter.descendingKeys
|
public List<T> descendingKeys() {
List<T> list = new ArrayList<T>(map.keySet());
sort(list, new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
MutableLong l1 = map.get(o1);
MutableLong l2 = map.get(o2);
return compare(l2.value, l1.value);
}
private int compare(long x, long y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
});
return list;
}
|
java
|
public List<T> descendingKeys() {
List<T> list = new ArrayList<T>(map.keySet());
sort(list, new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
MutableLong l1 = map.get(o1);
MutableLong l2 = map.get(o2);
return compare(l2.value, l1.value);
}
private int compare(long x, long y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
});
return list;
}
|
[
"public",
"List",
"<",
"T",
">",
"descendingKeys",
"(",
")",
"{",
"List",
"<",
"T",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"map",
".",
"keySet",
"(",
")",
")",
";",
"sort",
"(",
"list",
",",
"new",
"Comparator",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"T",
"o1",
",",
"T",
"o2",
")",
"{",
"MutableLong",
"l1",
"=",
"map",
".",
"get",
"(",
"o1",
")",
";",
"MutableLong",
"l2",
"=",
"map",
".",
"get",
"(",
"o2",
")",
";",
"return",
"compare",
"(",
"l2",
".",
"value",
",",
"l1",
".",
"value",
")",
";",
"}",
"private",
"int",
"compare",
"(",
"long",
"x",
",",
"long",
"y",
")",
"{",
"return",
"(",
"x",
"<",
"y",
")",
"?",
"-",
"1",
":",
"(",
"(",
"x",
"==",
"y",
")",
"?",
"0",
":",
"1",
")",
";",
"}",
"}",
")",
";",
"return",
"list",
";",
"}"
] |
Returns a List of keys in descending value order.
@return the list of keys
|
[
"Returns",
"a",
"List",
"of",
"keys",
"in",
"descending",
"value",
"order",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java#L63-L80
|
15,235
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java
|
ItemCounter.get
|
public long get(T item) {
MutableLong count = map.get(item);
return count == null ? 0 : count.value;
}
|
java
|
public long get(T item) {
MutableLong count = map.get(item);
return count == null ? 0 : count.value;
}
|
[
"public",
"long",
"get",
"(",
"T",
"item",
")",
"{",
"MutableLong",
"count",
"=",
"map",
".",
"get",
"(",
"item",
")",
";",
"return",
"count",
"==",
"null",
"?",
"0",
":",
"count",
".",
"value",
";",
"}"
] |
Get current counter for an item item
@param item
@return current state of a counter for item
|
[
"Get",
"current",
"counter",
"for",
"an",
"item",
"item"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java#L88-L91
|
15,236
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java
|
ItemCounter.set
|
public void set(T item, long value) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(value);
map.put(item, entry);
total += value;
} else {
total -= entry.value;
total += value;
entry.value = value;
}
}
|
java
|
public void set(T item, long value) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(value);
map.put(item, entry);
total += value;
} else {
total -= entry.value;
total += value;
entry.value = value;
}
}
|
[
"public",
"void",
"set",
"(",
"T",
"item",
",",
"long",
"value",
")",
"{",
"MutableLong",
"entry",
"=",
"map",
".",
"get",
"(",
"item",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"entry",
"=",
"MutableLong",
".",
"valueOf",
"(",
"value",
")",
";",
"map",
".",
"put",
"(",
"item",
",",
"entry",
")",
";",
"total",
"+=",
"value",
";",
"}",
"else",
"{",
"total",
"-=",
"entry",
".",
"value",
";",
"total",
"+=",
"value",
";",
"entry",
".",
"value",
"=",
"value",
";",
"}",
"}"
] |
Set counter of item to value
@param item to set set the value for
@param value a new value
|
[
"Set",
"counter",
"of",
"item",
"to",
"value"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java#L99-L110
|
15,237
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java
|
ItemCounter.add
|
public void add(T item, long delta) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(delta);
map.put(item, entry);
} else {
entry.value += delta;
}
total += delta;
}
|
java
|
public void add(T item, long delta) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(delta);
map.put(item, entry);
} else {
entry.value += delta;
}
total += delta;
}
|
[
"public",
"void",
"add",
"(",
"T",
"item",
",",
"long",
"delta",
")",
"{",
"MutableLong",
"entry",
"=",
"map",
".",
"get",
"(",
"item",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"entry",
"=",
"MutableLong",
".",
"valueOf",
"(",
"delta",
")",
";",
"map",
".",
"put",
"(",
"item",
",",
"entry",
")",
";",
"}",
"else",
"{",
"entry",
".",
"value",
"+=",
"delta",
";",
"}",
"total",
"+=",
"delta",
";",
"}"
] |
Add delta to the item
@param item
@param delta
|
[
"Add",
"delta",
"to",
"the",
"item"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java#L127-L136
|
15,238
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java
|
ItemCounter.getAndSet
|
public long getAndSet(T item, long value) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(value);
map.put(item, entry);
total += value;
return 0;
}
long oldValue = entry.value;
total = total - oldValue + value;
entry.value = value;
return oldValue;
}
|
java
|
public long getAndSet(T item, long value) {
MutableLong entry = map.get(item);
if (entry == null) {
entry = MutableLong.valueOf(value);
map.put(item, entry);
total += value;
return 0;
}
long oldValue = entry.value;
total = total - oldValue + value;
entry.value = value;
return oldValue;
}
|
[
"public",
"long",
"getAndSet",
"(",
"T",
"item",
",",
"long",
"value",
")",
"{",
"MutableLong",
"entry",
"=",
"map",
".",
"get",
"(",
"item",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"entry",
"=",
"MutableLong",
".",
"valueOf",
"(",
"value",
")",
";",
"map",
".",
"put",
"(",
"item",
",",
"entry",
")",
";",
"total",
"+=",
"value",
";",
"return",
"0",
";",
"}",
"long",
"oldValue",
"=",
"entry",
".",
"value",
";",
"total",
"=",
"total",
"-",
"oldValue",
"+",
"value",
";",
"entry",
".",
"value",
"=",
"value",
";",
"return",
"oldValue",
";",
"}"
] |
Set counter for item and return previous value
@param item
@param value
@return
|
[
"Set",
"counter",
"for",
"item",
"and",
"return",
"previous",
"value"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ItemCounter.java#L166-L180
|
15,239
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/nio/iobalancer/LoadMigrationStrategy.java
|
LoadMigrationStrategy.imbalanceDetected
|
@Override
public boolean imbalanceDetected(LoadImbalance imbalance) {
long min = imbalance.minimumLoad;
long max = imbalance.maximumLoad;
if (min == Long.MIN_VALUE || max == Long.MAX_VALUE) {
return false;
}
long lowerBound = (long) (MIN_MAX_RATIO_MIGRATION_THRESHOLD * max);
return min < lowerBound;
}
|
java
|
@Override
public boolean imbalanceDetected(LoadImbalance imbalance) {
long min = imbalance.minimumLoad;
long max = imbalance.maximumLoad;
if (min == Long.MIN_VALUE || max == Long.MAX_VALUE) {
return false;
}
long lowerBound = (long) (MIN_MAX_RATIO_MIGRATION_THRESHOLD * max);
return min < lowerBound;
}
|
[
"@",
"Override",
"public",
"boolean",
"imbalanceDetected",
"(",
"LoadImbalance",
"imbalance",
")",
"{",
"long",
"min",
"=",
"imbalance",
".",
"minimumLoad",
";",
"long",
"max",
"=",
"imbalance",
".",
"maximumLoad",
";",
"if",
"(",
"min",
"==",
"Long",
".",
"MIN_VALUE",
"||",
"max",
"==",
"Long",
".",
"MAX_VALUE",
")",
"{",
"return",
"false",
";",
"}",
"long",
"lowerBound",
"=",
"(",
"long",
")",
"(",
"MIN_MAX_RATIO_MIGRATION_THRESHOLD",
"*",
"max",
")",
";",
"return",
"min",
"<",
"lowerBound",
";",
"}"
] |
Checks if an imbalance was detected in the system
@param imbalance
@return <code>true</code> if imbalance threshold has been reached and migration
should be attempted
|
[
"Checks",
"if",
"an",
"imbalance",
"was",
"detected",
"in",
"the",
"system"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/nio/iobalancer/LoadMigrationStrategy.java#L60-L70
|
15,240
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/nio/iobalancer/LoadMigrationStrategy.java
|
LoadMigrationStrategy.findPipelineToMigrate
|
@Override
public MigratablePipeline findPipelineToMigrate(LoadImbalance imbalance) {
Set<? extends MigratablePipeline> candidates = imbalance.getPipelinesOwnedBy(imbalance.srcOwner);
long migrationThreshold = (long) ((imbalance.maximumLoad - imbalance.minimumLoad)
* MAXIMUM_NO_OF_EVENTS_AFTER_MIGRATION_COEFFICIENT);
MigratablePipeline candidate = null;
long loadInSelectedPipeline = 0;
for (MigratablePipeline pipeline : candidates) {
long load = imbalance.getLoad(pipeline);
if (load > loadInSelectedPipeline) {
if (load < migrationThreshold) {
loadInSelectedPipeline = load;
candidate = pipeline;
}
}
}
return candidate;
}
|
java
|
@Override
public MigratablePipeline findPipelineToMigrate(LoadImbalance imbalance) {
Set<? extends MigratablePipeline> candidates = imbalance.getPipelinesOwnedBy(imbalance.srcOwner);
long migrationThreshold = (long) ((imbalance.maximumLoad - imbalance.minimumLoad)
* MAXIMUM_NO_OF_EVENTS_AFTER_MIGRATION_COEFFICIENT);
MigratablePipeline candidate = null;
long loadInSelectedPipeline = 0;
for (MigratablePipeline pipeline : candidates) {
long load = imbalance.getLoad(pipeline);
if (load > loadInSelectedPipeline) {
if (load < migrationThreshold) {
loadInSelectedPipeline = load;
candidate = pipeline;
}
}
}
return candidate;
}
|
[
"@",
"Override",
"public",
"MigratablePipeline",
"findPipelineToMigrate",
"(",
"LoadImbalance",
"imbalance",
")",
"{",
"Set",
"<",
"?",
"extends",
"MigratablePipeline",
">",
"candidates",
"=",
"imbalance",
".",
"getPipelinesOwnedBy",
"(",
"imbalance",
".",
"srcOwner",
")",
";",
"long",
"migrationThreshold",
"=",
"(",
"long",
")",
"(",
"(",
"imbalance",
".",
"maximumLoad",
"-",
"imbalance",
".",
"minimumLoad",
")",
"*",
"MAXIMUM_NO_OF_EVENTS_AFTER_MIGRATION_COEFFICIENT",
")",
";",
"MigratablePipeline",
"candidate",
"=",
"null",
";",
"long",
"loadInSelectedPipeline",
"=",
"0",
";",
"for",
"(",
"MigratablePipeline",
"pipeline",
":",
"candidates",
")",
"{",
"long",
"load",
"=",
"imbalance",
".",
"getLoad",
"(",
"pipeline",
")",
";",
"if",
"(",
"load",
">",
"loadInSelectedPipeline",
")",
"{",
"if",
"(",
"load",
"<",
"migrationThreshold",
")",
"{",
"loadInSelectedPipeline",
"=",
"load",
";",
"candidate",
"=",
"pipeline",
";",
"}",
"}",
"}",
"return",
"candidate",
";",
"}"
] |
Attempt to find a pipeline to migrate to a new NioThread.
@param imbalance describing a snapshot of NioThread load
@return the pipeline to migrate to a new NioThread or null if no
pipeline needs to be migrated.
|
[
"Attempt",
"to",
"find",
"a",
"pipeline",
"to",
"migrate",
"to",
"a",
"new",
"NioThread",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/nio/iobalancer/LoadMigrationStrategy.java#L79-L96
|
15,241
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheEventSet.java
|
CacheEventSet.addEventData
|
public void addEventData(CacheEventData cacheEventData) {
if (events == null) {
events = new HashSet<CacheEventData>();
}
this.events.add(cacheEventData);
}
|
java
|
public void addEventData(CacheEventData cacheEventData) {
if (events == null) {
events = new HashSet<CacheEventData>();
}
this.events.add(cacheEventData);
}
|
[
"public",
"void",
"addEventData",
"(",
"CacheEventData",
"cacheEventData",
")",
"{",
"if",
"(",
"events",
"==",
"null",
")",
"{",
"events",
"=",
"new",
"HashSet",
"<",
"CacheEventData",
">",
"(",
")",
";",
"}",
"this",
".",
"events",
".",
"add",
"(",
"cacheEventData",
")",
";",
"}"
] |
Helper method for adding multiple CacheEventData into this Set
@param cacheEventData event data representing a single event's data.
@see CacheEventData
|
[
"Helper",
"method",
"for",
"adding",
"multiple",
"CacheEventData",
"into",
"this",
"Set"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheEventSet.java#L92-L97
|
15,242
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/util/InstantiationUtils.java
|
InstantiationUtils.newInstanceOrNull
|
public static <T> T newInstanceOrNull(Class<? extends T> clazz, Object...params) {
Constructor<T> constructor = selectMatchingConstructor(clazz, params);
if (constructor == null) {
return null;
}
try {
return constructor.newInstance(params);
} catch (IllegalAccessException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (InvocationTargetException e) {
return null;
}
}
|
java
|
public static <T> T newInstanceOrNull(Class<? extends T> clazz, Object...params) {
Constructor<T> constructor = selectMatchingConstructor(clazz, params);
if (constructor == null) {
return null;
}
try {
return constructor.newInstance(params);
} catch (IllegalAccessException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (InvocationTargetException e) {
return null;
}
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"newInstanceOrNull",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"clazz",
",",
"Object",
"...",
"params",
")",
"{",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"selectMatchingConstructor",
"(",
"clazz",
",",
"params",
")",
";",
"if",
"(",
"constructor",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"constructor",
".",
"newInstance",
"(",
"params",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Create a new instance of a given class. It will search for a constructor matching passed parameters.
If a matching constructor is not found then it returns null.
Constructor is matching when it can be invoked with given parameters. The order of parameters is significant.
When a class constructor contains a primitive argument then it's matching if and only if
a parameter at the same position is not null.
It throws {@link AmbigiousInstantiationException} when multiple matching constructors are found.
@param clazz class to be instantiated
@param params parameters to be passed to the constructor
@param <T> class type to be instantiated
@return a new instance of a given class
@throws AmbigiousInstantiationException when multiple constructors matching the parameters
|
[
"Create",
"a",
"new",
"instance",
"of",
"a",
"given",
"class",
".",
"It",
"will",
"search",
"for",
"a",
"constructor",
"matching",
"passed",
"parameters",
".",
"If",
"a",
"matching",
"constructor",
"is",
"not",
"found",
"then",
"it",
"returns",
"null",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/InstantiationUtils.java#L49-L63
|
15,243
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/AggregatingMap.java
|
AggregatingMap.aggregate
|
public static <K, V> Map<K, V> aggregate(Map<K, V> map1, Map<K, V> map2) {
return new AggregatingMap<K, V>(map1, map2);
}
|
java
|
public static <K, V> Map<K, V> aggregate(Map<K, V> map1, Map<K, V> map2) {
return new AggregatingMap<K, V>(map1, map2);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"aggregate",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map1",
",",
"Map",
"<",
"K",
",",
"V",
">",
"map2",
")",
"{",
"return",
"new",
"AggregatingMap",
"<",
"K",
",",
"V",
">",
"(",
"map1",
",",
"map2",
")",
";",
"}"
] |
Creates new aggregating maps.
@param map1
@param map2
@param <K>
@param <V>
@return
|
[
"Creates",
"new",
"aggregating",
"maps",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/AggregatingMap.java#L61-L63
|
15,244
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/InvokeOnPartitions.java
|
InvokeOnPartitions.invokeAsync
|
@SuppressWarnings("unchecked")
<T> ICompletableFuture<Map<Integer, T>> invokeAsync() {
assert !invoked : "already invoked";
invoked = true;
ensureNotCallingFromPartitionOperationThread();
invokeOnAllPartitions();
return future;
}
|
java
|
@SuppressWarnings("unchecked")
<T> ICompletableFuture<Map<Integer, T>> invokeAsync() {
assert !invoked : "already invoked";
invoked = true;
ensureNotCallingFromPartitionOperationThread();
invokeOnAllPartitions();
return future;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"<",
"T",
">",
"ICompletableFuture",
"<",
"Map",
"<",
"Integer",
",",
"T",
">",
">",
"invokeAsync",
"(",
")",
"{",
"assert",
"!",
"invoked",
":",
"\"already invoked\"",
";",
"invoked",
"=",
"true",
";",
"ensureNotCallingFromPartitionOperationThread",
"(",
")",
";",
"invokeOnAllPartitions",
"(",
")",
";",
"return",
"future",
";",
"}"
] |
Executes all the operations on the partitions.
|
[
"Executes",
"all",
"the",
"operations",
"on",
"the",
"partitions",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/InvokeOnPartitions.java#L94-L101
|
15,245
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/merge/RingbufferMergeData.java
|
RingbufferMergeData.read
|
@SuppressWarnings("unchecked")
public <E> E read(long sequence) {
checkReadSequence(sequence);
return (E) items[toIndex(sequence)];
}
|
java
|
@SuppressWarnings("unchecked")
public <E> E read(long sequence) {
checkReadSequence(sequence);
return (E) items[toIndex(sequence)];
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
">",
"E",
"read",
"(",
"long",
"sequence",
")",
"{",
"checkReadSequence",
"(",
"sequence",
")",
";",
"return",
"(",
"E",
")",
"items",
"[",
"toIndex",
"(",
"sequence",
")",
"]",
";",
"}"
] |
Reads one item from the ringbuffer.
@param sequence the sequence of the item to read
@param <E> ringbuffer item type
@return the ringbuffer item
@throws StaleSequenceException if the sequence is smaller then {@link #getHeadSequence()}
or larger than {@link #getTailSequence()}
|
[
"Reads",
"one",
"item",
"from",
"the",
"ringbuffer",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/merge/RingbufferMergeData.java#L165-L169
|
15,246
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractCacheRecordStore.java
|
AbstractCacheRecordStore.markExpirable
|
protected void markExpirable(long expiryTime) {
if (expiryTime > 0 && expiryTime < Long.MAX_VALUE) {
hasEntryWithExpiration = true;
}
if (isPrimary() && hasEntryWithExpiration) {
cacheService.getExpirationManager().scheduleExpirationTask();
}
}
|
java
|
protected void markExpirable(long expiryTime) {
if (expiryTime > 0 && expiryTime < Long.MAX_VALUE) {
hasEntryWithExpiration = true;
}
if (isPrimary() && hasEntryWithExpiration) {
cacheService.getExpirationManager().scheduleExpirationTask();
}
}
|
[
"protected",
"void",
"markExpirable",
"(",
"long",
"expiryTime",
")",
"{",
"if",
"(",
"expiryTime",
">",
"0",
"&&",
"expiryTime",
"<",
"Long",
".",
"MAX_VALUE",
")",
"{",
"hasEntryWithExpiration",
"=",
"true",
";",
"}",
"if",
"(",
"isPrimary",
"(",
")",
"&&",
"hasEntryWithExpiration",
")",
"{",
"cacheService",
".",
"getExpirationManager",
"(",
")",
".",
"scheduleExpirationTask",
"(",
")",
";",
"}",
"}"
] |
This method marks current replica as expirable and also starts expiration task if necessary.
The expiration task runs on only primary replicas. Expiration on backup replicas are dictated by primary replicas. However,
it is still important to mark a backup replica as expirable because it might be promoted to be the primary in a later time.
@param expiryTime
|
[
"This",
"method",
"marks",
"current",
"replica",
"as",
"expirable",
"and",
"also",
"starts",
"expiration",
"task",
"if",
"necessary",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractCacheRecordStore.java#L1615-L1623
|
15,247
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java
|
ArrayUtils.createCopy
|
public static <T> T[] createCopy(T[] src) {
return Arrays.copyOf(src, src.length);
}
|
java
|
public static <T> T[] createCopy(T[] src) {
return Arrays.copyOf(src, src.length);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"createCopy",
"(",
"T",
"[",
"]",
"src",
")",
"{",
"return",
"Arrays",
".",
"copyOf",
"(",
"src",
",",
"src",
".",
"length",
")",
";",
"}"
] |
Create copy of the src array.
@param src
@param <T>
@return copy of the original array
|
[
"Create",
"copy",
"of",
"the",
"src",
"array",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java#L37-L39
|
15,248
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java
|
ArrayUtils.remove
|
public static <T> T[] remove(T[] src, T object) {
int index = indexOf(src, object);
if (index == -1) {
return src;
}
T[] dst = (T[]) Array.newInstance(src.getClass().getComponentType(), src.length - 1);
System.arraycopy(src, 0, dst, 0, index);
if (index < src.length - 1) {
System.arraycopy(src, index + 1, dst, index, src.length - index - 1);
}
return dst;
}
|
java
|
public static <T> T[] remove(T[] src, T object) {
int index = indexOf(src, object);
if (index == -1) {
return src;
}
T[] dst = (T[]) Array.newInstance(src.getClass().getComponentType(), src.length - 1);
System.arraycopy(src, 0, dst, 0, index);
if (index < src.length - 1) {
System.arraycopy(src, index + 1, dst, index, src.length - index - 1);
}
return dst;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"remove",
"(",
"T",
"[",
"]",
"src",
",",
"T",
"object",
")",
"{",
"int",
"index",
"=",
"indexOf",
"(",
"src",
",",
"object",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"src",
";",
"}",
"T",
"[",
"]",
"dst",
"=",
"(",
"T",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"src",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"src",
".",
"length",
"-",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"src",
",",
"0",
",",
"dst",
",",
"0",
",",
"index",
")",
";",
"if",
"(",
"index",
"<",
"src",
".",
"length",
"-",
"1",
")",
"{",
"System",
".",
"arraycopy",
"(",
"src",
",",
"index",
"+",
"1",
",",
"dst",
",",
"index",
",",
"src",
".",
"length",
"-",
"index",
"-",
"1",
")",
";",
"}",
"return",
"dst",
";",
"}"
] |
Removes an item from the array.
If the item has been found, a new array is returned where this item is removed. Otherwise the original array is returned.
@param src the src array
@param object the object to remove
@param <T> the type of the array
@return the resulting array
|
[
"Removes",
"an",
"item",
"from",
"the",
"array",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java#L51-L63
|
15,249
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java
|
ArrayUtils.append
|
public static <T> T[] append(T[] array1, T[] array2) {
T[] dst = (T[]) Array.newInstance(array1.getClass().getComponentType(), array1.length + array2.length);
System.arraycopy(array1, 0, dst, 0, array1.length);
System.arraycopy(array2, 0, dst, array1.length, array2.length);
return dst;
}
|
java
|
public static <T> T[] append(T[] array1, T[] array2) {
T[] dst = (T[]) Array.newInstance(array1.getClass().getComponentType(), array1.length + array2.length);
System.arraycopy(array1, 0, dst, 0, array1.length);
System.arraycopy(array2, 0, dst, array1.length, array2.length);
return dst;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"append",
"(",
"T",
"[",
"]",
"array1",
",",
"T",
"[",
"]",
"array2",
")",
"{",
"T",
"[",
"]",
"dst",
"=",
"(",
"T",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"array1",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"array1",
".",
"length",
"+",
"array2",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"array1",
",",
"0",
",",
"dst",
",",
"0",
",",
"array1",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"array2",
",",
"0",
",",
"dst",
",",
"array1",
".",
"length",
",",
"array2",
".",
"length",
")",
";",
"return",
"dst",
";",
"}"
] |
Appends 2 arrays.
@param array1 the first array
@param array2 the second array
@param <T> the type of the array
@return the resulting array
|
[
"Appends",
"2",
"arrays",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java#L73-L78
|
15,250
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java
|
ArrayUtils.replaceFirst
|
public static <T> T[] replaceFirst(T[] src, T oldValue, T[] newValues) {
int index = indexOf(src, oldValue);
if (index == -1) {
return src;
}
T[] dst = (T[]) Array.newInstance(src.getClass().getComponentType(), src.length - 1 + newValues.length);
// copy the first part till the match
System.arraycopy(src, 0, dst, 0, index);
// copy the second part from the match
System.arraycopy(src, index + 1, dst, index + newValues.length, src.length - index - 1);
// copy the newValues into the dst
System.arraycopy(newValues, 0, dst, index, newValues.length);
return dst;
}
|
java
|
public static <T> T[] replaceFirst(T[] src, T oldValue, T[] newValues) {
int index = indexOf(src, oldValue);
if (index == -1) {
return src;
}
T[] dst = (T[]) Array.newInstance(src.getClass().getComponentType(), src.length - 1 + newValues.length);
// copy the first part till the match
System.arraycopy(src, 0, dst, 0, index);
// copy the second part from the match
System.arraycopy(src, index + 1, dst, index + newValues.length, src.length - index - 1);
// copy the newValues into the dst
System.arraycopy(newValues, 0, dst, index, newValues.length);
return dst;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"replaceFirst",
"(",
"T",
"[",
"]",
"src",
",",
"T",
"oldValue",
",",
"T",
"[",
"]",
"newValues",
")",
"{",
"int",
"index",
"=",
"indexOf",
"(",
"src",
",",
"oldValue",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"src",
";",
"}",
"T",
"[",
"]",
"dst",
"=",
"(",
"T",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"src",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"src",
".",
"length",
"-",
"1",
"+",
"newValues",
".",
"length",
")",
";",
"// copy the first part till the match",
"System",
".",
"arraycopy",
"(",
"src",
",",
"0",
",",
"dst",
",",
"0",
",",
"index",
")",
";",
"// copy the second part from the match",
"System",
".",
"arraycopy",
"(",
"src",
",",
"index",
"+",
"1",
",",
"dst",
",",
"index",
"+",
"newValues",
".",
"length",
",",
"src",
".",
"length",
"-",
"index",
"-",
"1",
")",
";",
"// copy the newValues into the dst",
"System",
".",
"arraycopy",
"(",
"newValues",
",",
"0",
",",
"dst",
",",
"index",
",",
"newValues",
".",
"length",
")",
";",
"return",
"dst",
";",
"}"
] |
Replaces the first occurrence of the oldValue by the newValue.
If the item is found, a new array is returned. Otherwise the original array is returned.
@param src
@param oldValue the value to look for
@param newValues the value that is inserted.
@param <T> the type of the array
@return
|
[
"Replaces",
"the",
"first",
"occurrence",
"of",
"the",
"oldValue",
"by",
"the",
"newValue",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/collection/ArrayUtils.java#L91-L108
|
15,251
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/instance/HazelcastInstanceFactory.java
|
HazelcastInstanceFactory.getInstanceName
|
public static String getInstanceName(String instanceName, Config config) {
String name = instanceName;
if (name == null || name.trim().length() == 0) {
name = createInstanceName(config);
}
return name;
}
|
java
|
public static String getInstanceName(String instanceName, Config config) {
String name = instanceName;
if (name == null || name.trim().length() == 0) {
name = createInstanceName(config);
}
return name;
}
|
[
"public",
"static",
"String",
"getInstanceName",
"(",
"String",
"instanceName",
",",
"Config",
"config",
")",
"{",
"String",
"name",
"=",
"instanceName",
";",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"name",
"=",
"createInstanceName",
"(",
"config",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Return real name for the hazelcast instance's instance
@param instanceName - template of the name
@param config - config
@return - real hazelcast instance's name
|
[
"Return",
"real",
"name",
"for",
"the",
"hazelcast",
"instance",
"s",
"instance"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/instance/HazelcastInstanceFactory.java#L175-L183
|
15,252
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/state/RaftState.java
|
RaftState.toCandidate
|
public VoteRequest toCandidate() {
role = RaftRole.CANDIDATE;
preCandidateState = null;
leaderState = null;
candidateState = new CandidateState(majority());
candidateState.grantVote(localEndpoint);
persistVote(incrementTerm(), localEndpoint);
return new VoteRequest(localEndpoint, term, log.lastLogOrSnapshotTerm(), log.lastLogOrSnapshotIndex());
}
|
java
|
public VoteRequest toCandidate() {
role = RaftRole.CANDIDATE;
preCandidateState = null;
leaderState = null;
candidateState = new CandidateState(majority());
candidateState.grantVote(localEndpoint);
persistVote(incrementTerm(), localEndpoint);
return new VoteRequest(localEndpoint, term, log.lastLogOrSnapshotTerm(), log.lastLogOrSnapshotIndex());
}
|
[
"public",
"VoteRequest",
"toCandidate",
"(",
")",
"{",
"role",
"=",
"RaftRole",
".",
"CANDIDATE",
";",
"preCandidateState",
"=",
"null",
";",
"leaderState",
"=",
"null",
";",
"candidateState",
"=",
"new",
"CandidateState",
"(",
"majority",
"(",
")",
")",
";",
"candidateState",
".",
"grantVote",
"(",
"localEndpoint",
")",
";",
"persistVote",
"(",
"incrementTerm",
"(",
")",
",",
"localEndpoint",
")",
";",
"return",
"new",
"VoteRequest",
"(",
"localEndpoint",
",",
"term",
",",
"log",
".",
"lastLogOrSnapshotTerm",
"(",
")",
",",
"log",
".",
"lastLogOrSnapshotIndex",
"(",
")",
")",
";",
"}"
] |
Switches this node to candidate role. Clears pre-candidate and leader states.
Initializes candidate state for current majority and grants vote for local endpoint as a candidate.
@return vote request to sent to other members during leader election
|
[
"Switches",
"this",
"node",
"to",
"candidate",
"role",
".",
"Clears",
"pre",
"-",
"candidate",
"and",
"leader",
"states",
".",
"Initializes",
"candidate",
"state",
"for",
"current",
"majority",
"and",
"grants",
"vote",
"for",
"local",
"endpoint",
"as",
"a",
"candidate",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/state/RaftState.java#L328-L337
|
15,253
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/state/RaftState.java
|
RaftState.updateGroupMembers
|
public void updateGroupMembers(long logIndex, Collection<Endpoint> members) {
assert committedGroupMembers == lastGroupMembers
: "Cannot update group members to: " + members + " at log index: " + logIndex + " because last group members: "
+ lastGroupMembers + " is different than committed group members: " + committedGroupMembers;
assert lastGroupMembers.index() < logIndex
: "Cannot update group members to: " + members + " at log index: " + logIndex + " because last group members: "
+ lastGroupMembers + " has a bigger log index.";
RaftGroupMembers newGroupMembers = new RaftGroupMembers(logIndex, members, localEndpoint);
committedGroupMembers = lastGroupMembers;
lastGroupMembers = newGroupMembers;
if (leaderState != null) {
for (Endpoint endpoint : members) {
if (!committedGroupMembers.isKnownMember(endpoint)) {
leaderState.add(endpoint, log.lastLogOrSnapshotIndex());
}
}
for (Endpoint endpoint : committedGroupMembers.remoteMembers()) {
if (!members.contains(endpoint)) {
leaderState.remove(endpoint);
}
}
}
}
|
java
|
public void updateGroupMembers(long logIndex, Collection<Endpoint> members) {
assert committedGroupMembers == lastGroupMembers
: "Cannot update group members to: " + members + " at log index: " + logIndex + " because last group members: "
+ lastGroupMembers + " is different than committed group members: " + committedGroupMembers;
assert lastGroupMembers.index() < logIndex
: "Cannot update group members to: " + members + " at log index: " + logIndex + " because last group members: "
+ lastGroupMembers + " has a bigger log index.";
RaftGroupMembers newGroupMembers = new RaftGroupMembers(logIndex, members, localEndpoint);
committedGroupMembers = lastGroupMembers;
lastGroupMembers = newGroupMembers;
if (leaderState != null) {
for (Endpoint endpoint : members) {
if (!committedGroupMembers.isKnownMember(endpoint)) {
leaderState.add(endpoint, log.lastLogOrSnapshotIndex());
}
}
for (Endpoint endpoint : committedGroupMembers.remoteMembers()) {
if (!members.contains(endpoint)) {
leaderState.remove(endpoint);
}
}
}
}
|
[
"public",
"void",
"updateGroupMembers",
"(",
"long",
"logIndex",
",",
"Collection",
"<",
"Endpoint",
">",
"members",
")",
"{",
"assert",
"committedGroupMembers",
"==",
"lastGroupMembers",
":",
"\"Cannot update group members to: \"",
"+",
"members",
"+",
"\" at log index: \"",
"+",
"logIndex",
"+",
"\" because last group members: \"",
"+",
"lastGroupMembers",
"+",
"\" is different than committed group members: \"",
"+",
"committedGroupMembers",
";",
"assert",
"lastGroupMembers",
".",
"index",
"(",
")",
"<",
"logIndex",
":",
"\"Cannot update group members to: \"",
"+",
"members",
"+",
"\" at log index: \"",
"+",
"logIndex",
"+",
"\" because last group members: \"",
"+",
"lastGroupMembers",
"+",
"\" has a bigger log index.\"",
";",
"RaftGroupMembers",
"newGroupMembers",
"=",
"new",
"RaftGroupMembers",
"(",
"logIndex",
",",
"members",
",",
"localEndpoint",
")",
";",
"committedGroupMembers",
"=",
"lastGroupMembers",
";",
"lastGroupMembers",
"=",
"newGroupMembers",
";",
"if",
"(",
"leaderState",
"!=",
"null",
")",
"{",
"for",
"(",
"Endpoint",
"endpoint",
":",
"members",
")",
"{",
"if",
"(",
"!",
"committedGroupMembers",
".",
"isKnownMember",
"(",
"endpoint",
")",
")",
"{",
"leaderState",
".",
"add",
"(",
"endpoint",
",",
"log",
".",
"lastLogOrSnapshotIndex",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"Endpoint",
"endpoint",
":",
"committedGroupMembers",
".",
"remoteMembers",
"(",
")",
")",
"{",
"if",
"(",
"!",
"members",
".",
"contains",
"(",
"endpoint",
")",
")",
"{",
"leaderState",
".",
"remove",
"(",
"endpoint",
")",
";",
"}",
"}",
"}",
"}"
] |
Initializes the last applied group members with the members and logIndex.
This method expects there's no uncommitted membership changes, committed members are the same as
the last applied members.
Leader state is updated for the members which don't exist in committed members and committed members
those don't exist in latest applied members are removed.
@param logIndex log index of membership change
@param members latest applied members
|
[
"Initializes",
"the",
"last",
"applied",
"group",
"members",
"with",
"the",
"members",
"and",
"logIndex",
".",
"This",
"method",
"expects",
"there",
"s",
"no",
"uncommitted",
"membership",
"changes",
"committed",
"members",
"are",
"the",
"same",
"as",
"the",
"last",
"applied",
"members",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/state/RaftState.java#L384-L409
|
15,254
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.init
|
public void init(boolean fromBackup) {
if (!fromBackup && store.isEnabled()) {
Set<Long> keys = store.loadAllKeys();
if (keys != null) {
long maxId = -1;
for (Long key : keys) {
QueueItem item = new QueueItem(this, key, null);
getItemQueue().offer(item);
maxId = Math.max(maxId, key);
}
idGenerator = maxId + 1;
}
}
}
|
java
|
public void init(boolean fromBackup) {
if (!fromBackup && store.isEnabled()) {
Set<Long> keys = store.loadAllKeys();
if (keys != null) {
long maxId = -1;
for (Long key : keys) {
QueueItem item = new QueueItem(this, key, null);
getItemQueue().offer(item);
maxId = Math.max(maxId, key);
}
idGenerator = maxId + 1;
}
}
}
|
[
"public",
"void",
"init",
"(",
"boolean",
"fromBackup",
")",
"{",
"if",
"(",
"!",
"fromBackup",
"&&",
"store",
".",
"isEnabled",
"(",
")",
")",
"{",
"Set",
"<",
"Long",
">",
"keys",
"=",
"store",
".",
"loadAllKeys",
"(",
")",
";",
"if",
"(",
"keys",
"!=",
"null",
")",
"{",
"long",
"maxId",
"=",
"-",
"1",
";",
"for",
"(",
"Long",
"key",
":",
"keys",
")",
"{",
"QueueItem",
"item",
"=",
"new",
"QueueItem",
"(",
"this",
",",
"key",
",",
"null",
")",
";",
"getItemQueue",
"(",
")",
".",
"offer",
"(",
"item",
")",
";",
"maxId",
"=",
"Math",
".",
"max",
"(",
"maxId",
",",
"key",
")",
";",
"}",
"idGenerator",
"=",
"maxId",
"+",
"1",
";",
"}",
"}",
"}"
] |
Initializes the item queue with items from the queue store if the store is enabled and if item queue is not being
initialized as a part of a backup operation. If the item queue is being initialized as a part of a backup operation then
the operation is in charge of adding items to a queue and the items are not loaded from a queue store.
@param fromBackup indicates if this item queue is being initialized from a backup operation. If false, the
item queue will initialize from the queue store. If true, it will not initialize
|
[
"Initializes",
"the",
"item",
"queue",
"with",
"items",
"from",
"the",
"queue",
"store",
"if",
"the",
"store",
"is",
"enabled",
"and",
"if",
"item",
"queue",
"is",
"not",
"being",
"initialized",
"as",
"a",
"part",
"of",
"a",
"backup",
"operation",
".",
"If",
"the",
"item",
"queue",
"is",
"being",
"initialized",
"as",
"a",
"part",
"of",
"a",
"backup",
"operation",
"then",
"the",
"operation",
"is",
"in",
"charge",
"of",
"adding",
"items",
"to",
"a",
"queue",
"and",
"the",
"items",
"are",
"not",
"loaded",
"from",
"a",
"queue",
"store",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L119-L132
|
15,255
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.txnPollBackupReserve
|
public void txnPollBackupReserve(long itemId, String transactionId) {
QueueItem item = getBackupMap().remove(itemId);
if (item != null) {
txMap.put(itemId, new TxQueueItem(item).setPollOperation(true).setTransactionId(transactionId));
return;
}
if (txMap.remove(itemId) == null) {
logger.warning("Poll backup reserve failed, itemId: " + itemId + " is not found");
}
}
|
java
|
public void txnPollBackupReserve(long itemId, String transactionId) {
QueueItem item = getBackupMap().remove(itemId);
if (item != null) {
txMap.put(itemId, new TxQueueItem(item).setPollOperation(true).setTransactionId(transactionId));
return;
}
if (txMap.remove(itemId) == null) {
logger.warning("Poll backup reserve failed, itemId: " + itemId + " is not found");
}
}
|
[
"public",
"void",
"txnPollBackupReserve",
"(",
"long",
"itemId",
",",
"String",
"transactionId",
")",
"{",
"QueueItem",
"item",
"=",
"getBackupMap",
"(",
")",
".",
"remove",
"(",
"itemId",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"txMap",
".",
"put",
"(",
"itemId",
",",
"new",
"TxQueueItem",
"(",
"item",
")",
".",
"setPollOperation",
"(",
"true",
")",
".",
"setTransactionId",
"(",
"transactionId",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"txMap",
".",
"remove",
"(",
"itemId",
")",
"==",
"null",
")",
"{",
"logger",
".",
"warning",
"(",
"\"Poll backup reserve failed, itemId: \"",
"+",
"itemId",
"+",
"\" is not found\"",
")",
";",
"}",
"}"
] |
Makes a reservation for a poll operation. Should be executed as
a part of the prepare phase for a transactional queue poll
on the partition backup replica.
The ID of the item being polled is determined by the partition
owner.
@param itemId the ID of the reserved item to be polled
@param transactionId the transaction ID
@see #txnPollReserve(long, String)
@see com.hazelcast.collection.impl.txnqueue.operations.TxnReservePollOperation
|
[
"Makes",
"a",
"reservation",
"for",
"a",
"poll",
"operation",
".",
"Should",
"be",
"executed",
"as",
"a",
"part",
"of",
"the",
"prepare",
"phase",
"for",
"a",
"transactional",
"queue",
"poll",
"on",
"the",
"partition",
"backup",
"replica",
".",
"The",
"ID",
"of",
"the",
"item",
"being",
"polled",
"is",
"determined",
"by",
"the",
"partition",
"owner",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L216-L225
|
15,256
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.offer
|
public long offer(Data data) {
QueueItem item = new QueueItem(this, nextId(), null);
if (store.isEnabled()) {
try {
store.store(item.getItemId(), data);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(data);
}
getItemQueue().offer(item);
cancelEvictionIfExists();
return item.getItemId();
}
|
java
|
public long offer(Data data) {
QueueItem item = new QueueItem(this, nextId(), null);
if (store.isEnabled()) {
try {
store.store(item.getItemId(), data);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(data);
}
getItemQueue().offer(item);
cancelEvictionIfExists();
return item.getItemId();
}
|
[
"public",
"long",
"offer",
"(",
"Data",
"data",
")",
"{",
"QueueItem",
"item",
"=",
"new",
"QueueItem",
"(",
"this",
",",
"nextId",
"(",
")",
",",
"null",
")",
";",
"if",
"(",
"store",
".",
"isEnabled",
"(",
")",
")",
"{",
"try",
"{",
"store",
".",
"store",
"(",
"item",
".",
"getItemId",
"(",
")",
",",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"!",
"store",
".",
"isEnabled",
"(",
")",
"||",
"store",
".",
"getMemoryLimit",
"(",
")",
">",
"getItemQueue",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"item",
".",
"setData",
"(",
"data",
")",
";",
"}",
"getItemQueue",
"(",
")",
".",
"offer",
"(",
"item",
")",
";",
"cancelEvictionIfExists",
"(",
")",
";",
"return",
"item",
".",
"getItemId",
"(",
")",
";",
"}"
] |
TX Methods Ends
|
[
"TX",
"Methods",
"Ends"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L438-L453
|
15,257
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.offerBackup
|
public void offerBackup(Data data, long itemId) {
QueueItem item = new QueueItem(this, itemId, null);
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(data);
}
getBackupMap().put(itemId, item);
}
|
java
|
public void offerBackup(Data data, long itemId) {
QueueItem item = new QueueItem(this, itemId, null);
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(data);
}
getBackupMap().put(itemId, item);
}
|
[
"public",
"void",
"offerBackup",
"(",
"Data",
"data",
",",
"long",
"itemId",
")",
"{",
"QueueItem",
"item",
"=",
"new",
"QueueItem",
"(",
"this",
",",
"itemId",
",",
"null",
")",
";",
"if",
"(",
"!",
"store",
".",
"isEnabled",
"(",
")",
"||",
"store",
".",
"getMemoryLimit",
"(",
")",
">",
"getItemQueue",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"item",
".",
"setData",
"(",
"data",
")",
";",
"}",
"getBackupMap",
"(",
")",
".",
"put",
"(",
"itemId",
",",
"item",
")",
";",
"}"
] |
Offers the item to the backup map. If the memory limit
has been achieved the item data will not be kept in-memory.
Executed on the backup replica
@param data the item data
@param itemId the item ID as determined by the primary replica
|
[
"Offers",
"the",
"item",
"to",
"the",
"backup",
"map",
".",
"If",
"the",
"memory",
"limit",
"has",
"been",
"achieved",
"the",
"item",
"data",
"will",
"not",
"be",
"kept",
"in",
"-",
"memory",
".",
"Executed",
"on",
"the",
"backup",
"replica"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L463-L469
|
15,258
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.addAllBackup
|
public void addAllBackup(Map<Long, Data> dataMap) {
for (Map.Entry<Long, Data> entry : dataMap.entrySet()) {
QueueItem item = new QueueItem(this, entry.getKey(), null);
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(entry.getValue());
}
getBackupMap().put(item.getItemId(), item);
}
}
|
java
|
public void addAllBackup(Map<Long, Data> dataMap) {
for (Map.Entry<Long, Data> entry : dataMap.entrySet()) {
QueueItem item = new QueueItem(this, entry.getKey(), null);
if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
item.setData(entry.getValue());
}
getBackupMap().put(item.getItemId(), item);
}
}
|
[
"public",
"void",
"addAllBackup",
"(",
"Map",
"<",
"Long",
",",
"Data",
">",
"dataMap",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Data",
">",
"entry",
":",
"dataMap",
".",
"entrySet",
"(",
")",
")",
"{",
"QueueItem",
"item",
"=",
"new",
"QueueItem",
"(",
"this",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"null",
")",
";",
"if",
"(",
"!",
"store",
".",
"isEnabled",
"(",
")",
"||",
"store",
".",
"getMemoryLimit",
"(",
")",
">",
"getItemQueue",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"item",
".",
"setData",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"getBackupMap",
"(",
")",
".",
"put",
"(",
"item",
".",
"getItemId",
"(",
")",
",",
"item",
")",
";",
"}",
"}"
] |
Offers the items to the backup map in bulk. If the memory limit
has been achieved the item data will not be kept in-memory.
Executed on the backup replica
@param dataMap the map from item ID to queue item
@see #offerBackup(Data, long)
|
[
"Offers",
"the",
"items",
"to",
"the",
"backup",
"map",
"in",
"bulk",
".",
"If",
"the",
"memory",
"limit",
"has",
"been",
"achieved",
"the",
"item",
"data",
"will",
"not",
"be",
"kept",
"in",
"-",
"memory",
".",
"Executed",
"on",
"the",
"backup",
"replica"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L512-L520
|
15,259
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.pollBackup
|
public void pollBackup(long itemId) {
QueueItem item = getBackupMap().remove(itemId);
if (item != null) {
// for stats
age(item, Clock.currentTimeMillis());
}
}
|
java
|
public void pollBackup(long itemId) {
QueueItem item = getBackupMap().remove(itemId);
if (item != null) {
// for stats
age(item, Clock.currentTimeMillis());
}
}
|
[
"public",
"void",
"pollBackup",
"(",
"long",
"itemId",
")",
"{",
"QueueItem",
"item",
"=",
"getBackupMap",
"(",
")",
".",
"remove",
"(",
"itemId",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"// for stats",
"age",
"(",
"item",
",",
"Clock",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}",
"}"
] |
Polls an item on the backup replica. The item ID is predetermined
when executing the poll operation on the partition owner.
Executed on the backup replica
@param itemId the item ID as determined by the primary replica
|
[
"Polls",
"an",
"item",
"on",
"the",
"backup",
"replica",
".",
"The",
"item",
"ID",
"is",
"predetermined",
"when",
"executing",
"the",
"poll",
"operation",
"on",
"the",
"partition",
"owner",
".",
"Executed",
"on",
"the",
"backup",
"replica"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L574-L580
|
15,260
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.remove
|
public long remove(Data data) {
Iterator<QueueItem> iterator = getItemQueue().iterator();
while (iterator.hasNext()) {
QueueItem item = iterator.next();
if (data.equals(item.getData())) {
if (store.isEnabled()) {
try {
store.delete(item.getItemId());
} catch (Exception e) {
throw new HazelcastException(e);
}
}
iterator.remove();
// for stats
age(item, Clock.currentTimeMillis());
scheduleEvictionIfEmpty();
return item.getItemId();
}
}
return -1;
}
|
java
|
public long remove(Data data) {
Iterator<QueueItem> iterator = getItemQueue().iterator();
while (iterator.hasNext()) {
QueueItem item = iterator.next();
if (data.equals(item.getData())) {
if (store.isEnabled()) {
try {
store.delete(item.getItemId());
} catch (Exception e) {
throw new HazelcastException(e);
}
}
iterator.remove();
// for stats
age(item, Clock.currentTimeMillis());
scheduleEvictionIfEmpty();
return item.getItemId();
}
}
return -1;
}
|
[
"public",
"long",
"remove",
"(",
"Data",
"data",
")",
"{",
"Iterator",
"<",
"QueueItem",
">",
"iterator",
"=",
"getItemQueue",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"QueueItem",
"item",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"data",
".",
"equals",
"(",
"item",
".",
"getData",
"(",
")",
")",
")",
"{",
"if",
"(",
"store",
".",
"isEnabled",
"(",
")",
")",
"{",
"try",
"{",
"store",
".",
"delete",
"(",
"item",
".",
"getItemId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"e",
")",
";",
"}",
"}",
"iterator",
".",
"remove",
"(",
")",
";",
"// for stats",
"age",
"(",
"item",
",",
"Clock",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"scheduleEvictionIfEmpty",
"(",
")",
";",
"return",
"item",
".",
"getItemId",
"(",
")",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
iterates all items, checks equality with data
This method does not trigger store load.
|
[
"iterates",
"all",
"items",
"checks",
"equality",
"with",
"data",
"This",
"method",
"does",
"not",
"trigger",
"store",
"load",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L688-L708
|
15,261
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.contains
|
public boolean contains(Collection<Data> dataSet) {
for (Data data : dataSet) {
boolean contains = false;
for (QueueItem item : getItemQueue()) {
if (item.getData() != null && item.getData().equals(data)) {
contains = true;
break;
}
}
if (!contains) {
return false;
}
}
return true;
}
|
java
|
public boolean contains(Collection<Data> dataSet) {
for (Data data : dataSet) {
boolean contains = false;
for (QueueItem item : getItemQueue()) {
if (item.getData() != null && item.getData().equals(data)) {
contains = true;
break;
}
}
if (!contains) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"contains",
"(",
"Collection",
"<",
"Data",
">",
"dataSet",
")",
"{",
"for",
"(",
"Data",
"data",
":",
"dataSet",
")",
"{",
"boolean",
"contains",
"=",
"false",
";",
"for",
"(",
"QueueItem",
"item",
":",
"getItemQueue",
"(",
")",
")",
"{",
"if",
"(",
"item",
".",
"getData",
"(",
")",
"!=",
"null",
"&&",
"item",
".",
"getData",
"(",
")",
".",
"equals",
"(",
"data",
")",
")",
"{",
"contains",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"contains",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if the queue contains all items in the dataSet. This method does not trigger store load.
@param dataSet the items which should be stored in the queue
@return true if the queue contains all items, false otherwise
|
[
"Checks",
"if",
"the",
"queue",
"contains",
"all",
"items",
"in",
"the",
"dataSet",
".",
"This",
"method",
"does",
"not",
"trigger",
"store",
"load",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L726-L740
|
15,262
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.getAsDataList
|
public List<Data> getAsDataList() {
List<Data> dataList = new ArrayList<Data>(getItemQueue().size());
for (QueueItem item : getItemQueue()) {
if (store.isEnabled() && item.getData() == null) {
try {
load(item);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
dataList.add(item.getData());
}
return dataList;
}
|
java
|
public List<Data> getAsDataList() {
List<Data> dataList = new ArrayList<Data>(getItemQueue().size());
for (QueueItem item : getItemQueue()) {
if (store.isEnabled() && item.getData() == null) {
try {
load(item);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
dataList.add(item.getData());
}
return dataList;
}
|
[
"public",
"List",
"<",
"Data",
">",
"getAsDataList",
"(",
")",
"{",
"List",
"<",
"Data",
">",
"dataList",
"=",
"new",
"ArrayList",
"<",
"Data",
">",
"(",
"getItemQueue",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"QueueItem",
"item",
":",
"getItemQueue",
"(",
")",
")",
"{",
"if",
"(",
"store",
".",
"isEnabled",
"(",
")",
"&&",
"item",
".",
"getData",
"(",
")",
"==",
"null",
")",
"{",
"try",
"{",
"load",
"(",
"item",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"e",
")",
";",
"}",
"}",
"dataList",
".",
"add",
"(",
"item",
".",
"getData",
"(",
")",
")",
";",
"}",
"return",
"dataList",
";",
"}"
] |
Returns data in the queue. This method triggers store load.
@return the item data in the queue.
|
[
"Returns",
"data",
"in",
"the",
"queue",
".",
"This",
"method",
"triggers",
"store",
"load",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L747-L760
|
15,263
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.getItemQueue
|
public Deque<QueueItem> getItemQueue() {
if (itemQueue == null) {
itemQueue = new LinkedList<QueueItem>();
if (backupMap != null && !backupMap.isEmpty()) {
List<QueueItem> values = new ArrayList<QueueItem>(backupMap.values());
Collections.sort(values);
itemQueue.addAll(values);
QueueItem lastItem = itemQueue.peekLast();
if (lastItem != null) {
setId(lastItem.itemId + ID_PROMOTION_OFFSET);
}
backupMap.clear();
backupMap = null;
}
if (!txMap.isEmpty()) {
long maxItemId = Long.MIN_VALUE;
for (TxQueueItem item : txMap.values()) {
maxItemId = Math.max(maxItemId, item.itemId);
}
setId(maxItemId + ID_PROMOTION_OFFSET);
}
}
return itemQueue;
}
|
java
|
public Deque<QueueItem> getItemQueue() {
if (itemQueue == null) {
itemQueue = new LinkedList<QueueItem>();
if (backupMap != null && !backupMap.isEmpty()) {
List<QueueItem> values = new ArrayList<QueueItem>(backupMap.values());
Collections.sort(values);
itemQueue.addAll(values);
QueueItem lastItem = itemQueue.peekLast();
if (lastItem != null) {
setId(lastItem.itemId + ID_PROMOTION_OFFSET);
}
backupMap.clear();
backupMap = null;
}
if (!txMap.isEmpty()) {
long maxItemId = Long.MIN_VALUE;
for (TxQueueItem item : txMap.values()) {
maxItemId = Math.max(maxItemId, item.itemId);
}
setId(maxItemId + ID_PROMOTION_OFFSET);
}
}
return itemQueue;
}
|
[
"public",
"Deque",
"<",
"QueueItem",
">",
"getItemQueue",
"(",
")",
"{",
"if",
"(",
"itemQueue",
"==",
"null",
")",
"{",
"itemQueue",
"=",
"new",
"LinkedList",
"<",
"QueueItem",
">",
"(",
")",
";",
"if",
"(",
"backupMap",
"!=",
"null",
"&&",
"!",
"backupMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"List",
"<",
"QueueItem",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"QueueItem",
">",
"(",
"backupMap",
".",
"values",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"values",
")",
";",
"itemQueue",
".",
"addAll",
"(",
"values",
")",
";",
"QueueItem",
"lastItem",
"=",
"itemQueue",
".",
"peekLast",
"(",
")",
";",
"if",
"(",
"lastItem",
"!=",
"null",
")",
"{",
"setId",
"(",
"lastItem",
".",
"itemId",
"+",
"ID_PROMOTION_OFFSET",
")",
";",
"}",
"backupMap",
".",
"clear",
"(",
")",
";",
"backupMap",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"txMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"long",
"maxItemId",
"=",
"Long",
".",
"MIN_VALUE",
";",
"for",
"(",
"TxQueueItem",
"item",
":",
"txMap",
".",
"values",
"(",
")",
")",
"{",
"maxItemId",
"=",
"Math",
".",
"max",
"(",
"maxItemId",
",",
"item",
".",
"itemId",
")",
";",
"}",
"setId",
"(",
"maxItemId",
"+",
"ID_PROMOTION_OFFSET",
")",
";",
"}",
"}",
"return",
"itemQueue",
";",
"}"
] |
Returns the item queue on the partition owner. This method
will also move the items from the backup map if this
member has been promoted from a backup replica to the
partition owner and clear the backup map.
@return the item queue
|
[
"Returns",
"the",
"item",
"queue",
"on",
"the",
"partition",
"owner",
".",
"This",
"method",
"will",
"also",
"move",
"the",
"items",
"from",
"the",
"backup",
"map",
"if",
"this",
"member",
"has",
"been",
"promoted",
"from",
"a",
"backup",
"replica",
"to",
"the",
"partition",
"owner",
"and",
"clear",
"the",
"backup",
"map",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L894-L917
|
15,264
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java
|
QueueContainer.getBackupMap
|
public Map<Long, QueueItem> getBackupMap() {
if (backupMap == null) {
if (itemQueue != null) {
backupMap = createHashMap(itemQueue.size());
for (QueueItem item : itemQueue) {
backupMap.put(item.getItemId(), item);
}
itemQueue.clear();
itemQueue = null;
} else {
backupMap = new HashMap<Long, QueueItem>();
}
}
return backupMap;
}
|
java
|
public Map<Long, QueueItem> getBackupMap() {
if (backupMap == null) {
if (itemQueue != null) {
backupMap = createHashMap(itemQueue.size());
for (QueueItem item : itemQueue) {
backupMap.put(item.getItemId(), item);
}
itemQueue.clear();
itemQueue = null;
} else {
backupMap = new HashMap<Long, QueueItem>();
}
}
return backupMap;
}
|
[
"public",
"Map",
"<",
"Long",
",",
"QueueItem",
">",
"getBackupMap",
"(",
")",
"{",
"if",
"(",
"backupMap",
"==",
"null",
")",
"{",
"if",
"(",
"itemQueue",
"!=",
"null",
")",
"{",
"backupMap",
"=",
"createHashMap",
"(",
"itemQueue",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"QueueItem",
"item",
":",
"itemQueue",
")",
"{",
"backupMap",
".",
"put",
"(",
"item",
".",
"getItemId",
"(",
")",
",",
"item",
")",
";",
"}",
"itemQueue",
".",
"clear",
"(",
")",
";",
"itemQueue",
"=",
"null",
";",
"}",
"else",
"{",
"backupMap",
"=",
"new",
"HashMap",
"<",
"Long",
",",
"QueueItem",
">",
"(",
")",
";",
"}",
"}",
"return",
"backupMap",
";",
"}"
] |
Return the map containing queue items when this instance is
a backup replica.
The map contains both items that are parts of different
transactions and items which have already been committed
to the queue.
@return backup replica map from item ID to queue item
|
[
"Return",
"the",
"map",
"containing",
"queue",
"items",
"when",
"this",
"instance",
"is",
"a",
"backup",
"replica",
".",
"The",
"map",
"contains",
"both",
"items",
"that",
"are",
"parts",
"of",
"different",
"transactions",
"and",
"items",
"which",
"have",
"already",
"been",
"committed",
"to",
"the",
"queue",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueContainer.java#L928-L942
|
15,265
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/collection/impl/txncollection/CollectionTransactionLogRecord.java
|
CollectionTransactionLogRecord.createItemIdArray
|
protected long[] createItemIdArray() {
int size = operationList.size();
long[] itemIds = new long[size];
for (int i = 0; i < size; i++) {
CollectionTxnOperation operation = (CollectionTxnOperation) operationList.get(i);
itemIds[i] = CollectionTxnUtil.getItemId(operation);
}
return itemIds;
}
|
java
|
protected long[] createItemIdArray() {
int size = operationList.size();
long[] itemIds = new long[size];
for (int i = 0; i < size; i++) {
CollectionTxnOperation operation = (CollectionTxnOperation) operationList.get(i);
itemIds[i] = CollectionTxnUtil.getItemId(operation);
}
return itemIds;
}
|
[
"protected",
"long",
"[",
"]",
"createItemIdArray",
"(",
")",
"{",
"int",
"size",
"=",
"operationList",
".",
"size",
"(",
")",
";",
"long",
"[",
"]",
"itemIds",
"=",
"new",
"long",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"CollectionTxnOperation",
"operation",
"=",
"(",
"CollectionTxnOperation",
")",
"operationList",
".",
"get",
"(",
"i",
")",
";",
"itemIds",
"[",
"i",
"]",
"=",
"CollectionTxnUtil",
".",
"getItemId",
"(",
"operation",
")",
";",
"}",
"return",
"itemIds",
";",
"}"
] |
Creates an array of IDs for all operations in this transaction log. The ID is negative if the operation is a remove
operation.
@return an array of IDs for all operations in this transaction log
|
[
"Creates",
"an",
"array",
"of",
"IDs",
"for",
"all",
"operations",
"in",
"this",
"transaction",
"log",
".",
"The",
"ID",
"is",
"negative",
"if",
"the",
"operation",
"is",
"a",
"remove",
"operation",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/txncollection/CollectionTransactionLogRecord.java#L108-L116
|
15,266
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/operations/ReplicationOperation.java
|
ReplicationOperation.getRingbufferConfig
|
private RingbufferConfig getRingbufferConfig(RingbufferService service, ObjectNamespace ns) {
final String serviceName = ns.getServiceName();
if (RingbufferService.SERVICE_NAME.equals(serviceName)) {
return service.getRingbufferConfig(ns.getObjectName());
} else if (MapService.SERVICE_NAME.equals(serviceName)) {
final MapService mapService = getNodeEngine().getService(MapService.SERVICE_NAME);
final MapEventJournal journal = mapService.getMapServiceContext().getEventJournal();
final EventJournalConfig journalConfig = journal.getEventJournalConfig(ns);
return journal.toRingbufferConfig(journalConfig, ns);
} else if (CacheService.SERVICE_NAME.equals(serviceName)) {
final CacheService cacheService = getNodeEngine().getService(CacheService.SERVICE_NAME);
final CacheEventJournal journal = cacheService.getEventJournal();
final EventJournalConfig journalConfig = journal.getEventJournalConfig(ns);
return journal.toRingbufferConfig(journalConfig, ns);
} else {
throw new IllegalArgumentException("Unsupported ringbuffer service name " + serviceName);
}
}
|
java
|
private RingbufferConfig getRingbufferConfig(RingbufferService service, ObjectNamespace ns) {
final String serviceName = ns.getServiceName();
if (RingbufferService.SERVICE_NAME.equals(serviceName)) {
return service.getRingbufferConfig(ns.getObjectName());
} else if (MapService.SERVICE_NAME.equals(serviceName)) {
final MapService mapService = getNodeEngine().getService(MapService.SERVICE_NAME);
final MapEventJournal journal = mapService.getMapServiceContext().getEventJournal();
final EventJournalConfig journalConfig = journal.getEventJournalConfig(ns);
return journal.toRingbufferConfig(journalConfig, ns);
} else if (CacheService.SERVICE_NAME.equals(serviceName)) {
final CacheService cacheService = getNodeEngine().getService(CacheService.SERVICE_NAME);
final CacheEventJournal journal = cacheService.getEventJournal();
final EventJournalConfig journalConfig = journal.getEventJournalConfig(ns);
return journal.toRingbufferConfig(journalConfig, ns);
} else {
throw new IllegalArgumentException("Unsupported ringbuffer service name " + serviceName);
}
}
|
[
"private",
"RingbufferConfig",
"getRingbufferConfig",
"(",
"RingbufferService",
"service",
",",
"ObjectNamespace",
"ns",
")",
"{",
"final",
"String",
"serviceName",
"=",
"ns",
".",
"getServiceName",
"(",
")",
";",
"if",
"(",
"RingbufferService",
".",
"SERVICE_NAME",
".",
"equals",
"(",
"serviceName",
")",
")",
"{",
"return",
"service",
".",
"getRingbufferConfig",
"(",
"ns",
".",
"getObjectName",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"MapService",
".",
"SERVICE_NAME",
".",
"equals",
"(",
"serviceName",
")",
")",
"{",
"final",
"MapService",
"mapService",
"=",
"getNodeEngine",
"(",
")",
".",
"getService",
"(",
"MapService",
".",
"SERVICE_NAME",
")",
";",
"final",
"MapEventJournal",
"journal",
"=",
"mapService",
".",
"getMapServiceContext",
"(",
")",
".",
"getEventJournal",
"(",
")",
";",
"final",
"EventJournalConfig",
"journalConfig",
"=",
"journal",
".",
"getEventJournalConfig",
"(",
"ns",
")",
";",
"return",
"journal",
".",
"toRingbufferConfig",
"(",
"journalConfig",
",",
"ns",
")",
";",
"}",
"else",
"if",
"(",
"CacheService",
".",
"SERVICE_NAME",
".",
"equals",
"(",
"serviceName",
")",
")",
"{",
"final",
"CacheService",
"cacheService",
"=",
"getNodeEngine",
"(",
")",
".",
"getService",
"(",
"CacheService",
".",
"SERVICE_NAME",
")",
";",
"final",
"CacheEventJournal",
"journal",
"=",
"cacheService",
".",
"getEventJournal",
"(",
")",
";",
"final",
"EventJournalConfig",
"journalConfig",
"=",
"journal",
".",
"getEventJournalConfig",
"(",
"ns",
")",
";",
"return",
"journal",
".",
"toRingbufferConfig",
"(",
"journalConfig",
",",
"ns",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported ringbuffer service name \"",
"+",
"serviceName",
")",
";",
"}",
"}"
] |
Returns the ringbuffer config for the provided namespace. The namespace
provides information whether the requested ringbuffer is a ringbuffer
that the user is directly interacting with through a ringbuffer proxy
or if this is a backing ringbuffer for an event journal.
If a ringbuffer configuration for an event journal is requested, this
method will expect the configuration for the relevant map or cache
to be available.
@param service the ringbuffer service
@param ns the object namespace for which we are creating a ringbuffer
@return the ringbuffer configuration
@throws CacheNotExistsException if a config for a cache event journal was requested
and the cache configuration was not found
|
[
"Returns",
"the",
"ringbuffer",
"config",
"for",
"the",
"provided",
"namespace",
".",
"The",
"namespace",
"provides",
"information",
"whether",
"the",
"requested",
"ringbuffer",
"is",
"a",
"ringbuffer",
"that",
"the",
"user",
"is",
"directly",
"interacting",
"with",
"through",
"a",
"ringbuffer",
"proxy",
"or",
"if",
"this",
"is",
"a",
"backing",
"ringbuffer",
"for",
"an",
"event",
"journal",
".",
"If",
"a",
"ringbuffer",
"configuration",
"for",
"an",
"event",
"journal",
"is",
"requested",
"this",
"method",
"will",
"expect",
"the",
"configuration",
"for",
"the",
"relevant",
"map",
"or",
"cache",
"to",
"be",
"available",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/operations/ReplicationOperation.java#L82-L99
|
15,267
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/RepairingHandler.java
|
RepairingHandler.handle
|
public void handle(Data key, String sourceUuid, UUID partitionUuid, long sequence) {
// apply invalidation if it's not originated by local member/client (because local
// Near Caches are invalidated immediately there is no need to invalidate them twice)
if (!localUuid.equals(sourceUuid)) {
// sourceUuid is allowed to be `null`
if (key == null) {
nearCache.clear();
} else {
nearCache.invalidate(serializeKeys ? key : serializationService.toObject(key));
}
}
int partitionId = getPartitionIdOrDefault(key);
checkOrRepairUuid(partitionId, partitionUuid);
checkOrRepairSequence(partitionId, sequence, false);
}
|
java
|
public void handle(Data key, String sourceUuid, UUID partitionUuid, long sequence) {
// apply invalidation if it's not originated by local member/client (because local
// Near Caches are invalidated immediately there is no need to invalidate them twice)
if (!localUuid.equals(sourceUuid)) {
// sourceUuid is allowed to be `null`
if (key == null) {
nearCache.clear();
} else {
nearCache.invalidate(serializeKeys ? key : serializationService.toObject(key));
}
}
int partitionId = getPartitionIdOrDefault(key);
checkOrRepairUuid(partitionId, partitionUuid);
checkOrRepairSequence(partitionId, sequence, false);
}
|
[
"public",
"void",
"handle",
"(",
"Data",
"key",
",",
"String",
"sourceUuid",
",",
"UUID",
"partitionUuid",
",",
"long",
"sequence",
")",
"{",
"// apply invalidation if it's not originated by local member/client (because local",
"// Near Caches are invalidated immediately there is no need to invalidate them twice)",
"if",
"(",
"!",
"localUuid",
".",
"equals",
"(",
"sourceUuid",
")",
")",
"{",
"// sourceUuid is allowed to be `null`",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"nearCache",
".",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"nearCache",
".",
"invalidate",
"(",
"serializeKeys",
"?",
"key",
":",
"serializationService",
".",
"toObject",
"(",
"key",
")",
")",
";",
"}",
"}",
"int",
"partitionId",
"=",
"getPartitionIdOrDefault",
"(",
"key",
")",
";",
"checkOrRepairUuid",
"(",
"partitionId",
",",
"partitionUuid",
")",
";",
"checkOrRepairSequence",
"(",
"partitionId",
",",
"sequence",
",",
"false",
")",
";",
"}"
] |
Handles a single invalidation
|
[
"Handles",
"a",
"single",
"invalidation"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/RepairingHandler.java#L82-L97
|
15,268
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/RepairingHandler.java
|
RepairingHandler.handle
|
public void handle(Collection<Data> keys, Collection<String> sourceUuids,
Collection<UUID> partitionUuids, Collection<Long> sequences) {
Iterator<Data> keyIterator = keys.iterator();
Iterator<Long> sequenceIterator = sequences.iterator();
Iterator<UUID> partitionUuidIterator = partitionUuids.iterator();
Iterator<String> sourceUuidsIterator = sourceUuids.iterator();
while (keyIterator.hasNext() && sourceUuidsIterator.hasNext()
&& partitionUuidIterator.hasNext() && sequenceIterator.hasNext()) {
handle(keyIterator.next(), sourceUuidsIterator.next(), partitionUuidIterator.next(), sequenceIterator.next());
}
}
|
java
|
public void handle(Collection<Data> keys, Collection<String> sourceUuids,
Collection<UUID> partitionUuids, Collection<Long> sequences) {
Iterator<Data> keyIterator = keys.iterator();
Iterator<Long> sequenceIterator = sequences.iterator();
Iterator<UUID> partitionUuidIterator = partitionUuids.iterator();
Iterator<String> sourceUuidsIterator = sourceUuids.iterator();
while (keyIterator.hasNext() && sourceUuidsIterator.hasNext()
&& partitionUuidIterator.hasNext() && sequenceIterator.hasNext()) {
handle(keyIterator.next(), sourceUuidsIterator.next(), partitionUuidIterator.next(), sequenceIterator.next());
}
}
|
[
"public",
"void",
"handle",
"(",
"Collection",
"<",
"Data",
">",
"keys",
",",
"Collection",
"<",
"String",
">",
"sourceUuids",
",",
"Collection",
"<",
"UUID",
">",
"partitionUuids",
",",
"Collection",
"<",
"Long",
">",
"sequences",
")",
"{",
"Iterator",
"<",
"Data",
">",
"keyIterator",
"=",
"keys",
".",
"iterator",
"(",
")",
";",
"Iterator",
"<",
"Long",
">",
"sequenceIterator",
"=",
"sequences",
".",
"iterator",
"(",
")",
";",
"Iterator",
"<",
"UUID",
">",
"partitionUuidIterator",
"=",
"partitionUuids",
".",
"iterator",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"sourceUuidsIterator",
"=",
"sourceUuids",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"keyIterator",
".",
"hasNext",
"(",
")",
"&&",
"sourceUuidsIterator",
".",
"hasNext",
"(",
")",
"&&",
"partitionUuidIterator",
".",
"hasNext",
"(",
")",
"&&",
"sequenceIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"handle",
"(",
"keyIterator",
".",
"next",
"(",
")",
",",
"sourceUuidsIterator",
".",
"next",
"(",
")",
",",
"partitionUuidIterator",
".",
"next",
"(",
")",
",",
"sequenceIterator",
".",
"next",
"(",
")",
")",
";",
"}",
"}"
] |
Handles batch invalidations
|
[
"Handles",
"batch",
"invalidations"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/RepairingHandler.java#L111-L122
|
15,269
|
hazelcast/hazelcast
|
hazelcast-client/src/main/java/com/hazelcast/client/impl/clientside/ClientExceptionFactory.java
|
ClientExceptionFactory.register
|
@SuppressWarnings("WeakerAccess")
public void register(int errorCode, Class clazz, ExceptionFactory exceptionFactory) {
if (intToFactory.containsKey(errorCode)) {
throw new HazelcastException("Code " + errorCode + " already used");
}
if (!clazz.equals(exceptionFactory.createException("", null).getClass())) {
throw new HazelcastException("Exception factory did not produce an instance of expected class");
}
intToFactory.put(errorCode, exceptionFactory);
}
|
java
|
@SuppressWarnings("WeakerAccess")
public void register(int errorCode, Class clazz, ExceptionFactory exceptionFactory) {
if (intToFactory.containsKey(errorCode)) {
throw new HazelcastException("Code " + errorCode + " already used");
}
if (!clazz.equals(exceptionFactory.createException("", null).getClass())) {
throw new HazelcastException("Exception factory did not produce an instance of expected class");
}
intToFactory.put(errorCode, exceptionFactory);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"void",
"register",
"(",
"int",
"errorCode",
",",
"Class",
"clazz",
",",
"ExceptionFactory",
"exceptionFactory",
")",
"{",
"if",
"(",
"intToFactory",
".",
"containsKey",
"(",
"errorCode",
")",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"\"Code \"",
"+",
"errorCode",
"+",
"\" already used\"",
")",
";",
"}",
"if",
"(",
"!",
"clazz",
".",
"equals",
"(",
"exceptionFactory",
".",
"createException",
"(",
"\"\"",
",",
"null",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"HazelcastException",
"(",
"\"Exception factory did not produce an instance of expected class\"",
")",
";",
"}",
"intToFactory",
".",
"put",
"(",
"errorCode",
",",
"exceptionFactory",
")",
";",
"}"
] |
method is used by Jet
|
[
"method",
"is",
"used",
"by",
"Jet"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/impl/clientside/ClientExceptionFactory.java#L812-L823
|
15,270
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/eviction/MapClearExpiredRecordsTask.java
|
MapClearExpiredRecordsTask.notHaveAnyExpirableRecord
|
@Override
protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) {
boolean notExist = true;
final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps();
for (RecordStore store : maps.values()) {
if (store.isExpirable()) {
notExist = false;
break;
}
}
return notExist;
}
|
java
|
@Override
protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) {
boolean notExist = true;
final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps();
for (RecordStore store : maps.values()) {
if (store.isExpirable()) {
notExist = false;
break;
}
}
return notExist;
}
|
[
"@",
"Override",
"protected",
"boolean",
"notHaveAnyExpirableRecord",
"(",
"PartitionContainer",
"partitionContainer",
")",
"{",
"boolean",
"notExist",
"=",
"true",
";",
"final",
"ConcurrentMap",
"<",
"String",
",",
"RecordStore",
">",
"maps",
"=",
"partitionContainer",
".",
"getMaps",
"(",
")",
";",
"for",
"(",
"RecordStore",
"store",
":",
"maps",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"store",
".",
"isExpirable",
"(",
")",
")",
"{",
"notExist",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"notExist",
";",
"}"
] |
Here we check if that partition has any expirable record or not,
if no expirable record exists in that partition no need to fire
an expiration operation.
@param partitionContainer corresponding partition container.
@return <code>true</code> if no expirable record in that
partition <code>false</code> otherwise.
|
[
"Here",
"we",
"check",
"if",
"that",
"partition",
"has",
"any",
"expirable",
"record",
"or",
"not",
"if",
"no",
"expirable",
"record",
"exists",
"in",
"that",
"partition",
"no",
"need",
"to",
"fire",
"an",
"expiration",
"operation",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/eviction/MapClearExpiredRecordsTask.java#L213-L224
|
15,271
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/RestApiConfig.java
|
RestApiConfig.enableGroups
|
public RestApiConfig enableGroups(RestEndpointGroup... endpointGroups) {
if (endpointGroups != null) {
enabledGroups.addAll(Arrays.asList(endpointGroups));
}
return this;
}
|
java
|
public RestApiConfig enableGroups(RestEndpointGroup... endpointGroups) {
if (endpointGroups != null) {
enabledGroups.addAll(Arrays.asList(endpointGroups));
}
return this;
}
|
[
"public",
"RestApiConfig",
"enableGroups",
"(",
"RestEndpointGroup",
"...",
"endpointGroups",
")",
"{",
"if",
"(",
"endpointGroups",
"!=",
"null",
")",
"{",
"enabledGroups",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"endpointGroups",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Enables provided REST endpoint groups. It doesn't replace already enabled groups.
|
[
"Enables",
"provided",
"REST",
"endpoint",
"groups",
".",
"It",
"doesn",
"t",
"replace",
"already",
"enabled",
"groups",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/RestApiConfig.java#L57-L62
|
15,272
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/RestApiConfig.java
|
RestApiConfig.disableGroups
|
public RestApiConfig disableGroups(RestEndpointGroup... endpointGroups) {
if (endpointGroups != null) {
enabledGroups.removeAll(Arrays.asList(endpointGroups));
}
return this;
}
|
java
|
public RestApiConfig disableGroups(RestEndpointGroup... endpointGroups) {
if (endpointGroups != null) {
enabledGroups.removeAll(Arrays.asList(endpointGroups));
}
return this;
}
|
[
"public",
"RestApiConfig",
"disableGroups",
"(",
"RestEndpointGroup",
"...",
"endpointGroups",
")",
"{",
"if",
"(",
"endpointGroups",
"!=",
"null",
")",
"{",
"enabledGroups",
".",
"removeAll",
"(",
"Arrays",
".",
"asList",
"(",
"endpointGroups",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Disables provided REST endpoint groups.
|
[
"Disables",
"provided",
"REST",
"endpoint",
"groups",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/RestApiConfig.java#L75-L80
|
15,273
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/crdt/CRDTMigrationTask.java
|
CRDTMigrationTask.getLocalMemberListIndex
|
private int getLocalMemberListIndex() {
final Collection<Member> dataMembers = nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR);
int index = -1;
for (Member dataMember : dataMembers) {
index++;
if (dataMember.equals(nodeEngine.getLocalMember())) {
return index;
}
}
return index;
}
|
java
|
private int getLocalMemberListIndex() {
final Collection<Member> dataMembers = nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR);
int index = -1;
for (Member dataMember : dataMembers) {
index++;
if (dataMember.equals(nodeEngine.getLocalMember())) {
return index;
}
}
return index;
}
|
[
"private",
"int",
"getLocalMemberListIndex",
"(",
")",
"{",
"final",
"Collection",
"<",
"Member",
">",
"dataMembers",
"=",
"nodeEngine",
".",
"getClusterService",
"(",
")",
".",
"getMembers",
"(",
"DATA_MEMBER_SELECTOR",
")",
";",
"int",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"Member",
"dataMember",
":",
"dataMembers",
")",
"{",
"index",
"++",
";",
"if",
"(",
"dataMember",
".",
"equals",
"(",
"nodeEngine",
".",
"getLocalMember",
"(",
")",
")",
")",
"{",
"return",
"index",
";",
"}",
"}",
"return",
"index",
";",
"}"
] |
Returns the index of the local member in the membership list containing
only data members.
|
[
"Returns",
"the",
"index",
"of",
"the",
"local",
"member",
"in",
"the",
"membership",
"list",
"containing",
"only",
"data",
"members",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/crdt/CRDTMigrationTask.java#L124-L134
|
15,274
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java
|
JsonArray.add
|
public JsonArray add(JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.add(value);
return this;
}
|
java
|
public JsonArray add(JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.add(value);
return this;
}
|
[
"public",
"JsonArray",
"add",
"(",
"JsonValue",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"value is null\"",
")",
";",
"}",
"values",
".",
"add",
"(",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Appends the specified JSON value to the end of this array.
@param value
the JsonValue to add to the array, must not be <code>null</code>
@return the array itself, to enable method chaining
|
[
"Appends",
"the",
"specified",
"JSON",
"value",
"to",
"the",
"end",
"of",
"this",
"array",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java#L238-L244
|
15,275
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java
|
JsonArray.set
|
public JsonArray set(int index, JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.set(index, value);
return this;
}
|
java
|
public JsonArray set(int index, JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.set(index, value);
return this;
}
|
[
"public",
"JsonArray",
"set",
"(",
"int",
"index",
",",
"JsonValue",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"value is null\"",
")",
";",
"}",
"values",
".",
"set",
"(",
"index",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Replaces the element at the specified position in this array with the specified JSON value.
@param index
the index of the array element to replace
@param value
the value to be stored at the specified array position, must not be <code>null</code>
@return the array itself, to enable method chaining
@throws IndexOutOfBoundsException
if the index is out of range, i.e. <code>index < 0</code> or
<code>index >= size</code>
|
[
"Replaces",
"the",
"element",
"at",
"the",
"specified",
"position",
"in",
"this",
"array",
"with",
"the",
"specified",
"JSON",
"value",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java#L366-L372
|
15,276
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java
|
JsonArray.iterator
|
public Iterator<JsonValue> iterator() {
final Iterator<JsonValue> iterator = values.iterator();
return new Iterator<JsonValue>() {
public boolean hasNext() {
return iterator.hasNext();
}
public JsonValue next() {
return iterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
|
java
|
public Iterator<JsonValue> iterator() {
final Iterator<JsonValue> iterator = values.iterator();
return new Iterator<JsonValue>() {
public boolean hasNext() {
return iterator.hasNext();
}
public JsonValue next() {
return iterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
|
[
"public",
"Iterator",
"<",
"JsonValue",
">",
"iterator",
"(",
")",
"{",
"final",
"Iterator",
"<",
"JsonValue",
">",
"iterator",
"=",
"values",
".",
"iterator",
"(",
")",
";",
"return",
"new",
"Iterator",
"<",
"JsonValue",
">",
"(",
")",
"{",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"iterator",
".",
"hasNext",
"(",
")",
";",
"}",
"public",
"JsonValue",
"next",
"(",
")",
"{",
"return",
"iterator",
".",
"next",
"(",
")",
";",
"}",
"public",
"void",
"remove",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Returns an iterator over the values of this array in document order. The returned iterator
cannot be used to modify this array.
@return an iterator over the values of this array
|
[
"Returns",
"an",
"iterator",
"over",
"the",
"values",
"of",
"this",
"array",
"in",
"document",
"order",
".",
"The",
"returned",
"iterator",
"cannot",
"be",
"used",
"to",
"modify",
"this",
"array",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java#L438-L454
|
15,277
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/BufferBuilder.java
|
BufferBuilder.append
|
public BufferBuilder append(ClientProtocolBuffer srcBuffer, int srcOffset, int length) {
ensureCapacity(length);
srcBuffer.getBytes(srcOffset, protocolBuffer.byteArray(), position, length);
position += length;
return this;
}
|
java
|
public BufferBuilder append(ClientProtocolBuffer srcBuffer, int srcOffset, int length) {
ensureCapacity(length);
srcBuffer.getBytes(srcOffset, protocolBuffer.byteArray(), position, length);
position += length;
return this;
}
|
[
"public",
"BufferBuilder",
"append",
"(",
"ClientProtocolBuffer",
"srcBuffer",
",",
"int",
"srcOffset",
",",
"int",
"length",
")",
"{",
"ensureCapacity",
"(",
"length",
")",
";",
"srcBuffer",
".",
"getBytes",
"(",
"srcOffset",
",",
"protocolBuffer",
".",
"byteArray",
"(",
")",
",",
"position",
",",
"length",
")",
";",
"position",
"+=",
"length",
";",
"return",
"this",
";",
"}"
] |
Append a source buffer to the end of the internal buffer, resizing the internal buffer as required.
@param srcBuffer from which to copy.
@param srcOffset in the source buffer from which to copy.
@param length in bytes to copy from the source buffer.
@return the builder for fluent API usage.
|
[
"Append",
"a",
"source",
"buffer",
"to",
"the",
"end",
"of",
"the",
"internal",
"buffer",
"resizing",
"the",
"internal",
"buffer",
"as",
"required",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/util/BufferBuilder.java#L95-L102
|
15,278
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/log/RaftLog.java
|
RaftLog.appendEntries
|
public void appendEntries(LogEntry... newEntries) {
int lastTerm = lastLogOrSnapshotTerm();
long lastIndex = lastLogOrSnapshotIndex();
if (!checkAvailableCapacity(newEntries.length)) {
throw new IllegalStateException("Not enough capacity! Capacity: " + logs.getCapacity()
+ ", Size: " + logs.size() + ", New entries: " + newEntries.length);
}
for (LogEntry entry : newEntries) {
if (entry.term() < lastTerm) {
throw new IllegalArgumentException("Cannot append " + entry + " since its term is lower than last log term: "
+ lastTerm);
}
if (entry.index() != lastIndex + 1) {
throw new IllegalArgumentException("Cannot append " + entry
+ " since its index is bigger than (lastLogIndex + 1): " + (lastIndex + 1));
}
logs.add(entry);
lastIndex++;
lastTerm = Math.max(lastTerm, entry.term());
}
}
|
java
|
public void appendEntries(LogEntry... newEntries) {
int lastTerm = lastLogOrSnapshotTerm();
long lastIndex = lastLogOrSnapshotIndex();
if (!checkAvailableCapacity(newEntries.length)) {
throw new IllegalStateException("Not enough capacity! Capacity: " + logs.getCapacity()
+ ", Size: " + logs.size() + ", New entries: " + newEntries.length);
}
for (LogEntry entry : newEntries) {
if (entry.term() < lastTerm) {
throw new IllegalArgumentException("Cannot append " + entry + " since its term is lower than last log term: "
+ lastTerm);
}
if (entry.index() != lastIndex + 1) {
throw new IllegalArgumentException("Cannot append " + entry
+ " since its index is bigger than (lastLogIndex + 1): " + (lastIndex + 1));
}
logs.add(entry);
lastIndex++;
lastTerm = Math.max(lastTerm, entry.term());
}
}
|
[
"public",
"void",
"appendEntries",
"(",
"LogEntry",
"...",
"newEntries",
")",
"{",
"int",
"lastTerm",
"=",
"lastLogOrSnapshotTerm",
"(",
")",
";",
"long",
"lastIndex",
"=",
"lastLogOrSnapshotIndex",
"(",
")",
";",
"if",
"(",
"!",
"checkAvailableCapacity",
"(",
"newEntries",
".",
"length",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Not enough capacity! Capacity: \"",
"+",
"logs",
".",
"getCapacity",
"(",
")",
"+",
"\", Size: \"",
"+",
"logs",
".",
"size",
"(",
")",
"+",
"\", New entries: \"",
"+",
"newEntries",
".",
"length",
")",
";",
"}",
"for",
"(",
"LogEntry",
"entry",
":",
"newEntries",
")",
"{",
"if",
"(",
"entry",
".",
"term",
"(",
")",
"<",
"lastTerm",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot append \"",
"+",
"entry",
"+",
"\" since its term is lower than last log term: \"",
"+",
"lastTerm",
")",
";",
"}",
"if",
"(",
"entry",
".",
"index",
"(",
")",
"!=",
"lastIndex",
"+",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot append \"",
"+",
"entry",
"+",
"\" since its index is bigger than (lastLogIndex + 1): \"",
"+",
"(",
"lastIndex",
"+",
"1",
")",
")",
";",
"}",
"logs",
".",
"add",
"(",
"entry",
")",
";",
"lastIndex",
"++",
";",
"lastTerm",
"=",
"Math",
".",
"max",
"(",
"lastTerm",
",",
"entry",
".",
"term",
"(",
")",
")",
";",
"}",
"}"
] |
Appends new entries to the Raft log.
@throws IllegalArgumentException If an entry is appended with a lower
term than the last term in the log or
if an entry is appended with an index
not equal to
{@code index == lastIndex + 1}.
|
[
"Appends",
"new",
"entries",
"to",
"the",
"Raft",
"log",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/log/RaftLog.java#L172-L194
|
15,279
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/json/JsonReducedValueParser.java
|
JsonReducedValueParser.parse
|
public JsonValue parse(Reader reader, int buffersize) throws IOException {
if (reader == null) {
throw new NullPointerException("reader is null");
}
if (buffersize <= 0) {
throw new IllegalArgumentException("buffersize is zero or negative");
}
this.reader = reader;
buffer = new char[buffersize];
bufferOffset = 0;
index = 0;
fill = 0;
line = 1;
lineOffset = 0;
current = 0;
captureStart = -1;
read();
return readValue();
}
|
java
|
public JsonValue parse(Reader reader, int buffersize) throws IOException {
if (reader == null) {
throw new NullPointerException("reader is null");
}
if (buffersize <= 0) {
throw new IllegalArgumentException("buffersize is zero or negative");
}
this.reader = reader;
buffer = new char[buffersize];
bufferOffset = 0;
index = 0;
fill = 0;
line = 1;
lineOffset = 0;
current = 0;
captureStart = -1;
read();
return readValue();
}
|
[
"public",
"JsonValue",
"parse",
"(",
"Reader",
"reader",
",",
"int",
"buffersize",
")",
"throws",
"IOException",
"{",
"if",
"(",
"reader",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"reader is null\"",
")",
";",
"}",
"if",
"(",
"buffersize",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"buffersize is zero or negative\"",
")",
";",
"}",
"this",
".",
"reader",
"=",
"reader",
";",
"buffer",
"=",
"new",
"char",
"[",
"buffersize",
"]",
";",
"bufferOffset",
"=",
"0",
";",
"index",
"=",
"0",
";",
"fill",
"=",
"0",
";",
"line",
"=",
"1",
";",
"lineOffset",
"=",
"0",
";",
"current",
"=",
"0",
";",
"captureStart",
"=",
"-",
"1",
";",
"read",
"(",
")",
";",
"return",
"readValue",
"(",
")",
";",
"}"
] |
Reads a single value from the given reader and parses it as JsonValue.
The input must be pointing to the beginning of a JsonLiteral,
not JsonArray or JsonObject.
@param reader the reader to read the input from
@param buffersize the size of the input buffer in chars
@throws IOException if an I/O error occurs in the reader
@throws ParseException if the input is not valid JSON
|
[
"Reads",
"a",
"single",
"value",
"from",
"the",
"given",
"reader",
"and",
"parses",
"it",
"as",
"JsonValue",
".",
"The",
"input",
"must",
"be",
"pointing",
"to",
"the",
"beginning",
"of",
"a",
"JsonLiteral",
"not",
"JsonArray",
"or",
"JsonObject",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonReducedValueParser.java#L78-L96
|
15,280
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ThreadUtil.java
|
ThreadUtil.getThreadId
|
public static long getThreadId() {
final Long threadId = THREAD_LOCAL.get();
if (threadId != null) {
return threadId;
}
return Thread.currentThread().getId();
}
|
java
|
public static long getThreadId() {
final Long threadId = THREAD_LOCAL.get();
if (threadId != null) {
return threadId;
}
return Thread.currentThread().getId();
}
|
[
"public",
"static",
"long",
"getThreadId",
"(",
")",
"{",
"final",
"Long",
"threadId",
"=",
"THREAD_LOCAL",
".",
"get",
"(",
")",
";",
"if",
"(",
"threadId",
"!=",
"null",
")",
"{",
"return",
"threadId",
";",
"}",
"return",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
";",
"}"
] |
Get the thread ID.
@return the thread ID
|
[
"Get",
"the",
"thread",
"ID",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ThreadUtil.java#L36-L42
|
15,281
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/ThreadUtil.java
|
ThreadUtil.createThreadName
|
public static String createThreadName(String hzName, String name) {
checkNotNull(name, "name can't be null");
return "hz." + hzName + "." + name;
}
|
java
|
public static String createThreadName(String hzName, String name) {
checkNotNull(name, "name can't be null");
return "hz." + hzName + "." + name;
}
|
[
"public",
"static",
"String",
"createThreadName",
"(",
"String",
"hzName",
",",
"String",
"name",
")",
"{",
"checkNotNull",
"(",
"name",
",",
"\"name can't be null\"",
")",
";",
"return",
"\"hz.\"",
"+",
"hzName",
"+",
"\".\"",
"+",
"name",
";",
"}"
] |
Creates the threadname with prefix and notation.
@param hzName the name of the hazelcast instance
@param name the basic name of the thread
@return the threadname .
@throws java.lang.NullPointerException if name is null.
|
[
"Creates",
"the",
"threadname",
"with",
"prefix",
"and",
"notation",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ThreadUtil.java#L69-L72
|
15,282
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/DeferredValue.java
|
DeferredValue.get
|
public V get(SerializationService serializationService) {
if (!valueExists) {
// it's ok to deserialize twice in case of race
assert serializationService != null;
value = serializationService.toObject(serializedValue);
valueExists = true;
}
return value;
}
|
java
|
public V get(SerializationService serializationService) {
if (!valueExists) {
// it's ok to deserialize twice in case of race
assert serializationService != null;
value = serializationService.toObject(serializedValue);
valueExists = true;
}
return value;
}
|
[
"public",
"V",
"get",
"(",
"SerializationService",
"serializationService",
")",
"{",
"if",
"(",
"!",
"valueExists",
")",
"{",
"// it's ok to deserialize twice in case of race",
"assert",
"serializationService",
"!=",
"null",
";",
"value",
"=",
"serializationService",
".",
"toObject",
"(",
"serializedValue",
")",
";",
"valueExists",
"=",
"true",
";",
"}",
"return",
"value",
";",
"}"
] |
get-or-deserialize-and-get
|
[
"get",
"-",
"or",
"-",
"deserialize",
"-",
"and",
"-",
"get"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/DeferredValue.java#L55-L63
|
15,283
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/DeferredValue.java
|
DeferredValue.shallowCopy
|
public DeferredValue<V> shallowCopy() {
if (this == NULL_VALUE) {
return NULL_VALUE;
}
DeferredValue<V> copy = new DeferredValue<V>();
if (serializedValueExists) {
copy.serializedValueExists = true;
copy.serializedValue = serializedValue;
}
if (valueExists) {
copy.valueExists = true;
copy.value = value;
}
return copy;
}
|
java
|
public DeferredValue<V> shallowCopy() {
if (this == NULL_VALUE) {
return NULL_VALUE;
}
DeferredValue<V> copy = new DeferredValue<V>();
if (serializedValueExists) {
copy.serializedValueExists = true;
copy.serializedValue = serializedValue;
}
if (valueExists) {
copy.valueExists = true;
copy.value = value;
}
return copy;
}
|
[
"public",
"DeferredValue",
"<",
"V",
">",
"shallowCopy",
"(",
")",
"{",
"if",
"(",
"this",
"==",
"NULL_VALUE",
")",
"{",
"return",
"NULL_VALUE",
";",
"}",
"DeferredValue",
"<",
"V",
">",
"copy",
"=",
"new",
"DeferredValue",
"<",
"V",
">",
"(",
")",
";",
"if",
"(",
"serializedValueExists",
")",
"{",
"copy",
".",
"serializedValueExists",
"=",
"true",
";",
"copy",
".",
"serializedValue",
"=",
"serializedValue",
";",
"}",
"if",
"(",
"valueExists",
")",
"{",
"copy",
".",
"valueExists",
"=",
"true",
";",
"copy",
".",
"value",
"=",
"value",
";",
"}",
"return",
"copy",
";",
"}"
] |
returns a new DeferredValue representing the same value as this
|
[
"returns",
"a",
"new",
"DeferredValue",
"representing",
"the",
"same",
"value",
"as",
"this"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/DeferredValue.java#L75-L89
|
15,284
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/MembershipManager.java
|
MembershipManager.updateMembers
|
void updateMembers(MembersView membersView) {
MemberMap currentMemberMap = memberMapRef.get();
Collection<MemberImpl> addedMembers = new LinkedList<>();
Collection<MemberImpl> removedMembers = new LinkedList<>();
ClusterHeartbeatManager clusterHeartbeatManager = clusterService.getClusterHeartbeatManager();
MemberImpl[] members = new MemberImpl[membersView.size()];
int memberIndex = 0;
for (MemberInfo memberInfo : membersView.getMembers()) {
Address address = memberInfo.getAddress();
MemberImpl member = currentMemberMap.getMember(address);
if (member != null && member.getUuid().equals(memberInfo.getUuid())) {
member = createNewMemberImplIfChanged(memberInfo, member);
members[memberIndex++] = member;
continue;
}
if (member != null) {
assert !(member.localMember() && member.equals(clusterService.getLocalMember()))
: "Local " + member + " cannot be replaced with " + memberInfo;
// UUID changed: means member has gone and come back with a new uuid
removedMembers.add(member);
}
member = createMember(memberInfo, memberInfo.getAttributes());
addedMembers.add(member);
long now = clusterService.getClusterTime();
clusterHeartbeatManager.onHeartbeat(member, now);
repairPartitionTableIfReturningMember(member);
members[memberIndex++] = member;
}
MemberMap newMemberMap = membersView.toMemberMap();
for (MemberImpl member : currentMemberMap.getMembers()) {
if (!newMemberMap.contains(member.getAddress())) {
removedMembers.add(member);
}
}
setMembers(MemberMap.createNew(membersView.getVersion(), members));
for (MemberImpl member : removedMembers) {
closeConnection(member.getAddress(), "Member left event received from master");
handleMemberRemove(memberMapRef.get(), member);
}
clusterService.getClusterJoinManager().insertIntoRecentlyJoinedMemberSet(addedMembers);
sendMembershipEvents(currentMemberMap.getMembers(), addedMembers);
removeFromMissingMembers(members);
clusterHeartbeatManager.heartbeat();
clusterService.printMemberList();
//async call
node.getNodeExtension().scheduleClusterVersionAutoUpgrade();
}
|
java
|
void updateMembers(MembersView membersView) {
MemberMap currentMemberMap = memberMapRef.get();
Collection<MemberImpl> addedMembers = new LinkedList<>();
Collection<MemberImpl> removedMembers = new LinkedList<>();
ClusterHeartbeatManager clusterHeartbeatManager = clusterService.getClusterHeartbeatManager();
MemberImpl[] members = new MemberImpl[membersView.size()];
int memberIndex = 0;
for (MemberInfo memberInfo : membersView.getMembers()) {
Address address = memberInfo.getAddress();
MemberImpl member = currentMemberMap.getMember(address);
if (member != null && member.getUuid().equals(memberInfo.getUuid())) {
member = createNewMemberImplIfChanged(memberInfo, member);
members[memberIndex++] = member;
continue;
}
if (member != null) {
assert !(member.localMember() && member.equals(clusterService.getLocalMember()))
: "Local " + member + " cannot be replaced with " + memberInfo;
// UUID changed: means member has gone and come back with a new uuid
removedMembers.add(member);
}
member = createMember(memberInfo, memberInfo.getAttributes());
addedMembers.add(member);
long now = clusterService.getClusterTime();
clusterHeartbeatManager.onHeartbeat(member, now);
repairPartitionTableIfReturningMember(member);
members[memberIndex++] = member;
}
MemberMap newMemberMap = membersView.toMemberMap();
for (MemberImpl member : currentMemberMap.getMembers()) {
if (!newMemberMap.contains(member.getAddress())) {
removedMembers.add(member);
}
}
setMembers(MemberMap.createNew(membersView.getVersion(), members));
for (MemberImpl member : removedMembers) {
closeConnection(member.getAddress(), "Member left event received from master");
handleMemberRemove(memberMapRef.get(), member);
}
clusterService.getClusterJoinManager().insertIntoRecentlyJoinedMemberSet(addedMembers);
sendMembershipEvents(currentMemberMap.getMembers(), addedMembers);
removeFromMissingMembers(members);
clusterHeartbeatManager.heartbeat();
clusterService.printMemberList();
//async call
node.getNodeExtension().scheduleClusterVersionAutoUpgrade();
}
|
[
"void",
"updateMembers",
"(",
"MembersView",
"membersView",
")",
"{",
"MemberMap",
"currentMemberMap",
"=",
"memberMapRef",
".",
"get",
"(",
")",
";",
"Collection",
"<",
"MemberImpl",
">",
"addedMembers",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"Collection",
"<",
"MemberImpl",
">",
"removedMembers",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"ClusterHeartbeatManager",
"clusterHeartbeatManager",
"=",
"clusterService",
".",
"getClusterHeartbeatManager",
"(",
")",
";",
"MemberImpl",
"[",
"]",
"members",
"=",
"new",
"MemberImpl",
"[",
"membersView",
".",
"size",
"(",
")",
"]",
";",
"int",
"memberIndex",
"=",
"0",
";",
"for",
"(",
"MemberInfo",
"memberInfo",
":",
"membersView",
".",
"getMembers",
"(",
")",
")",
"{",
"Address",
"address",
"=",
"memberInfo",
".",
"getAddress",
"(",
")",
";",
"MemberImpl",
"member",
"=",
"currentMemberMap",
".",
"getMember",
"(",
"address",
")",
";",
"if",
"(",
"member",
"!=",
"null",
"&&",
"member",
".",
"getUuid",
"(",
")",
".",
"equals",
"(",
"memberInfo",
".",
"getUuid",
"(",
")",
")",
")",
"{",
"member",
"=",
"createNewMemberImplIfChanged",
"(",
"memberInfo",
",",
"member",
")",
";",
"members",
"[",
"memberIndex",
"++",
"]",
"=",
"member",
";",
"continue",
";",
"}",
"if",
"(",
"member",
"!=",
"null",
")",
"{",
"assert",
"!",
"(",
"member",
".",
"localMember",
"(",
")",
"&&",
"member",
".",
"equals",
"(",
"clusterService",
".",
"getLocalMember",
"(",
")",
")",
")",
":",
"\"Local \"",
"+",
"member",
"+",
"\" cannot be replaced with \"",
"+",
"memberInfo",
";",
"// UUID changed: means member has gone and come back with a new uuid",
"removedMembers",
".",
"add",
"(",
"member",
")",
";",
"}",
"member",
"=",
"createMember",
"(",
"memberInfo",
",",
"memberInfo",
".",
"getAttributes",
"(",
")",
")",
";",
"addedMembers",
".",
"add",
"(",
"member",
")",
";",
"long",
"now",
"=",
"clusterService",
".",
"getClusterTime",
"(",
")",
";",
"clusterHeartbeatManager",
".",
"onHeartbeat",
"(",
"member",
",",
"now",
")",
";",
"repairPartitionTableIfReturningMember",
"(",
"member",
")",
";",
"members",
"[",
"memberIndex",
"++",
"]",
"=",
"member",
";",
"}",
"MemberMap",
"newMemberMap",
"=",
"membersView",
".",
"toMemberMap",
"(",
")",
";",
"for",
"(",
"MemberImpl",
"member",
":",
"currentMemberMap",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"!",
"newMemberMap",
".",
"contains",
"(",
"member",
".",
"getAddress",
"(",
")",
")",
")",
"{",
"removedMembers",
".",
"add",
"(",
"member",
")",
";",
"}",
"}",
"setMembers",
"(",
"MemberMap",
".",
"createNew",
"(",
"membersView",
".",
"getVersion",
"(",
")",
",",
"members",
")",
")",
";",
"for",
"(",
"MemberImpl",
"member",
":",
"removedMembers",
")",
"{",
"closeConnection",
"(",
"member",
".",
"getAddress",
"(",
")",
",",
"\"Member left event received from master\"",
")",
";",
"handleMemberRemove",
"(",
"memberMapRef",
".",
"get",
"(",
")",
",",
"member",
")",
";",
"}",
"clusterService",
".",
"getClusterJoinManager",
"(",
")",
".",
"insertIntoRecentlyJoinedMemberSet",
"(",
"addedMembers",
")",
";",
"sendMembershipEvents",
"(",
"currentMemberMap",
".",
"getMembers",
"(",
")",
",",
"addedMembers",
")",
";",
"removeFromMissingMembers",
"(",
"members",
")",
";",
"clusterHeartbeatManager",
".",
"heartbeat",
"(",
")",
";",
"clusterService",
".",
"printMemberList",
"(",
")",
";",
"//async call",
"node",
".",
"getNodeExtension",
"(",
")",
".",
"scheduleClusterVersionAutoUpgrade",
"(",
")",
";",
"}"
] |
handles both new and left members
|
[
"handles",
"both",
"new",
"and",
"left",
"members"
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/MembershipManager.java#L283-L344
|
15,285
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/config/replacer/AbstractPbeReplacer.java
|
AbstractPbeReplacer.decrypt
|
protected String decrypt(String encryptedStr) throws Exception {
String[] split = encryptedStr.split(":");
checkTrue(split.length == 3, "Wrong format of the encrypted variable (" + encryptedStr + ")");
byte[] salt = Base64.getDecoder().decode(split[0].getBytes(UTF8_CHARSET));
checkTrue(salt.length == saltLengthBytes, "Salt length doesn't match.");
int iterations = Integer.parseInt(split[1]);
byte[] encryptedVal = Base64.getDecoder().decode(split[2].getBytes(UTF8_CHARSET));
return new String(transform(Cipher.DECRYPT_MODE, encryptedVal, salt, iterations), UTF8_CHARSET);
}
|
java
|
protected String decrypt(String encryptedStr) throws Exception {
String[] split = encryptedStr.split(":");
checkTrue(split.length == 3, "Wrong format of the encrypted variable (" + encryptedStr + ")");
byte[] salt = Base64.getDecoder().decode(split[0].getBytes(UTF8_CHARSET));
checkTrue(salt.length == saltLengthBytes, "Salt length doesn't match.");
int iterations = Integer.parseInt(split[1]);
byte[] encryptedVal = Base64.getDecoder().decode(split[2].getBytes(UTF8_CHARSET));
return new String(transform(Cipher.DECRYPT_MODE, encryptedVal, salt, iterations), UTF8_CHARSET);
}
|
[
"protected",
"String",
"decrypt",
"(",
"String",
"encryptedStr",
")",
"throws",
"Exception",
"{",
"String",
"[",
"]",
"split",
"=",
"encryptedStr",
".",
"split",
"(",
"\":\"",
")",
";",
"checkTrue",
"(",
"split",
".",
"length",
"==",
"3",
",",
"\"Wrong format of the encrypted variable (\"",
"+",
"encryptedStr",
"+",
"\")\"",
")",
";",
"byte",
"[",
"]",
"salt",
"=",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"decode",
"(",
"split",
"[",
"0",
"]",
".",
"getBytes",
"(",
"UTF8_CHARSET",
")",
")",
";",
"checkTrue",
"(",
"salt",
".",
"length",
"==",
"saltLengthBytes",
",",
"\"Salt length doesn't match.\"",
")",
";",
"int",
"iterations",
"=",
"Integer",
".",
"parseInt",
"(",
"split",
"[",
"1",
"]",
")",
";",
"byte",
"[",
"]",
"encryptedVal",
"=",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"decode",
"(",
"split",
"[",
"2",
"]",
".",
"getBytes",
"(",
"UTF8_CHARSET",
")",
")",
";",
"return",
"new",
"String",
"(",
"transform",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"encryptedVal",
",",
"salt",
",",
"iterations",
")",
",",
"UTF8_CHARSET",
")",
";",
"}"
] |
Decrypts given encrypted variable.
@param encryptedStr
@return
|
[
"Decrypts",
"given",
"encrypted",
"variable",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/replacer/AbstractPbeReplacer.java#L139-L147
|
15,286
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/OperationServiceImpl.java
|
OperationServiceImpl.shutdownInvocations
|
public void shutdownInvocations() {
logger.finest("Shutting down invocations");
invocationRegistry.shutdown();
invocationMonitor.shutdown();
inboundResponseHandlerSupplier.shutdown();
try {
invocationMonitor.awaitTermination(TERMINATION_TIMEOUT_MILLIS);
} catch (InterruptedException e) {
// TODO: we need a better mechanism for dealing with interruption and waiting for termination
Thread.currentThread().interrupt();
}
}
|
java
|
public void shutdownInvocations() {
logger.finest("Shutting down invocations");
invocationRegistry.shutdown();
invocationMonitor.shutdown();
inboundResponseHandlerSupplier.shutdown();
try {
invocationMonitor.awaitTermination(TERMINATION_TIMEOUT_MILLIS);
} catch (InterruptedException e) {
// TODO: we need a better mechanism for dealing with interruption and waiting for termination
Thread.currentThread().interrupt();
}
}
|
[
"public",
"void",
"shutdownInvocations",
"(",
")",
"{",
"logger",
".",
"finest",
"(",
"\"Shutting down invocations\"",
")",
";",
"invocationRegistry",
".",
"shutdown",
"(",
")",
";",
"invocationMonitor",
".",
"shutdown",
"(",
")",
";",
"inboundResponseHandlerSupplier",
".",
"shutdown",
"(",
")",
";",
"try",
"{",
"invocationMonitor",
".",
"awaitTermination",
"(",
"TERMINATION_TIMEOUT_MILLIS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// TODO: we need a better mechanism for dealing with interruption and waiting for termination",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
] |
Shuts down invocation infrastructure.
New invocation requests will be rejected after shutdown and all pending invocations
will be notified with a failure response.
|
[
"Shuts",
"down",
"invocation",
"infrastructure",
".",
"New",
"invocation",
"requests",
"will",
"be",
"rejected",
"after",
"shutdown",
"and",
"all",
"pending",
"invocations",
"will",
"be",
"notified",
"with",
"a",
"failure",
"response",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/OperationServiceImpl.java#L500-L513
|
15,287
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.markPartitionAsIndexed
|
public static void markPartitionAsIndexed(int partitionId, InternalIndex[] indexes) {
for (InternalIndex index : indexes) {
index.markPartitionAsIndexed(partitionId);
}
}
|
java
|
public static void markPartitionAsIndexed(int partitionId, InternalIndex[] indexes) {
for (InternalIndex index : indexes) {
index.markPartitionAsIndexed(partitionId);
}
}
|
[
"public",
"static",
"void",
"markPartitionAsIndexed",
"(",
"int",
"partitionId",
",",
"InternalIndex",
"[",
"]",
"indexes",
")",
"{",
"for",
"(",
"InternalIndex",
"index",
":",
"indexes",
")",
"{",
"index",
".",
"markPartitionAsIndexed",
"(",
"partitionId",
")",
";",
"}",
"}"
] |
Marks the given partition as indexed by the given indexes.
@param partitionId the ID of the partition to mark as indexed.
@param indexes the indexes by which the given partition is indexed.
|
[
"Marks",
"the",
"given",
"partition",
"as",
"indexed",
"by",
"the",
"given",
"indexes",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L81-L85
|
15,288
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.markPartitionAsUnindexed
|
public static void markPartitionAsUnindexed(int partitionId, InternalIndex[] indexes) {
for (InternalIndex index : indexes) {
index.markPartitionAsUnindexed(partitionId);
}
}
|
java
|
public static void markPartitionAsUnindexed(int partitionId, InternalIndex[] indexes) {
for (InternalIndex index : indexes) {
index.markPartitionAsUnindexed(partitionId);
}
}
|
[
"public",
"static",
"void",
"markPartitionAsUnindexed",
"(",
"int",
"partitionId",
",",
"InternalIndex",
"[",
"]",
"indexes",
")",
"{",
"for",
"(",
"InternalIndex",
"index",
":",
"indexes",
")",
"{",
"index",
".",
"markPartitionAsUnindexed",
"(",
"partitionId",
")",
";",
"}",
"}"
] |
Marks the given partition as unindexed by the given indexes.
@param partitionId the ID of the partition to mark as unindexed.
@param indexes the indexes by which the given partition is unindexed.
|
[
"Marks",
"the",
"given",
"partition",
"as",
"unindexed",
"by",
"the",
"given",
"indexes",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L93-L97
|
15,289
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.destroyIndexes
|
public void destroyIndexes() {
InternalIndex[] indexesSnapshot = getIndexes();
indexes = EMPTY_INDEXES;
compositeIndexes = EMPTY_INDEXES;
indexesByName.clear();
attributeIndexRegistry.clear();
converterCache.clear();
for (InternalIndex index : indexesSnapshot) {
index.destroy();
}
}
|
java
|
public void destroyIndexes() {
InternalIndex[] indexesSnapshot = getIndexes();
indexes = EMPTY_INDEXES;
compositeIndexes = EMPTY_INDEXES;
indexesByName.clear();
attributeIndexRegistry.clear();
converterCache.clear();
for (InternalIndex index : indexesSnapshot) {
index.destroy();
}
}
|
[
"public",
"void",
"destroyIndexes",
"(",
")",
"{",
"InternalIndex",
"[",
"]",
"indexesSnapshot",
"=",
"getIndexes",
"(",
")",
";",
"indexes",
"=",
"EMPTY_INDEXES",
";",
"compositeIndexes",
"=",
"EMPTY_INDEXES",
";",
"indexesByName",
".",
"clear",
"(",
")",
";",
"attributeIndexRegistry",
".",
"clear",
"(",
")",
";",
"converterCache",
".",
"clear",
"(",
")",
";",
"for",
"(",
"InternalIndex",
"index",
":",
"indexesSnapshot",
")",
"{",
"index",
".",
"destroy",
"(",
")",
";",
"}",
"}"
] |
Destroys and then removes all the indexes from this indexes instance.
|
[
"Destroys",
"and",
"then",
"removes",
"all",
"the",
"indexes",
"from",
"this",
"indexes",
"instance",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L175-L187
|
15,290
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.putEntry
|
public void putEntry(QueryableEntry queryableEntry, Object oldValue, Index.OperationSource operationSource) {
InternalIndex[] indexes = getIndexes();
for (InternalIndex index : indexes) {
index.putEntry(queryableEntry, oldValue, operationSource);
}
}
|
java
|
public void putEntry(QueryableEntry queryableEntry, Object oldValue, Index.OperationSource operationSource) {
InternalIndex[] indexes = getIndexes();
for (InternalIndex index : indexes) {
index.putEntry(queryableEntry, oldValue, operationSource);
}
}
|
[
"public",
"void",
"putEntry",
"(",
"QueryableEntry",
"queryableEntry",
",",
"Object",
"oldValue",
",",
"Index",
".",
"OperationSource",
"operationSource",
")",
"{",
"InternalIndex",
"[",
"]",
"indexes",
"=",
"getIndexes",
"(",
")",
";",
"for",
"(",
"InternalIndex",
"index",
":",
"indexes",
")",
"{",
"index",
".",
"putEntry",
"(",
"queryableEntry",
",",
"oldValue",
",",
"operationSource",
")",
";",
"}",
"}"
] |
Inserts a new queryable entry into this indexes instance or updates the
existing one.
@param queryableEntry the queryable entry to insert or update.
@param oldValue the old entry value to update, {@code null} if
inserting the new entry.
@param operationSource the operation source.
|
[
"Inserts",
"a",
"new",
"queryable",
"entry",
"into",
"this",
"indexes",
"instance",
"or",
"updates",
"the",
"existing",
"one",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L217-L222
|
15,291
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.removeEntry
|
public void removeEntry(Data key, Object value, Index.OperationSource operationSource) {
InternalIndex[] indexes = getIndexes();
for (InternalIndex index : indexes) {
index.removeEntry(key, value, operationSource);
}
}
|
java
|
public void removeEntry(Data key, Object value, Index.OperationSource operationSource) {
InternalIndex[] indexes = getIndexes();
for (InternalIndex index : indexes) {
index.removeEntry(key, value, operationSource);
}
}
|
[
"public",
"void",
"removeEntry",
"(",
"Data",
"key",
",",
"Object",
"value",
",",
"Index",
".",
"OperationSource",
"operationSource",
")",
"{",
"InternalIndex",
"[",
"]",
"indexes",
"=",
"getIndexes",
"(",
")",
";",
"for",
"(",
"InternalIndex",
"index",
":",
"indexes",
")",
"{",
"index",
".",
"removeEntry",
"(",
"key",
",",
"value",
",",
"operationSource",
")",
";",
"}",
"}"
] |
Removes the entry from this indexes instance identified by the given key
and value.
@param key the key if the entry to remove.
@param value the value of the entry to remove.
@param operationSource the operation source.
|
[
"Removes",
"the",
"entry",
"from",
"this",
"indexes",
"instance",
"identified",
"by",
"the",
"given",
"key",
"and",
"value",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L232-L237
|
15,292
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java
|
Indexes.query
|
@SuppressWarnings("unchecked")
public Set<QueryableEntry> query(Predicate predicate) {
stats.incrementQueryCount();
if (!haveAtLeastOneIndex() || !(predicate instanceof IndexAwarePredicate)) {
return null;
}
IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate;
QueryContext queryContext = queryContextProvider.obtainContextFor(this);
if (!indexAwarePredicate.isIndexed(queryContext)) {
return null;
}
Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext);
if (result != null) {
stats.incrementIndexedQueryCount();
queryContext.applyPerQueryStats();
}
return result;
}
|
java
|
@SuppressWarnings("unchecked")
public Set<QueryableEntry> query(Predicate predicate) {
stats.incrementQueryCount();
if (!haveAtLeastOneIndex() || !(predicate instanceof IndexAwarePredicate)) {
return null;
}
IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate;
QueryContext queryContext = queryContextProvider.obtainContextFor(this);
if (!indexAwarePredicate.isIndexed(queryContext)) {
return null;
}
Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext);
if (result != null) {
stats.incrementIndexedQueryCount();
queryContext.applyPerQueryStats();
}
return result;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Set",
"<",
"QueryableEntry",
">",
"query",
"(",
"Predicate",
"predicate",
")",
"{",
"stats",
".",
"incrementQueryCount",
"(",
")",
";",
"if",
"(",
"!",
"haveAtLeastOneIndex",
"(",
")",
"||",
"!",
"(",
"predicate",
"instanceof",
"IndexAwarePredicate",
")",
")",
"{",
"return",
"null",
";",
"}",
"IndexAwarePredicate",
"indexAwarePredicate",
"=",
"(",
"IndexAwarePredicate",
")",
"predicate",
";",
"QueryContext",
"queryContext",
"=",
"queryContextProvider",
".",
"obtainContextFor",
"(",
"this",
")",
";",
"if",
"(",
"!",
"indexAwarePredicate",
".",
"isIndexed",
"(",
"queryContext",
")",
")",
"{",
"return",
"null",
";",
"}",
"Set",
"<",
"QueryableEntry",
">",
"result",
"=",
"indexAwarePredicate",
".",
"filter",
"(",
"queryContext",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"stats",
".",
"incrementIndexedQueryCount",
"(",
")",
";",
"queryContext",
".",
"applyPerQueryStats",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Performs a query on this indexes instance using the given predicate.
@param predicate the predicate to evaluate.
@return the produced result set or {@code null} if the query can't be
performed using the indexes known to this indexes instance.
|
[
"Performs",
"a",
"query",
"on",
"this",
"indexes",
"instance",
"using",
"the",
"given",
"predicate",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/Indexes.java#L270-L291
|
15,293
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyNodeStarted
|
private void verifyNodeStarted() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
nodeStartCompleted = nodeEngine.getNode().getNodeExtension().isStartCompleted();
if (!nodeStartCompleted) {
throw new IllegalStateException("Migration operation is received before startup is completed. "
+ "Sender: " + getCallerAddress());
}
}
|
java
|
private void verifyNodeStarted() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
nodeStartCompleted = nodeEngine.getNode().getNodeExtension().isStartCompleted();
if (!nodeStartCompleted) {
throw new IllegalStateException("Migration operation is received before startup is completed. "
+ "Sender: " + getCallerAddress());
}
}
|
[
"private",
"void",
"verifyNodeStarted",
"(",
")",
"{",
"NodeEngineImpl",
"nodeEngine",
"=",
"(",
"NodeEngineImpl",
")",
"getNodeEngine",
"(",
")",
";",
"nodeStartCompleted",
"=",
"nodeEngine",
".",
"getNode",
"(",
")",
".",
"getNodeExtension",
"(",
")",
".",
"isStartCompleted",
"(",
")",
";",
"if",
"(",
"!",
"nodeStartCompleted",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Migration operation is received before startup is completed. \"",
"+",
"\"Sender: \"",
"+",
"getCallerAddress",
"(",
")",
")",
";",
"}",
"}"
] |
Verifies that the node startup is completed.
|
[
"Verifies",
"that",
"the",
"node",
"startup",
"is",
"completed",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L98-L105
|
15,294
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyPartitionStateVersion
|
private void verifyPartitionStateVersion() {
InternalPartitionService partitionService = getService();
int localPartitionStateVersion = partitionService.getPartitionStateVersion();
if (partitionStateVersion != localPartitionStateVersion) {
if (getNodeEngine().getThisAddress().equals(migrationInfo.getMaster())) {
return;
}
// this is expected when cluster member list changes during migration
throw new PartitionStateVersionMismatchException(partitionStateVersion, localPartitionStateVersion);
}
}
|
java
|
private void verifyPartitionStateVersion() {
InternalPartitionService partitionService = getService();
int localPartitionStateVersion = partitionService.getPartitionStateVersion();
if (partitionStateVersion != localPartitionStateVersion) {
if (getNodeEngine().getThisAddress().equals(migrationInfo.getMaster())) {
return;
}
// this is expected when cluster member list changes during migration
throw new PartitionStateVersionMismatchException(partitionStateVersion, localPartitionStateVersion);
}
}
|
[
"private",
"void",
"verifyPartitionStateVersion",
"(",
")",
"{",
"InternalPartitionService",
"partitionService",
"=",
"getService",
"(",
")",
";",
"int",
"localPartitionStateVersion",
"=",
"partitionService",
".",
"getPartitionStateVersion",
"(",
")",
";",
"if",
"(",
"partitionStateVersion",
"!=",
"localPartitionStateVersion",
")",
"{",
"if",
"(",
"getNodeEngine",
"(",
")",
".",
"getThisAddress",
"(",
")",
".",
"equals",
"(",
"migrationInfo",
".",
"getMaster",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"// this is expected when cluster member list changes during migration",
"throw",
"new",
"PartitionStateVersionMismatchException",
"(",
"partitionStateVersion",
",",
"localPartitionStateVersion",
")",
";",
"}",
"}"
] |
Verifies that the sent partition state version matches the local version or this node is master.
|
[
"Verifies",
"that",
"the",
"sent",
"partition",
"state",
"version",
"matches",
"the",
"local",
"version",
"or",
"this",
"node",
"is",
"master",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L118-L129
|
15,295
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyMaster
|
final void verifyMaster() {
NodeEngine nodeEngine = getNodeEngine();
Address masterAddress = nodeEngine.getMasterAddress();
if (!migrationInfo.getMaster().equals(masterAddress)) {
throw new IllegalStateException("Migration initiator is not master node! => " + toString());
}
if (getMigrationParticipantType() == MigrationParticipant.SOURCE && !masterAddress.equals(getCallerAddress())) {
throw new IllegalStateException("Caller is not master node! => " + toString());
}
}
|
java
|
final void verifyMaster() {
NodeEngine nodeEngine = getNodeEngine();
Address masterAddress = nodeEngine.getMasterAddress();
if (!migrationInfo.getMaster().equals(masterAddress)) {
throw new IllegalStateException("Migration initiator is not master node! => " + toString());
}
if (getMigrationParticipantType() == MigrationParticipant.SOURCE && !masterAddress.equals(getCallerAddress())) {
throw new IllegalStateException("Caller is not master node! => " + toString());
}
}
|
[
"final",
"void",
"verifyMaster",
"(",
")",
"{",
"NodeEngine",
"nodeEngine",
"=",
"getNodeEngine",
"(",
")",
";",
"Address",
"masterAddress",
"=",
"nodeEngine",
".",
"getMasterAddress",
"(",
")",
";",
"if",
"(",
"!",
"migrationInfo",
".",
"getMaster",
"(",
")",
".",
"equals",
"(",
"masterAddress",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Migration initiator is not master node! => \"",
"+",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"getMigrationParticipantType",
"(",
")",
"==",
"MigrationParticipant",
".",
"SOURCE",
"&&",
"!",
"masterAddress",
".",
"equals",
"(",
"getCallerAddress",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Caller is not master node! => \"",
"+",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Verifies that the local master is equal to the migration master.
|
[
"Verifies",
"that",
"the",
"local",
"master",
"is",
"equal",
"to",
"the",
"migration",
"master",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L132-L143
|
15,296
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyMigrationParticipant
|
private void verifyMigrationParticipant() {
Member localMember = getNodeEngine().getLocalMember();
if (getMigrationParticipantType() == MigrationParticipant.SOURCE) {
if (migrationInfo.getSourceCurrentReplicaIndex() == 0
&& !migrationInfo.getSource().isIdentical(localMember)) {
throw new IllegalStateException(localMember
+ " is the migration source but has a different identity! Migration: " + migrationInfo);
}
verifyPartitionOwner();
verifyExistingDestination();
} else if (getMigrationParticipantType() == MigrationParticipant.DESTINATION) {
if (!migrationInfo.getDestination().isIdentical(localMember)) {
throw new IllegalStateException(localMember
+ " is the migration destination but has a different identity! Migration: " + migrationInfo);
}
}
}
|
java
|
private void verifyMigrationParticipant() {
Member localMember = getNodeEngine().getLocalMember();
if (getMigrationParticipantType() == MigrationParticipant.SOURCE) {
if (migrationInfo.getSourceCurrentReplicaIndex() == 0
&& !migrationInfo.getSource().isIdentical(localMember)) {
throw new IllegalStateException(localMember
+ " is the migration source but has a different identity! Migration: " + migrationInfo);
}
verifyPartitionOwner();
verifyExistingDestination();
} else if (getMigrationParticipantType() == MigrationParticipant.DESTINATION) {
if (!migrationInfo.getDestination().isIdentical(localMember)) {
throw new IllegalStateException(localMember
+ " is the migration destination but has a different identity! Migration: " + migrationInfo);
}
}
}
|
[
"private",
"void",
"verifyMigrationParticipant",
"(",
")",
"{",
"Member",
"localMember",
"=",
"getNodeEngine",
"(",
")",
".",
"getLocalMember",
"(",
")",
";",
"if",
"(",
"getMigrationParticipantType",
"(",
")",
"==",
"MigrationParticipant",
".",
"SOURCE",
")",
"{",
"if",
"(",
"migrationInfo",
".",
"getSourceCurrentReplicaIndex",
"(",
")",
"==",
"0",
"&&",
"!",
"migrationInfo",
".",
"getSource",
"(",
")",
".",
"isIdentical",
"(",
"localMember",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"localMember",
"+",
"\" is the migration source but has a different identity! Migration: \"",
"+",
"migrationInfo",
")",
";",
"}",
"verifyPartitionOwner",
"(",
")",
";",
"verifyExistingDestination",
"(",
")",
";",
"}",
"else",
"if",
"(",
"getMigrationParticipantType",
"(",
")",
"==",
"MigrationParticipant",
".",
"DESTINATION",
")",
"{",
"if",
"(",
"!",
"migrationInfo",
".",
"getDestination",
"(",
")",
".",
"isIdentical",
"(",
"localMember",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"localMember",
"+",
"\" is the migration destination but has a different identity! Migration: \"",
"+",
"migrationInfo",
")",
";",
"}",
"}",
"}"
] |
Checks if the local member matches the migration source or destination if this node is the migration source or
destination.
|
[
"Checks",
"if",
"the",
"local",
"member",
"matches",
"the",
"migration",
"source",
"or",
"destination",
"if",
"this",
"node",
"is",
"the",
"migration",
"source",
"or",
"destination",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L149-L165
|
15,297
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyPartitionOwner
|
private void verifyPartitionOwner() {
InternalPartition partition = getPartition();
PartitionReplica owner = partition.getOwnerReplicaOrNull();
if (owner == null) {
throw new RetryableHazelcastException("Cannot migrate at the moment! Owner of the partition is null => "
+ migrationInfo);
}
if (!owner.isIdentical(getNodeEngine().getLocalMember())) {
throw new RetryableHazelcastException("Owner of partition is not this node! => " + toString());
}
}
|
java
|
private void verifyPartitionOwner() {
InternalPartition partition = getPartition();
PartitionReplica owner = partition.getOwnerReplicaOrNull();
if (owner == null) {
throw new RetryableHazelcastException("Cannot migrate at the moment! Owner of the partition is null => "
+ migrationInfo);
}
if (!owner.isIdentical(getNodeEngine().getLocalMember())) {
throw new RetryableHazelcastException("Owner of partition is not this node! => " + toString());
}
}
|
[
"private",
"void",
"verifyPartitionOwner",
"(",
")",
"{",
"InternalPartition",
"partition",
"=",
"getPartition",
"(",
")",
";",
"PartitionReplica",
"owner",
"=",
"partition",
".",
"getOwnerReplicaOrNull",
"(",
")",
";",
"if",
"(",
"owner",
"==",
"null",
")",
"{",
"throw",
"new",
"RetryableHazelcastException",
"(",
"\"Cannot migrate at the moment! Owner of the partition is null => \"",
"+",
"migrationInfo",
")",
";",
"}",
"if",
"(",
"!",
"owner",
".",
"isIdentical",
"(",
"getNodeEngine",
"(",
")",
".",
"getLocalMember",
"(",
")",
")",
")",
"{",
"throw",
"new",
"RetryableHazelcastException",
"(",
"\"Owner of partition is not this node! => \"",
"+",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Verifies that this node is the owner of the partition.
|
[
"Verifies",
"that",
"this",
"node",
"is",
"the",
"owner",
"of",
"the",
"partition",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L168-L179
|
15,298
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyExistingDestination
|
final void verifyExistingDestination() {
PartitionReplica destination = migrationInfo.getDestination();
Member target = getNodeEngine().getClusterService().getMember(destination.address(), destination.uuid());
if (target == null) {
throw new TargetNotMemberException("Destination of migration could not be found! => " + toString());
}
}
|
java
|
final void verifyExistingDestination() {
PartitionReplica destination = migrationInfo.getDestination();
Member target = getNodeEngine().getClusterService().getMember(destination.address(), destination.uuid());
if (target == null) {
throw new TargetNotMemberException("Destination of migration could not be found! => " + toString());
}
}
|
[
"final",
"void",
"verifyExistingDestination",
"(",
")",
"{",
"PartitionReplica",
"destination",
"=",
"migrationInfo",
".",
"getDestination",
"(",
")",
";",
"Member",
"target",
"=",
"getNodeEngine",
"(",
")",
".",
"getClusterService",
"(",
")",
".",
"getMember",
"(",
"destination",
".",
"address",
"(",
")",
",",
"destination",
".",
"uuid",
"(",
")",
")",
";",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"throw",
"new",
"TargetNotMemberException",
"(",
"\"Destination of migration could not be found! => \"",
"+",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Verifies that the destination is a cluster member.
|
[
"Verifies",
"that",
"the",
"destination",
"is",
"a",
"cluster",
"member",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L182-L188
|
15,299
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java
|
BaseMigrationOperation.verifyClusterState
|
private void verifyClusterState() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
if (!clusterState.isMigrationAllowed()) {
throw new IllegalStateException("Cluster state does not allow migrations! " + clusterState);
}
}
|
java
|
private void verifyClusterState() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
if (!clusterState.isMigrationAllowed()) {
throw new IllegalStateException("Cluster state does not allow migrations! " + clusterState);
}
}
|
[
"private",
"void",
"verifyClusterState",
"(",
")",
"{",
"NodeEngineImpl",
"nodeEngine",
"=",
"(",
"NodeEngineImpl",
")",
"getNodeEngine",
"(",
")",
";",
"ClusterState",
"clusterState",
"=",
"nodeEngine",
".",
"getClusterService",
"(",
")",
".",
"getClusterState",
"(",
")",
";",
"if",
"(",
"!",
"clusterState",
".",
"isMigrationAllowed",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cluster state does not allow migrations! \"",
"+",
"clusterState",
")",
";",
"}",
"}"
] |
Verifies that the cluster is active.
|
[
"Verifies",
"that",
"the",
"cluster",
"is",
"active",
"."
] |
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/BaseMigrationOperation.java#L192-L198
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.