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,400
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
PortablePositionNavigator.navigateContextToNextPortableTokenFromPortableArrayCell
private static void navigateContextToNextPortableTokenFromPortableArrayCell( PortableNavigatorContext ctx, PortablePathCursor path, int index) throws IOException { BufferObjectDataInput in = ctx.getIn(); // find the array field position that's stored in the fieldDefinition int the context and navigate to it int pos = getStreamPositionOfTheField(ctx); in.position(pos); // read array length and ignore in.readInt(); // read factory and class ID and validate if it's the same as expected in the fieldDefinition int factoryId = in.readInt(); int classId = in.readInt(); validateFactoryAndClass(ctx.getCurrentFieldDefinition(), factoryId, classId, path.path()); // calculate the offset of the cell given by the index final int cellOffset = in.position() + index * Bits.INT_SIZE_IN_BYTES; in.position(cellOffset); // read the position of the portable addressed in this array cell (array contains portable position only) int portablePosition = in.readInt(); // navigate to portable position and read it's version in.position(portablePosition); int versionId = in.readInt(); // initialise context with the given portable field for further navigation ctx.advanceContextToNextPortableToken(factoryId, classId, versionId); }
java
private static void navigateContextToNextPortableTokenFromPortableArrayCell( PortableNavigatorContext ctx, PortablePathCursor path, int index) throws IOException { BufferObjectDataInput in = ctx.getIn(); // find the array field position that's stored in the fieldDefinition int the context and navigate to it int pos = getStreamPositionOfTheField(ctx); in.position(pos); // read array length and ignore in.readInt(); // read factory and class ID and validate if it's the same as expected in the fieldDefinition int factoryId = in.readInt(); int classId = in.readInt(); validateFactoryAndClass(ctx.getCurrentFieldDefinition(), factoryId, classId, path.path()); // calculate the offset of the cell given by the index final int cellOffset = in.position() + index * Bits.INT_SIZE_IN_BYTES; in.position(cellOffset); // read the position of the portable addressed in this array cell (array contains portable position only) int portablePosition = in.readInt(); // navigate to portable position and read it's version in.position(portablePosition); int versionId = in.readInt(); // initialise context with the given portable field for further navigation ctx.advanceContextToNextPortableToken(factoryId, classId, versionId); }
[ "private", "static", "void", "navigateContextToNextPortableTokenFromPortableArrayCell", "(", "PortableNavigatorContext", "ctx", ",", "PortablePathCursor", "path", ",", "int", "index", ")", "throws", "IOException", "{", "BufferObjectDataInput", "in", "=", "ctx", ".", "getIn", "(", ")", ";", "// find the array field position that's stored in the fieldDefinition int the context and navigate to it", "int", "pos", "=", "getStreamPositionOfTheField", "(", "ctx", ")", ";", "in", ".", "position", "(", "pos", ")", ";", "// read array length and ignore", "in", ".", "readInt", "(", ")", ";", "// read factory and class ID and validate if it's the same as expected in the fieldDefinition", "int", "factoryId", "=", "in", ".", "readInt", "(", ")", ";", "int", "classId", "=", "in", ".", "readInt", "(", ")", ";", "validateFactoryAndClass", "(", "ctx", ".", "getCurrentFieldDefinition", "(", ")", ",", "factoryId", ",", "classId", ",", "path", ".", "path", "(", ")", ")", ";", "// calculate the offset of the cell given by the index", "final", "int", "cellOffset", "=", "in", ".", "position", "(", ")", "+", "index", "*", "Bits", ".", "INT_SIZE_IN_BYTES", ";", "in", ".", "position", "(", "cellOffset", ")", ";", "// read the position of the portable addressed in this array cell (array contains portable position only)", "int", "portablePosition", "=", "in", ".", "readInt", "(", ")", ";", "// navigate to portable position and read it's version", "in", ".", "position", "(", "portablePosition", ")", ";", "int", "versionId", "=", "in", ".", "readInt", "(", ")", ";", "// initialise context with the given portable field for further navigation", "ctx", ".", "advanceContextToNextPortableToken", "(", "factoryId", ",", "classId", ",", "versionId", ")", ";", "}" ]
this navigation always succeeds since the caller validates if the index is inbound
[ "this", "navigation", "always", "succeeds", "since", "the", "caller", "validates", "if", "the", "index", "is", "inbound" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L387-L416
15,401
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
PortablePositionNavigator.createPositionForReadAccess
private static PortablePosition createPositionForReadAccess( PortableNavigatorContext ctx, PortablePathCursor path) throws IOException { int notArrayCellAccessIndex = -1; return createPositionForReadAccess(ctx, path, notArrayCellAccessIndex); }
java
private static PortablePosition createPositionForReadAccess( PortableNavigatorContext ctx, PortablePathCursor path) throws IOException { int notArrayCellAccessIndex = -1; return createPositionForReadAccess(ctx, path, notArrayCellAccessIndex); }
[ "private", "static", "PortablePosition", "createPositionForReadAccess", "(", "PortableNavigatorContext", "ctx", ",", "PortablePathCursor", "path", ")", "throws", "IOException", "{", "int", "notArrayCellAccessIndex", "=", "-", "1", ";", "return", "createPositionForReadAccess", "(", "ctx", ",", "path", ",", "notArrayCellAccessIndex", ")", ";", "}" ]
Special case of the position creation, where there's no quantifier, so the index does not count.
[ "Special", "case", "of", "the", "position", "creation", "where", "there", "s", "no", "quantifier", "so", "the", "index", "does", "not", "count", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L488-L492
15,402
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/management/ConsoleCommandHandler.java
ConsoleCommandHandler.handleCommand
public String handleCommand(final String command) throws InterruptedException { if (lock.tryLock(1, TimeUnit.SECONDS)) { try { return doHandleCommand(command); } finally { lock.unlock(); } } return "'" + command + "' execution is timed out!"; }
java
public String handleCommand(final String command) throws InterruptedException { if (lock.tryLock(1, TimeUnit.SECONDS)) { try { return doHandleCommand(command); } finally { lock.unlock(); } } return "'" + command + "' execution is timed out!"; }
[ "public", "String", "handleCommand", "(", "final", "String", "command", ")", "throws", "InterruptedException", "{", "if", "(", "lock", ".", "tryLock", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ")", "{", "try", "{", "return", "doHandleCommand", "(", "command", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}", "return", "\"'\"", "+", "command", "+", "\"' execution is timed out!\"", ";", "}" ]
Runs a command on the console. Will not run "exit", "quit", "shutdown", their upper-case or mixed case counterparts. @param command The command to run. @return either the command is handled, or a console message is returned if the command is not handled. @throws java.lang.InterruptedException
[ "Runs", "a", "command", "on", "the", "console", ".", "Will", "not", "run", "exit", "quit", "shutdown", "their", "upper", "-", "case", "or", "mixed", "case", "counterparts", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/management/ConsoleCommandHandler.java#L50-L59
15,403
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/management/ConsoleCommandHandler.java
ConsoleCommandHandler.doHandleCommand
String doHandleCommand(final String command) { app.handleCommand(command); final String output = buffer.toString(); buffer.setLength(0); return output; }
java
String doHandleCommand(final String command) { app.handleCommand(command); final String output = buffer.toString(); buffer.setLength(0); return output; }
[ "String", "doHandleCommand", "(", "final", "String", "command", ")", "{", "app", ".", "handleCommand", "(", "command", ")", ";", "final", "String", "output", "=", "buffer", ".", "toString", "(", ")", ";", "buffer", ".", "setLength", "(", "0", ")", ";", "return", "output", ";", "}" ]
Called by handleCommand.
[ "Called", "by", "handleCommand", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/management/ConsoleCommandHandler.java#L64-L69
15,404
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/config/WanReplicationConfig.java
WanReplicationConfig.setWanPublisherConfigs
public void setWanPublisherConfigs(List<WanPublisherConfig> wanPublisherConfigs) { if (wanPublisherConfigs != null && !wanPublisherConfigs.isEmpty()) { this.wanPublisherConfigs = wanPublisherConfigs; } }
java
public void setWanPublisherConfigs(List<WanPublisherConfig> wanPublisherConfigs) { if (wanPublisherConfigs != null && !wanPublisherConfigs.isEmpty()) { this.wanPublisherConfigs = wanPublisherConfigs; } }
[ "public", "void", "setWanPublisherConfigs", "(", "List", "<", "WanPublisherConfig", ">", "wanPublisherConfigs", ")", "{", "if", "(", "wanPublisherConfigs", "!=", "null", "&&", "!", "wanPublisherConfigs", ".", "isEmpty", "(", ")", ")", "{", "this", ".", "wanPublisherConfigs", "=", "wanPublisherConfigs", ";", "}", "}" ]
Sets the list of configured WAN publisher targets for this WAN replication. @param wanPublisherConfigs WAN publisher list
[ "Sets", "the", "list", "of", "configured", "WAN", "publisher", "targets", "for", "this", "WAN", "replication", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/WanReplicationConfig.java#L106-L110
15,405
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/AbstractPartitionPrimaryReplicaAntiEntropyTask.java
AbstractPartitionPrimaryReplicaAntiEntropyTask.retainAndGetNamespaces
final Collection<ServiceNamespace> retainAndGetNamespaces() { PartitionReplicationEvent event = new PartitionReplicationEvent(partitionId, 0); Collection<FragmentedMigrationAwareService> services = nodeEngine.getServices(FragmentedMigrationAwareService.class); Set<ServiceNamespace> namespaces = new HashSet<>(); for (FragmentedMigrationAwareService service : services) { Collection<ServiceNamespace> serviceNamespaces = service.getAllServiceNamespaces(event); if (serviceNamespaces != null) { namespaces.addAll(serviceNamespaces); } } namespaces.add(NonFragmentedServiceNamespace.INSTANCE); PartitionReplicaManager replicaManager = partitionService.getReplicaManager(); replicaManager.retainNamespaces(partitionId, namespaces); return replicaManager.getNamespaces(partitionId); }
java
final Collection<ServiceNamespace> retainAndGetNamespaces() { PartitionReplicationEvent event = new PartitionReplicationEvent(partitionId, 0); Collection<FragmentedMigrationAwareService> services = nodeEngine.getServices(FragmentedMigrationAwareService.class); Set<ServiceNamespace> namespaces = new HashSet<>(); for (FragmentedMigrationAwareService service : services) { Collection<ServiceNamespace> serviceNamespaces = service.getAllServiceNamespaces(event); if (serviceNamespaces != null) { namespaces.addAll(serviceNamespaces); } } namespaces.add(NonFragmentedServiceNamespace.INSTANCE); PartitionReplicaManager replicaManager = partitionService.getReplicaManager(); replicaManager.retainNamespaces(partitionId, namespaces); return replicaManager.getNamespaces(partitionId); }
[ "final", "Collection", "<", "ServiceNamespace", ">", "retainAndGetNamespaces", "(", ")", "{", "PartitionReplicationEvent", "event", "=", "new", "PartitionReplicationEvent", "(", "partitionId", ",", "0", ")", ";", "Collection", "<", "FragmentedMigrationAwareService", ">", "services", "=", "nodeEngine", ".", "getServices", "(", "FragmentedMigrationAwareService", ".", "class", ")", ";", "Set", "<", "ServiceNamespace", ">", "namespaces", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "FragmentedMigrationAwareService", "service", ":", "services", ")", "{", "Collection", "<", "ServiceNamespace", ">", "serviceNamespaces", "=", "service", ".", "getAllServiceNamespaces", "(", "event", ")", ";", "if", "(", "serviceNamespaces", "!=", "null", ")", "{", "namespaces", ".", "addAll", "(", "serviceNamespaces", ")", ";", "}", "}", "namespaces", ".", "add", "(", "NonFragmentedServiceNamespace", ".", "INSTANCE", ")", ";", "PartitionReplicaManager", "replicaManager", "=", "partitionService", ".", "getReplicaManager", "(", ")", ";", "replicaManager", ".", "retainNamespaces", "(", "partitionId", ",", "namespaces", ")", ";", "return", "replicaManager", ".", "getNamespaces", "(", "partitionId", ")", ";", "}" ]
works only on primary. backups are retained in PartitionBackupReplicaAntiEntropyTask
[ "works", "only", "on", "primary", ".", "backups", "are", "retained", "in", "PartitionBackupReplicaAntiEntropyTask" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/AbstractPartitionPrimaryReplicaAntiEntropyTask.java#L66-L82
15,406
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java
PortableNavigatorContext.initFinalPositionAndOffset
private void initFinalPositionAndOffset(BufferObjectDataInput in, ClassDefinition cd) { int fieldCount; try { // final position after portable is read finalPosition = in.readInt(); fieldCount = in.readInt(); } catch (IOException e) { throw new HazelcastSerializationException(e); } if (fieldCount != cd.getFieldCount()) { throw new IllegalStateException("Field count[" + fieldCount + "] in stream does not match " + cd); } offset = in.position(); }
java
private void initFinalPositionAndOffset(BufferObjectDataInput in, ClassDefinition cd) { int fieldCount; try { // final position after portable is read finalPosition = in.readInt(); fieldCount = in.readInt(); } catch (IOException e) { throw new HazelcastSerializationException(e); } if (fieldCount != cd.getFieldCount()) { throw new IllegalStateException("Field count[" + fieldCount + "] in stream does not match " + cd); } offset = in.position(); }
[ "private", "void", "initFinalPositionAndOffset", "(", "BufferObjectDataInput", "in", ",", "ClassDefinition", "cd", ")", "{", "int", "fieldCount", ";", "try", "{", "// final position after portable is read", "finalPosition", "=", "in", ".", "readInt", "(", ")", ";", "fieldCount", "=", "in", ".", "readInt", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "HazelcastSerializationException", "(", "e", ")", ";", "}", "if", "(", "fieldCount", "!=", "cd", ".", "getFieldCount", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Field count[\"", "+", "fieldCount", "+", "\"] in stream does not match \"", "+", "cd", ")", ";", "}", "offset", "=", "in", ".", "position", "(", ")", ";", "}" ]
Initialises the finalPosition and offset and validates the fieldCount against the given class definition
[ "Initialises", "the", "finalPosition", "and", "offset", "and", "validates", "the", "fieldCount", "against", "the", "given", "class", "definition" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java#L72-L85
15,407
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java
PortableNavigatorContext.reset
void reset() { cd = initCd; serializer = initSerializer; in.position(initPosition); finalPosition = initFinalPosition; offset = initOffset; }
java
void reset() { cd = initCd; serializer = initSerializer; in.position(initPosition); finalPosition = initFinalPosition; offset = initOffset; }
[ "void", "reset", "(", ")", "{", "cd", "=", "initCd", ";", "serializer", "=", "initSerializer", ";", "in", ".", "position", "(", "initPosition", ")", ";", "finalPosition", "=", "initFinalPosition", ";", "offset", "=", "initOffset", ";", "}" ]
Resets the state to the initial state for future reuse.
[ "Resets", "the", "state", "to", "the", "initial", "state", "for", "future", "reuse", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java#L90-L96
15,408
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java
PortableNavigatorContext.advanceContextToNextPortableToken
void advanceContextToNextPortableToken(int factoryId, int classId, int version) throws IOException { cd = serializer.setupPositionAndDefinition(in, factoryId, classId, version); initFinalPositionAndOffset(in, cd); }
java
void advanceContextToNextPortableToken(int factoryId, int classId, int version) throws IOException { cd = serializer.setupPositionAndDefinition(in, factoryId, classId, version); initFinalPositionAndOffset(in, cd); }
[ "void", "advanceContextToNextPortableToken", "(", "int", "factoryId", ",", "int", "classId", ",", "int", "version", ")", "throws", "IOException", "{", "cd", "=", "serializer", ".", "setupPositionAndDefinition", "(", "in", ",", "factoryId", ",", "classId", ",", "version", ")", ";", "initFinalPositionAndOffset", "(", "in", ",", "cd", ")", ";", "}" ]
When we advance in the token navigation we need to re-initialise the class definition with the coordinates of the new portable object in the context of which we will be navigating further.
[ "When", "we", "advance", "in", "the", "token", "navigation", "we", "need", "to", "re", "-", "initialise", "the", "class", "definition", "with", "the", "coordinates", "of", "the", "new", "portable", "object", "in", "the", "context", "of", "which", "we", "will", "be", "navigating", "further", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java#L138-L141
15,409
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java
PortableNavigatorContext.advanceContextToGivenFrame
void advanceContextToGivenFrame(NavigationFrame frame) { in.position(frame.streamPosition); offset = frame.streamOffset; cd = frame.cd; }
java
void advanceContextToGivenFrame(NavigationFrame frame) { in.position(frame.streamPosition); offset = frame.streamOffset; cd = frame.cd; }
[ "void", "advanceContextToGivenFrame", "(", "NavigationFrame", "frame", ")", "{", "in", ".", "position", "(", "frame", ".", "streamPosition", ")", ";", "offset", "=", "frame", ".", "streamOffset", ";", "cd", "=", "frame", ".", "cd", ";", "}" ]
Sets up the stream for the given frame which contains all info required to change to context for a given field.
[ "Sets", "up", "the", "stream", "for", "the", "given", "frame", "which", "contains", "all", "info", "required", "to", "change", "to", "context", "for", "a", "given", "field", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortableNavigatorContext.java#L146-L150
15,410
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractHazelcastCacheManager.java
AbstractHazelcastCacheManager.getOrCreateCache
@SuppressWarnings({"unchecked", "unused"}) public <K, V> ICache<K, V> getOrCreateCache(String cacheName, CacheConfig<K, V> cacheConfig) { ensureOpen(); String cacheNameWithPrefix = getCacheNameWithPrefix(cacheName); ICacheInternal<?, ?> cache = caches.get(cacheNameWithPrefix); if (cache == null) { cache = createCacheInternal(cacheName, cacheConfig); } return ensureOpenIfAvailable((ICacheInternal<K, V>) cache); }
java
@SuppressWarnings({"unchecked", "unused"}) public <K, V> ICache<K, V> getOrCreateCache(String cacheName, CacheConfig<K, V> cacheConfig) { ensureOpen(); String cacheNameWithPrefix = getCacheNameWithPrefix(cacheName); ICacheInternal<?, ?> cache = caches.get(cacheNameWithPrefix); if (cache == null) { cache = createCacheInternal(cacheName, cacheConfig); } return ensureOpenIfAvailable((ICacheInternal<K, V>) cache); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"unused\"", "}", ")", "public", "<", "K", ",", "V", ">", "ICache", "<", "K", ",", "V", ">", "getOrCreateCache", "(", "String", "cacheName", ",", "CacheConfig", "<", "K", ",", "V", ">", "cacheConfig", ")", "{", "ensureOpen", "(", ")", ";", "String", "cacheNameWithPrefix", "=", "getCacheNameWithPrefix", "(", "cacheName", ")", ";", "ICacheInternal", "<", "?", ",", "?", ">", "cache", "=", "caches", ".", "get", "(", "cacheNameWithPrefix", ")", ";", "if", "(", "cache", "==", "null", ")", "{", "cache", "=", "createCacheInternal", "(", "cacheName", ",", "cacheConfig", ")", ";", "}", "return", "ensureOpenIfAvailable", "(", "(", "ICacheInternal", "<", "K", ",", "V", ">", ")", "cache", ")", ";", "}" ]
used in EE
[ "used", "in", "EE" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractHazelcastCacheManager.java#L194-L203
15,411
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractHazelcastCacheManager.java
AbstractHazelcastCacheManager.destroy
@Override public void destroy() { if (!isDestroyed.compareAndSet(false, true)) { return; } deregisterLifecycleListener(); for (ICacheInternal cache : caches.values()) { cache.destroy(); } caches.clear(); isClosed.set(true); postDestroy(); }
java
@Override public void destroy() { if (!isDestroyed.compareAndSet(false, true)) { return; } deregisterLifecycleListener(); for (ICacheInternal cache : caches.values()) { cache.destroy(); } caches.clear(); isClosed.set(true); postDestroy(); }
[ "@", "Override", "public", "void", "destroy", "(", ")", "{", "if", "(", "!", "isDestroyed", ".", "compareAndSet", "(", "false", ",", "true", ")", ")", "{", "return", ";", "}", "deregisterLifecycleListener", "(", ")", ";", "for", "(", "ICacheInternal", "cache", ":", "caches", ".", "values", "(", ")", ")", "{", "cache", ".", "destroy", "(", ")", ";", "}", "caches", ".", "clear", "(", ")", ";", "isClosed", ".", "set", "(", "true", ")", ";", "postDestroy", "(", ")", ";", "}" ]
Destroys all managed caches.
[ "Destroys", "all", "managed", "caches", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/AbstractHazelcastCacheManager.java#L328-L343
15,412
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java
ConfigXmlGenerator.generate
public String generate(Config config) { isNotNull(config, "Config"); StringBuilder xml = new StringBuilder(); XmlGenerator gen = new XmlGenerator(xml); xml.append("<hazelcast ") .append("xmlns=\"http://www.hazelcast.com/schema/config\"\n") .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n") .append("xsi:schemaLocation=\"http://www.hazelcast.com/schema/config ") .append("http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd\">"); gen.open("group") .node("name", config.getGroupConfig().getName()) .node("password", getOrMaskValue(config.getGroupConfig().getPassword())) .close() .node("license-key", getOrMaskValue(config.getLicenseKey())) .node("instance-name", config.getInstanceName()); manCenterXmlGenerator(gen, config); gen.appendProperties(config.getProperties()); securityXmlGenerator(gen, config); wanReplicationXmlGenerator(gen, config); networkConfigXmlGenerator(gen, config); advancedNetworkConfigXmlGenerator(gen, config); mapConfigXmlGenerator(gen, config); replicatedMapConfigXmlGenerator(gen, config); cacheConfigXmlGenerator(gen, config); queueXmlGenerator(gen, config); multiMapXmlGenerator(gen, config); collectionXmlGenerator(gen, "list", config.getListConfigs().values()); collectionXmlGenerator(gen, "set", config.getSetConfigs().values()); topicXmlGenerator(gen, config); semaphoreXmlGenerator(gen, config); lockXmlGenerator(gen, config); countDownLatchXmlGenerator(gen, config); ringbufferXmlGenerator(gen, config); atomicLongXmlGenerator(gen, config); atomicReferenceXmlGenerator(gen, config); executorXmlGenerator(gen, config); durableExecutorXmlGenerator(gen, config); scheduledExecutorXmlGenerator(gen, config); eventJournalXmlGenerator(gen, config); merkleTreeXmlGenerator(gen, config); partitionGroupXmlGenerator(gen, config); cardinalityEstimatorXmlGenerator(gen, config); listenerXmlGenerator(gen, config); serializationXmlGenerator(gen, config); reliableTopicXmlGenerator(gen, config); liteMemberXmlGenerator(gen, config); nativeMemoryXmlGenerator(gen, config); servicesXmlGenerator(gen, config); hotRestartXmlGenerator(gen, config); flakeIdGeneratorXmlGenerator(gen, config); crdtReplicationXmlGenerator(gen, config); pnCounterXmlGenerator(gen, config); quorumXmlGenerator(gen, config); cpSubsystemConfig(gen, config); xml.append("</hazelcast>"); return format(xml.toString(), INDENT); }
java
public String generate(Config config) { isNotNull(config, "Config"); StringBuilder xml = new StringBuilder(); XmlGenerator gen = new XmlGenerator(xml); xml.append("<hazelcast ") .append("xmlns=\"http://www.hazelcast.com/schema/config\"\n") .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n") .append("xsi:schemaLocation=\"http://www.hazelcast.com/schema/config ") .append("http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd\">"); gen.open("group") .node("name", config.getGroupConfig().getName()) .node("password", getOrMaskValue(config.getGroupConfig().getPassword())) .close() .node("license-key", getOrMaskValue(config.getLicenseKey())) .node("instance-name", config.getInstanceName()); manCenterXmlGenerator(gen, config); gen.appendProperties(config.getProperties()); securityXmlGenerator(gen, config); wanReplicationXmlGenerator(gen, config); networkConfigXmlGenerator(gen, config); advancedNetworkConfigXmlGenerator(gen, config); mapConfigXmlGenerator(gen, config); replicatedMapConfigXmlGenerator(gen, config); cacheConfigXmlGenerator(gen, config); queueXmlGenerator(gen, config); multiMapXmlGenerator(gen, config); collectionXmlGenerator(gen, "list", config.getListConfigs().values()); collectionXmlGenerator(gen, "set", config.getSetConfigs().values()); topicXmlGenerator(gen, config); semaphoreXmlGenerator(gen, config); lockXmlGenerator(gen, config); countDownLatchXmlGenerator(gen, config); ringbufferXmlGenerator(gen, config); atomicLongXmlGenerator(gen, config); atomicReferenceXmlGenerator(gen, config); executorXmlGenerator(gen, config); durableExecutorXmlGenerator(gen, config); scheduledExecutorXmlGenerator(gen, config); eventJournalXmlGenerator(gen, config); merkleTreeXmlGenerator(gen, config); partitionGroupXmlGenerator(gen, config); cardinalityEstimatorXmlGenerator(gen, config); listenerXmlGenerator(gen, config); serializationXmlGenerator(gen, config); reliableTopicXmlGenerator(gen, config); liteMemberXmlGenerator(gen, config); nativeMemoryXmlGenerator(gen, config); servicesXmlGenerator(gen, config); hotRestartXmlGenerator(gen, config); flakeIdGeneratorXmlGenerator(gen, config); crdtReplicationXmlGenerator(gen, config); pnCounterXmlGenerator(gen, config); quorumXmlGenerator(gen, config); cpSubsystemConfig(gen, config); xml.append("</hazelcast>"); return format(xml.toString(), INDENT); }
[ "public", "String", "generate", "(", "Config", "config", ")", "{", "isNotNull", "(", "config", ",", "\"Config\"", ")", ";", "StringBuilder", "xml", "=", "new", "StringBuilder", "(", ")", ";", "XmlGenerator", "gen", "=", "new", "XmlGenerator", "(", "xml", ")", ";", "xml", ".", "append", "(", "\"<hazelcast \"", ")", ".", "append", "(", "\"xmlns=\\\"http://www.hazelcast.com/schema/config\\\"\\n\"", ")", ".", "append", "(", "\"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\\n\"", ")", ".", "append", "(", "\"xsi:schemaLocation=\\\"http://www.hazelcast.com/schema/config \"", ")", ".", "append", "(", "\"http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd\\\">\"", ")", ";", "gen", ".", "open", "(", "\"group\"", ")", ".", "node", "(", "\"name\"", ",", "config", ".", "getGroupConfig", "(", ")", ".", "getName", "(", ")", ")", ".", "node", "(", "\"password\"", ",", "getOrMaskValue", "(", "config", ".", "getGroupConfig", "(", ")", ".", "getPassword", "(", ")", ")", ")", ".", "close", "(", ")", ".", "node", "(", "\"license-key\"", ",", "getOrMaskValue", "(", "config", ".", "getLicenseKey", "(", ")", ")", ")", ".", "node", "(", "\"instance-name\"", ",", "config", ".", "getInstanceName", "(", ")", ")", ";", "manCenterXmlGenerator", "(", "gen", ",", "config", ")", ";", "gen", ".", "appendProperties", "(", "config", ".", "getProperties", "(", ")", ")", ";", "securityXmlGenerator", "(", "gen", ",", "config", ")", ";", "wanReplicationXmlGenerator", "(", "gen", ",", "config", ")", ";", "networkConfigXmlGenerator", "(", "gen", ",", "config", ")", ";", "advancedNetworkConfigXmlGenerator", "(", "gen", ",", "config", ")", ";", "mapConfigXmlGenerator", "(", "gen", ",", "config", ")", ";", "replicatedMapConfigXmlGenerator", "(", "gen", ",", "config", ")", ";", "cacheConfigXmlGenerator", "(", "gen", ",", "config", ")", ";", "queueXmlGenerator", "(", "gen", ",", "config", ")", ";", "multiMapXmlGenerator", "(", "gen", ",", "config", ")", ";", "collectionXmlGenerator", "(", "gen", ",", "\"list\"", ",", "config", ".", "getListConfigs", "(", ")", ".", "values", "(", ")", ")", ";", "collectionXmlGenerator", "(", "gen", ",", "\"set\"", ",", "config", ".", "getSetConfigs", "(", ")", ".", "values", "(", ")", ")", ";", "topicXmlGenerator", "(", "gen", ",", "config", ")", ";", "semaphoreXmlGenerator", "(", "gen", ",", "config", ")", ";", "lockXmlGenerator", "(", "gen", ",", "config", ")", ";", "countDownLatchXmlGenerator", "(", "gen", ",", "config", ")", ";", "ringbufferXmlGenerator", "(", "gen", ",", "config", ")", ";", "atomicLongXmlGenerator", "(", "gen", ",", "config", ")", ";", "atomicReferenceXmlGenerator", "(", "gen", ",", "config", ")", ";", "executorXmlGenerator", "(", "gen", ",", "config", ")", ";", "durableExecutorXmlGenerator", "(", "gen", ",", "config", ")", ";", "scheduledExecutorXmlGenerator", "(", "gen", ",", "config", ")", ";", "eventJournalXmlGenerator", "(", "gen", ",", "config", ")", ";", "merkleTreeXmlGenerator", "(", "gen", ",", "config", ")", ";", "partitionGroupXmlGenerator", "(", "gen", ",", "config", ")", ";", "cardinalityEstimatorXmlGenerator", "(", "gen", ",", "config", ")", ";", "listenerXmlGenerator", "(", "gen", ",", "config", ")", ";", "serializationXmlGenerator", "(", "gen", ",", "config", ")", ";", "reliableTopicXmlGenerator", "(", "gen", ",", "config", ")", ";", "liteMemberXmlGenerator", "(", "gen", ",", "config", ")", ";", "nativeMemoryXmlGenerator", "(", "gen", ",", "config", ")", ";", "servicesXmlGenerator", "(", "gen", ",", "config", ")", ";", "hotRestartXmlGenerator", "(", "gen", ",", "config", ")", ";", "flakeIdGeneratorXmlGenerator", "(", "gen", ",", "config", ")", ";", "crdtReplicationXmlGenerator", "(", "gen", ",", "config", ")", ";", "pnCounterXmlGenerator", "(", "gen", ",", "config", ")", ";", "quorumXmlGenerator", "(", "gen", ",", "config", ")", ";", "cpSubsystemConfig", "(", "gen", ",", "config", ")", ";", "xml", ".", "append", "(", "\"</hazelcast>\"", ")", ";", "return", "format", "(", "xml", ".", "toString", "(", ")", ",", "INDENT", ")", ";", "}" ]
Generates the XML string based on some Config. @param config the configuration @return the XML string
[ "Generates", "the", "XML", "string", "based", "on", "some", "Config", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java#L111-L172
15,413
hazelcast/hazelcast
hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java
ClientPNCounterProxy.toVectorClock
private VectorClock toVectorClock(List<Entry<String, Long>> replicaLogicalTimestamps) { final VectorClock timestamps = new VectorClock(); for (Entry<String, Long> replicaTimestamp : replicaLogicalTimestamps) { timestamps.setReplicaTimestamp(replicaTimestamp.getKey(), replicaTimestamp.getValue()); } return timestamps; }
java
private VectorClock toVectorClock(List<Entry<String, Long>> replicaLogicalTimestamps) { final VectorClock timestamps = new VectorClock(); for (Entry<String, Long> replicaTimestamp : replicaLogicalTimestamps) { timestamps.setReplicaTimestamp(replicaTimestamp.getKey(), replicaTimestamp.getValue()); } return timestamps; }
[ "private", "VectorClock", "toVectorClock", "(", "List", "<", "Entry", "<", "String", ",", "Long", ">", ">", "replicaLogicalTimestamps", ")", "{", "final", "VectorClock", "timestamps", "=", "new", "VectorClock", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "Long", ">", "replicaTimestamp", ":", "replicaLogicalTimestamps", ")", "{", "timestamps", ".", "setReplicaTimestamp", "(", "replicaTimestamp", ".", "getKey", "(", ")", ",", "replicaTimestamp", ".", "getValue", "(", ")", ")", ";", "}", "return", "timestamps", ";", "}" ]
Transforms the list of replica logical timestamps to a vector clock instance. @param replicaLogicalTimestamps the logical timestamps @return a vector clock instance
[ "Transforms", "the", "list", "of", "replica", "logical", "timestamps", "to", "a", "vector", "clock", "instance", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java#L213-L219
15,414
hazelcast/hazelcast
hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java
ClientPNCounterProxy.getMaxConfiguredReplicaCount
private int getMaxConfiguredReplicaCount() { if (maxConfiguredReplicaCount > 0) { return maxConfiguredReplicaCount; } else { final ClientMessage request = PNCounterGetConfiguredReplicaCountCodec.encodeRequest(name); final ClientMessage response = invoke(request); final PNCounterGetConfiguredReplicaCountCodec.ResponseParameters resultParameters = PNCounterGetConfiguredReplicaCountCodec.decodeResponse(response); maxConfiguredReplicaCount = resultParameters.response; } return maxConfiguredReplicaCount; }
java
private int getMaxConfiguredReplicaCount() { if (maxConfiguredReplicaCount > 0) { return maxConfiguredReplicaCount; } else { final ClientMessage request = PNCounterGetConfiguredReplicaCountCodec.encodeRequest(name); final ClientMessage response = invoke(request); final PNCounterGetConfiguredReplicaCountCodec.ResponseParameters resultParameters = PNCounterGetConfiguredReplicaCountCodec.decodeResponse(response); maxConfiguredReplicaCount = resultParameters.response; } return maxConfiguredReplicaCount; }
[ "private", "int", "getMaxConfiguredReplicaCount", "(", ")", "{", "if", "(", "maxConfiguredReplicaCount", ">", "0", ")", "{", "return", "maxConfiguredReplicaCount", ";", "}", "else", "{", "final", "ClientMessage", "request", "=", "PNCounterGetConfiguredReplicaCountCodec", ".", "encodeRequest", "(", "name", ")", ";", "final", "ClientMessage", "response", "=", "invoke", "(", "request", ")", ";", "final", "PNCounterGetConfiguredReplicaCountCodec", ".", "ResponseParameters", "resultParameters", "=", "PNCounterGetConfiguredReplicaCountCodec", ".", "decodeResponse", "(", "response", ")", ";", "maxConfiguredReplicaCount", "=", "resultParameters", ".", "response", ";", "}", "return", "maxConfiguredReplicaCount", ";", "}" ]
Returns the max configured replica count. When invoked for the first time, this method will fetch the configuration from a cluster member. @return the maximum configured replica count
[ "Returns", "the", "max", "configured", "replica", "count", ".", "When", "invoked", "for", "the", "first", "time", "this", "method", "will", "fetch", "the", "configuration", "from", "a", "cluster", "member", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java#L392-L403
15,415
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/AbstractMapDataStore.java
AbstractMapDataStore.convertToObjectKeys
private List<Object> convertToObjectKeys(Collection keys) { if (keys == null || keys.isEmpty()) { return Collections.emptyList(); } final List<Object> objectKeys = new ArrayList<>(keys.size()); for (Object key : keys) { objectKeys.add(toObject(key)); } return objectKeys; }
java
private List<Object> convertToObjectKeys(Collection keys) { if (keys == null || keys.isEmpty()) { return Collections.emptyList(); } final List<Object> objectKeys = new ArrayList<>(keys.size()); for (Object key : keys) { objectKeys.add(toObject(key)); } return objectKeys; }
[ "private", "List", "<", "Object", ">", "convertToObjectKeys", "(", "Collection", "keys", ")", "{", "if", "(", "keys", "==", "null", "||", "keys", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "final", "List", "<", "Object", ">", "objectKeys", "=", "new", "ArrayList", "<>", "(", "keys", ".", "size", "(", ")", ")", ";", "for", "(", "Object", "key", ":", "keys", ")", "{", "objectKeys", ".", "add", "(", "toObject", "(", "key", ")", ")", ";", "}", "return", "objectKeys", ";", "}" ]
Deserialises all of the items in the provided collection if they are not deserialised already. @param keys the items to be deserialised @return the list of deserialised items
[ "Deserialises", "all", "of", "the", "items", "in", "the", "provided", "collection", "if", "they", "are", "not", "deserialised", "already", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/AbstractMapDataStore.java#L98-L107
15,416
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/AbstractQueryCacheEndToEndConstructor.java
AbstractQueryCacheEndToEndConstructor.createNew
@Override public final InternalQueryCache createNew(String cacheId) { try { QueryCacheConfig queryCacheConfig = initQueryCacheConfig(request, cacheId); if (queryCacheConfig == null) { // no matching configuration was found, `null` will // be returned to user from IMap#getQueryCache call. return NULL_QUERY_CACHE; } queryCache = createUnderlyingQueryCache(queryCacheConfig, request, cacheId); AccumulatorInfo info = toAccumulatorInfo(queryCacheConfig, mapName, cacheId, predicate); addInfoToSubscriberContext(info); info.setPublishable(true); String publisherListenerId = queryCache.getPublisherListenerId(); if (publisherListenerId == null) { createSubscriberAccumulator(info); } createPublisherAccumulator(info); queryCache.setPublisherListenerId(this.publisherListenerId); } catch (Throwable throwable) { removeQueryCacheConfig(mapName, request.getCacheName()); throw rethrow(throwable); } return queryCache; }
java
@Override public final InternalQueryCache createNew(String cacheId) { try { QueryCacheConfig queryCacheConfig = initQueryCacheConfig(request, cacheId); if (queryCacheConfig == null) { // no matching configuration was found, `null` will // be returned to user from IMap#getQueryCache call. return NULL_QUERY_CACHE; } queryCache = createUnderlyingQueryCache(queryCacheConfig, request, cacheId); AccumulatorInfo info = toAccumulatorInfo(queryCacheConfig, mapName, cacheId, predicate); addInfoToSubscriberContext(info); info.setPublishable(true); String publisherListenerId = queryCache.getPublisherListenerId(); if (publisherListenerId == null) { createSubscriberAccumulator(info); } createPublisherAccumulator(info); queryCache.setPublisherListenerId(this.publisherListenerId); } catch (Throwable throwable) { removeQueryCacheConfig(mapName, request.getCacheName()); throw rethrow(throwable); } return queryCache; }
[ "@", "Override", "public", "final", "InternalQueryCache", "createNew", "(", "String", "cacheId", ")", "{", "try", "{", "QueryCacheConfig", "queryCacheConfig", "=", "initQueryCacheConfig", "(", "request", ",", "cacheId", ")", ";", "if", "(", "queryCacheConfig", "==", "null", ")", "{", "// no matching configuration was found, `null` will", "// be returned to user from IMap#getQueryCache call.", "return", "NULL_QUERY_CACHE", ";", "}", "queryCache", "=", "createUnderlyingQueryCache", "(", "queryCacheConfig", ",", "request", ",", "cacheId", ")", ";", "AccumulatorInfo", "info", "=", "toAccumulatorInfo", "(", "queryCacheConfig", ",", "mapName", ",", "cacheId", ",", "predicate", ")", ";", "addInfoToSubscriberContext", "(", "info", ")", ";", "info", ".", "setPublishable", "(", "true", ")", ";", "String", "publisherListenerId", "=", "queryCache", ".", "getPublisherListenerId", "(", ")", ";", "if", "(", "publisherListenerId", "==", "null", ")", "{", "createSubscriberAccumulator", "(", "info", ")", ";", "}", "createPublisherAccumulator", "(", "info", ")", ";", "queryCache", ".", "setPublisherListenerId", "(", "this", ".", "publisherListenerId", ")", ";", "}", "catch", "(", "Throwable", "throwable", ")", "{", "removeQueryCacheConfig", "(", "mapName", ",", "request", ".", "getCacheName", "(", ")", ")", ";", "throw", "rethrow", "(", "throwable", ")", ";", "}", "return", "queryCache", ";", "}" ]
Here order of method calls should not change.
[ "Here", "order", "of", "method", "calls", "should", "not", "change", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/AbstractQueryCacheEndToEndConstructor.java#L71-L101
15,417
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/AbstractQueryCacheEndToEndConstructor.java
AbstractQueryCacheEndToEndConstructor.createUnderlyingQueryCache
private InternalQueryCache createUnderlyingQueryCache(QueryCacheConfig queryCacheConfig, QueryCacheRequest request, String cacheId) { SubscriberContext subscriberContext = context.getSubscriberContext(); QueryCacheFactory queryCacheFactory = subscriberContext.getQueryCacheFactory(); request.withQueryCacheConfig(queryCacheConfig); return queryCacheFactory.create(request, cacheId); }
java
private InternalQueryCache createUnderlyingQueryCache(QueryCacheConfig queryCacheConfig, QueryCacheRequest request, String cacheId) { SubscriberContext subscriberContext = context.getSubscriberContext(); QueryCacheFactory queryCacheFactory = subscriberContext.getQueryCacheFactory(); request.withQueryCacheConfig(queryCacheConfig); return queryCacheFactory.create(request, cacheId); }
[ "private", "InternalQueryCache", "createUnderlyingQueryCache", "(", "QueryCacheConfig", "queryCacheConfig", ",", "QueryCacheRequest", "request", ",", "String", "cacheId", ")", "{", "SubscriberContext", "subscriberContext", "=", "context", ".", "getSubscriberContext", "(", ")", ";", "QueryCacheFactory", "queryCacheFactory", "=", "subscriberContext", ".", "getQueryCacheFactory", "(", ")", ";", "request", ".", "withQueryCacheConfig", "(", "queryCacheConfig", ")", ";", "return", "queryCacheFactory", ".", "create", "(", "request", ",", "cacheId", ")", ";", "}" ]
This is the cache which we store all key-value pairs.
[ "This", "is", "the", "cache", "which", "we", "store", "all", "key", "-", "value", "pairs", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/AbstractQueryCacheEndToEndConstructor.java#L106-L113
15,418
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/config/MapIndexConfig.java
MapIndexConfig.validateIndexAttribute
public static String validateIndexAttribute(String attribute) { checkHasText(attribute, "Map index attribute must contain text"); String keyPrefix = KEY_ATTRIBUTE_NAME.value(); if (attribute.startsWith(keyPrefix) && attribute.length() > keyPrefix.length()) { if (attribute.charAt(keyPrefix.length()) != '#') { LOG.warning(KEY_ATTRIBUTE_NAME.value() + " used without a following '#' char in index attribute '" + attribute + "'. Don't you want to index a key?"); } } return attribute; }
java
public static String validateIndexAttribute(String attribute) { checkHasText(attribute, "Map index attribute must contain text"); String keyPrefix = KEY_ATTRIBUTE_NAME.value(); if (attribute.startsWith(keyPrefix) && attribute.length() > keyPrefix.length()) { if (attribute.charAt(keyPrefix.length()) != '#') { LOG.warning(KEY_ATTRIBUTE_NAME.value() + " used without a following '#' char in index attribute '" + attribute + "'. Don't you want to index a key?"); } } return attribute; }
[ "public", "static", "String", "validateIndexAttribute", "(", "String", "attribute", ")", "{", "checkHasText", "(", "attribute", ",", "\"Map index attribute must contain text\"", ")", ";", "String", "keyPrefix", "=", "KEY_ATTRIBUTE_NAME", ".", "value", "(", ")", ";", "if", "(", "attribute", ".", "startsWith", "(", "keyPrefix", ")", "&&", "attribute", ".", "length", "(", ")", ">", "keyPrefix", ".", "length", "(", ")", ")", "{", "if", "(", "attribute", ".", "charAt", "(", "keyPrefix", ".", "length", "(", ")", ")", "!=", "'", "'", ")", "{", "LOG", ".", "warning", "(", "KEY_ATTRIBUTE_NAME", ".", "value", "(", ")", "+", "\" used without a following '#' char in index attribute '\"", "+", "attribute", "+", "\"'. Don't you want to index a key?\"", ")", ";", "}", "}", "return", "attribute", ";", "}" ]
Validates index attribute content. @param attribute attribute to validate @return the attribute for fluent assignment
[ "Validates", "index", "attribute", "content", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/MapIndexConfig.java#L136-L146
15,419
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java
PublisherCreateOperation.replayEventsOverResultSet
private void replayEventsOverResultSet(QueryResult queryResult) throws Exception { Map<Integer, Future<Object>> future = readAccumulators(); for (Map.Entry<Integer, Future<Object>> entry : future.entrySet()) { int partitionId = entry.getKey(); Object eventsInOneAcc = entry.getValue().get(); if (eventsInOneAcc == null) { continue; } eventsInOneAcc = mapServiceContext.toObject(eventsInOneAcc); List<QueryCacheEventData> eventDataList = (List<QueryCacheEventData>) eventsInOneAcc; for (QueryCacheEventData eventData : eventDataList) { if (eventData.getDataKey() == null) { // this means a map-wide event like clear-all or evict-all // is inside the accumulator buffers removePartitionResults(queryResult, partitionId); } else { add(queryResult, newQueryResultRow(eventData)); } } } }
java
private void replayEventsOverResultSet(QueryResult queryResult) throws Exception { Map<Integer, Future<Object>> future = readAccumulators(); for (Map.Entry<Integer, Future<Object>> entry : future.entrySet()) { int partitionId = entry.getKey(); Object eventsInOneAcc = entry.getValue().get(); if (eventsInOneAcc == null) { continue; } eventsInOneAcc = mapServiceContext.toObject(eventsInOneAcc); List<QueryCacheEventData> eventDataList = (List<QueryCacheEventData>) eventsInOneAcc; for (QueryCacheEventData eventData : eventDataList) { if (eventData.getDataKey() == null) { // this means a map-wide event like clear-all or evict-all // is inside the accumulator buffers removePartitionResults(queryResult, partitionId); } else { add(queryResult, newQueryResultRow(eventData)); } } } }
[ "private", "void", "replayEventsOverResultSet", "(", "QueryResult", "queryResult", ")", "throws", "Exception", "{", "Map", "<", "Integer", ",", "Future", "<", "Object", ">", ">", "future", "=", "readAccumulators", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Integer", ",", "Future", "<", "Object", ">", ">", "entry", ":", "future", ".", "entrySet", "(", ")", ")", "{", "int", "partitionId", "=", "entry", ".", "getKey", "(", ")", ";", "Object", "eventsInOneAcc", "=", "entry", ".", "getValue", "(", ")", ".", "get", "(", ")", ";", "if", "(", "eventsInOneAcc", "==", "null", ")", "{", "continue", ";", "}", "eventsInOneAcc", "=", "mapServiceContext", ".", "toObject", "(", "eventsInOneAcc", ")", ";", "List", "<", "QueryCacheEventData", ">", "eventDataList", "=", "(", "List", "<", "QueryCacheEventData", ">", ")", "eventsInOneAcc", ";", "for", "(", "QueryCacheEventData", "eventData", ":", "eventDataList", ")", "{", "if", "(", "eventData", ".", "getDataKey", "(", ")", "==", "null", ")", "{", "// this means a map-wide event like clear-all or evict-all", "// is inside the accumulator buffers", "removePartitionResults", "(", "queryResult", ",", "partitionId", ")", ";", "}", "else", "{", "add", "(", "queryResult", ",", "newQueryResultRow", "(", "eventData", ")", ")", ";", "}", "}", "}", "}" ]
Replay events over the result set of initial query. These events are received events during execution of the initial query.
[ "Replay", "events", "over", "the", "result", "set", "of", "initial", "query", ".", "These", "events", "are", "received", "events", "during", "execution", "of", "the", "initial", "query", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java#L171-L191
15,420
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java
PublisherCreateOperation.removePartitionResults
private void removePartitionResults(QueryResult queryResult, int partitionId) { List<QueryResultRow> rows = queryResult.getRows(); rows.removeIf(resultRow -> getPartitionId(resultRow) == partitionId); }
java
private void removePartitionResults(QueryResult queryResult, int partitionId) { List<QueryResultRow> rows = queryResult.getRows(); rows.removeIf(resultRow -> getPartitionId(resultRow) == partitionId); }
[ "private", "void", "removePartitionResults", "(", "QueryResult", "queryResult", ",", "int", "partitionId", ")", "{", "List", "<", "QueryResultRow", ">", "rows", "=", "queryResult", ".", "getRows", "(", ")", ";", "rows", ".", "removeIf", "(", "resultRow", "->", "getPartitionId", "(", "resultRow", ")", "==", "partitionId", ")", ";", "}" ]
Remove matching entries from given result set with the given partition ID.
[ "Remove", "matching", "entries", "from", "given", "result", "set", "with", "the", "given", "partition", "ID", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java#L197-L200
15,421
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java
PublisherCreateOperation.readAndResetAccumulator
private Future<Object> readAndResetAccumulator(String mapName, String cacheId, Integer partitionId) { Operation operation = new ReadAndResetAccumulatorOperation(mapName, cacheId); OperationService operationService = getNodeEngine().getOperationService(); return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId); }
java
private Future<Object> readAndResetAccumulator(String mapName, String cacheId, Integer partitionId) { Operation operation = new ReadAndResetAccumulatorOperation(mapName, cacheId); OperationService operationService = getNodeEngine().getOperationService(); return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId); }
[ "private", "Future", "<", "Object", ">", "readAndResetAccumulator", "(", "String", "mapName", ",", "String", "cacheId", ",", "Integer", "partitionId", ")", "{", "Operation", "operation", "=", "new", "ReadAndResetAccumulatorOperation", "(", "mapName", ",", "cacheId", ")", ";", "OperationService", "operationService", "=", "getNodeEngine", "(", ")", ".", "getOperationService", "(", ")", ";", "return", "operationService", ".", "invokeOnPartition", "(", "MapService", ".", "SERVICE_NAME", ",", "operation", ",", "partitionId", ")", ";", "}" ]
Read and reset the accumulator of query cache inside the given partition.
[ "Read", "and", "reset", "the", "accumulator", "of", "query", "cache", "inside", "the", "given", "partition", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java#L229-L233
15,422
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/core/DistributedObjectUtil.java
DistributedObjectUtil.getName
public static String getName(DistributedObject distributedObject) { /* * The motivation of this behaviour is that some distributed objects (`ICache`) can have prefixed name. * For example, for the point of view of cache, * it has pure name and full name which contains prefixes also. * * However both of our `DistributedObject` and `javax.cache.Cache` (from JCache spec) interfaces * have same method name with same signature. It is `String getName()`. * * From the distributed object side, name must be fully qualified name of object, * but from the JCache spec side (also for backward compatibility), * it must be pure cache name without any prefix. * So there is same method name with same signature for different purposes. * Therefore, `PrefixedDistributedObject` has been introduced to retrieve the * fully qualified name of distributed object when it is needed. * * For cache case, the fully qualified name is full cache name contains Hazelcast prefix (`/hz`), * cache name prefix regarding to URI and/or classloader if specified and pure cache name. */ if (distributedObject instanceof PrefixedDistributedObject) { return ((PrefixedDistributedObject) distributedObject).getPrefixedName(); } else { return distributedObject.getName(); } }
java
public static String getName(DistributedObject distributedObject) { /* * The motivation of this behaviour is that some distributed objects (`ICache`) can have prefixed name. * For example, for the point of view of cache, * it has pure name and full name which contains prefixes also. * * However both of our `DistributedObject` and `javax.cache.Cache` (from JCache spec) interfaces * have same method name with same signature. It is `String getName()`. * * From the distributed object side, name must be fully qualified name of object, * but from the JCache spec side (also for backward compatibility), * it must be pure cache name without any prefix. * So there is same method name with same signature for different purposes. * Therefore, `PrefixedDistributedObject` has been introduced to retrieve the * fully qualified name of distributed object when it is needed. * * For cache case, the fully qualified name is full cache name contains Hazelcast prefix (`/hz`), * cache name prefix regarding to URI and/or classloader if specified and pure cache name. */ if (distributedObject instanceof PrefixedDistributedObject) { return ((PrefixedDistributedObject) distributedObject).getPrefixedName(); } else { return distributedObject.getName(); } }
[ "public", "static", "String", "getName", "(", "DistributedObject", "distributedObject", ")", "{", "/*\n * The motivation of this behaviour is that some distributed objects (`ICache`) can have prefixed name.\n * For example, for the point of view of cache,\n * it has pure name and full name which contains prefixes also.\n *\n * However both of our `DistributedObject` and `javax.cache.Cache` (from JCache spec) interfaces\n * have same method name with same signature. It is `String getName()`.\n *\n * From the distributed object side, name must be fully qualified name of object,\n * but from the JCache spec side (also for backward compatibility),\n * it must be pure cache name without any prefix.\n * So there is same method name with same signature for different purposes.\n * Therefore, `PrefixedDistributedObject` has been introduced to retrieve the\n * fully qualified name of distributed object when it is needed.\n *\n * For cache case, the fully qualified name is full cache name contains Hazelcast prefix (`/hz`),\n * cache name prefix regarding to URI and/or classloader if specified and pure cache name.\n */", "if", "(", "distributedObject", "instanceof", "PrefixedDistributedObject", ")", "{", "return", "(", "(", "PrefixedDistributedObject", ")", "distributedObject", ")", ".", "getPrefixedName", "(", ")", ";", "}", "else", "{", "return", "distributedObject", ".", "getName", "(", ")", ";", "}", "}" ]
Gets the name of the given distributed object. @param distributedObject the {@link DistributedObject} instance whose name is requested @return name of the given distributed object
[ "Gets", "the", "name", "of", "the", "given", "distributed", "object", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/core/DistributedObjectUtil.java#L33-L57
15,423
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/cache/impl/operation/CacheExpireBatchBackupOperation.java
CacheExpireBatchBackupOperation.equalizeEntryCountWithPrimary
private void equalizeEntryCountWithPrimary() { int diff = recordStore.size() - primaryEntryCount; if (diff > 0) { recordStore.sampleAndForceRemoveEntries(diff); assert recordStore.size() == primaryEntryCount : String.format("Failed" + " to remove %d entries while attempting to match" + " primary entry count %d," + " recordStore size is now %d", diff, primaryEntryCount, recordStore.size()); } }
java
private void equalizeEntryCountWithPrimary() { int diff = recordStore.size() - primaryEntryCount; if (diff > 0) { recordStore.sampleAndForceRemoveEntries(diff); assert recordStore.size() == primaryEntryCount : String.format("Failed" + " to remove %d entries while attempting to match" + " primary entry count %d," + " recordStore size is now %d", diff, primaryEntryCount, recordStore.size()); } }
[ "private", "void", "equalizeEntryCountWithPrimary", "(", ")", "{", "int", "diff", "=", "recordStore", ".", "size", "(", ")", "-", "primaryEntryCount", ";", "if", "(", "diff", ">", "0", ")", "{", "recordStore", ".", "sampleAndForceRemoveEntries", "(", "diff", ")", ";", "assert", "recordStore", ".", "size", "(", ")", "==", "primaryEntryCount", ":", "String", ".", "format", "(", "\"Failed\"", "+", "\" to remove %d entries while attempting to match\"", "+", "\" primary entry count %d,\"", "+", "\" recordStore size is now %d\"", ",", "diff", ",", "primaryEntryCount", ",", "recordStore", ".", "size", "(", ")", ")", ";", "}", "}" ]
Equalizes backup entry count with primary in order to have identical memory occupancy.
[ "Equalizes", "backup", "entry", "count", "with", "primary", "in", "order", "to", "have", "identical", "memory", "occupancy", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/operation/CacheExpireBatchBackupOperation.java#L65-L76
15,424
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java
Invalidator.invalidateKey
public final void invalidateKey(Data key, String dataStructureName, String sourceUuid) { checkNotNull(key, "key cannot be null"); checkNotNull(sourceUuid, "sourceUuid cannot be null"); Invalidation invalidation = newKeyInvalidation(key, dataStructureName, sourceUuid); invalidateInternal(invalidation, getPartitionId(key)); }
java
public final void invalidateKey(Data key, String dataStructureName, String sourceUuid) { checkNotNull(key, "key cannot be null"); checkNotNull(sourceUuid, "sourceUuid cannot be null"); Invalidation invalidation = newKeyInvalidation(key, dataStructureName, sourceUuid); invalidateInternal(invalidation, getPartitionId(key)); }
[ "public", "final", "void", "invalidateKey", "(", "Data", "key", ",", "String", "dataStructureName", ",", "String", "sourceUuid", ")", "{", "checkNotNull", "(", "key", ",", "\"key cannot be null\"", ")", ";", "checkNotNull", "(", "sourceUuid", ",", "\"sourceUuid cannot be null\"", ")", ";", "Invalidation", "invalidation", "=", "newKeyInvalidation", "(", "key", ",", "dataStructureName", ",", "sourceUuid", ")", ";", "invalidateInternal", "(", "invalidation", ",", "getPartitionId", "(", "key", ")", ")", ";", "}" ]
Invalidates supplied key from Near Caches of supplied data structure name. @param key key of the entry to be removed from Near Cache @param dataStructureName name of the data structure to be invalidated
[ "Invalidates", "supplied", "key", "from", "Near", "Caches", "of", "supplied", "data", "structure", "name", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java#L67-L73
15,425
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java
Invalidator.invalidateAllKeys
public final void invalidateAllKeys(String dataStructureName, String sourceUuid) { checkNotNull(sourceUuid, "sourceUuid cannot be null"); int orderKey = getPartitionId(dataStructureName); Invalidation invalidation = newClearInvalidation(dataStructureName, sourceUuid); sendImmediately(invalidation, orderKey); }
java
public final void invalidateAllKeys(String dataStructureName, String sourceUuid) { checkNotNull(sourceUuid, "sourceUuid cannot be null"); int orderKey = getPartitionId(dataStructureName); Invalidation invalidation = newClearInvalidation(dataStructureName, sourceUuid); sendImmediately(invalidation, orderKey); }
[ "public", "final", "void", "invalidateAllKeys", "(", "String", "dataStructureName", ",", "String", "sourceUuid", ")", "{", "checkNotNull", "(", "sourceUuid", ",", "\"sourceUuid cannot be null\"", ")", ";", "int", "orderKey", "=", "getPartitionId", "(", "dataStructureName", ")", ";", "Invalidation", "invalidation", "=", "newClearInvalidation", "(", "dataStructureName", ",", "sourceUuid", ")", ";", "sendImmediately", "(", "invalidation", ",", "orderKey", ")", ";", "}" ]
Invalidates all keys from Near Caches of supplied data structure name. @param dataStructureName name of the data structure to be cleared
[ "Invalidates", "all", "keys", "from", "Near", "Caches", "of", "supplied", "data", "structure", "name", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java#L80-L86
15,426
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java
DefaultRecordStore.flush
private void flush(Collection<Record> recordsToBeFlushed, boolean backup) { for (Record record : recordsToBeFlushed) { mapDataStore.flush(record.getKey(), record.getValue(), backup); } }
java
private void flush(Collection<Record> recordsToBeFlushed, boolean backup) { for (Record record : recordsToBeFlushed) { mapDataStore.flush(record.getKey(), record.getValue(), backup); } }
[ "private", "void", "flush", "(", "Collection", "<", "Record", ">", "recordsToBeFlushed", ",", "boolean", "backup", ")", "{", "for", "(", "Record", "record", ":", "recordsToBeFlushed", ")", "{", "mapDataStore", ".", "flush", "(", "record", ".", "getKey", "(", ")", ",", "record", ".", "getValue", "(", ")", ",", "backup", ")", ";", "}", "}" ]
Flushes evicted records to map store. @param recordsToBeFlushed records to be flushed to map-store. @param backup <code>true</code> if backup, false otherwise.
[ "Flushes", "evicted", "records", "to", "map", "store", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java#L146-L150
15,427
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java
DefaultRecordStore.readBackupData
@Override public Data readBackupData(Data key) { Record record = getRecord(key); if (record == null) { return null; } else { if (partitionService.isPartitionOwner(partitionId)) { // set last access time to prevent // premature removal of the entry because // of idleness based expiry record.setLastAccessTime(Clock.currentTimeMillis()); } } Object value = record.getValue(); mapServiceContext.interceptAfterGet(name, value); // this serialization step is needed not to expose the object, see issue 1292 return mapServiceContext.toData(value); }
java
@Override public Data readBackupData(Data key) { Record record = getRecord(key); if (record == null) { return null; } else { if (partitionService.isPartitionOwner(partitionId)) { // set last access time to prevent // premature removal of the entry because // of idleness based expiry record.setLastAccessTime(Clock.currentTimeMillis()); } } Object value = record.getValue(); mapServiceContext.interceptAfterGet(name, value); // this serialization step is needed not to expose the object, see issue 1292 return mapServiceContext.toData(value); }
[ "@", "Override", "public", "Data", "readBackupData", "(", "Data", "key", ")", "{", "Record", "record", "=", "getRecord", "(", "key", ")", ";", "if", "(", "record", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "if", "(", "partitionService", ".", "isPartitionOwner", "(", "partitionId", ")", ")", "{", "// set last access time to prevent", "// premature removal of the entry because", "// of idleness based expiry", "record", ".", "setLastAccessTime", "(", "Clock", ".", "currentTimeMillis", "(", ")", ")", ";", "}", "}", "Object", "value", "=", "record", ".", "getValue", "(", ")", ";", "mapServiceContext", ".", "interceptAfterGet", "(", "name", ",", "value", ")", ";", "// this serialization step is needed not to expose the object, see issue 1292", "return", "mapServiceContext", ".", "toData", "(", "value", ")", ";", "}" ]
This method is called directly by user threads, in other words it is called outside of the partition threads.
[ "This", "method", "is", "called", "directly", "by", "user", "threads", "in", "other", "words", "it", "is", "called", "outside", "of", "the", "partition", "threads", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java#L528-L547
15,428
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java
DefaultRecordStore.fullScanLocalDataToClear
private void fullScanLocalDataToClear(Indexes indexes) { InternalIndex[] indexesSnapshot = indexes.getIndexes(); for (Record record : storage.values()) { Data key = record.getKey(); Object value = Records.getValueOrCachedValue(record, serializationService); indexes.removeEntry(key, value, Index.OperationSource.SYSTEM); } Indexes.markPartitionAsUnindexed(partitionId, indexesSnapshot); }
java
private void fullScanLocalDataToClear(Indexes indexes) { InternalIndex[] indexesSnapshot = indexes.getIndexes(); for (Record record : storage.values()) { Data key = record.getKey(); Object value = Records.getValueOrCachedValue(record, serializationService); indexes.removeEntry(key, value, Index.OperationSource.SYSTEM); } Indexes.markPartitionAsUnindexed(partitionId, indexesSnapshot); }
[ "private", "void", "fullScanLocalDataToClear", "(", "Indexes", "indexes", ")", "{", "InternalIndex", "[", "]", "indexesSnapshot", "=", "indexes", ".", "getIndexes", "(", ")", ";", "for", "(", "Record", "record", ":", "storage", ".", "values", "(", ")", ")", "{", "Data", "key", "=", "record", ".", "getKey", "(", ")", ";", "Object", "value", "=", "Records", ".", "getValueOrCachedValue", "(", "record", ",", "serializationService", ")", ";", "indexes", ".", "removeEntry", "(", "key", ",", "value", ",", "Index", ".", "OperationSource", ".", "SYSTEM", ")", ";", "}", "Indexes", ".", "markPartitionAsUnindexed", "(", "partitionId", ",", "indexesSnapshot", ")", ";", "}" ]
Clears local data of this partition from global index by doing partition full-scan.
[ "Clears", "local", "data", "of", "this", "partition", "from", "global", "index", "by", "doing", "partition", "full", "-", "scan", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/DefaultRecordStore.java#L1340-L1348
15,429
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ConfigCheck.java
ConfigCheck.isCompatible
public boolean isCompatible(ConfigCheck found) { // check group-properties. if (!equals(groupName, found.groupName)) { return false; } verifyJoiner(found); verifyPartitionGroup(found); verifyPartitionCount(found); verifyApplicationValidationToken(found); return true; }
java
public boolean isCompatible(ConfigCheck found) { // check group-properties. if (!equals(groupName, found.groupName)) { return false; } verifyJoiner(found); verifyPartitionGroup(found); verifyPartitionCount(found); verifyApplicationValidationToken(found); return true; }
[ "public", "boolean", "isCompatible", "(", "ConfigCheck", "found", ")", "{", "// check group-properties.", "if", "(", "!", "equals", "(", "groupName", ",", "found", ".", "groupName", ")", ")", "{", "return", "false", ";", "}", "verifyJoiner", "(", "found", ")", ";", "verifyPartitionGroup", "(", "found", ")", ";", "verifyPartitionCount", "(", "found", ")", ";", "verifyApplicationValidationToken", "(", "found", ")", ";", "return", "true", ";", "}" ]
Checks if two Hazelcast configurations are compatible. @param found the {@link ConfigCheck} to compare this to @return true if compatible. False if part of another group. @throws ConfigMismatchException if the configuration is not compatible. An exception is thrown so we can pass a nice message.
[ "Checks", "if", "two", "Hazelcast", "configurations", "are", "compatible", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/ConfigCheck.java#L93-L104
15,430
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/nio/tcp/UnifiedProtocolEncoder.java
UnifiedProtocolEncoder.signalProtocolEstablished
void signalProtocolEstablished(String inboundProtocol) { assert !channel.isClientMode() : "Signal protocol should only be made on channel in serverMode"; this.inboundProtocol = inboundProtocol; channel.outboundPipeline().wakeup(); }
java
void signalProtocolEstablished(String inboundProtocol) { assert !channel.isClientMode() : "Signal protocol should only be made on channel in serverMode"; this.inboundProtocol = inboundProtocol; channel.outboundPipeline().wakeup(); }
[ "void", "signalProtocolEstablished", "(", "String", "inboundProtocol", ")", "{", "assert", "!", "channel", ".", "isClientMode", "(", ")", ":", "\"Signal protocol should only be made on channel in serverMode\"", ";", "this", ".", "inboundProtocol", "=", "inboundProtocol", ";", "channel", ".", "outboundPipeline", "(", ")", ".", "wakeup", "(", ")", ";", "}" ]
Signals the ProtocolEncoder that the protocol is known. This call will be made by the ProtocolDecoder as soon as it knows the inbound protocol. @param inboundProtocol
[ "Signals", "the", "ProtocolEncoder", "that", "the", "protocol", "is", "known", ".", "This", "call", "will", "be", "made", "by", "the", "ProtocolDecoder", "as", "soon", "as", "it", "knows", "the", "inbound", "protocol", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/nio/tcp/UnifiedProtocolEncoder.java#L80-L84
15,431
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/eviction/ExpirationManager.java
ExpirationManager.scheduleExpirationTask
public void scheduleExpirationTask() { if (nodeEngine.getLocalMember().isLiteMember() || scheduled.get() || !scheduled.compareAndSet(false, true)) { return; } scheduledExpirationTask = globalTaskScheduler.scheduleWithRepetition(task, taskPeriodSeconds, taskPeriodSeconds, SECONDS); scheduledOneTime.set(true); }
java
public void scheduleExpirationTask() { if (nodeEngine.getLocalMember().isLiteMember() || scheduled.get() || !scheduled.compareAndSet(false, true)) { return; } scheduledExpirationTask = globalTaskScheduler.scheduleWithRepetition(task, taskPeriodSeconds, taskPeriodSeconds, SECONDS); scheduledOneTime.set(true); }
[ "public", "void", "scheduleExpirationTask", "(", ")", "{", "if", "(", "nodeEngine", ".", "getLocalMember", "(", ")", ".", "isLiteMember", "(", ")", "||", "scheduled", ".", "get", "(", ")", "||", "!", "scheduled", ".", "compareAndSet", "(", "false", ",", "true", ")", ")", "{", "return", ";", "}", "scheduledExpirationTask", "=", "globalTaskScheduler", ".", "scheduleWithRepetition", "(", "task", ",", "taskPeriodSeconds", ",", "taskPeriodSeconds", ",", "SECONDS", ")", ";", "scheduledOneTime", ".", "set", "(", "true", ")", ";", "}" ]
Starts scheduling of the task that clears expired entries. Calling this method multiple times has same effect.
[ "Starts", "scheduling", "of", "the", "task", "that", "clears", "expired", "entries", ".", "Calling", "this", "method", "multiple", "times", "has", "same", "effect", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/eviction/ExpirationManager.java#L85-L96
15,432
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/eviction/ExpirationManager.java
ExpirationManager.unscheduleExpirationTask
void unscheduleExpirationTask() { scheduled.set(false); ScheduledFuture<?> scheduledFuture = this.scheduledExpirationTask; if (scheduledFuture != null) { scheduledFuture.cancel(false); } }
java
void unscheduleExpirationTask() { scheduled.set(false); ScheduledFuture<?> scheduledFuture = this.scheduledExpirationTask; if (scheduledFuture != null) { scheduledFuture.cancel(false); } }
[ "void", "unscheduleExpirationTask", "(", ")", "{", "scheduled", ".", "set", "(", "false", ")", ";", "ScheduledFuture", "<", "?", ">", "scheduledFuture", "=", "this", ".", "scheduledExpirationTask", ";", "if", "(", "scheduledFuture", "!=", "null", ")", "{", "scheduledFuture", ".", "cancel", "(", "false", ")", ";", "}", "}" ]
Ends scheduling of the task that clears expired entries. Calling this method multiple times has same effect.
[ "Ends", "scheduling", "of", "the", "task", "that", "clears", "expired", "entries", ".", "Calling", "this", "method", "multiple", "times", "has", "same", "effect", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/eviction/ExpirationManager.java#L102-L108
15,433
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsUtil.java
LocalMapStatsUtil.incrementOtherOperationsCount
public static void incrementOtherOperationsCount(MapService service, String mapName) { MapServiceContext mapServiceContext = service.getMapServiceContext(); MapContainer mapContainer = mapServiceContext.getMapContainer(mapName); if (mapContainer.getMapConfig().isStatisticsEnabled()) { LocalMapStatsImpl localMapStats = mapServiceContext.getLocalMapStatsProvider().getLocalMapStatsImpl(mapName); localMapStats.incrementOtherOperations(); } }
java
public static void incrementOtherOperationsCount(MapService service, String mapName) { MapServiceContext mapServiceContext = service.getMapServiceContext(); MapContainer mapContainer = mapServiceContext.getMapContainer(mapName); if (mapContainer.getMapConfig().isStatisticsEnabled()) { LocalMapStatsImpl localMapStats = mapServiceContext.getLocalMapStatsProvider().getLocalMapStatsImpl(mapName); localMapStats.incrementOtherOperations(); } }
[ "public", "static", "void", "incrementOtherOperationsCount", "(", "MapService", "service", ",", "String", "mapName", ")", "{", "MapServiceContext", "mapServiceContext", "=", "service", ".", "getMapServiceContext", "(", ")", ";", "MapContainer", "mapContainer", "=", "mapServiceContext", ".", "getMapContainer", "(", "mapName", ")", ";", "if", "(", "mapContainer", ".", "getMapConfig", "(", ")", ".", "isStatisticsEnabled", "(", ")", ")", "{", "LocalMapStatsImpl", "localMapStats", "=", "mapServiceContext", ".", "getLocalMapStatsProvider", "(", ")", ".", "getLocalMapStatsImpl", "(", "mapName", ")", ";", "localMapStats", ".", "incrementOtherOperations", "(", ")", ";", "}", "}" ]
Increments other operations count statistic in local map statistics. @param service @param mapName
[ "Increments", "other", "operations", "count", "statistic", "in", "local", "map", "statistics", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsUtil.java#L35-L42
15,434
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/concurrent/lock/operations/UnlockIfLeaseExpiredOperation.java
UnlockIfLeaseExpiredOperation.shouldBackup
@Override public boolean shouldBackup() { NodeEngine nodeEngine = getNodeEngine(); IPartitionService partitionService = nodeEngine.getPartitionService(); Address thisAddress = nodeEngine.getThisAddress(); IPartition partition = partitionService.getPartition(getPartitionId()); if (!thisAddress.equals(partition.getOwnerOrNull())) { return false; } return super.shouldBackup(); }
java
@Override public boolean shouldBackup() { NodeEngine nodeEngine = getNodeEngine(); IPartitionService partitionService = nodeEngine.getPartitionService(); Address thisAddress = nodeEngine.getThisAddress(); IPartition partition = partitionService.getPartition(getPartitionId()); if (!thisAddress.equals(partition.getOwnerOrNull())) { return false; } return super.shouldBackup(); }
[ "@", "Override", "public", "boolean", "shouldBackup", "(", ")", "{", "NodeEngine", "nodeEngine", "=", "getNodeEngine", "(", ")", ";", "IPartitionService", "partitionService", "=", "nodeEngine", ".", "getPartitionService", "(", ")", ";", "Address", "thisAddress", "=", "nodeEngine", ".", "getThisAddress", "(", ")", ";", "IPartition", "partition", "=", "partitionService", ".", "getPartition", "(", "getPartitionId", "(", ")", ")", ";", "if", "(", "!", "thisAddress", ".", "equals", "(", "partition", ".", "getOwnerOrNull", "(", ")", ")", ")", "{", "return", "false", ";", "}", "return", "super", ".", "shouldBackup", "(", ")", ";", "}" ]
This operation runs on both primary and backup If it is running on backup we should not send a backup operation @return
[ "This", "operation", "runs", "on", "both", "primary", "and", "backup", "If", "it", "is", "running", "on", "backup", "we", "should", "not", "send", "a", "backup", "operation" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/concurrent/lock/operations/UnlockIfLeaseExpiredOperation.java#L70-L80
15,435
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferExpirationPolicy.java
RingbufferExpirationPolicy.cleanup
@SuppressWarnings("unchecked") void cleanup(Ringbuffer ringbuffer) { if (ringbuffer.headSequence() > ringbuffer.tailSequence()) { return; } long now = currentTimeMillis(); while (ringbuffer.headSequence() <= ringbuffer.tailSequence()) { final long headSequence = ringbuffer.headSequence(); if (ringExpirationMs[toIndex(headSequence)] > now) { return; } // we null the slot and allow the gc to take care of the object. // if we don't clean it, we'll have a potential memory leak. ringbuffer.set(headSequence, null); // we don't need to 0 the ringExpirationMs slot since it contains a long value. // and we move the head to the next item. // if nothing remains in the ringbuffer, then the head will be 1 larger than the tail. ringbuffer.setHeadSequence(ringbuffer.headSequence() + 1); } }
java
@SuppressWarnings("unchecked") void cleanup(Ringbuffer ringbuffer) { if (ringbuffer.headSequence() > ringbuffer.tailSequence()) { return; } long now = currentTimeMillis(); while (ringbuffer.headSequence() <= ringbuffer.tailSequence()) { final long headSequence = ringbuffer.headSequence(); if (ringExpirationMs[toIndex(headSequence)] > now) { return; } // we null the slot and allow the gc to take care of the object. // if we don't clean it, we'll have a potential memory leak. ringbuffer.set(headSequence, null); // we don't need to 0 the ringExpirationMs slot since it contains a long value. // and we move the head to the next item. // if nothing remains in the ringbuffer, then the head will be 1 larger than the tail. ringbuffer.setHeadSequence(ringbuffer.headSequence() + 1); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "void", "cleanup", "(", "Ringbuffer", "ringbuffer", ")", "{", "if", "(", "ringbuffer", ".", "headSequence", "(", ")", ">", "ringbuffer", ".", "tailSequence", "(", ")", ")", "{", "return", ";", "}", "long", "now", "=", "currentTimeMillis", "(", ")", ";", "while", "(", "ringbuffer", ".", "headSequence", "(", ")", "<=", "ringbuffer", ".", "tailSequence", "(", ")", ")", "{", "final", "long", "headSequence", "=", "ringbuffer", ".", "headSequence", "(", ")", ";", "if", "(", "ringExpirationMs", "[", "toIndex", "(", "headSequence", ")", "]", ">", "now", ")", "{", "return", ";", "}", "// we null the slot and allow the gc to take care of the object.", "// if we don't clean it, we'll have a potential memory leak.", "ringbuffer", ".", "set", "(", "headSequence", ",", "null", ")", ";", "// we don't need to 0 the ringExpirationMs slot since it contains a long value.", "// and we move the head to the next item.", "// if nothing remains in the ringbuffer, then the head will be 1 larger than the tail.", "ringbuffer", ".", "setHeadSequence", "(", "ringbuffer", ".", "headSequence", "(", ")", "+", "1", ")", ";", "}", "}" ]
Cleans up the ringbuffer by deleting all expired items.
[ "Cleans", "up", "the", "ringbuffer", "by", "deleting", "all", "expired", "items", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferExpirationPolicy.java#L40-L64
15,436
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/crdt/pncounter/operations/AddOperation.java
AddOperation.updateStatistics
private void updateStatistics() { final PNCounterService service = getService(); final LocalPNCounterStatsImpl stats = service.getLocalPNCounterStats(name); if (delta > 0) { stats.incrementIncrementOperationCount(); } else if (delta < 0) { stats.incrementDecrementOperationCount(); } stats.setValue(getBeforeUpdate ? (response.getValue() + delta) : response.getValue()); }
java
private void updateStatistics() { final PNCounterService service = getService(); final LocalPNCounterStatsImpl stats = service.getLocalPNCounterStats(name); if (delta > 0) { stats.incrementIncrementOperationCount(); } else if (delta < 0) { stats.incrementDecrementOperationCount(); } stats.setValue(getBeforeUpdate ? (response.getValue() + delta) : response.getValue()); }
[ "private", "void", "updateStatistics", "(", ")", "{", "final", "PNCounterService", "service", "=", "getService", "(", ")", ";", "final", "LocalPNCounterStatsImpl", "stats", "=", "service", ".", "getLocalPNCounterStats", "(", "name", ")", ";", "if", "(", "delta", ">", "0", ")", "{", "stats", ".", "incrementIncrementOperationCount", "(", ")", ";", "}", "else", "if", "(", "delta", "<", "0", ")", "{", "stats", ".", "incrementDecrementOperationCount", "(", ")", ";", "}", "stats", ".", "setValue", "(", "getBeforeUpdate", "?", "(", "response", ".", "getValue", "(", ")", "+", "delta", ")", ":", "response", ".", "getValue", "(", ")", ")", ";", "}" ]
Updates the local PN counter statistics
[ "Updates", "the", "local", "PN", "counter", "statistics" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/crdt/pncounter/operations/AddOperation.java#L73-L82
15,437
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/preloader/NearCachePreloader.java
NearCachePreloader.storeKeys
public void storeKeys(Iterator<K> iterator) { long startedNanos = System.nanoTime(); FileOutputStream fos = null; try { buf = allocate(BUFFER_SIZE); lastWrittenBytes = 0; lastKeyCount = 0; fos = new FileOutputStream(tmpStoreFile, false); // write header and keys writeInt(fos, MAGIC_BYTES); writeInt(fos, FileFormat.INTERLEAVED_LENGTH_FIELD.ordinal()); writeKeySet(fos, fos.getChannel(), iterator); // cleanup if no keys have been written if (lastKeyCount == 0) { deleteQuietly(storeFile); updatePersistenceStats(startedNanos); return; } fos.flush(); closeResource(fos); rename(tmpStoreFile, storeFile); updatePersistenceStats(startedNanos); } catch (Exception e) { logger.warning(format("Could not store keys of Near Cache %s (%s)", nearCacheName, storeFile.getAbsolutePath()), e); nearCacheStats.addPersistenceFailure(e); } finally { closeResource(fos); deleteQuietly(tmpStoreFile); } }
java
public void storeKeys(Iterator<K> iterator) { long startedNanos = System.nanoTime(); FileOutputStream fos = null; try { buf = allocate(BUFFER_SIZE); lastWrittenBytes = 0; lastKeyCount = 0; fos = new FileOutputStream(tmpStoreFile, false); // write header and keys writeInt(fos, MAGIC_BYTES); writeInt(fos, FileFormat.INTERLEAVED_LENGTH_FIELD.ordinal()); writeKeySet(fos, fos.getChannel(), iterator); // cleanup if no keys have been written if (lastKeyCount == 0) { deleteQuietly(storeFile); updatePersistenceStats(startedNanos); return; } fos.flush(); closeResource(fos); rename(tmpStoreFile, storeFile); updatePersistenceStats(startedNanos); } catch (Exception e) { logger.warning(format("Could not store keys of Near Cache %s (%s)", nearCacheName, storeFile.getAbsolutePath()), e); nearCacheStats.addPersistenceFailure(e); } finally { closeResource(fos); deleteQuietly(tmpStoreFile); } }
[ "public", "void", "storeKeys", "(", "Iterator", "<", "K", ">", "iterator", ")", "{", "long", "startedNanos", "=", "System", ".", "nanoTime", "(", ")", ";", "FileOutputStream", "fos", "=", "null", ";", "try", "{", "buf", "=", "allocate", "(", "BUFFER_SIZE", ")", ";", "lastWrittenBytes", "=", "0", ";", "lastKeyCount", "=", "0", ";", "fos", "=", "new", "FileOutputStream", "(", "tmpStoreFile", ",", "false", ")", ";", "// write header and keys", "writeInt", "(", "fos", ",", "MAGIC_BYTES", ")", ";", "writeInt", "(", "fos", ",", "FileFormat", ".", "INTERLEAVED_LENGTH_FIELD", ".", "ordinal", "(", ")", ")", ";", "writeKeySet", "(", "fos", ",", "fos", ".", "getChannel", "(", ")", ",", "iterator", ")", ";", "// cleanup if no keys have been written", "if", "(", "lastKeyCount", "==", "0", ")", "{", "deleteQuietly", "(", "storeFile", ")", ";", "updatePersistenceStats", "(", "startedNanos", ")", ";", "return", ";", "}", "fos", ".", "flush", "(", ")", ";", "closeResource", "(", "fos", ")", ";", "rename", "(", "tmpStoreFile", ",", "storeFile", ")", ";", "updatePersistenceStats", "(", "startedNanos", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warning", "(", "format", "(", "\"Could not store keys of Near Cache %s (%s)\"", ",", "nearCacheName", ",", "storeFile", ".", "getAbsolutePath", "(", ")", ")", ",", "e", ")", ";", "nearCacheStats", ".", "addPersistenceFailure", "(", "e", ")", ";", "}", "finally", "{", "closeResource", "(", "fos", ")", ";", "deleteQuietly", "(", "tmpStoreFile", ")", ";", "}", "}" ]
Stores the Near Cache keys from the supplied iterator. @param iterator {@link Iterator} over the key set of a {@link com.hazelcast.internal.nearcache.NearCacheRecordStore}
[ "Stores", "the", "Near", "Cache", "keys", "from", "the", "supplied", "iterator", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/preloader/NearCachePreloader.java#L169-L204
15,438
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/util/InvocationUtil.java
InvocationUtil.invokeOnStableClusterSerial
public static ICompletableFuture<Object> invokeOnStableClusterSerial(NodeEngine nodeEngine, Supplier<? extends Operation> operationSupplier, int maxRetries) { ClusterService clusterService = nodeEngine.getClusterService(); if (!clusterService.isJoined()) { return new CompletedFuture<Object>(null, null, new CallerRunsExecutor()); } RestartingMemberIterator memberIterator = new RestartingMemberIterator(clusterService, maxRetries); // we are going to iterate over all members and invoke an operation on each of them InvokeOnMemberFunction invokeOnMemberFunction = new InvokeOnMemberFunction(operationSupplier, nodeEngine, memberIterator); Iterator<ICompletableFuture<Object>> invocationIterator = map(memberIterator, invokeOnMemberFunction); ILogger logger = nodeEngine.getLogger(ChainingFuture.class); ExecutionService executionService = nodeEngine.getExecutionService(); ManagedExecutorService executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR); // ChainingFuture uses the iterator to start invocations // it invokes on another member only when the previous invocation is completed (so invocations are serial) // the future itself completes only when the last invocation completes (or if there is an error) return new ChainingFuture<Object>(invocationIterator, executor, memberIterator, logger); }
java
public static ICompletableFuture<Object> invokeOnStableClusterSerial(NodeEngine nodeEngine, Supplier<? extends Operation> operationSupplier, int maxRetries) { ClusterService clusterService = nodeEngine.getClusterService(); if (!clusterService.isJoined()) { return new CompletedFuture<Object>(null, null, new CallerRunsExecutor()); } RestartingMemberIterator memberIterator = new RestartingMemberIterator(clusterService, maxRetries); // we are going to iterate over all members and invoke an operation on each of them InvokeOnMemberFunction invokeOnMemberFunction = new InvokeOnMemberFunction(operationSupplier, nodeEngine, memberIterator); Iterator<ICompletableFuture<Object>> invocationIterator = map(memberIterator, invokeOnMemberFunction); ILogger logger = nodeEngine.getLogger(ChainingFuture.class); ExecutionService executionService = nodeEngine.getExecutionService(); ManagedExecutorService executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR); // ChainingFuture uses the iterator to start invocations // it invokes on another member only when the previous invocation is completed (so invocations are serial) // the future itself completes only when the last invocation completes (or if there is an error) return new ChainingFuture<Object>(invocationIterator, executor, memberIterator, logger); }
[ "public", "static", "ICompletableFuture", "<", "Object", ">", "invokeOnStableClusterSerial", "(", "NodeEngine", "nodeEngine", ",", "Supplier", "<", "?", "extends", "Operation", ">", "operationSupplier", ",", "int", "maxRetries", ")", "{", "ClusterService", "clusterService", "=", "nodeEngine", ".", "getClusterService", "(", ")", ";", "if", "(", "!", "clusterService", ".", "isJoined", "(", ")", ")", "{", "return", "new", "CompletedFuture", "<", "Object", ">", "(", "null", ",", "null", ",", "new", "CallerRunsExecutor", "(", ")", ")", ";", "}", "RestartingMemberIterator", "memberIterator", "=", "new", "RestartingMemberIterator", "(", "clusterService", ",", "maxRetries", ")", ";", "// we are going to iterate over all members and invoke an operation on each of them", "InvokeOnMemberFunction", "invokeOnMemberFunction", "=", "new", "InvokeOnMemberFunction", "(", "operationSupplier", ",", "nodeEngine", ",", "memberIterator", ")", ";", "Iterator", "<", "ICompletableFuture", "<", "Object", ">", ">", "invocationIterator", "=", "map", "(", "memberIterator", ",", "invokeOnMemberFunction", ")", ";", "ILogger", "logger", "=", "nodeEngine", ".", "getLogger", "(", "ChainingFuture", ".", "class", ")", ";", "ExecutionService", "executionService", "=", "nodeEngine", ".", "getExecutionService", "(", ")", ";", "ManagedExecutorService", "executor", "=", "executionService", ".", "getExecutor", "(", "ExecutionService", ".", "ASYNC_EXECUTOR", ")", ";", "// ChainingFuture uses the iterator to start invocations", "// it invokes on another member only when the previous invocation is completed (so invocations are serial)", "// the future itself completes only when the last invocation completes (or if there is an error)", "return", "new", "ChainingFuture", "<", "Object", ">", "(", "invocationIterator", ",", "executor", ",", "memberIterator", ",", "logger", ")", ";", "}" ]
Invoke operation on all cluster members. The invocation is serial: It iterates over all members starting from the oldest member to the youngest one. If there is a cluster membership change while invoking then it will restart invocations on all members. This implies the operation should be idempotent. If there is an exception - other than {@link com.hazelcast.core.MemberLeftException} or {@link com.hazelcast.spi.exception.TargetNotMemberException} while invoking then the iteration is interrupted and the exception is propagated to the caller.
[ "Invoke", "operation", "on", "all", "cluster", "members", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/InvocationUtil.java#L63-L87
15,439
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/SubscriberAccumulator.java
SubscriberAccumulator.isApplicable
private boolean isApplicable(QueryCacheEventData event) { if (!getInfo().isPublishable()) { return false; } final int partitionId = event.getPartitionId(); if (isEndEvent(event)) { sequenceProvider.reset(partitionId); removeFromBrokenSequences(event); return false; } if (isNextEvent(event)) { long currentSequence = sequenceProvider.getSequence(partitionId); sequenceProvider.compareAndSetSequence(currentSequence, event.getSequence(), partitionId); removeFromBrokenSequences(event); return true; } handleUnexpectedEvent(event); return false; }
java
private boolean isApplicable(QueryCacheEventData event) { if (!getInfo().isPublishable()) { return false; } final int partitionId = event.getPartitionId(); if (isEndEvent(event)) { sequenceProvider.reset(partitionId); removeFromBrokenSequences(event); return false; } if (isNextEvent(event)) { long currentSequence = sequenceProvider.getSequence(partitionId); sequenceProvider.compareAndSetSequence(currentSequence, event.getSequence(), partitionId); removeFromBrokenSequences(event); return true; } handleUnexpectedEvent(event); return false; }
[ "private", "boolean", "isApplicable", "(", "QueryCacheEventData", "event", ")", "{", "if", "(", "!", "getInfo", "(", ")", ".", "isPublishable", "(", ")", ")", "{", "return", "false", ";", "}", "final", "int", "partitionId", "=", "event", ".", "getPartitionId", "(", ")", ";", "if", "(", "isEndEvent", "(", "event", ")", ")", "{", "sequenceProvider", ".", "reset", "(", "partitionId", ")", ";", "removeFromBrokenSequences", "(", "event", ")", ";", "return", "false", ";", "}", "if", "(", "isNextEvent", "(", "event", ")", ")", "{", "long", "currentSequence", "=", "sequenceProvider", ".", "getSequence", "(", "partitionId", ")", ";", "sequenceProvider", ".", "compareAndSetSequence", "(", "currentSequence", ",", "event", ".", "getSequence", "(", ")", ",", "partitionId", ")", ";", "removeFromBrokenSequences", "(", "event", ")", ";", "return", "true", ";", "}", "handleUnexpectedEvent", "(", "event", ")", ";", "return", "false", ";", "}" ]
Checks whether the event data is applicable to the query cache.
[ "Checks", "whether", "the", "event", "data", "is", "applicable", "to", "the", "query", "cache", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/SubscriberAccumulator.java#L77-L101
15,440
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/PartitionStateManager.java
PartitionStateManager.removeUnknownMembers
void removeUnknownMembers() { ClusterServiceImpl clusterService = node.getClusterService(); for (InternalPartitionImpl partition : partitions) { for (int i = 0; i < InternalPartition.MAX_REPLICA_COUNT; i++) { PartitionReplica replica = partition.getReplica(i); if (replica == null) { continue; } if (clusterService.getMember(replica.address(), replica.uuid()) == null) { partition.setReplica(i, null); if (logger.isFinestEnabled()) { logger.finest("PartitionId=" + partition.getPartitionId() + " " + replica + " is removed from replica index: " + i + ", partition: " + partition); } } } } }
java
void removeUnknownMembers() { ClusterServiceImpl clusterService = node.getClusterService(); for (InternalPartitionImpl partition : partitions) { for (int i = 0; i < InternalPartition.MAX_REPLICA_COUNT; i++) { PartitionReplica replica = partition.getReplica(i); if (replica == null) { continue; } if (clusterService.getMember(replica.address(), replica.uuid()) == null) { partition.setReplica(i, null); if (logger.isFinestEnabled()) { logger.finest("PartitionId=" + partition.getPartitionId() + " " + replica + " is removed from replica index: " + i + ", partition: " + partition); } } } } }
[ "void", "removeUnknownMembers", "(", ")", "{", "ClusterServiceImpl", "clusterService", "=", "node", ".", "getClusterService", "(", ")", ";", "for", "(", "InternalPartitionImpl", "partition", ":", "partitions", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "InternalPartition", ".", "MAX_REPLICA_COUNT", ";", "i", "++", ")", "{", "PartitionReplica", "replica", "=", "partition", ".", "getReplica", "(", "i", ")", ";", "if", "(", "replica", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "clusterService", ".", "getMember", "(", "replica", ".", "address", "(", ")", ",", "replica", ".", "uuid", "(", ")", ")", "==", "null", ")", "{", "partition", ".", "setReplica", "(", "i", ",", "null", ")", ";", "if", "(", "logger", ".", "isFinestEnabled", "(", ")", ")", "{", "logger", ".", "finest", "(", "\"PartitionId=\"", "+", "partition", ".", "getPartitionId", "(", ")", "+", "\" \"", "+", "replica", "+", "\" is removed from replica index: \"", "+", "i", "+", "\", partition: \"", "+", "partition", ")", ";", "}", "}", "}", "}", "}" ]
Checks all replicas for all partitions. If the cluster service does not contain the member for any address in the partition table, it will remove the address from the partition. @see ClusterService#getMember(com.hazelcast.nio.Address, String)
[ "Checks", "all", "replicas", "for", "all", "partitions", ".", "If", "the", "cluster", "service", "does", "not", "contain", "the", "member", "for", "any", "address", "in", "the", "partition", "table", "it", "will", "remove", "the", "address", "from", "the", "partition", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/PartitionStateManager.java#L246-L265
15,441
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/partition/impl/PartitionStateManager.java
PartitionStateManager.getPartitionsCopy
public InternalPartition[] getPartitionsCopy() { NopPartitionListener listener = new NopPartitionListener(); InternalPartition[] result = new InternalPartition[partitions.length]; for (int i = 0; i < partitionCount; i++) { result[i] = partitions[i].copy(listener); } return result; }
java
public InternalPartition[] getPartitionsCopy() { NopPartitionListener listener = new NopPartitionListener(); InternalPartition[] result = new InternalPartition[partitions.length]; for (int i = 0; i < partitionCount; i++) { result[i] = partitions[i].copy(listener); } return result; }
[ "public", "InternalPartition", "[", "]", "getPartitionsCopy", "(", ")", "{", "NopPartitionListener", "listener", "=", "new", "NopPartitionListener", "(", ")", ";", "InternalPartition", "[", "]", "result", "=", "new", "InternalPartition", "[", "partitions", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "partitionCount", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "partitions", "[", "i", "]", ".", "copy", "(", "listener", ")", ";", "}", "return", "result", ";", "}" ]
Returns a copy of the current partition table.
[ "Returns", "a", "copy", "of", "the", "current", "partition", "table", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/PartitionStateManager.java#L282-L289
15,442
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/ExceptionUtil.java
ExceptionUtil.rethrowAllowedTypeFirst
public static <T extends Throwable> RuntimeException rethrowAllowedTypeFirst(final Throwable t, Class<T> allowedType) throws T { rethrowIfError(t); if (allowedType.isAssignableFrom(t.getClass())) { throw (T) t; } else { throw peel(t); } }
java
public static <T extends Throwable> RuntimeException rethrowAllowedTypeFirst(final Throwable t, Class<T> allowedType) throws T { rethrowIfError(t); if (allowedType.isAssignableFrom(t.getClass())) { throw (T) t; } else { throw peel(t); } }
[ "public", "static", "<", "T", "extends", "Throwable", ">", "RuntimeException", "rethrowAllowedTypeFirst", "(", "final", "Throwable", "t", ",", "Class", "<", "T", ">", "allowedType", ")", "throws", "T", "{", "rethrowIfError", "(", "t", ")", ";", "if", "(", "allowedType", ".", "isAssignableFrom", "(", "t", ".", "getClass", "(", ")", ")", ")", "{", "throw", "(", "T", ")", "t", ";", "}", "else", "{", "throw", "peel", "(", "t", ")", ";", "}", "}" ]
This rethrow the exception providing an allowed Exception in first priority, even it is a Runtime exception
[ "This", "rethrow", "the", "exception", "providing", "an", "allowed", "Exception", "in", "first", "priority", "even", "it", "is", "a", "Runtime", "exception" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ExceptionUtil.java#L145-L153
15,443
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/config/SerializerConfig.java
SerializerConfig.setClass
public SerializerConfig setClass(final Class<? extends Serializer> clazz) { String className = clazz == null ? null : clazz.getName(); return setClassName(className); }
java
public SerializerConfig setClass(final Class<? extends Serializer> clazz) { String className = clazz == null ? null : clazz.getName(); return setClassName(className); }
[ "public", "SerializerConfig", "setClass", "(", "final", "Class", "<", "?", "extends", "Serializer", ">", "clazz", ")", "{", "String", "className", "=", "clazz", "==", "null", "?", "null", ":", "clazz", ".", "getName", "(", ")", ";", "return", "setClassName", "(", "className", ")", ";", "}" ]
Sets the class of the serializer implementation. @param clazz the set class of the serializer implementation @return SerializerConfig
[ "Sets", "the", "class", "of", "the", "serializer", "implementation", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/SerializerConfig.java#L59-L62
15,444
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/CyclicWriteBehindQueue.java
CyclicWriteBehindQueue.contains
@Override public boolean contains(DelayedEntry entry) { Data key = (Data) entry.getKey(); return index.containsKey(key); }
java
@Override public boolean contains(DelayedEntry entry) { Data key = (Data) entry.getKey(); return index.containsKey(key); }
[ "@", "Override", "public", "boolean", "contains", "(", "DelayedEntry", "entry", ")", "{", "Data", "key", "=", "(", "Data", ")", "entry", ".", "getKey", "(", ")", ";", "return", "index", ".", "containsKey", "(", "key", ")", ";", "}" ]
Checks whether an item exist in queue or not. @param entry item to be checked @return <code>true</code> if exists, <code>false</code> otherwise
[ "Checks", "whether", "an", "item", "exist", "in", "queue", "or", "not", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/CyclicWriteBehindQueue.java#L109-L113
15,445
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/CyclicWriteBehindQueue.java
CyclicWriteBehindQueue.drainTo
@Override public int drainTo(Collection<DelayedEntry> collection) { checkNotNull(collection, "collection can not be null"); Iterator<DelayedEntry> iterator = deque.iterator(); while (iterator.hasNext()) { DelayedEntry e = iterator.next(); collection.add(e); iterator.remove(); } resetCountIndex(); return collection.size(); }
java
@Override public int drainTo(Collection<DelayedEntry> collection) { checkNotNull(collection, "collection can not be null"); Iterator<DelayedEntry> iterator = deque.iterator(); while (iterator.hasNext()) { DelayedEntry e = iterator.next(); collection.add(e); iterator.remove(); } resetCountIndex(); return collection.size(); }
[ "@", "Override", "public", "int", "drainTo", "(", "Collection", "<", "DelayedEntry", ">", "collection", ")", "{", "checkNotNull", "(", "collection", ",", "\"collection can not be null\"", ")", ";", "Iterator", "<", "DelayedEntry", ">", "iterator", "=", "deque", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "DelayedEntry", "e", "=", "iterator", ".", "next", "(", ")", ";", "collection", ".", "add", "(", "e", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "resetCountIndex", "(", ")", ";", "return", "collection", ".", "size", "(", ")", ";", "}" ]
Removes all available elements from this queue and adds them to the given collection. @param collection all elements to be added to this collection. @return number of removed items from this queue.
[ "Removes", "all", "available", "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/CyclicWriteBehindQueue.java#L133-L145
15,446
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getInt
public static int getInt(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asInt(); }
java
public static int getInt(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asInt(); }
[ "public", "static", "int", "getInt", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asInt", "(", ")", ";", "}" ]
Returns a field in a Json object as an int. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as an int
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "int", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L45-L49
15,447
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getInt
public static int getInt(JsonObject object, String field, int defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asInt(); } }
java
public static int getInt(JsonObject object, String field, int defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asInt(); } }
[ "public", "static", "int", "getInt", "(", "JsonObject", "object", ",", "String", "field", ",", "int", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asInt", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as an int. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as an int
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "int", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L59-L66
15,448
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getLong
public static long getLong(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asLong(); }
java
public static long getLong(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asLong(); }
[ "public", "static", "long", "getLong", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asLong", "(", ")", ";", "}" ]
Returns a field in a Json object as a long. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as a long
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "long", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L76-L80
15,449
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getLong
public static long getLong(JsonObject object, String field, long defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asLong(); } }
java
public static long getLong(JsonObject object, String field, long defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asLong(); } }
[ "public", "static", "long", "getLong", "(", "JsonObject", "object", ",", "String", "field", ",", "long", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asLong", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as a long. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a long
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "long", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L90-L97
15,450
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getDouble
public static double getDouble(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asDouble(); }
java
public static double getDouble(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asDouble(); }
[ "public", "static", "double", "getDouble", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asDouble", "(", ")", ";", "}" ]
Returns a field in a Json object as a double. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as a double
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "double", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L107-L111
15,451
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getDouble
public static double getDouble(JsonObject object, String field, double defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asDouble(); } }
java
public static double getDouble(JsonObject object, String field, double defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asDouble(); } }
[ "public", "static", "double", "getDouble", "(", "JsonObject", "object", ",", "String", "field", ",", "double", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asDouble", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as a double. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a double
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "double", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L120-L127
15,452
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getFloat
public static float getFloat(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asFloat(); }
java
public static float getFloat(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asFloat(); }
[ "public", "static", "float", "getFloat", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asFloat", "(", ")", ";", "}" ]
Returns a field in a Json object as a float. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as a float
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "float", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L137-L141
15,453
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getFloat
public static float getFloat(JsonObject object, String field, float defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asFloat(); } }
java
public static float getFloat(JsonObject object, String field, float defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asFloat(); } }
[ "public", "static", "float", "getFloat", "(", "JsonObject", "object", ",", "String", "field", ",", "float", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asFloat", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as a float. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a float
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "float", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L151-L158
15,454
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getString
public static String getString(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asString(); }
java
public static String getString(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asString(); }
[ "public", "static", "String", "getString", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asString", "(", ")", ";", "}" ]
Returns a field in a Json object as a string. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as a string
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "string", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L168-L172
15,455
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getString
public static String getString(JsonObject object, String field, String defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asString(); } }
java
public static String getString(JsonObject object, String field, String defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asString(); } }
[ "public", "static", "String", "getString", "(", "JsonObject", "object", ",", "String", "field", ",", "String", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asString", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as a string. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a string
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "string", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L182-L189
15,456
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getBoolean
public static boolean getBoolean(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asBoolean(); }
java
public static boolean getBoolean(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asBoolean(); }
[ "public", "static", "boolean", "getBoolean", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asBoolean", "(", ")", ";", "}" ]
Returns a field in a Json object as a boolean. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as a boolean
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "boolean", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L199-L203
15,457
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getBoolean
public static boolean getBoolean(JsonObject object, String field, boolean defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asBoolean(); } }
java
public static boolean getBoolean(JsonObject object, String field, boolean defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asBoolean(); } }
[ "public", "static", "boolean", "getBoolean", "(", "JsonObject", "object", ",", "String", "field", ",", "boolean", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asBoolean", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as a boolean. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a boolean
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "a", "boolean", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L213-L220
15,458
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getArray
public static JsonArray getArray(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asArray(); }
java
public static JsonArray getArray(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asArray(); }
[ "public", "static", "JsonArray", "getArray", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asArray", "(", ")", ";", "}" ]
Returns a field in a Json object as an array. Throws IllegalArgumentException if the field value is null. @param object the Json Object @param field the field in the Json object to return @return the Json field value as an array
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "array", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L230-L234
15,459
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getArray
public static JsonArray getArray(JsonObject object, String field, JsonArray defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asArray(); } }
java
public static JsonArray getArray(JsonObject object, String field, JsonArray defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asArray(); } }
[ "public", "static", "JsonArray", "getArray", "(", "JsonObject", "object", ",", "String", "field", ",", "JsonArray", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asArray", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as an array. @param object the Json Object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a Json array
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "array", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L244-L251
15,460
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getObject
public static JsonObject getObject(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asObject(); }
java
public static JsonObject getObject(JsonObject object, String field) { final JsonValue value = object.get(field); throwExceptionIfNull(value, field); return value.asObject(); }
[ "public", "static", "JsonObject", "getObject", "(", "JsonObject", "object", ",", "String", "field", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "throwExceptionIfNull", "(", "value", ",", "field", ")", ";", "return", "value", ".", "asObject", "(", ")", ";", "}" ]
Returns a field in a Json object as an object. Throws IllegalArgumentException if the field value is null. @param object the Json object @param field the field in the Json object to return @return the Json field value as a Json object
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "object", ".", "Throws", "IllegalArgumentException", "if", "the", "field", "value", "is", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L261-L265
15,461
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.getObject
public static JsonObject getObject(JsonObject object, String field, JsonObject defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asObject(); } }
java
public static JsonObject getObject(JsonObject object, String field, JsonObject defaultValue) { final JsonValue value = object.get(field); if (value == null || value.isNull()) { return defaultValue; } else { return value.asObject(); } }
[ "public", "static", "JsonObject", "getObject", "(", "JsonObject", "object", ",", "String", "field", ",", "JsonObject", "defaultValue", ")", "{", "final", "JsonValue", "value", "=", "object", ".", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "isNull", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "value", ".", "asObject", "(", ")", ";", "}", "}" ]
Returns a field in a Json object as an object. @param object the Json object @param field the field in the Json object to return @param defaultValue a default value for the field if the field value is null @return the Json field value as a Json object
[ "Returns", "a", "field", "in", "a", "Json", "object", "as", "an", "object", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L275-L282
15,462
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
JsonUtil.toJsonCollection
private static String toJsonCollection(Collection objects) { Iterator iterator = objects.iterator(); if (!iterator.hasNext()) { return ""; } final Object first = iterator.next(); if (!iterator.hasNext()) { return toJson(first); } final StringBuilder buf = new StringBuilder(); if (first != null) { buf.append(toJson(first)); } while (iterator.hasNext()) { buf.append(','); final Object obj = iterator.next(); if (obj != null) { buf.append(toJson(obj)); } } return buf.toString(); }
java
private static String toJsonCollection(Collection objects) { Iterator iterator = objects.iterator(); if (!iterator.hasNext()) { return ""; } final Object first = iterator.next(); if (!iterator.hasNext()) { return toJson(first); } final StringBuilder buf = new StringBuilder(); if (first != null) { buf.append(toJson(first)); } while (iterator.hasNext()) { buf.append(','); final Object obj = iterator.next(); if (obj != null) { buf.append(toJson(obj)); } } return buf.toString(); }
[ "private", "static", "String", "toJsonCollection", "(", "Collection", "objects", ")", "{", "Iterator", "iterator", "=", "objects", ".", "iterator", "(", ")", ";", "if", "(", "!", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "\"\"", ";", "}", "final", "Object", "first", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "toJson", "(", "first", ")", ";", "}", "final", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "first", "!=", "null", ")", "{", "buf", ".", "append", "(", "toJson", "(", "first", ")", ")", ";", "}", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "final", "Object", "obj", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "obj", "!=", "null", ")", "{", "buf", ".", "append", "(", "toJson", "(", "obj", ")", ")", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Serializes a collection of objects into its JSON representation. @param objects collection of items to be serialized into JSON @return the serialized JSON
[ "Serializes", "a", "collection", "of", "objects", "into", "its", "JSON", "representation", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L346-L369
15,463
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/spi/blocking/ResourceRegistry.java
ResourceRegistry.getWaitTimeouts
public final Map<Tuple2<String, UUID>, Tuple2<Long, Long>> getWaitTimeouts() { return unmodifiableMap(waitTimeouts); }
java
public final Map<Tuple2<String, UUID>, Tuple2<Long, Long>> getWaitTimeouts() { return unmodifiableMap(waitTimeouts); }
[ "public", "final", "Map", "<", "Tuple2", "<", "String", ",", "UUID", ">", ",", "Tuple2", "<", "Long", ",", "Long", ">", ">", "getWaitTimeouts", "(", ")", "{", "return", "unmodifiableMap", "(", "waitTimeouts", ")", ";", "}" ]
queried locally in tests
[ "queried", "locally", "in", "tests" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/spi/blocking/ResourceRegistry.java#L203-L205
15,464
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.init
public void init(RingbufferConfig config, NodeEngine nodeEngine) { this.config = config; this.serializationService = nodeEngine.getSerializationService(); initRingbufferStore(nodeEngine.getConfigClassLoader()); }
java
public void init(RingbufferConfig config, NodeEngine nodeEngine) { this.config = config; this.serializationService = nodeEngine.getSerializationService(); initRingbufferStore(nodeEngine.getConfigClassLoader()); }
[ "public", "void", "init", "(", "RingbufferConfig", "config", ",", "NodeEngine", "nodeEngine", ")", "{", "this", ".", "config", "=", "config", ";", "this", ".", "serializationService", "=", "nodeEngine", ".", "getSerializationService", "(", ")", ";", "initRingbufferStore", "(", "nodeEngine", ".", "getConfigClassLoader", "(", ")", ")", ";", "}" ]
Initializes the ring buffer with references to other services, the ringbuffer store and the config. This is because on a replication operation the container is only partially constructed. The init method finishes the configuration of the ring buffer container for further usage. @param config the configuration of the ring buffer @param nodeEngine the NodeEngine
[ "Initializes", "the", "ring", "buffer", "with", "references", "to", "other", "services", "the", "ringbuffer", "store", "and", "the", "config", ".", "This", "is", "because", "on", "a", "replication", "operation", "the", "container", "is", "only", "partially", "constructed", ".", "The", "init", "method", "finishes", "the", "configuration", "of", "the", "ring", "buffer", "container", "for", "further", "usage", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L141-L145
15,465
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.addAll
public long addAll(T[] items) { long firstSequence = ringbuffer.peekNextTailSequence(); long lastSequence = ringbuffer.peekNextTailSequence(); if (store.isEnabled() && items.length != 0) { try { store.storeAll(firstSequence, convertToData(items)); } catch (Exception e) { throw new HazelcastException(e); } } for (int i = 0; i < items.length; i++) { lastSequence = addInternal(items[i]); } return lastSequence; }
java
public long addAll(T[] items) { long firstSequence = ringbuffer.peekNextTailSequence(); long lastSequence = ringbuffer.peekNextTailSequence(); if (store.isEnabled() && items.length != 0) { try { store.storeAll(firstSequence, convertToData(items)); } catch (Exception e) { throw new HazelcastException(e); } } for (int i = 0; i < items.length; i++) { lastSequence = addInternal(items[i]); } return lastSequence; }
[ "public", "long", "addAll", "(", "T", "[", "]", "items", ")", "{", "long", "firstSequence", "=", "ringbuffer", ".", "peekNextTailSequence", "(", ")", ";", "long", "lastSequence", "=", "ringbuffer", ".", "peekNextTailSequence", "(", ")", ";", "if", "(", "store", ".", "isEnabled", "(", ")", "&&", "items", ".", "length", "!=", "0", ")", "{", "try", "{", "store", ".", "storeAll", "(", "firstSequence", ",", "convertToData", "(", "items", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "HazelcastException", "(", "e", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "lastSequence", "=", "addInternal", "(", "items", "[", "i", "]", ")", ";", "}", "return", "lastSequence", ";", "}" ]
Adds all items to the ringbuffer. Sets the expiration time if TTL is configured and also attempts to store the items in the data store if one is configured. @param items items to be stored in the ring buffer and data store @return the sequence ID of the last item stored in the ring buffer @throws HazelcastException if there was any exception thrown by the data store @throws HazelcastSerializationException if the ring buffer is configured to keep items in object format and the item could not be deserialized
[ "Adds", "all", "items", "to", "the", "ringbuffer", ".", "Sets", "the", "expiration", "time", "if", "TTL", "is", "configured", "and", "also", "attempts", "to", "store", "the", "items", "in", "the", "data", "store", "if", "one", "is", "configured", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L321-L337
15,466
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.set
@SuppressWarnings("unchecked") public void set(long sequenceId, T item) { final E rbItem = convertToRingbufferFormat(item); // first we write the dataItem in the ring. ringbuffer.set(sequenceId, rbItem); if (sequenceId > tailSequence()) { ringbuffer.setTailSequence(sequenceId); if (ringbuffer.size() > ringbuffer.getCapacity()) { ringbuffer.setHeadSequence(ringbuffer.tailSequence() - ringbuffer.getCapacity() + 1); } } if (sequenceId < headSequence()) { ringbuffer.setHeadSequence(sequenceId); } // and then we optionally write the expiration. if (expirationPolicy != null) { expirationPolicy.setExpirationAt(sequenceId); } }
java
@SuppressWarnings("unchecked") public void set(long sequenceId, T item) { final E rbItem = convertToRingbufferFormat(item); // first we write the dataItem in the ring. ringbuffer.set(sequenceId, rbItem); if (sequenceId > tailSequence()) { ringbuffer.setTailSequence(sequenceId); if (ringbuffer.size() > ringbuffer.getCapacity()) { ringbuffer.setHeadSequence(ringbuffer.tailSequence() - ringbuffer.getCapacity() + 1); } } if (sequenceId < headSequence()) { ringbuffer.setHeadSequence(sequenceId); } // and then we optionally write the expiration. if (expirationPolicy != null) { expirationPolicy.setExpirationAt(sequenceId); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "set", "(", "long", "sequenceId", ",", "T", "item", ")", "{", "final", "E", "rbItem", "=", "convertToRingbufferFormat", "(", "item", ")", ";", "// first we write the dataItem in the ring.", "ringbuffer", ".", "set", "(", "sequenceId", ",", "rbItem", ")", ";", "if", "(", "sequenceId", ">", "tailSequence", "(", ")", ")", "{", "ringbuffer", ".", "setTailSequence", "(", "sequenceId", ")", ";", "if", "(", "ringbuffer", ".", "size", "(", ")", ">", "ringbuffer", ".", "getCapacity", "(", ")", ")", "{", "ringbuffer", ".", "setHeadSequence", "(", "ringbuffer", ".", "tailSequence", "(", ")", "-", "ringbuffer", ".", "getCapacity", "(", ")", "+", "1", ")", ";", "}", "}", "if", "(", "sequenceId", "<", "headSequence", "(", ")", ")", "{", "ringbuffer", ".", "setHeadSequence", "(", "sequenceId", ")", ";", "}", "// and then we optionally write the expiration.", "if", "(", "expirationPolicy", "!=", "null", ")", "{", "expirationPolicy", ".", "setExpirationAt", "(", "sequenceId", ")", ";", "}", "}" ]
Sets the item at the given sequence ID and updates the expiration time if TTL is configured. Unlike other methods for adding items into the ring buffer, does not attempt to store the item in the data store. This method expands the ring buffer tail and head sequence to accommodate for the sequence. This means that it will move the head or tail sequence to the target sequence if the target sequence is less than the head sequence or greater than the tail sequence. @param sequenceId the sequence ID under which the item is stored @param item item to be stored in the ring buffer and data store @throws HazelcastSerializationException if the ring buffer is configured to keep items in object format and the item could not be deserialized
[ "Sets", "the", "item", "at", "the", "given", "sequence", "ID", "and", "updates", "the", "expiration", "time", "if", "TTL", "is", "configured", ".", "Unlike", "other", "methods", "for", "adding", "items", "into", "the", "ring", "buffer", "does", "not", "attempt", "to", "store", "the", "item", "in", "the", "data", "store", ".", "This", "method", "expands", "the", "ring", "buffer", "tail", "and", "head", "sequence", "to", "accommodate", "for", "the", "sequence", ".", "This", "means", "that", "it", "will", "move", "the", "head", "or", "tail", "sequence", "to", "the", "target", "sequence", "if", "the", "target", "sequence", "is", "less", "than", "the", "head", "sequence", "or", "greater", "than", "the", "tail", "sequence", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L354-L376
15,467
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.readAsData
public Data readAsData(long sequence) { checkReadSequence(sequence); Object rbItem = readOrLoadItem(sequence); return serializationService.toData(rbItem); }
java
public Data readAsData(long sequence) { checkReadSequence(sequence); Object rbItem = readOrLoadItem(sequence); return serializationService.toData(rbItem); }
[ "public", "Data", "readAsData", "(", "long", "sequence", ")", "{", "checkReadSequence", "(", "sequence", ")", ";", "Object", "rbItem", "=", "readOrLoadItem", "(", "sequence", ")", ";", "return", "serializationService", ".", "toData", "(", "rbItem", ")", ";", "}" ]
Reads one item from the ring buffer and returns the serialized format. If the item is not available, it will try and load it from the ringbuffer store. If the stored format is already serialized, there is no serialization. @param sequence The sequence of the item to be read @return The item read @throws StaleSequenceException if the sequence is : 1. larger than the tailSequence or 2. smaller than the headSequence and the data store is disabled
[ "Reads", "one", "item", "from", "the", "ring", "buffer", "and", "returns", "the", "serialized", "format", ".", "If", "the", "item", "is", "not", "available", "it", "will", "try", "and", "load", "it", "from", "the", "ringbuffer", "store", ".", "If", "the", "stored", "format", "is", "already", "serialized", "there", "is", "no", "serialization", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L389-L393
15,468
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.checkReadSequence
private void checkReadSequence(long sequence) { final long tailSequence = ringbuffer.tailSequence(); if (sequence > tailSequence) { throw new IllegalArgumentException("sequence:" + sequence + " is too large. The current tailSequence is:" + tailSequence); } if (isStaleSequence(sequence)) { throw new StaleSequenceException("sequence:" + sequence + " is too small and data store is disabled." + " The current headSequence is:" + headSequence() + " tailSequence is:" + tailSequence, headSequence()); } }
java
private void checkReadSequence(long sequence) { final long tailSequence = ringbuffer.tailSequence(); if (sequence > tailSequence) { throw new IllegalArgumentException("sequence:" + sequence + " is too large. The current tailSequence is:" + tailSequence); } if (isStaleSequence(sequence)) { throw new StaleSequenceException("sequence:" + sequence + " is too small and data store is disabled." + " The current headSequence is:" + headSequence() + " tailSequence is:" + tailSequence, headSequence()); } }
[ "private", "void", "checkReadSequence", "(", "long", "sequence", ")", "{", "final", "long", "tailSequence", "=", "ringbuffer", ".", "tailSequence", "(", ")", ";", "if", "(", "sequence", ">", "tailSequence", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"sequence:\"", "+", "sequence", "+", "\" is too large. The current tailSequence is:\"", "+", "tailSequence", ")", ";", "}", "if", "(", "isStaleSequence", "(", "sequence", ")", ")", "{", "throw", "new", "StaleSequenceException", "(", "\"sequence:\"", "+", "sequence", "+", "\" is too small and data store is disabled.\"", "+", "\" The current headSequence is:\"", "+", "headSequence", "(", ")", "+", "\" tailSequence is:\"", "+", "tailSequence", ",", "headSequence", "(", ")", ")", ";", "}", "}" ]
Check if the sequence can be read from the ring buffer. @param sequence the sequence wanting to be read @throws StaleSequenceException if the requested sequence is smaller than the head sequence and the data store is not enabled @throws IllegalArgumentException if the requested sequence is greater than the tail sequence
[ "Check", "if", "the", "sequence", "can", "be", "read", "from", "the", "ring", "buffer", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L472-L484
15,469
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.readOrLoadItem
private Object readOrLoadItem(long sequence) { Object item; if (sequence < ringbuffer.headSequence() && store.isEnabled()) { item = store.load(sequence); } else { item = ringbuffer.read(sequence); } return item; }
java
private Object readOrLoadItem(long sequence) { Object item; if (sequence < ringbuffer.headSequence() && store.isEnabled()) { item = store.load(sequence); } else { item = ringbuffer.read(sequence); } return item; }
[ "private", "Object", "readOrLoadItem", "(", "long", "sequence", ")", "{", "Object", "item", ";", "if", "(", "sequence", "<", "ringbuffer", ".", "headSequence", "(", ")", "&&", "store", ".", "isEnabled", "(", ")", ")", "{", "item", "=", "store", ".", "load", "(", "sequence", ")", ";", "}", "else", "{", "item", "=", "ringbuffer", ".", "read", "(", "sequence", ")", ";", "}", "return", "item", ";", "}" ]
Reads the item at the specified sequence or loads it from the ringbuffer store if one is enabled. The type of the returned object is equal to the ringbuffer format.
[ "Reads", "the", "item", "at", "the", "specified", "sequence", "or", "loads", "it", "from", "the", "ringbuffer", "store", "if", "one", "is", "enabled", ".", "The", "type", "of", "the", "returned", "object", "is", "equal", "to", "the", "ringbuffer", "format", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L491-L499
15,470
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java
RingbufferContainer.convertToData
private Data[] convertToData(T[] items) { if (items == null || items.length == 0) { return new Data[0]; } if (items[0] instanceof Data) { return (Data[]) items; } final Data[] ret = new Data[items.length]; for (int i = 0; i < items.length; i++) { ret[i] = convertToData(items[i]); } return ret; }
java
private Data[] convertToData(T[] items) { if (items == null || items.length == 0) { return new Data[0]; } if (items[0] instanceof Data) { return (Data[]) items; } final Data[] ret = new Data[items.length]; for (int i = 0; i < items.length; i++) { ret[i] = convertToData(items[i]); } return ret; }
[ "private", "Data", "[", "]", "convertToData", "(", "T", "[", "]", "items", ")", "{", "if", "(", "items", "==", "null", "||", "items", ".", "length", "==", "0", ")", "{", "return", "new", "Data", "[", "0", "]", ";", "}", "if", "(", "items", "[", "0", "]", "instanceof", "Data", ")", "{", "return", "(", "Data", "[", "]", ")", "items", ";", "}", "final", "Data", "[", "]", "ret", "=", "new", "Data", "[", "items", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "ret", "[", "i", "]", "=", "convertToData", "(", "items", "[", "i", "]", ")", ";", "}", "return", "ret", ";", "}" ]
Convert the supplied argument into serialized format. @throws HazelcastSerializationException when serialization fails.
[ "Convert", "the", "supplied", "argument", "into", "serialized", "format", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/ringbuffer/impl/RingbufferContainer.java#L545-L557
15,471
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/AbstractEvictableRecordStore.java
AbstractEvictableRecordStore.getOrNullIfExpired
protected Record getOrNullIfExpired(Record record, long now, boolean backup) { if (!isRecordStoreExpirable()) { return record; } if (record == null) { return null; } Data key = record.getKey(); if (isLocked(key)) { return record; } if (!isExpired(record, now, backup)) { return record; } evict(key, backup); if (!backup) { doPostEvictionOperations(record); } return null; }
java
protected Record getOrNullIfExpired(Record record, long now, boolean backup) { if (!isRecordStoreExpirable()) { return record; } if (record == null) { return null; } Data key = record.getKey(); if (isLocked(key)) { return record; } if (!isExpired(record, now, backup)) { return record; } evict(key, backup); if (!backup) { doPostEvictionOperations(record); } return null; }
[ "protected", "Record", "getOrNullIfExpired", "(", "Record", "record", ",", "long", "now", ",", "boolean", "backup", ")", "{", "if", "(", "!", "isRecordStoreExpirable", "(", ")", ")", "{", "return", "record", ";", "}", "if", "(", "record", "==", "null", ")", "{", "return", "null", ";", "}", "Data", "key", "=", "record", ".", "getKey", "(", ")", ";", "if", "(", "isLocked", "(", "key", ")", ")", "{", "return", "record", ";", "}", "if", "(", "!", "isExpired", "(", "record", ",", "now", ",", "backup", ")", ")", "{", "return", "record", ";", "}", "evict", "(", "key", ",", "backup", ")", ";", "if", "(", "!", "backup", ")", "{", "doPostEvictionOperations", "(", "record", ")", ";", "}", "return", "null", ";", "}" ]
Check if record is reachable according to TTL or idle times. If not reachable return null. @param record {@link com.hazelcast.map.impl.record.Record} @return null if evictable.
[ "Check", "if", "record", "is", "reachable", "according", "to", "TTL", "or", "idle", "times", ".", "If", "not", "reachable", "return", "null", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/AbstractEvictableRecordStore.java#L220-L239
15,472
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/query/impl/getters/Getter.java
Getter.getValue
Object getValue(Object obj, String attributePath, Object metadata) throws Exception { return getValue(obj, attributePath); }
java
Object getValue(Object obj, String attributePath, Object metadata) throws Exception { return getValue(obj, attributePath); }
[ "Object", "getValue", "(", "Object", "obj", ",", "String", "attributePath", ",", "Object", "metadata", ")", "throws", "Exception", "{", "return", "getValue", "(", "obj", ",", "attributePath", ")", ";", "}" ]
Method for generic getters that can make use of metadata if available. These getters must gracefully fallback to not using metadata if unavailable.
[ "Method", "for", "generic", "getters", "that", "can", "make", "use", "of", "metadata", "if", "available", ".", "These", "getters", "must", "gracefully", "fallback", "to", "not", "using", "metadata", "if", "unavailable", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/Getter.java#L47-L49
15,473
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java
IndexHeapMemoryCostUtil.estimateValueCost
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:returncount"}) public static long estimateValueCost(Object value) { if (value == null) { return 0; } Class<?> clazz = value.getClass(); Integer cost = KNOWN_FINAL_CLASSES_COSTS.get(clazz); if (cost != null) { return cost; } if (value instanceof String) { return BASE_STRING_COST + ((String) value).length() * 2L; } if (value instanceof Timestamp) { return SQL_TIMESTAMP_COST; } if (value instanceof Date) { return DATE_COST; } if (clazz.isEnum()) { // enum values are shared, so they don't cost anything return 0; } if (value instanceof BigDecimal) { return ROUGH_BIG_DECIMAL_COST; } if (value instanceof BigInteger) { return ROUGH_BIG_INTEGER_COST; } return ROUGH_UNKNOWN_CLASS_COST; }
java
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:returncount"}) public static long estimateValueCost(Object value) { if (value == null) { return 0; } Class<?> clazz = value.getClass(); Integer cost = KNOWN_FINAL_CLASSES_COSTS.get(clazz); if (cost != null) { return cost; } if (value instanceof String) { return BASE_STRING_COST + ((String) value).length() * 2L; } if (value instanceof Timestamp) { return SQL_TIMESTAMP_COST; } if (value instanceof Date) { return DATE_COST; } if (clazz.isEnum()) { // enum values are shared, so they don't cost anything return 0; } if (value instanceof BigDecimal) { return ROUGH_BIG_DECIMAL_COST; } if (value instanceof BigInteger) { return ROUGH_BIG_INTEGER_COST; } return ROUGH_UNKNOWN_CLASS_COST; }
[ "@", "SuppressWarnings", "(", "{", "\"checkstyle:npathcomplexity\"", ",", "\"checkstyle:returncount\"", "}", ")", "public", "static", "long", "estimateValueCost", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "0", ";", "}", "Class", "<", "?", ">", "clazz", "=", "value", ".", "getClass", "(", ")", ";", "Integer", "cost", "=", "KNOWN_FINAL_CLASSES_COSTS", ".", "get", "(", "clazz", ")", ";", "if", "(", "cost", "!=", "null", ")", "{", "return", "cost", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "return", "BASE_STRING_COST", "+", "(", "(", "String", ")", "value", ")", ".", "length", "(", ")", "*", "2L", ";", "}", "if", "(", "value", "instanceof", "Timestamp", ")", "{", "return", "SQL_TIMESTAMP_COST", ";", "}", "if", "(", "value", "instanceof", "Date", ")", "{", "return", "DATE_COST", ";", "}", "if", "(", "clazz", ".", "isEnum", "(", ")", ")", "{", "// enum values are shared, so they don't cost anything", "return", "0", ";", "}", "if", "(", "value", "instanceof", "BigDecimal", ")", "{", "return", "ROUGH_BIG_DECIMAL_COST", ";", "}", "if", "(", "value", "instanceof", "BigInteger", ")", "{", "return", "ROUGH_BIG_INTEGER_COST", ";", "}", "return", "ROUGH_UNKNOWN_CLASS_COST", ";", "}" ]
Estimates the on-heap memory cost of the given value. @param value the value to estimate the cost of. @return the estimated value cost.
[ "Estimates", "the", "on", "-", "heap", "memory", "cost", "of", "the", "given", "value", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java#L82-L120
15,474
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java
IndexHeapMemoryCostUtil.estimateMapCost
public static long estimateMapCost(long size, boolean ordered, boolean usesCachedQueryableEntries) { long mapCost; if (ordered) { mapCost = BASE_CONCURRENT_SKIP_LIST_MAP_COST + size * CONCURRENT_SKIP_LIST_MAP_ENTRY_COST; } else { mapCost = BASE_CONCURRENT_HASH_MAP_COST + size * CONCURRENT_HASH_MAP_ENTRY_COST; } long queryableEntriesCost; if (usesCachedQueryableEntries) { queryableEntriesCost = size * CACHED_QUERYABLE_ENTRY_COST; } else { queryableEntriesCost = size * QUERY_ENTRY_COST; } return mapCost + queryableEntriesCost; }
java
public static long estimateMapCost(long size, boolean ordered, boolean usesCachedQueryableEntries) { long mapCost; if (ordered) { mapCost = BASE_CONCURRENT_SKIP_LIST_MAP_COST + size * CONCURRENT_SKIP_LIST_MAP_ENTRY_COST; } else { mapCost = BASE_CONCURRENT_HASH_MAP_COST + size * CONCURRENT_HASH_MAP_ENTRY_COST; } long queryableEntriesCost; if (usesCachedQueryableEntries) { queryableEntriesCost = size * CACHED_QUERYABLE_ENTRY_COST; } else { queryableEntriesCost = size * QUERY_ENTRY_COST; } return mapCost + queryableEntriesCost; }
[ "public", "static", "long", "estimateMapCost", "(", "long", "size", ",", "boolean", "ordered", ",", "boolean", "usesCachedQueryableEntries", ")", "{", "long", "mapCost", ";", "if", "(", "ordered", ")", "{", "mapCost", "=", "BASE_CONCURRENT_SKIP_LIST_MAP_COST", "+", "size", "*", "CONCURRENT_SKIP_LIST_MAP_ENTRY_COST", ";", "}", "else", "{", "mapCost", "=", "BASE_CONCURRENT_HASH_MAP_COST", "+", "size", "*", "CONCURRENT_HASH_MAP_ENTRY_COST", ";", "}", "long", "queryableEntriesCost", ";", "if", "(", "usesCachedQueryableEntries", ")", "{", "queryableEntriesCost", "=", "size", "*", "CACHED_QUERYABLE_ENTRY_COST", ";", "}", "else", "{", "queryableEntriesCost", "=", "size", "*", "QUERY_ENTRY_COST", ";", "}", "return", "mapCost", "+", "queryableEntriesCost", ";", "}" ]
Estimates the on-heap memory cost of a map backing an index. @param size the size of the map to estimate the cost of. @param ordered {@code true} if the index managing the map being estimated is ordered, {@code false} otherwise. @param usesCachedQueryableEntries {@code true} if queryable entries indexed by the associated index are cached, {@code false} otherwise. @return the estimated map cost.
[ "Estimates", "the", "on", "-", "heap", "memory", "cost", "of", "a", "map", "backing", "an", "index", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java#L135-L151
15,475
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/ProbeUtils.java
ProbeUtils.getType
static int getType(Class classType) { Integer type = TYPES.get(classType); if (type != null) { return type; } List<Class<?>> flattenedClasses = new ArrayList<Class<?>>(); flatten(classType, flattenedClasses); for (Class<?> clazz : flattenedClasses) { type = TYPES.get(clazz); if (type != null) { return type; } } return -1; }
java
static int getType(Class classType) { Integer type = TYPES.get(classType); if (type != null) { return type; } List<Class<?>> flattenedClasses = new ArrayList<Class<?>>(); flatten(classType, flattenedClasses); for (Class<?> clazz : flattenedClasses) { type = TYPES.get(clazz); if (type != null) { return type; } } return -1; }
[ "static", "int", "getType", "(", "Class", "classType", ")", "{", "Integer", "type", "=", "TYPES", ".", "get", "(", "classType", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ";", "}", "List", "<", "Class", "<", "?", ">", ">", "flattenedClasses", "=", "new", "ArrayList", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "flatten", "(", "classType", ",", "flattenedClasses", ")", ";", "for", "(", "Class", "<", "?", ">", "clazz", ":", "flattenedClasses", ")", "{", "type", "=", "TYPES", ".", "get", "(", "clazz", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ";", "}", "}", "return", "-", "1", ";", "}" ]
Gets the accessible object probe type for this class object type. accessible object probe class object TYPE_PRIMITIVE_LONG = 1 byte, short, int, long TYPE_LONG_NUMBER = 2 Byte, Short, Integer, Long, AtomicInteger, AtomicLong TYPE_DOUBLE_PRIMITIVE = 3 double, float TYPE_DOUBLE_NUMBER = 4 Double, Float TYPE_COLLECTION = 5 Collection TYPE_MAP = 6 Map TYPE_COUNTER = 7 Counter @param classType the class object type. @return the accessible object probe type.
[ "Gets", "the", "accessible", "object", "probe", "type", "for", "this", "class", "object", "type", ".", "accessible", "object", "probe", "class", "object", "TYPE_PRIMITIVE_LONG", "=", "1", "byte", "short", "int", "long", "TYPE_LONG_NUMBER", "=", "2", "Byte", "Short", "Integer", "Long", "AtomicInteger", "AtomicLong", "TYPE_DOUBLE_PRIMITIVE", "=", "3", "double", "float", "TYPE_DOUBLE_NUMBER", "=", "4", "Double", "Float", "TYPE_COLLECTION", "=", "5", "Collection", "TYPE_MAP", "=", "6", "Map", "TYPE_COUNTER", "=", "7", "Counter" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/ProbeUtils.java#L101-L119
15,476
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/nio/tcp/DefaultChannelInitializerProvider.java
DefaultChannelInitializerProvider.checkSslConfigAvailability
private void checkSslConfigAvailability(Config config) { if (config.getAdvancedNetworkConfig().isEnabled()) { return; } SSLConfig sslConfig = config.getNetworkConfig().getSSLConfig(); checkSslConfigAvailability(sslConfig); }
java
private void checkSslConfigAvailability(Config config) { if (config.getAdvancedNetworkConfig().isEnabled()) { return; } SSLConfig sslConfig = config.getNetworkConfig().getSSLConfig(); checkSslConfigAvailability(sslConfig); }
[ "private", "void", "checkSslConfigAvailability", "(", "Config", "config", ")", "{", "if", "(", "config", ".", "getAdvancedNetworkConfig", "(", ")", ".", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "SSLConfig", "sslConfig", "=", "config", ".", "getNetworkConfig", "(", ")", ".", "getSSLConfig", "(", ")", ";", "checkSslConfigAvailability", "(", "sslConfig", ")", ";", "}" ]
check SSL config for unisocket member configuration
[ "check", "SSL", "config", "for", "unisocket", "member", "configuration" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/nio/tcp/DefaultChannelInitializerProvider.java#L112-L118
15,477
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/nio/tcp/DefaultChannelInitializerProvider.java
DefaultChannelInitializerProvider.checkSslConfigAvailability
private void checkSslConfigAvailability(SSLConfig sslConfig) { if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } }
java
private void checkSslConfigAvailability(SSLConfig sslConfig) { if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } }
[ "private", "void", "checkSslConfigAvailability", "(", "SSLConfig", "sslConfig", ")", "{", "if", "(", "sslConfig", "!=", "null", "&&", "sslConfig", ".", "isEnabled", "(", ")", ")", "{", "if", "(", "!", "BuildInfoProvider", ".", "getBuildInfo", "(", ")", ".", "isEnterprise", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"SSL/TLS requires Hazelcast Enterprise Edition\"", ")", ";", "}", "}", "}" ]
check given SSL config
[ "check", "given", "SSL", "config" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/nio/tcp/DefaultChannelInitializerProvider.java#L121-L127
15,478
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/wan/merkletree/MerkleTreeUtil.java
MerkleTreeUtil.getNodeRangeLow
static int getNodeRangeLow(int nodeOrder) { int level = getLevelOfNode(nodeOrder); int leftMostLeafOrder = getLeftMostNodeOrderOnLevel(level); int levelHashStep = (int) getNodeHashRangeOnLevel(level); int leafOrderOnLevel = nodeOrder - leftMostLeafOrder; return Integer.MIN_VALUE + (leafOrderOnLevel * levelHashStep); }
java
static int getNodeRangeLow(int nodeOrder) { int level = getLevelOfNode(nodeOrder); int leftMostLeafOrder = getLeftMostNodeOrderOnLevel(level); int levelHashStep = (int) getNodeHashRangeOnLevel(level); int leafOrderOnLevel = nodeOrder - leftMostLeafOrder; return Integer.MIN_VALUE + (leafOrderOnLevel * levelHashStep); }
[ "static", "int", "getNodeRangeLow", "(", "int", "nodeOrder", ")", "{", "int", "level", "=", "getLevelOfNode", "(", "nodeOrder", ")", ";", "int", "leftMostLeafOrder", "=", "getLeftMostNodeOrderOnLevel", "(", "level", ")", ";", "int", "levelHashStep", "=", "(", "int", ")", "getNodeHashRangeOnLevel", "(", "level", ")", ";", "int", "leafOrderOnLevel", "=", "nodeOrder", "-", "leftMostLeafOrder", ";", "return", "Integer", ".", "MIN_VALUE", "+", "(", "leafOrderOnLevel", "*", "levelHashStep", ")", ";", "}" ]
Returns the lower bound of the hash range for a given node @param nodeOrder The breadth-first order of the node @return the lower bound of the hash range
[ "Returns", "the", "lower", "bound", "of", "the", "hash", "range", "for", "a", "given", "node" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/wan/merkletree/MerkleTreeUtil.java#L74-L81
15,479
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/executor/impl/ExecutorServiceProxy.java
ExecutorServiceProxy.checkSync
private boolean checkSync() { boolean sync = false; long last = lastSubmitTime; long now = Clock.currentTimeMillis(); if (last + SYNC_DELAY_MS < now) { CONSECUTIVE_SUBMITS.set(this, 0); } else if (CONSECUTIVE_SUBMITS.incrementAndGet(this) % SYNC_FREQUENCY == 0) { sync = true; } lastSubmitTime = now; return sync; }
java
private boolean checkSync() { boolean sync = false; long last = lastSubmitTime; long now = Clock.currentTimeMillis(); if (last + SYNC_DELAY_MS < now) { CONSECUTIVE_SUBMITS.set(this, 0); } else if (CONSECUTIVE_SUBMITS.incrementAndGet(this) % SYNC_FREQUENCY == 0) { sync = true; } lastSubmitTime = now; return sync; }
[ "private", "boolean", "checkSync", "(", ")", "{", "boolean", "sync", "=", "false", ";", "long", "last", "=", "lastSubmitTime", ";", "long", "now", "=", "Clock", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "last", "+", "SYNC_DELAY_MS", "<", "now", ")", "{", "CONSECUTIVE_SUBMITS", ".", "set", "(", "this", ",", "0", ")", ";", "}", "else", "if", "(", "CONSECUTIVE_SUBMITS", ".", "incrementAndGet", "(", "this", ")", "%", "SYNC_FREQUENCY", "==", "0", ")", "{", "sync", "=", "true", ";", "}", "lastSubmitTime", "=", "now", ";", "return", "sync", ";", "}" ]
This is a hack to prevent overloading the system with unprocessed tasks. Once backpressure is added, this can be removed.
[ "This", "is", "a", "hack", "to", "prevent", "overloading", "the", "system", "with", "unprocessed", "tasks", ".", "Once", "backpressure", "is", "added", "this", "can", "be", "removed", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/executor/impl/ExecutorServiceProxy.java#L274-L285
15,480
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java
ConcurrentConveyor.concurrentConveyor
public static <E1> ConcurrentConveyor<E1> concurrentConveyor( E1 submitterGoneItem, QueuedPipe<E1>... queues ) { return new ConcurrentConveyor<E1>(submitterGoneItem, queues); }
java
public static <E1> ConcurrentConveyor<E1> concurrentConveyor( E1 submitterGoneItem, QueuedPipe<E1>... queues ) { return new ConcurrentConveyor<E1>(submitterGoneItem, queues); }
[ "public", "static", "<", "E1", ">", "ConcurrentConveyor", "<", "E1", ">", "concurrentConveyor", "(", "E1", "submitterGoneItem", ",", "QueuedPipe", "<", "E1", ">", "...", "queues", ")", "{", "return", "new", "ConcurrentConveyor", "<", "E1", ">", "(", "submitterGoneItem", ",", "queues", ")", ";", "}" ]
Creates a new concurrent conveyor. @param submitterGoneItem the object that a submitter thread can use to signal it's done submitting @param queues the concurrent queues the conveyor will manage
[ "Creates", "a", "new", "concurrent", "conveyor", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java#L173-L177
15,481
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java
ConcurrentConveyor.offer
public final boolean offer(Queue<E> queue, E item) throws ConcurrentConveyorException { if (queue.offer(item)) { return true; } else { checkDrainerGone(); unparkDrainer(); return false; } }
java
public final boolean offer(Queue<E> queue, E item) throws ConcurrentConveyorException { if (queue.offer(item)) { return true; } else { checkDrainerGone(); unparkDrainer(); return false; } }
[ "public", "final", "boolean", "offer", "(", "Queue", "<", "E", ">", "queue", ",", "E", "item", ")", "throws", "ConcurrentConveyorException", "{", "if", "(", "queue", ".", "offer", "(", "item", ")", ")", "{", "return", "true", ";", "}", "else", "{", "checkDrainerGone", "(", ")", ";", "unparkDrainer", "(", ")", ";", "return", "false", ";", "}", "}" ]
Offers an item to the given queue. No check is performed that the queue actually belongs to this conveyor. @return whether the item was accepted by the queue @throws ConcurrentConveyorException if the draining thread has already left
[ "Offers", "an", "item", "to", "the", "given", "queue", ".", "No", "check", "is", "performed", "that", "the", "queue", "actually", "belongs", "to", "this", "conveyor", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java#L240-L248
15,482
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java
ConcurrentConveyor.drainTo
public final int drainTo(int queueIndex, Collection<? super E> drain) { return drain(queues[queueIndex], drain, Integer.MAX_VALUE); }
java
public final int drainTo(int queueIndex, Collection<? super E> drain) { return drain(queues[queueIndex], drain, Integer.MAX_VALUE); }
[ "public", "final", "int", "drainTo", "(", "int", "queueIndex", ",", "Collection", "<", "?", "super", "E", ">", "drain", ")", "{", "return", "drain", "(", "queues", "[", "queueIndex", "]", ",", "drain", ",", "Integer", ".", "MAX_VALUE", ")", ";", "}" ]
Drains a batch of items from the queue at the supplied index into the supplied collection. @return the number of items drained
[ "Drains", "a", "batch", "of", "items", "from", "the", "queue", "at", "the", "supplied", "index", "into", "the", "supplied", "collection", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java#L287-L289
15,483
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java
ConcurrentConveyor.drainerFailed
public final void drainerFailed(Throwable t) { if (t == null) { throw new NullPointerException("ConcurrentConveyor.drainerFailed(null)"); } drainer = null; drainerDepartureCause = t; }
java
public final void drainerFailed(Throwable t) { if (t == null) { throw new NullPointerException("ConcurrentConveyor.drainerFailed(null)"); } drainer = null; drainerDepartureCause = t; }
[ "public", "final", "void", "drainerFailed", "(", "Throwable", "t", ")", "{", "if", "(", "t", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"ConcurrentConveyor.drainerFailed(null)\"", ")", ";", "}", "drainer", "=", "null", ";", "drainerDepartureCause", "=", "t", ";", "}" ]
Called by the drainer thread to signal that it has failed and will drain no more items from the queue. @param t the drainer's failure
[ "Called", "by", "the", "drainer", "thread", "to", "signal", "that", "it", "has", "failed", "and", "will", "drain", "no", "more", "items", "from", "the", "queue", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/util/concurrent/ConcurrentConveyor.java#L337-L343
15,484
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/BatchInvalidator.java
BatchInvalidator.registerNodeShutdownListener
private String registerNodeShutdownListener() { HazelcastInstance node = nodeEngine.getHazelcastInstance(); LifecycleService lifecycleService = node.getLifecycleService(); return lifecycleService.addLifecycleListener(new LifecycleListener() { @Override public void stateChanged(LifecycleEvent event) { if (event.getState() == SHUTTING_DOWN) { Set<Map.Entry<String, InvalidationQueue<Invalidation>>> entries = invalidationQueues.entrySet(); for (Map.Entry<String, InvalidationQueue<Invalidation>> entry : entries) { pollAndSendInvalidations(entry.getKey(), entry.getValue()); } } } }); }
java
private String registerNodeShutdownListener() { HazelcastInstance node = nodeEngine.getHazelcastInstance(); LifecycleService lifecycleService = node.getLifecycleService(); return lifecycleService.addLifecycleListener(new LifecycleListener() { @Override public void stateChanged(LifecycleEvent event) { if (event.getState() == SHUTTING_DOWN) { Set<Map.Entry<String, InvalidationQueue<Invalidation>>> entries = invalidationQueues.entrySet(); for (Map.Entry<String, InvalidationQueue<Invalidation>> entry : entries) { pollAndSendInvalidations(entry.getKey(), entry.getValue()); } } } }); }
[ "private", "String", "registerNodeShutdownListener", "(", ")", "{", "HazelcastInstance", "node", "=", "nodeEngine", ".", "getHazelcastInstance", "(", ")", ";", "LifecycleService", "lifecycleService", "=", "node", ".", "getLifecycleService", "(", ")", ";", "return", "lifecycleService", ".", "addLifecycleListener", "(", "new", "LifecycleListener", "(", ")", "{", "@", "Override", "public", "void", "stateChanged", "(", "LifecycleEvent", "event", ")", "{", "if", "(", "event", ".", "getState", "(", ")", "==", "SHUTTING_DOWN", ")", "{", "Set", "<", "Map", ".", "Entry", "<", "String", ",", "InvalidationQueue", "<", "Invalidation", ">", ">", ">", "entries", "=", "invalidationQueues", ".", "entrySet", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "InvalidationQueue", "<", "Invalidation", ">", ">", "entry", ":", "entries", ")", "{", "pollAndSendInvalidations", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "}", ")", ";", "}" ]
Sends remaining invalidation events in this invalidator's queues to the recipients.
[ "Sends", "remaining", "invalidation", "events", "in", "this", "invalidator", "s", "queues", "to", "the", "recipients", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/BatchInvalidator.java#L159-L173
15,485
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java
MapDataStores.createWriteBehindStore
public static <K, V> MapDataStore<K, V> createWriteBehindStore(MapStoreContext mapStoreContext, int partitionId, WriteBehindProcessor writeBehindProcessor) { MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig(); InternalSerializationService serializationService = ((InternalSerializationService) nodeEngine.getSerializationService()); WriteBehindStore mapDataStore = new WriteBehindStore(mapStoreContext, partitionId, serializationService); mapDataStore.setWriteBehindQueue(newWriteBehindQueue(mapServiceContext, mapStoreConfig.isWriteCoalescing())); mapDataStore.setWriteBehindProcessor(writeBehindProcessor); return (MapDataStore<K, V>) mapDataStore; }
java
public static <K, V> MapDataStore<K, V> createWriteBehindStore(MapStoreContext mapStoreContext, int partitionId, WriteBehindProcessor writeBehindProcessor) { MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig(); InternalSerializationService serializationService = ((InternalSerializationService) nodeEngine.getSerializationService()); WriteBehindStore mapDataStore = new WriteBehindStore(mapStoreContext, partitionId, serializationService); mapDataStore.setWriteBehindQueue(newWriteBehindQueue(mapServiceContext, mapStoreConfig.isWriteCoalescing())); mapDataStore.setWriteBehindProcessor(writeBehindProcessor); return (MapDataStore<K, V>) mapDataStore; }
[ "public", "static", "<", "K", ",", "V", ">", "MapDataStore", "<", "K", ",", "V", ">", "createWriteBehindStore", "(", "MapStoreContext", "mapStoreContext", ",", "int", "partitionId", ",", "WriteBehindProcessor", "writeBehindProcessor", ")", "{", "MapServiceContext", "mapServiceContext", "=", "mapStoreContext", ".", "getMapServiceContext", "(", ")", ";", "NodeEngine", "nodeEngine", "=", "mapServiceContext", ".", "getNodeEngine", "(", ")", ";", "MapStoreConfig", "mapStoreConfig", "=", "mapStoreContext", ".", "getMapStoreConfig", "(", ")", ";", "InternalSerializationService", "serializationService", "=", "(", "(", "InternalSerializationService", ")", "nodeEngine", ".", "getSerializationService", "(", ")", ")", ";", "WriteBehindStore", "mapDataStore", "=", "new", "WriteBehindStore", "(", "mapStoreContext", ",", "partitionId", ",", "serializationService", ")", ";", "mapDataStore", ".", "setWriteBehindQueue", "(", "newWriteBehindQueue", "(", "mapServiceContext", ",", "mapStoreConfig", ".", "isWriteCoalescing", "(", ")", ")", ")", ";", "mapDataStore", ".", "setWriteBehindProcessor", "(", "writeBehindProcessor", ")", ";", "return", "(", "MapDataStore", "<", "K", ",", "V", ">", ")", "mapDataStore", ";", "}" ]
Creates a write behind data store. @param mapStoreContext context for map store operations @param partitionId partition ID of partition @param writeBehindProcessor the {@link WriteBehindProcessor} @param <K> type of key to store @param <V> type of value to store @return new write behind store manager
[ "Creates", "a", "write", "behind", "data", "store", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java#L58-L69
15,486
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java
MapDataStores.createWriteThroughStore
public static <K, V> MapDataStore<K, V> createWriteThroughStore(MapStoreContext mapStoreContext) { final MapStoreWrapper store = mapStoreContext.getMapStoreWrapper(); final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); final NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); final InternalSerializationService serializationService = ((InternalSerializationService) nodeEngine.getSerializationService()); return (MapDataStore<K, V>) new WriteThroughStore(store, serializationService); }
java
public static <K, V> MapDataStore<K, V> createWriteThroughStore(MapStoreContext mapStoreContext) { final MapStoreWrapper store = mapStoreContext.getMapStoreWrapper(); final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext(); final NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); final InternalSerializationService serializationService = ((InternalSerializationService) nodeEngine.getSerializationService()); return (MapDataStore<K, V>) new WriteThroughStore(store, serializationService); }
[ "public", "static", "<", "K", ",", "V", ">", "MapDataStore", "<", "K", ",", "V", ">", "createWriteThroughStore", "(", "MapStoreContext", "mapStoreContext", ")", "{", "final", "MapStoreWrapper", "store", "=", "mapStoreContext", ".", "getMapStoreWrapper", "(", ")", ";", "final", "MapServiceContext", "mapServiceContext", "=", "mapStoreContext", ".", "getMapServiceContext", "(", ")", ";", "final", "NodeEngine", "nodeEngine", "=", "mapServiceContext", ".", "getNodeEngine", "(", ")", ";", "final", "InternalSerializationService", "serializationService", "=", "(", "(", "InternalSerializationService", ")", "nodeEngine", ".", "getSerializationService", "(", ")", ")", ";", "return", "(", "MapDataStore", "<", "K", ",", "V", ">", ")", "new", "WriteThroughStore", "(", "store", ",", "serializationService", ")", ";", "}" ]
Creates a write through data store. @param mapStoreContext context for map store operations @param <K> type of key to store @param <V> type of value to store @return new write through store manager
[ "Creates", "a", "write", "through", "data", "store", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java#L86-L95
15,487
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java
MapDataStores.emptyStore
public static <K, V> MapDataStore<K, V> emptyStore() { return (MapDataStore<K, V>) EMPTY_MAP_DATA_STORE; }
java
public static <K, V> MapDataStore<K, V> emptyStore() { return (MapDataStore<K, V>) EMPTY_MAP_DATA_STORE; }
[ "public", "static", "<", "K", ",", "V", ">", "MapDataStore", "<", "K", ",", "V", ">", "emptyStore", "(", ")", "{", "return", "(", "MapDataStore", "<", "K", ",", "V", ">", ")", "EMPTY_MAP_DATA_STORE", ";", "}" ]
Used for providing neutral null behaviour. @param <K> type of key to store @param <V> type of value to store @return empty store manager
[ "Used", "for", "providing", "neutral", "null", "behaviour", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/MapDataStores.java#L104-L106
15,488
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/query/impl/getters/JsonPathCursor.java
JsonPathCursor.createCursor
public static JsonPathCursor createCursor(String attributePath) { ArrayList<Triple> triples = new ArrayList<Triple>(DEFAULT_PATH_ELEMENT_COUNT); int start = 0; int end; while (start < attributePath.length()) { boolean isArray = false; try { while (attributePath.charAt(start) == '[' || attributePath.charAt(start) == '.') { start++; } } catch (IndexOutOfBoundsException e) { throw createIllegalArgumentException(attributePath); } end = start + 1; while (end < attributePath.length()) { char c = attributePath.charAt(end); if ('.' == c || '[' == c) { break; } else if (']' == c) { isArray = true; break; } end++; } String part = attributePath.substring(start, end); Triple triple = new Triple(part, part.getBytes(UTF8_CHARSET), isArray); triples.add(triple); start = end + 1; } return new JsonPathCursor(attributePath, triples); }
java
public static JsonPathCursor createCursor(String attributePath) { ArrayList<Triple> triples = new ArrayList<Triple>(DEFAULT_PATH_ELEMENT_COUNT); int start = 0; int end; while (start < attributePath.length()) { boolean isArray = false; try { while (attributePath.charAt(start) == '[' || attributePath.charAt(start) == '.') { start++; } } catch (IndexOutOfBoundsException e) { throw createIllegalArgumentException(attributePath); } end = start + 1; while (end < attributePath.length()) { char c = attributePath.charAt(end); if ('.' == c || '[' == c) { break; } else if (']' == c) { isArray = true; break; } end++; } String part = attributePath.substring(start, end); Triple triple = new Triple(part, part.getBytes(UTF8_CHARSET), isArray); triples.add(triple); start = end + 1; } return new JsonPathCursor(attributePath, triples); }
[ "public", "static", "JsonPathCursor", "createCursor", "(", "String", "attributePath", ")", "{", "ArrayList", "<", "Triple", ">", "triples", "=", "new", "ArrayList", "<", "Triple", ">", "(", "DEFAULT_PATH_ELEMENT_COUNT", ")", ";", "int", "start", "=", "0", ";", "int", "end", ";", "while", "(", "start", "<", "attributePath", ".", "length", "(", ")", ")", "{", "boolean", "isArray", "=", "false", ";", "try", "{", "while", "(", "attributePath", ".", "charAt", "(", "start", ")", "==", "'", "'", "||", "attributePath", ".", "charAt", "(", "start", ")", "==", "'", "'", ")", "{", "start", "++", ";", "}", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "createIllegalArgumentException", "(", "attributePath", ")", ";", "}", "end", "=", "start", "+", "1", ";", "while", "(", "end", "<", "attributePath", ".", "length", "(", ")", ")", "{", "char", "c", "=", "attributePath", ".", "charAt", "(", "end", ")", ";", "if", "(", "'", "'", "==", "c", "||", "'", "'", "==", "c", ")", "{", "break", ";", "}", "else", "if", "(", "'", "'", "==", "c", ")", "{", "isArray", "=", "true", ";", "break", ";", "}", "end", "++", ";", "}", "String", "part", "=", "attributePath", ".", "substring", "(", "start", ",", "end", ")", ";", "Triple", "triple", "=", "new", "Triple", "(", "part", ",", "part", ".", "getBytes", "(", "UTF8_CHARSET", ")", ",", "isArray", ")", ";", "triples", ".", "add", "(", "triple", ")", ";", "start", "=", "end", "+", "1", ";", "}", "return", "new", "JsonPathCursor", "(", "attributePath", ",", "triples", ")", ";", "}" ]
Creates a new cursor from given attribute path. @param attributePath
[ "Creates", "a", "new", "cursor", "from", "given", "attribute", "path", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/JsonPathCursor.java#L63-L94
15,489
hazelcast/hazelcast
hazelcast-client/src/main/java/com/hazelcast/client/spi/ClientProxy.java
ClientProxy.destroyRemotely
public final void destroyRemotely() { ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName()); try { new ClientInvocation(getClient(), clientMessage, getName()).invoke().get(); } catch (Exception e) { throw rethrow(e); } }
java
public final void destroyRemotely() { ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName()); try { new ClientInvocation(getClient(), clientMessage, getName()).invoke().get(); } catch (Exception e) { throw rethrow(e); } }
[ "public", "final", "void", "destroyRemotely", "(", ")", "{", "ClientMessage", "clientMessage", "=", "ClientDestroyProxyCodec", ".", "encodeRequest", "(", "getDistributedObjectName", "(", ")", ",", "getServiceName", "(", ")", ")", ";", "try", "{", "new", "ClientInvocation", "(", "getClient", "(", ")", ",", "clientMessage", ",", "getName", "(", ")", ")", ".", "invoke", "(", ")", ".", "get", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "rethrow", "(", "e", ")", ";", "}", "}" ]
Destroys the remote distributed object counterpart of this proxy by issuing the destruction request to the cluster.
[ "Destroys", "the", "remote", "distributed", "object", "counterpart", "of", "this", "proxy", "by", "issuing", "the", "destruction", "request", "to", "the", "cluster", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/spi/ClientProxy.java#L171-L178
15,490
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/AbstractWriteBehindProcessor.java
AbstractWriteBehindProcessor.getBatchChunk
protected List<T> getBatchChunk(List<T> list, int batchSize, int chunkNumber) { if (list == null || list.isEmpty()) { return null; } final int start = chunkNumber * batchSize; final int end = Math.min(start + batchSize, list.size()); if (start >= end) { return null; } return list.subList(start, end); }
java
protected List<T> getBatchChunk(List<T> list, int batchSize, int chunkNumber) { if (list == null || list.isEmpty()) { return null; } final int start = chunkNumber * batchSize; final int end = Math.min(start + batchSize, list.size()); if (start >= end) { return null; } return list.subList(start, end); }
[ "protected", "List", "<", "T", ">", "getBatchChunk", "(", "List", "<", "T", ">", "list", ",", "int", "batchSize", ",", "int", "chunkNumber", ")", "{", "if", "(", "list", "==", "null", "||", "list", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "final", "int", "start", "=", "chunkNumber", "*", "batchSize", ";", "final", "int", "end", "=", "Math", ".", "min", "(", "start", "+", "batchSize", ",", "list", ".", "size", "(", ")", ")", ";", "if", "(", "start", ">=", "end", ")", "{", "return", "null", ";", "}", "return", "list", ".", "subList", "(", "start", ",", "end", ")", ";", "}" ]
Used to partition the list to chunks. @param list to be paged. @param batchSize batch operation size. @param chunkNumber batch chunk number. @return sub-list of list if any or null.
[ "Used", "to", "partition", "the", "list", "to", "chunks", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/mapstore/writebehind/AbstractWriteBehindProcessor.java#L66-L77
15,491
hazelcast/hazelcast
hazelcast-client/src/main/java/com/hazelcast/client/connection/ClientConnectionStrategy.java
ClientConnectionStrategy.init
public void init(ClientContext clientContext) { this.clientContext = clientContext; this.clientConnectionStrategyConfig = clientContext.getClientConfig().getConnectionStrategyConfig(); this.logger = clientContext.getLoggingService().getLogger(ClientConnectionStrategy.class); }
java
public void init(ClientContext clientContext) { this.clientContext = clientContext; this.clientConnectionStrategyConfig = clientContext.getClientConfig().getConnectionStrategyConfig(); this.logger = clientContext.getLoggingService().getLogger(ClientConnectionStrategy.class); }
[ "public", "void", "init", "(", "ClientContext", "clientContext", ")", "{", "this", ".", "clientContext", "=", "clientContext", ";", "this", ".", "clientConnectionStrategyConfig", "=", "clientContext", ".", "getClientConfig", "(", ")", ".", "getConnectionStrategyConfig", "(", ")", ";", "this", ".", "logger", "=", "clientContext", ".", "getLoggingService", "(", ")", ".", "getLogger", "(", "ClientConnectionStrategy", ".", "class", ")", ";", "}" ]
Initialize this strategy with client context and config @param clientContext hazelcast client context to access internal services
[ "Initialize", "this", "strategy", "with", "client", "context", "and", "config" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/connection/ClientConnectionStrategy.java#L42-L46
15,492
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/config/MerkleTreeConfig.java
MerkleTreeConfig.setMapName
public MerkleTreeConfig setMapName(String mapName) { if (StringUtil.isNullOrEmpty(mapName)) { throw new IllegalArgumentException("Merkle tree map name must not be empty."); } this.mapName = mapName; return this; }
java
public MerkleTreeConfig setMapName(String mapName) { if (StringUtil.isNullOrEmpty(mapName)) { throw new IllegalArgumentException("Merkle tree map name must not be empty."); } this.mapName = mapName; return this; }
[ "public", "MerkleTreeConfig", "setMapName", "(", "String", "mapName", ")", "{", "if", "(", "StringUtil", ".", "isNullOrEmpty", "(", "mapName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Merkle tree map name must not be empty.\"", ")", ";", "}", "this", ".", "mapName", "=", "mapName", ";", "return", "this", ";", "}" ]
Sets the map name to which this config applies. Map names are also matched by pattern and merkle with map name "default" applies to all maps that do not have more specific merkle tree configs. @param mapName the map name @return the merkle tree config @throws IllegalArgumentException if the {@code mapName} is {@code null} or empty.
[ "Sets", "the", "map", "name", "to", "which", "this", "config", "applies", ".", "Map", "names", "are", "also", "matched", "by", "pattern", "and", "merkle", "with", "map", "name", "default", "applies", "to", "all", "maps", "that", "do", "not", "have", "more", "specific", "merkle", "tree", "configs", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/MerkleTreeConfig.java#L171-L177
15,493
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicSecurityConfig.java
DynamicSecurityConfig.setClientPermissionConfigs
@Override public SecurityConfig setClientPermissionConfigs(Set<PermissionConfig> permissions) { if (securityService == null) { throw new UnsupportedOperationException("Unsupported operation"); } securityService.refreshClientPermissions(permissions); return this; }
java
@Override public SecurityConfig setClientPermissionConfigs(Set<PermissionConfig> permissions) { if (securityService == null) { throw new UnsupportedOperationException("Unsupported operation"); } securityService.refreshClientPermissions(permissions); return this; }
[ "@", "Override", "public", "SecurityConfig", "setClientPermissionConfigs", "(", "Set", "<", "PermissionConfig", ">", "permissions", ")", "{", "if", "(", "securityService", "==", "null", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Unsupported operation\"", ")", ";", "}", "securityService", ".", "refreshClientPermissions", "(", "permissions", ")", ";", "return", "this", ";", "}" ]
Updates client permission configuration cluster-wide.
[ "Updates", "client", "permission", "configuration", "cluster", "-", "wide", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicSecurityConfig.java#L144-L151
15,494
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/QueryCacheEndToEndProvider.java
QueryCacheEndToEndProvider.tryCreateQueryCache
public InternalQueryCache<K, V> tryCreateQueryCache(String mapName, String cacheName, ConstructorFunction<String, InternalQueryCache<K, V>> constructor) { ContextMutexFactory.Mutex mutex = lifecycleMutexFactory.mutexFor(mapName); try { synchronized (mutex) { ConcurrentMap<String, InternalQueryCache<K, V>> queryCacheRegistry = getOrPutIfAbsent(queryCacheRegistryPerMap, mapName, queryCacheRegistryConstructor); InternalQueryCache<K, V> queryCache = queryCacheRegistry.get(cacheName); // if this is a recreation we expect to have a Uuid otherwise we // need to generate one for the first creation of query cache. String cacheId = queryCache == null ? UuidUtil.newUnsecureUuidString() : queryCache.getCacheId(); queryCache = constructor.createNew(cacheId); if (queryCache != NULL_QUERY_CACHE) { queryCacheRegistry.put(cacheName, queryCache); return queryCache; } return null; } } finally { closeResource(mutex); } }
java
public InternalQueryCache<K, V> tryCreateQueryCache(String mapName, String cacheName, ConstructorFunction<String, InternalQueryCache<K, V>> constructor) { ContextMutexFactory.Mutex mutex = lifecycleMutexFactory.mutexFor(mapName); try { synchronized (mutex) { ConcurrentMap<String, InternalQueryCache<K, V>> queryCacheRegistry = getOrPutIfAbsent(queryCacheRegistryPerMap, mapName, queryCacheRegistryConstructor); InternalQueryCache<K, V> queryCache = queryCacheRegistry.get(cacheName); // if this is a recreation we expect to have a Uuid otherwise we // need to generate one for the first creation of query cache. String cacheId = queryCache == null ? UuidUtil.newUnsecureUuidString() : queryCache.getCacheId(); queryCache = constructor.createNew(cacheId); if (queryCache != NULL_QUERY_CACHE) { queryCacheRegistry.put(cacheName, queryCache); return queryCache; } return null; } } finally { closeResource(mutex); } }
[ "public", "InternalQueryCache", "<", "K", ",", "V", ">", "tryCreateQueryCache", "(", "String", "mapName", ",", "String", "cacheName", ",", "ConstructorFunction", "<", "String", ",", "InternalQueryCache", "<", "K", ",", "V", ">", ">", "constructor", ")", "{", "ContextMutexFactory", ".", "Mutex", "mutex", "=", "lifecycleMutexFactory", ".", "mutexFor", "(", "mapName", ")", ";", "try", "{", "synchronized", "(", "mutex", ")", "{", "ConcurrentMap", "<", "String", ",", "InternalQueryCache", "<", "K", ",", "V", ">", ">", "queryCacheRegistry", "=", "getOrPutIfAbsent", "(", "queryCacheRegistryPerMap", ",", "mapName", ",", "queryCacheRegistryConstructor", ")", ";", "InternalQueryCache", "<", "K", ",", "V", ">", "queryCache", "=", "queryCacheRegistry", ".", "get", "(", "cacheName", ")", ";", "// if this is a recreation we expect to have a Uuid otherwise we", "// need to generate one for the first creation of query cache.", "String", "cacheId", "=", "queryCache", "==", "null", "?", "UuidUtil", ".", "newUnsecureUuidString", "(", ")", ":", "queryCache", ".", "getCacheId", "(", ")", ";", "queryCache", "=", "constructor", ".", "createNew", "(", "cacheId", ")", ";", "if", "(", "queryCache", "!=", "NULL_QUERY_CACHE", ")", "{", "queryCacheRegistry", ".", "put", "(", "cacheName", ",", "queryCache", ")", ";", "return", "queryCache", ";", "}", "return", "null", ";", "}", "}", "finally", "{", "closeResource", "(", "mutex", ")", ";", "}", "}" ]
Idempotent query cache create mechanism.
[ "Idempotent", "query", "cache", "create", "mechanism", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/QueryCacheEndToEndProvider.java#L73-L100
15,495
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/QueryCacheEndToEndProvider.java
QueryCacheEndToEndProvider.getQueryCacheCount
public int getQueryCacheCount(String mapName) { Map<String, InternalQueryCache<K, V>> queryCacheRegistry = queryCacheRegistryPerMap.get(mapName); if (queryCacheRegistry == null) { return 0; } return queryCacheRegistry.size(); }
java
public int getQueryCacheCount(String mapName) { Map<String, InternalQueryCache<K, V>> queryCacheRegistry = queryCacheRegistryPerMap.get(mapName); if (queryCacheRegistry == null) { return 0; } return queryCacheRegistry.size(); }
[ "public", "int", "getQueryCacheCount", "(", "String", "mapName", ")", "{", "Map", "<", "String", ",", "InternalQueryCache", "<", "K", ",", "V", ">", ">", "queryCacheRegistry", "=", "queryCacheRegistryPerMap", ".", "get", "(", "mapName", ")", ";", "if", "(", "queryCacheRegistry", "==", "null", ")", "{", "return", "0", ";", "}", "return", "queryCacheRegistry", ".", "size", "(", ")", ";", "}" ]
only used in tests
[ "only", "used", "in", "tests" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/QueryCacheEndToEndProvider.java#L133-L139
15,496
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/mapreduce/impl/task/ReducerTaskScheduler.java
ReducerTaskScheduler.requestExecution
void requestExecution() { for (;;) { State currentState = state.get(); switch (currentState) { case INACTIVE: if (state.compareAndSet(State.INACTIVE, State.RUNNING)) { scheduleExecution(); return; } break; case RUNNING: if (state.compareAndSet(State.RUNNING, State.REQUESTED)) { return; } break; default: //someone else already requested execution return; } } }
java
void requestExecution() { for (;;) { State currentState = state.get(); switch (currentState) { case INACTIVE: if (state.compareAndSet(State.INACTIVE, State.RUNNING)) { scheduleExecution(); return; } break; case RUNNING: if (state.compareAndSet(State.RUNNING, State.REQUESTED)) { return; } break; default: //someone else already requested execution return; } } }
[ "void", "requestExecution", "(", ")", "{", "for", "(", ";", ";", ")", "{", "State", "currentState", "=", "state", ".", "get", "(", ")", ";", "switch", "(", "currentState", ")", "{", "case", "INACTIVE", ":", "if", "(", "state", ".", "compareAndSet", "(", "State", ".", "INACTIVE", ",", "State", ".", "RUNNING", ")", ")", "{", "scheduleExecution", "(", ")", ";", "return", ";", "}", "break", ";", "case", "RUNNING", ":", "if", "(", "state", ".", "compareAndSet", "(", "State", ".", "RUNNING", ",", "State", ".", "REQUESTED", ")", ")", "{", "return", ";", "}", "break", ";", "default", ":", "//someone else already requested execution", "return", ";", "}", "}", "}" ]
Request a new task execution if needed.
[ "Request", "a", "new", "task", "execution", "if", "needed", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/mapreduce/impl/task/ReducerTaskScheduler.java#L59-L79
15,497
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/mapreduce/impl/task/ReducerTaskScheduler.java
ReducerTaskScheduler.afterExecution
void afterExecution() { for (;;) { State currentState = state.get(); switch (currentState) { case REQUESTED: state.set(State.RUNNING); scheduleExecution(); return; case RUNNING: if (state.compareAndSet(State.RUNNING, State.INACTIVE)) { return; } break; default: throw new IllegalStateException("Inactive state is illegal here."); } } }
java
void afterExecution() { for (;;) { State currentState = state.get(); switch (currentState) { case REQUESTED: state.set(State.RUNNING); scheduleExecution(); return; case RUNNING: if (state.compareAndSet(State.RUNNING, State.INACTIVE)) { return; } break; default: throw new IllegalStateException("Inactive state is illegal here."); } } }
[ "void", "afterExecution", "(", ")", "{", "for", "(", ";", ";", ")", "{", "State", "currentState", "=", "state", ".", "get", "(", ")", ";", "switch", "(", "currentState", ")", "{", "case", "REQUESTED", ":", "state", ".", "set", "(", "State", ".", "RUNNING", ")", ";", "scheduleExecution", "(", ")", ";", "return", ";", "case", "RUNNING", ":", "if", "(", "state", ".", "compareAndSet", "(", "State", ".", "RUNNING", ",", "State", ".", "INACTIVE", ")", ")", "{", "return", ";", "}", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Inactive state is illegal here.\"", ")", ";", "}", "}", "}" ]
The task has to call this method after its execution.
[ "The", "task", "has", "to", "call", "this", "method", "after", "its", "execution", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/mapreduce/impl/task/ReducerTaskScheduler.java#L85-L102
15,498
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java
MapKeyLoader.calculateRole
private Role calculateRole() { boolean isPartitionOwner = partitionService.isPartitionOwner(partitionId); boolean isMapNamePartition = partitionId == mapNamePartition; boolean isMapNamePartitionFirstReplica = false; if (hasBackup && isMapNamePartition) { IPartition partition = partitionService.getPartition(partitionId); Address firstReplicaAddress = partition.getReplicaAddress(1); Member member = clusterService.getMember(firstReplicaAddress); if (member != null) { isMapNamePartitionFirstReplica = member.localMember(); } } return assignRole(isPartitionOwner, isMapNamePartition, isMapNamePartitionFirstReplica); }
java
private Role calculateRole() { boolean isPartitionOwner = partitionService.isPartitionOwner(partitionId); boolean isMapNamePartition = partitionId == mapNamePartition; boolean isMapNamePartitionFirstReplica = false; if (hasBackup && isMapNamePartition) { IPartition partition = partitionService.getPartition(partitionId); Address firstReplicaAddress = partition.getReplicaAddress(1); Member member = clusterService.getMember(firstReplicaAddress); if (member != null) { isMapNamePartitionFirstReplica = member.localMember(); } } return assignRole(isPartitionOwner, isMapNamePartition, isMapNamePartitionFirstReplica); }
[ "private", "Role", "calculateRole", "(", ")", "{", "boolean", "isPartitionOwner", "=", "partitionService", ".", "isPartitionOwner", "(", "partitionId", ")", ";", "boolean", "isMapNamePartition", "=", "partitionId", "==", "mapNamePartition", ";", "boolean", "isMapNamePartitionFirstReplica", "=", "false", ";", "if", "(", "hasBackup", "&&", "isMapNamePartition", ")", "{", "IPartition", "partition", "=", "partitionService", ".", "getPartition", "(", "partitionId", ")", ";", "Address", "firstReplicaAddress", "=", "partition", ".", "getReplicaAddress", "(", "1", ")", ";", "Member", "member", "=", "clusterService", ".", "getMember", "(", "firstReplicaAddress", ")", ";", "if", "(", "member", "!=", "null", ")", "{", "isMapNamePartitionFirstReplica", "=", "member", ".", "localMember", "(", ")", ";", "}", "}", "return", "assignRole", "(", "isPartitionOwner", ",", "isMapNamePartition", ",", "isMapNamePartitionFirstReplica", ")", ";", "}" ]
Calculates and returns the role for the map key loader on this partition
[ "Calculates", "and", "returns", "the", "role", "for", "the", "map", "key", "loader", "on", "this", "partition" ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java#L210-L223
15,499
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java
MapKeyLoader.loadingFinishedCallback
private ExecutionCallback<Boolean> loadingFinishedCallback() { return new ExecutionCallback<Boolean>() { @Override public void onResponse(Boolean loadingFinished) { if (loadingFinished) { updateLocalKeyLoadStatus(null); } } @Override public void onFailure(Throwable t) { updateLocalKeyLoadStatus(t); } }; }
java
private ExecutionCallback<Boolean> loadingFinishedCallback() { return new ExecutionCallback<Boolean>() { @Override public void onResponse(Boolean loadingFinished) { if (loadingFinished) { updateLocalKeyLoadStatus(null); } } @Override public void onFailure(Throwable t) { updateLocalKeyLoadStatus(t); } }; }
[ "private", "ExecutionCallback", "<", "Boolean", ">", "loadingFinishedCallback", "(", ")", "{", "return", "new", "ExecutionCallback", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "void", "onResponse", "(", "Boolean", "loadingFinished", ")", "{", "if", "(", "loadingFinished", ")", "{", "updateLocalKeyLoadStatus", "(", "null", ")", ";", "}", "}", "@", "Override", "public", "void", "onFailure", "(", "Throwable", "t", ")", "{", "updateLocalKeyLoadStatus", "(", "t", ")", ";", "}", "}", ";", "}" ]
Returns an execution callback to notify the record store for this map key loader that the key loading has finished.
[ "Returns", "an", "execution", "callback", "to", "notify", "the", "record", "store", "for", "this", "map", "key", "loader", "that", "the", "key", "loading", "has", "finished", "." ]
8c4bc10515dbbfb41a33e0302c0caedf3cda1baf
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java#L281-L295