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
29,500
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/BeanUtils.java
BeanUtils.setterMethod
public static Method setterMethod(Class<?> target, Class<?> componentClass) { try { return target.getMethod(setterName(componentClass), componentClass); } catch (NoSuchMethodException e) { //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target); return null; } catch (NullPointerException e) { return null; } }
java
public static Method setterMethod(Class<?> target, Class<?> componentClass) { try { return target.getMethod(setterName(componentClass), componentClass); } catch (NoSuchMethodException e) { //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target); return null; } catch (NullPointerException e) { return null; } }
[ "public", "static", "Method", "setterMethod", "(", "Class", "<", "?", ">", "target", ",", "Class", "<", "?", ">", "componentClass", ")", "{", "try", "{", "return", "target", ".", "getMethod", "(", "setterName", "(", "componentClass", ")", ",", "componentCl...
Returns a Method object corresponding to a setter that sets an instance of componentClass from target. @param target class that the setter should exist on @param componentClass component to set @return Method object, or null of one does not exist
[ "Returns", "a", "Method", "object", "corresponding", "to", "a", "setter", "that", "sets", "an", "instance", "of", "componentClass", "from", "target", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/BeanUtils.java#L101-L112
29,501
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheAdd.java
CacheAdd.extractIndexingProperties
private Properties extractIndexingProperties(OperationContext context, ModelNode operation, String cacheConfiguration) { Properties properties = new Properties(); PathAddress cacheAddress = getCacheAddressFromOperation(operation); Resource cacheConfigResource = context.readResourceFromRoot(cacheAddress.subAddress(0, 2), true) .getChild(PathElement.pathElement(ModelKeys.CONFIGURATIONS, ModelKeys.CONFIGURATIONS_NAME)) .getChild(PathElement.pathElement(getConfigurationKey(), cacheConfiguration)); PathElement indexingPathElement = PathElement.pathElement(ModelKeys.INDEXING, ModelKeys.INDEXING_NAME); if (cacheConfigResource == null || !cacheConfigResource.hasChild(indexingPathElement)) { return properties; } Resource indexingResource = cacheConfigResource.getChild(indexingPathElement); if (indexingResource == null) return properties; ModelNode indexingModel = indexingResource.getModel(); boolean hasProperties = indexingModel.hasDefined(ModelKeys.INDEXING_PROPERTIES); if (!hasProperties) return properties; ModelNode modelNode = indexingResource.getModel().get(ModelKeys.INDEXING_PROPERTIES); List<Property> modelProperties = modelNode.asPropertyList(); modelProperties.forEach(p -> properties.put(p.getName(), p.getValue().asString())); return properties; }
java
private Properties extractIndexingProperties(OperationContext context, ModelNode operation, String cacheConfiguration) { Properties properties = new Properties(); PathAddress cacheAddress = getCacheAddressFromOperation(operation); Resource cacheConfigResource = context.readResourceFromRoot(cacheAddress.subAddress(0, 2), true) .getChild(PathElement.pathElement(ModelKeys.CONFIGURATIONS, ModelKeys.CONFIGURATIONS_NAME)) .getChild(PathElement.pathElement(getConfigurationKey(), cacheConfiguration)); PathElement indexingPathElement = PathElement.pathElement(ModelKeys.INDEXING, ModelKeys.INDEXING_NAME); if (cacheConfigResource == null || !cacheConfigResource.hasChild(indexingPathElement)) { return properties; } Resource indexingResource = cacheConfigResource.getChild(indexingPathElement); if (indexingResource == null) return properties; ModelNode indexingModel = indexingResource.getModel(); boolean hasProperties = indexingModel.hasDefined(ModelKeys.INDEXING_PROPERTIES); if (!hasProperties) return properties; ModelNode modelNode = indexingResource.getModel().get(ModelKeys.INDEXING_PROPERTIES); List<Property> modelProperties = modelNode.asPropertyList(); modelProperties.forEach(p -> properties.put(p.getName(), p.getValue().asString())); return properties; }
[ "private", "Properties", "extractIndexingProperties", "(", "OperationContext", "context", ",", "ModelNode", "operation", ",", "String", "cacheConfiguration", ")", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "PathAddress", "cacheAddress", ...
Extract indexing information for the cache from the model. @return a {@link Properties} with the indexing properties or empty if the cache is not indexed
[ "Extract", "indexing", "information", "for", "the", "cache", "from", "the", "model", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheAdd.java#L115-L140
29,502
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheAdd.java
CacheAdd.populate
void populate(ModelNode fromModel, ModelNode toModel) throws OperationFailedException { for(AttributeDefinition attr : CacheResource.CACHE_ATTRIBUTES) { attr.validateAndSet(fromModel, toModel); } }
java
void populate(ModelNode fromModel, ModelNode toModel) throws OperationFailedException { for(AttributeDefinition attr : CacheResource.CACHE_ATTRIBUTES) { attr.validateAndSet(fromModel, toModel); } }
[ "void", "populate", "(", "ModelNode", "fromModel", ",", "ModelNode", "toModel", ")", "throws", "OperationFailedException", "{", "for", "(", "AttributeDefinition", "attr", ":", "CacheResource", ".", "CACHE_ATTRIBUTES", ")", "{", "attr", ".", "validateAndSet", "(", ...
Transfer elements common to both operations and models @param fromModel @param toModel
[ "Transfer", "elements", "common", "to", "both", "operations", "and", "models" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheAdd.java#L270-L274
29,503
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java
ReflectionUtil.getAllMethodsShallow
public static List<Method> getAllMethodsShallow(Class<?> c, Class<? extends Annotation> annotationType) { List<Method> annotated = new ArrayList<>(); for (Method m : c.getDeclaredMethods()) { if (m.isAnnotationPresent(annotationType)) annotated.add(m); } return annotated; }
java
public static List<Method> getAllMethodsShallow(Class<?> c, Class<? extends Annotation> annotationType) { List<Method> annotated = new ArrayList<>(); for (Method m : c.getDeclaredMethods()) { if (m.isAnnotationPresent(annotationType)) annotated.add(m); } return annotated; }
[ "public", "static", "List", "<", "Method", ">", "getAllMethodsShallow", "(", "Class", "<", "?", ">", "c", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotationType", ")", "{", "List", "<", "Method", ">", "annotated", "=", "new", "ArrayList", ...
Returns a set of Methods that contain the given method annotation. This includes all public, protected, package and private methods, but not those of superclasses and interfaces. @param c class to inspect @param annotationType the type of annotation to look for @return List of Method objects that require injection.
[ "Returns", "a", "set", "of", "Methods", "that", "contain", "the", "given", "method", "annotation", ".", "This", "includes", "all", "public", "protected", "package", "and", "private", "methods", "but", "not", "those", "of", "superclasses", "and", "interfaces", ...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L55-L63
29,504
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java
ReflectionUtil.notFound
private static boolean notFound(Method m, Collection<Method> s) { for (Method found : s) { if (m.getName().equals(found.getName()) && Arrays.equals(m.getParameterTypes(), found.getParameterTypes())) return false; } return true; }
java
private static boolean notFound(Method m, Collection<Method> s) { for (Method found : s) { if (m.getName().equals(found.getName()) && Arrays.equals(m.getParameterTypes(), found.getParameterTypes())) return false; } return true; }
[ "private", "static", "boolean", "notFound", "(", "Method", "m", ",", "Collection", "<", "Method", ">", "s", ")", "{", "for", "(", "Method", "found", ":", "s", ")", "{", "if", "(", "m", ".", "getName", "(", ")", ".", "equals", "(", "found", ".", "...
Tests whether a method has already been found, i.e., overridden. @param m method to inspect @param s collection of methods found @return true a method with the same signature already exists.
[ "Tests", "whether", "a", "method", "has", "already", "been", "found", "i", ".", "e", ".", "overridden", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L154-L161
29,505
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java
ReflectionUtil.getValue
public static Object getValue(Object instance, String fieldName) { Field f = findFieldRecursively(instance.getClass(), fieldName); if (f == null) throw new CacheException("Could not find field named '" + fieldName + "' on instance " + instance); try { f.setAccessible(true); return f.get(instance); } catch (IllegalAccessException iae) { throw new CacheException("Cannot access field " + f, iae); } }
java
public static Object getValue(Object instance, String fieldName) { Field f = findFieldRecursively(instance.getClass(), fieldName); if (f == null) throw new CacheException("Could not find field named '" + fieldName + "' on instance " + instance); try { f.setAccessible(true); return f.get(instance); } catch (IllegalAccessException iae) { throw new CacheException("Cannot access field " + f, iae); } }
[ "public", "static", "Object", "getValue", "(", "Object", "instance", ",", "String", "fieldName", ")", "{", "Field", "f", "=", "findFieldRecursively", "(", "instance", ".", "getClass", "(", ")", ",", "fieldName", ")", ";", "if", "(", "f", "==", "null", ")...
Retrieves the value of a field of an object instance via reflection @param instance to inspect @param fieldName name of field to retrieve @return a value
[ "Retrieves", "the", "value", "of", "a", "field", "of", "an", "object", "instance", "via", "reflection" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L272-L281
29,506
infinispan/infinispan
query/src/main/java/org/infinispan/query/indexmanager/IndexManagerBasedLockController.java
IndexManagerBasedLockController.waitForAvailabilityInternal
private boolean waitForAvailabilityInternal() { final Directory directory = indexManager.getDirectoryProvider().getDirectory(); try { Lock lock = directory.obtainLock(IndexWriter.WRITE_LOCK_NAME); lock.close(); return true; } catch (LockObtainFailedException lofe) { return false; } catch (IOException e) { log.error(e); return false; } }
java
private boolean waitForAvailabilityInternal() { final Directory directory = indexManager.getDirectoryProvider().getDirectory(); try { Lock lock = directory.obtainLock(IndexWriter.WRITE_LOCK_NAME); lock.close(); return true; } catch (LockObtainFailedException lofe) { return false; } catch (IOException e) { log.error(e); return false; } }
[ "private", "boolean", "waitForAvailabilityInternal", "(", ")", "{", "final", "Directory", "directory", "=", "indexManager", ".", "getDirectoryProvider", "(", ")", ".", "getDirectory", "(", ")", ";", "try", "{", "Lock", "lock", "=", "directory", ".", "obtainLock"...
This is returning as soon as the lock is available, or after 10 seconds. @return true if the lock is free at the time of returning.
[ "This", "is", "returning", "as", "soon", "as", "the", "lock", "is", "available", "or", "after", "10", "seconds", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/indexmanager/IndexManagerBasedLockController.java#L56-L68
29,507
infinispan/infinispan
lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java
RequestExpirationScheduler.scheduleForCompletion
public void scheduleForCompletion(String requestId, CompletableFuture<Boolean> request, long time, TimeUnit unit) { if (request.isDone()) { if (trace) { log.tracef("Request[%s] is not scheduled because is already done", requestId); } return; } if (scheduledRequests.containsKey(requestId)) { String message = String.format("Request[%s] is not scheduled because it is already scheduled", requestId); log.error(message); throw new IllegalStateException(message); } if (trace) { log.tracef("Request[%s] being scheduled to be completed in [%d, %s]", requestId, time, unit); } ScheduledFuture<?> scheduledFuture = scheduledExecutorService.schedule(() -> { request.complete(false); scheduledRequests.remove(requestId); }, time, unit); scheduledRequests.putIfAbsent(requestId, new ScheduledRequest(request, scheduledFuture)); }
java
public void scheduleForCompletion(String requestId, CompletableFuture<Boolean> request, long time, TimeUnit unit) { if (request.isDone()) { if (trace) { log.tracef("Request[%s] is not scheduled because is already done", requestId); } return; } if (scheduledRequests.containsKey(requestId)) { String message = String.format("Request[%s] is not scheduled because it is already scheduled", requestId); log.error(message); throw new IllegalStateException(message); } if (trace) { log.tracef("Request[%s] being scheduled to be completed in [%d, %s]", requestId, time, unit); } ScheduledFuture<?> scheduledFuture = scheduledExecutorService.schedule(() -> { request.complete(false); scheduledRequests.remove(requestId); }, time, unit); scheduledRequests.putIfAbsent(requestId, new ScheduledRequest(request, scheduledFuture)); }
[ "public", "void", "scheduleForCompletion", "(", "String", "requestId", ",", "CompletableFuture", "<", "Boolean", ">", "request", ",", "long", "time", ",", "TimeUnit", "unit", ")", "{", "if", "(", "request", ".", "isDone", "(", ")", ")", "{", "if", "(", "...
Schedules a request for completion @param requestId, the unique identifier if the request @param request, the request @param time, time expressed in long @param unit, {@link TimeUnit}
[ "Schedules", "a", "request", "for", "completion" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java#L58-L82
29,508
infinispan/infinispan
lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java
RequestExpirationScheduler.abortScheduling
public void abortScheduling(String requestId, boolean force) { if (trace) { log.tracef("Request[%s] abort scheduling", requestId); } ScheduledRequest scheduledRequest = scheduledRequests.get(requestId); if (scheduledRequest != null && (scheduledRequest.request.isDone() || force)) { scheduledRequest.scheduledFuture.cancel(false); scheduledRequests.remove(requestId); } }
java
public void abortScheduling(String requestId, boolean force) { if (trace) { log.tracef("Request[%s] abort scheduling", requestId); } ScheduledRequest scheduledRequest = scheduledRequests.get(requestId); if (scheduledRequest != null && (scheduledRequest.request.isDone() || force)) { scheduledRequest.scheduledFuture.cancel(false); scheduledRequests.remove(requestId); } }
[ "public", "void", "abortScheduling", "(", "String", "requestId", ",", "boolean", "force", ")", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"Request[%s] abort scheduling\"", ",", "requestId", ")", ";", "}", "ScheduledRequest", "scheduledReques...
Aborts the scheduled request. If force is true, it will abort even if the request is not completed @param requestId, unique identifier of the request @param force, force abort
[ "Aborts", "the", "scheduled", "request", ".", "If", "force", "is", "true", "it", "will", "abort", "even", "if", "the", "request", "is", "not", "completed" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java#L99-L108
29,509
infinispan/infinispan
tasks/api/src/main/java/org/infinispan/tasks/TaskContext.java
TaskContext.addParameter
public TaskContext addParameter(String name, Object value) { Map<String, Object> params = (Map<String, Object>) parameters.orElseGet(HashMap::new); params.put(name, value); return parameters(params); }
java
public TaskContext addParameter(String name, Object value) { Map<String, Object> params = (Map<String, Object>) parameters.orElseGet(HashMap::new); params.put(name, value); return parameters(params); }
[ "public", "TaskContext", "addParameter", "(", "String", "name", ",", "Object", "value", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "parameters", ".", "orElseGet", "(", "HashMap",...
Adds a named parameter to the task context
[ "Adds", "a", "named", "parameter", "to", "the", "task", "context" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/tasks/api/src/main/java/org/infinispan/tasks/TaskContext.java#L78-L83
29,510
infinispan/infinispan
core/src/main/java/org/infinispan/container/impl/L1SegmentedDataContainer.java
L1SegmentedDataContainer.clear
@Override public void clear(IntSet segments) { IntSet extraSegments = null; PrimitiveIterator.OfInt iter = segments.iterator(); // First try to just clear the respective maps while (iter.hasNext()) { int segment = iter.nextInt(); ConcurrentMap<K, InternalCacheEntry<K, V>> map = maps.get(segment); if (map != null) { map.clear(); } else { // If we don't have a map for a segment we have to later go through the unowned segments and remove // those entries separately if (extraSegments == null) { extraSegments = IntSets.mutableEmptySet(segments.size()); } extraSegments.set(segment); } } if (extraSegments != null) { IntSet finalExtraSegments = extraSegments; nonOwnedEntries.keySet().removeIf(k -> finalExtraSegments.contains(getSegmentForKey(k))); } }
java
@Override public void clear(IntSet segments) { IntSet extraSegments = null; PrimitiveIterator.OfInt iter = segments.iterator(); // First try to just clear the respective maps while (iter.hasNext()) { int segment = iter.nextInt(); ConcurrentMap<K, InternalCacheEntry<K, V>> map = maps.get(segment); if (map != null) { map.clear(); } else { // If we don't have a map for a segment we have to later go through the unowned segments and remove // those entries separately if (extraSegments == null) { extraSegments = IntSets.mutableEmptySet(segments.size()); } extraSegments.set(segment); } } if (extraSegments != null) { IntSet finalExtraSegments = extraSegments; nonOwnedEntries.keySet().removeIf(k -> finalExtraSegments.contains(getSegmentForKey(k))); } }
[ "@", "Override", "public", "void", "clear", "(", "IntSet", "segments", ")", "{", "IntSet", "extraSegments", "=", "null", ";", "PrimitiveIterator", ".", "OfInt", "iter", "=", "segments", ".", "iterator", "(", ")", ";", "// First try to just clear the respective map...
Removes all entries that map to the given segments @param segments the segments to clear data for
[ "Removes", "all", "entries", "that", "map", "to", "the", "given", "segments" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/container/impl/L1SegmentedDataContainer.java#L145-L169
29,511
infinispan/infinispan
query/src/main/java/org/infinispan/query/backend/QueryKnownClasses.java
QueryKnownClasses.startInternalCache
private void startInternalCache() { if (knownClassesCache == null) { synchronized (this) { if (knownClassesCache == null) { internalCacheRegistry.registerInternalCache(QUERY_KNOWN_CLASSES_CACHE_NAME, getInternalCacheConfig(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT)); Cache<KeyValuePair<String, Class<?>>, Boolean> knownClassesCache = SecurityActions.getCache(cacheManager, QUERY_KNOWN_CLASSES_CACHE_NAME); this.knownClassesCache = knownClassesCache.getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.IGNORE_RETURN_VALUES); transactionHelper = new TransactionHelper(this.knownClassesCache.getTransactionManager()); } } } }
java
private void startInternalCache() { if (knownClassesCache == null) { synchronized (this) { if (knownClassesCache == null) { internalCacheRegistry.registerInternalCache(QUERY_KNOWN_CLASSES_CACHE_NAME, getInternalCacheConfig(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT)); Cache<KeyValuePair<String, Class<?>>, Boolean> knownClassesCache = SecurityActions.getCache(cacheManager, QUERY_KNOWN_CLASSES_CACHE_NAME); this.knownClassesCache = knownClassesCache.getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.IGNORE_RETURN_VALUES); transactionHelper = new TransactionHelper(this.knownClassesCache.getTransactionManager()); } } } }
[ "private", "void", "startInternalCache", "(", ")", "{", "if", "(", "knownClassesCache", "==", "null", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "knownClassesCache", "==", "null", ")", "{", "internalCacheRegistry", ".", "registerInternalCache", ...
Start the internal cache lazily.
[ "Start", "the", "internal", "cache", "lazily", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/backend/QueryKnownClasses.java#L206-L217
29,512
infinispan/infinispan
query/src/main/java/org/infinispan/query/backend/QueryKnownClasses.java
QueryKnownClasses.getInternalCacheConfig
private Configuration getInternalCacheConfig() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // allow the registry to work for local caches as well as clustered caches CacheMode cacheMode = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; configurationBuilder.clustering().cacheMode(cacheMode); // use invocation batching (cache-only transactions) for high consistency as writes are expected to be rare in this cache configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(null).invocationBatching().enable(); configurationBuilder.security().authorization().disable(); return configurationBuilder.build(); }
java
private Configuration getInternalCacheConfig() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // allow the registry to work for local caches as well as clustered caches CacheMode cacheMode = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; configurationBuilder.clustering().cacheMode(cacheMode); // use invocation batching (cache-only transactions) for high consistency as writes are expected to be rare in this cache configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(null).invocationBatching().enable(); configurationBuilder.security().authorization().disable(); return configurationBuilder.build(); }
[ "private", "Configuration", "getInternalCacheConfig", "(", ")", "{", "ConfigurationBuilder", "configurationBuilder", "=", "new", "ConfigurationBuilder", "(", ")", ";", "// allow the registry to work for local caches as well as clustered caches", "CacheMode", "cacheMode", "=", "ca...
Create the configuration for the internal cache.
[ "Create", "the", "configuration", "for", "the", "internal", "cache", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/backend/QueryKnownClasses.java#L222-L236
29,513
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheCommands.java
CacheCommands.execute
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); ListIterator<PathElement> iterator = address.iterator(); PathElement element = iterator.next(); while (!element.getValue().equals(InfinispanSubsystem.SUBSYSTEM_NAME)) { element = iterator.next(); } final String cacheContainerName = iterator.next().getValue(); final String cacheName = iterator.next().getValue(); if (context.isNormalServer()) { final ServiceController<?> controller = context.getServiceRegistry(false).getService(CacheServiceName.CACHE.getServiceName(cacheContainerName, cacheName)); Cache<?, ?> cache = (Cache<?, ?>) controller.getValue(); ModelNode operationResult; try { operationResult = invokeCommand(cache, operation, context); } catch (Exception e) { throw new OperationFailedException(MESSAGES.failedToInvokeOperation(e.getLocalizedMessage()), e); } if (operationResult != null) { context.getResult().set(operationResult); } } }
java
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); ListIterator<PathElement> iterator = address.iterator(); PathElement element = iterator.next(); while (!element.getValue().equals(InfinispanSubsystem.SUBSYSTEM_NAME)) { element = iterator.next(); } final String cacheContainerName = iterator.next().getValue(); final String cacheName = iterator.next().getValue(); if (context.isNormalServer()) { final ServiceController<?> controller = context.getServiceRegistry(false).getService(CacheServiceName.CACHE.getServiceName(cacheContainerName, cacheName)); Cache<?, ?> cache = (Cache<?, ?>) controller.getValue(); ModelNode operationResult; try { operationResult = invokeCommand(cache, operation, context); } catch (Exception e) { throw new OperationFailedException(MESSAGES.failedToInvokeOperation(e.getLocalizedMessage()), e); } if (operationResult != null) { context.getResult().set(operationResult); } } }
[ "@", "Override", "public", "void", "execute", "(", "OperationContext", "context", ",", "ModelNode", "operation", ")", "throws", "OperationFailedException", "{", "final", "PathAddress", "address", "=", "PathAddress", ".", "pathAddress", "(", "operation", ".", "requir...
An attribute write handler which performs cache operations @param context the operation context @param operation the operation being executed @throws org.jboss.as.controller.OperationFailedException
[ "An", "attribute", "write", "handler", "which", "performs", "cache", "operations" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheCommands.java#L75-L99
29,514
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java
DummyTransaction.commit
@Override public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException { if (trace) { log.tracef("Transaction.commit() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot commit transaction."); } runPrepare(); runCommit(false); }
java
@Override public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException { if (trace) { log.tracef("Transaction.commit() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot commit transaction."); } runPrepare(); runCommit(false); }
[ "@", "Override", "public", "void", "commit", "(", ")", "throws", "RollbackException", ",", "HeuristicMixedException", ",", "HeuristicRollbackException", ",", "SecurityException", ",", "SystemException", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(",...
Attempt to commit this transaction. @throws RollbackException If the transaction was marked for rollback only, the transaction is rolled back and this exception is thrown. @throws SystemException If the transaction service fails in an unexpected way. @throws HeuristicMixedException If a heuristic decision was made and some some parts of the transaction have been committed while other parts have been rolled back. @throws HeuristicRollbackException If a heuristic decision to roll back the transaction was made. @throws SecurityException If the caller is not allowed to commit this transaction.
[ "Attempt", "to", "commit", "this", "transaction", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java#L104-L114
29,515
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java
DummyTransaction.rollback
@Override public void rollback() throws IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.rollback() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot rollback transaction"); } try { status = Status.STATUS_MARKED_ROLLBACK; endResources(); runCommit(false); } catch (HeuristicMixedException | HeuristicRollbackException e) { log.errorRollingBack(e); SystemException systemException = new SystemException("Unable to rollback transaction"); systemException.initCause(e); throw systemException; } catch (RollbackException e) { //ignored if (trace) { log.trace("RollbackException thrown while rolling back", e); } } }
java
@Override public void rollback() throws IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.rollback() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot rollback transaction"); } try { status = Status.STATUS_MARKED_ROLLBACK; endResources(); runCommit(false); } catch (HeuristicMixedException | HeuristicRollbackException e) { log.errorRollingBack(e); SystemException systemException = new SystemException("Unable to rollback transaction"); systemException.initCause(e); throw systemException; } catch (RollbackException e) { //ignored if (trace) { log.trace("RollbackException thrown while rolling back", e); } } }
[ "@", "Override", "public", "void", "rollback", "(", ")", "throws", "IllegalStateException", ",", "SystemException", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"Transaction.rollback() invoked in transaction with Xid=%s\"", ",", "xid", ")", ";", ...
Rolls back this transaction. @throws IllegalStateException If the transaction is in a state where it cannot be rolled back. This could be because the transaction is no longer active, or because it is in the {@link Status#STATUS_PREPARED prepared state}. @throws SystemException If the transaction service fails in an unexpected way.
[ "Rolls", "back", "this", "transaction", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java#L124-L147
29,516
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java
DummyTransaction.setRollbackOnly
@Override public void setRollbackOnly() throws IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.setRollbackOnly() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot change status"); } markRollbackOnly(new RollbackException("Transaction marked as rollback only.")); }
java
@Override public void setRollbackOnly() throws IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.setRollbackOnly() invoked in transaction with Xid=%s", xid); } if (isDone()) { throw new IllegalStateException("Transaction is done. Cannot change status"); } markRollbackOnly(new RollbackException("Transaction marked as rollback only.")); }
[ "@", "Override", "public", "void", "setRollbackOnly", "(", ")", "throws", "IllegalStateException", ",", "SystemException", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"Transaction.setRollbackOnly() invoked in transaction with Xid=%s\"", ",", "xid", ...
Mark the transaction so that the only possible outcome is a rollback. @throws IllegalStateException If the transaction is not in an active state. @throws SystemException If the transaction service fails in an unexpected way.
[ "Mark", "the", "transaction", "so", "that", "the", "only", "possible", "outcome", "is", "a", "rollback", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java#L155-L164
29,517
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java
DummyTransaction.enlistResource
@Override public boolean enlistResource(XAResource resource) throws RollbackException, IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.enlistResource(%s) invoked in transaction with Xid=%s", resource, xid); } checkStatusBeforeRegister("resource"); //avoid duplicates for (Map.Entry<XAResource, Integer> otherResourceEntry : resources) { try { if (otherResourceEntry.getKey().isSameRM(resource)) { log.debug("Ignoring resource. It is already there."); return true; } } catch (XAException e) { //ignored } } resources.add(new AbstractMap.SimpleEntry<>(resource, null)); try { if (trace) { log.tracef("XaResource.start() invoked in transaction with Xid=%s", xid); } resource.start(xid, XAResource.TMNOFLAGS); } catch (XAException e) { if (isRollbackCode(e)) { RollbackException exception = newRollbackException(format("Resource %s rolled back the transaction while XaResource.start()", resource), e); markRollbackOnly(exception); log.errorEnlistingResource(e); throw exception; } log.errorEnlistingResource(e); throw new SystemException(e.getMessage()); } return true; }
java
@Override public boolean enlistResource(XAResource resource) throws RollbackException, IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.enlistResource(%s) invoked in transaction with Xid=%s", resource, xid); } checkStatusBeforeRegister("resource"); //avoid duplicates for (Map.Entry<XAResource, Integer> otherResourceEntry : resources) { try { if (otherResourceEntry.getKey().isSameRM(resource)) { log.debug("Ignoring resource. It is already there."); return true; } } catch (XAException e) { //ignored } } resources.add(new AbstractMap.SimpleEntry<>(resource, null)); try { if (trace) { log.tracef("XaResource.start() invoked in transaction with Xid=%s", xid); } resource.start(xid, XAResource.TMNOFLAGS); } catch (XAException e) { if (isRollbackCode(e)) { RollbackException exception = newRollbackException(format("Resource %s rolled back the transaction while XaResource.start()", resource), e); markRollbackOnly(exception); log.errorEnlistingResource(e); throw exception; } log.errorEnlistingResource(e); throw new SystemException(e.getMessage()); } return true; }
[ "@", "Override", "public", "boolean", "enlistResource", "(", "XAResource", "resource", ")", "throws", "RollbackException", ",", "IllegalStateException", ",", "SystemException", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"Transaction.enlistResour...
Enlist an XA resource with this transaction. @return <code>true</code> if the resource could be enlisted with this transaction, otherwise <code>false</code>. @throws RollbackException If the transaction is marked for rollback only. @throws IllegalStateException If the transaction is in a state where resources cannot be enlisted. This could be because the transaction is no longer active, or because it is in the {@link Status#STATUS_PREPARED prepared state}. @throws SystemException If the transaction service fails in an unexpected way.
[ "Enlist", "an", "XA", "resource", "with", "this", "transaction", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java#L187-L224
29,518
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java
DummyTransaction.runCommit
public void runCommit(boolean forceRollback) throws HeuristicMixedException, HeuristicRollbackException, RollbackException { if (trace) { log.tracef("runCommit(forceRollback=%b) invoked in transaction with Xid=%s", forceRollback, xid); } if (forceRollback) { markRollbackOnly(new RollbackException(FORCE_ROLLBACK_MESSAGE)); } int notifyAfterStatus = 0; try { if (status == Status.STATUS_MARKED_ROLLBACK) { notifyAfterStatus = Status.STATUS_ROLLEDBACK; rollbackResources(); } else { notifyAfterStatus = Status.STATUS_COMMITTED; commitResources(); } } finally { notifyAfterCompletion(notifyAfterStatus); DummyBaseTransactionManager.setTransaction(null); } throwRollbackExceptionIfAny(forceRollback); }
java
public void runCommit(boolean forceRollback) throws HeuristicMixedException, HeuristicRollbackException, RollbackException { if (trace) { log.tracef("runCommit(forceRollback=%b) invoked in transaction with Xid=%s", forceRollback, xid); } if (forceRollback) { markRollbackOnly(new RollbackException(FORCE_ROLLBACK_MESSAGE)); } int notifyAfterStatus = 0; try { if (status == Status.STATUS_MARKED_ROLLBACK) { notifyAfterStatus = Status.STATUS_ROLLEDBACK; rollbackResources(); } else { notifyAfterStatus = Status.STATUS_COMMITTED; commitResources(); } } finally { notifyAfterCompletion(notifyAfterStatus); DummyBaseTransactionManager.setTransaction(null); } throwRollbackExceptionIfAny(forceRollback); }
[ "public", "void", "runCommit", "(", "boolean", "forceRollback", ")", "throws", "HeuristicMixedException", ",", "HeuristicRollbackException", ",", "RollbackException", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"runCommit(forceRollback=%b) invoked in...
Runs the second phase of two-phase-commit protocol. If {@code forceRollback} is {@code true}, then a {@link RollbackException} is thrown with the message {@link #FORCE_ROLLBACK_MESSAGE}. @param forceRollback force the transaction to rollback.
[ "Runs", "the", "second", "phase", "of", "two", "-", "phase", "-", "commit", "protocol", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/tm/DummyTransaction.java#L314-L337
29,519
infinispan/infinispan
lucene/lucene-directory/src/main/java/org/infinispan/lucene/LuceneKey2StringMapper.java
LuceneKey2StringMapper.getKeyMapping
@Override public Object getKeyMapping(String key) { if (key == null) { throw new IllegalArgumentException("Not supporting null keys"); } // ChunkCacheKey: "C|" + fileName + "|" + chunkId + "|" + bufferSize "|" + indexName + "|" + affinitySegmentId; // FileCacheKey : "M|" + fileName + "|"+ indexName + "|" + affinitySegmentId; // FileListCacheKey : "*|" + indexName + "|" + affinitySegmentId; // FileReadLockKey : "RL|" + fileName + "|"+ indexName + "|" + affinitySegmentId; String[] split = singlePipePattern.split(key); switch (split[0]) { case "C": { if (split.length != 6) { throw log.keyMappperUnexpectedStringFormat(key); } final String indexName = split[4]; final String fileName = split[1]; final int chunkId = toInt(split[2], key); final int bufferSize = toInt(split[3], key); final int affinitySegmentId = toInt(split[5], key); return new ChunkCacheKey(indexName, fileName, chunkId, bufferSize, affinitySegmentId); } case "M": { if (split.length != 4) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[2]; final String fileName = split[1]; final int affinitySegmentId = toInt(split[3], key); return new FileCacheKey(indexName, fileName, affinitySegmentId); } case "*": { if (split.length != 3) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[1]; final int affinitySegmentId = toInt(split[2], key); return new FileListCacheKey(indexName, affinitySegmentId); } case "RL": { if (split.length != 4) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[2]; final String fileName = split[1]; final int affinitySegmentId = toInt(split[3], key); return new FileReadLockKey(indexName, fileName, affinitySegmentId); } default: throw log.keyMappperUnexpectedStringFormat(key); } }
java
@Override public Object getKeyMapping(String key) { if (key == null) { throw new IllegalArgumentException("Not supporting null keys"); } // ChunkCacheKey: "C|" + fileName + "|" + chunkId + "|" + bufferSize "|" + indexName + "|" + affinitySegmentId; // FileCacheKey : "M|" + fileName + "|"+ indexName + "|" + affinitySegmentId; // FileListCacheKey : "*|" + indexName + "|" + affinitySegmentId; // FileReadLockKey : "RL|" + fileName + "|"+ indexName + "|" + affinitySegmentId; String[] split = singlePipePattern.split(key); switch (split[0]) { case "C": { if (split.length != 6) { throw log.keyMappperUnexpectedStringFormat(key); } final String indexName = split[4]; final String fileName = split[1]; final int chunkId = toInt(split[2], key); final int bufferSize = toInt(split[3], key); final int affinitySegmentId = toInt(split[5], key); return new ChunkCacheKey(indexName, fileName, chunkId, bufferSize, affinitySegmentId); } case "M": { if (split.length != 4) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[2]; final String fileName = split[1]; final int affinitySegmentId = toInt(split[3], key); return new FileCacheKey(indexName, fileName, affinitySegmentId); } case "*": { if (split.length != 3) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[1]; final int affinitySegmentId = toInt(split[2], key); return new FileListCacheKey(indexName, affinitySegmentId); } case "RL": { if (split.length != 4) throw log.keyMappperUnexpectedStringFormat(key); final String indexName = split[2]; final String fileName = split[1]; final int affinitySegmentId = toInt(split[3], key); return new FileReadLockKey(indexName, fileName, affinitySegmentId); } default: throw log.keyMappperUnexpectedStringFormat(key); } }
[ "@", "Override", "public", "Object", "getKeyMapping", "(", "String", "key", ")", "{", "if", "(", "key", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Not supporting null keys\"", ")", ";", "}", "// ChunkCacheKey: \"C|\" + fileName + \"|...
This method has to perform the inverse transformation of the keys used in the Lucene Directory from String to object. So this implementation is strongly coupled to the toString method of each key type. @see ChunkCacheKey#toString() @see FileCacheKey#toString() @see FileListCacheKey#toString() @see FileReadLockKey#toString()
[ "This", "method", "has", "to", "perform", "the", "inverse", "transformation", "of", "the", "keys", "used", "in", "the", "Lucene", "Directory", "from", "String", "to", "object", ".", "So", "this", "implementation", "is", "strongly", "coupled", "to", "the", "t...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lucene/lucene-directory/src/main/java/org/infinispan/lucene/LuceneKey2StringMapper.java#L52-L97
29,520
infinispan/infinispan
hibernate/cache-v51/src/main/java/org/infinispan/hibernate/cache/v51/impl/BaseRegion.java
BaseRegion.suspend
public Transaction suspend() { Transaction tx = null; try { if ( tm != null ) { tx = tm.suspend(); } } catch (SystemException se) { throw log.cannotSuspendTx(se); } return tx; }
java
public Transaction suspend() { Transaction tx = null; try { if ( tm != null ) { tx = tm.suspend(); } } catch (SystemException se) { throw log.cannotSuspendTx(se); } return tx; }
[ "public", "Transaction", "suspend", "(", ")", "{", "Transaction", "tx", "=", "null", ";", "try", "{", "if", "(", "tm", "!=", "null", ")", "{", "tx", "=", "tm", ".", "suspend", "(", ")", ";", "}", "}", "catch", "(", "SystemException", "se", ")", "...
Tell the TransactionManager to suspend any ongoing transaction. @return the transaction that was suspended, or <code>null</code> if there wasn't one
[ "Tell", "the", "TransactionManager", "to", "suspend", "any", "ongoing", "transaction", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-v51/src/main/java/org/infinispan/hibernate/cache/v51/impl/BaseRegion.java#L168-L179
29,521
infinispan/infinispan
hibernate/cache-v51/src/main/java/org/infinispan/hibernate/cache/v51/impl/BaseRegion.java
BaseRegion.resume
public void resume(Transaction tx) { try { if ( tx != null ) { tm.resume( tx ); } } catch (Exception e) { throw log.cannotResumeTx( e ); } }
java
public void resume(Transaction tx) { try { if ( tx != null ) { tm.resume( tx ); } } catch (Exception e) { throw log.cannotResumeTx( e ); } }
[ "public", "void", "resume", "(", "Transaction", "tx", ")", "{", "try", "{", "if", "(", "tx", "!=", "null", ")", "{", "tm", ".", "resume", "(", "tx", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "log", ".", "cannotResumeT...
Tell the TransactionManager to resume the given transaction @param tx the transaction to suspend. May be <code>null</code>.
[ "Tell", "the", "TransactionManager", "to", "resume", "the", "given", "transaction" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-v51/src/main/java/org/infinispan/hibernate/cache/v51/impl/BaseRegion.java#L186-L195
29,522
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/AddAliasCommand.java
AddAliasCommand.addNewAliasToList
private ModelNode addNewAliasToList(ModelNode list, String alias) { // check for empty string if (alias == null || alias.equals("")) return list ; // check for undefined list (AS7-3476) if (!list.isDefined()) { list.setEmptyList(); } ModelNode newList = list.clone() ; List<ModelNode> listElements = list.asList(); boolean found = false; for (ModelNode listElement : listElements) { if (listElement.asString().equals(alias)) { found = true; } } if (!found) { newList.add().set(alias); } return newList ; }
java
private ModelNode addNewAliasToList(ModelNode list, String alias) { // check for empty string if (alias == null || alias.equals("")) return list ; // check for undefined list (AS7-3476) if (!list.isDefined()) { list.setEmptyList(); } ModelNode newList = list.clone() ; List<ModelNode> listElements = list.asList(); boolean found = false; for (ModelNode listElement : listElements) { if (listElement.asString().equals(alias)) { found = true; } } if (!found) { newList.add().set(alias); } return newList ; }
[ "private", "ModelNode", "addNewAliasToList", "(", "ModelNode", "list", ",", "String", "alias", ")", "{", "// check for empty string", "if", "(", "alias", "==", "null", "||", "alias", ".", "equals", "(", "\"\"", ")", ")", "return", "list", ";", "// check for un...
Adds new alias to a LIST ModelNode of existing aliases. @param list LIST ModelNode of aliases @param alias @return LIST ModelNode with the added aliases
[ "Adds", "new", "alias", "to", "a", "LIST", "ModelNode", "of", "existing", "aliases", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/AddAliasCommand.java#L97-L121
29,523
infinispan/infinispan
query/src/main/java/org/infinispan/query/impl/ComponentRegistryUtils.java
ComponentRegistryUtils.getQueryCache
public static QueryCache getQueryCache(Cache<?, ?> cache) { return SecurityActions.getCacheGlobalComponentRegistry(cache.getAdvancedCache()).getComponent(QueryCache.class); }
java
public static QueryCache getQueryCache(Cache<?, ?> cache) { return SecurityActions.getCacheGlobalComponentRegistry(cache.getAdvancedCache()).getComponent(QueryCache.class); }
[ "public", "static", "QueryCache", "getQueryCache", "(", "Cache", "<", "?", ",", "?", ">", "cache", ")", "{", "return", "SecurityActions", ".", "getCacheGlobalComponentRegistry", "(", "cache", ".", "getAdvancedCache", "(", ")", ")", ".", "getComponent", "(", "Q...
Returns the optional QueryCache.
[ "Returns", "the", "optional", "QueryCache", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/impl/ComponentRegistryUtils.java#L66-L68
29,524
infinispan/infinispan
object-filter/src/main/java/org/infinispan/objectfilter/impl/predicateindex/AttributeNode.java
AttributeNode.addChild
public AttributeNode<AttributeMetadata, AttributeId> addChild(AttributeId attribute) { AttributeNode<AttributeMetadata, AttributeId> child; if (children == null) { children = new HashMap<>(); child = new AttributeNode<>(attribute, this); children.put(attribute, child); rebuildChildrenArray(); } else { child = children.get(attribute); if (child == null) { child = new AttributeNode<>(attribute, this); children.put(attribute, child); rebuildChildrenArray(); } } return child; }
java
public AttributeNode<AttributeMetadata, AttributeId> addChild(AttributeId attribute) { AttributeNode<AttributeMetadata, AttributeId> child; if (children == null) { children = new HashMap<>(); child = new AttributeNode<>(attribute, this); children.put(attribute, child); rebuildChildrenArray(); } else { child = children.get(attribute); if (child == null) { child = new AttributeNode<>(attribute, this); children.put(attribute, child); rebuildChildrenArray(); } } return child; }
[ "public", "AttributeNode", "<", "AttributeMetadata", ",", "AttributeId", ">", "addChild", "(", "AttributeId", "attribute", ")", "{", "AttributeNode", "<", "AttributeMetadata", ",", "AttributeId", ">", "child", ";", "if", "(", "children", "==", "null", ")", "{", ...
Add a child node. If the child already exists it just increments its usage counter and returns the existing child. @param attribute @return the added or existing child
[ "Add", "a", "child", "node", ".", "If", "the", "child", "already", "exists", "it", "just", "increments", "its", "usage", "counter", "and", "returns", "the", "existing", "child", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/object-filter/src/main/java/org/infinispan/objectfilter/impl/predicateindex/AttributeNode.java#L125-L141
29,525
infinispan/infinispan
object-filter/src/main/java/org/infinispan/objectfilter/impl/predicateindex/AttributeNode.java
AttributeNode.removeChild
public void removeChild(AttributeId attribute) { if (children == null) { throw new IllegalArgumentException("No child found : " + attribute); } AttributeNode<AttributeMetadata, AttributeId> child = children.get(attribute); if (child == null) { throw new IllegalArgumentException("No child found : " + attribute); } children.remove(attribute); rebuildChildrenArray(); }
java
public void removeChild(AttributeId attribute) { if (children == null) { throw new IllegalArgumentException("No child found : " + attribute); } AttributeNode<AttributeMetadata, AttributeId> child = children.get(attribute); if (child == null) { throw new IllegalArgumentException("No child found : " + attribute); } children.remove(attribute); rebuildChildrenArray(); }
[ "public", "void", "removeChild", "(", "AttributeId", "attribute", ")", "{", "if", "(", "children", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No child found : \"", "+", "attribute", ")", ";", "}", "AttributeNode", "<", "Attribute...
Decrement the usage counter of a child node and remove it if no usages remain. The removal works recursively up the path to the root. @param attribute the attribute of the child to be removed
[ "Decrement", "the", "usage", "counter", "of", "a", "child", "node", "and", "remove", "it", "if", "no", "usages", "remain", ".", "The", "removal", "works", "recursively", "up", "the", "path", "to", "the", "root", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/object-filter/src/main/java/org/infinispan/objectfilter/impl/predicateindex/AttributeNode.java#L149-L159
29,526
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java
TotalOrderManager.ensureOrder
public final void ensureOrder(TotalOrderRemoteTransactionState state, Collection<?> keysModified) throws InterruptedException { //the retries due to state transfer re-uses the same state. we need that the keys previous locked to be release //in order to insert it again in the keys locked. //NOTE: this method does not need to be synchronized because it is invoked by a one thread at the time, namely //the thread that is delivering the messages in total order. state.awaitUntilReset(); TotalOrderLatch transactionSynchronizedBlock = new TotalOrderLatchImpl(state.getGlobalTransaction().globalId()); state.setTransactionSynchronizedBlock(transactionSynchronizedBlock); //this will collect all the count down latch corresponding to the previous transactions in the queue for (Object key : keysModified) { TotalOrderLatch prevTx = keysLocked.put(key, transactionSynchronizedBlock); if (prevTx != null) { state.addSynchronizedBlock(prevTx); } state.addLockedKey(key); } TotalOrderLatch stateTransfer = stateTransferInProgress.get(); if (stateTransfer != null) { state.addSynchronizedBlock(stateTransfer); } if (trace) { log.tracef("Transaction [%s] will wait for %s and locked %s", state.getGlobalTransaction().globalId(), state.getConflictingTransactionBlocks(), state.getLockedKeys() == null ? "[ClearCommand]" : state.getLockedKeys()); } }
java
public final void ensureOrder(TotalOrderRemoteTransactionState state, Collection<?> keysModified) throws InterruptedException { //the retries due to state transfer re-uses the same state. we need that the keys previous locked to be release //in order to insert it again in the keys locked. //NOTE: this method does not need to be synchronized because it is invoked by a one thread at the time, namely //the thread that is delivering the messages in total order. state.awaitUntilReset(); TotalOrderLatch transactionSynchronizedBlock = new TotalOrderLatchImpl(state.getGlobalTransaction().globalId()); state.setTransactionSynchronizedBlock(transactionSynchronizedBlock); //this will collect all the count down latch corresponding to the previous transactions in the queue for (Object key : keysModified) { TotalOrderLatch prevTx = keysLocked.put(key, transactionSynchronizedBlock); if (prevTx != null) { state.addSynchronizedBlock(prevTx); } state.addLockedKey(key); } TotalOrderLatch stateTransfer = stateTransferInProgress.get(); if (stateTransfer != null) { state.addSynchronizedBlock(stateTransfer); } if (trace) { log.tracef("Transaction [%s] will wait for %s and locked %s", state.getGlobalTransaction().globalId(), state.getConflictingTransactionBlocks(), state.getLockedKeys() == null ? "[ClearCommand]" : state.getLockedKeys()); } }
[ "public", "final", "void", "ensureOrder", "(", "TotalOrderRemoteTransactionState", "state", ",", "Collection", "<", "?", ">", "keysModified", ")", "throws", "InterruptedException", "{", "//the retries due to state transfer re-uses the same state. we need that the keys previous lock...
It ensures the validation order for the transaction corresponding to the prepare command. This allow the prepare command to be moved to a thread pool. @param state the total order prepare state
[ "It", "ensures", "the", "validation", "order", "for", "the", "transaction", "corresponding", "to", "the", "prepare", "command", ".", "This", "allow", "the", "prepare", "command", "to", "be", "moved", "to", "a", "thread", "pool", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java#L65-L93
29,527
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java
TotalOrderManager.release
public final void release(TotalOrderRemoteTransactionState state) { TotalOrderLatch synchronizedBlock = state.getTransactionSynchronizedBlock(); if (synchronizedBlock == null) { //already released! return; } Collection<Object> lockedKeys = state.getLockedKeys(); synchronizedBlock.unBlock(); for (Object key : lockedKeys) { keysLocked.remove(key, synchronizedBlock); } if (trace) { log.tracef("Release %s and locked keys %s. Checking pending tasks!", synchronizedBlock, lockedKeys); } state.reset(); }
java
public final void release(TotalOrderRemoteTransactionState state) { TotalOrderLatch synchronizedBlock = state.getTransactionSynchronizedBlock(); if (synchronizedBlock == null) { //already released! return; } Collection<Object> lockedKeys = state.getLockedKeys(); synchronizedBlock.unBlock(); for (Object key : lockedKeys) { keysLocked.remove(key, synchronizedBlock); } if (trace) { log.tracef("Release %s and locked keys %s. Checking pending tasks!", synchronizedBlock, lockedKeys); } state.reset(); }
[ "public", "final", "void", "release", "(", "TotalOrderRemoteTransactionState", "state", ")", "{", "TotalOrderLatch", "synchronizedBlock", "=", "state", ".", "getTransactionSynchronizedBlock", "(", ")", ";", "if", "(", "synchronizedBlock", "==", "null", ")", "{", "//...
Release the locked key possibly unblock waiting prepares. @param state the state
[ "Release", "the", "locked", "key", "possibly", "unblock", "waiting", "prepares", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java#L100-L115
29,528
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java
TotalOrderManager.notifyStateTransferStart
public final Collection<TotalOrderLatch> notifyStateTransferStart(int topologyId, boolean isRebalance) { if (stateTransferInProgress.get() != null) { return Collections.emptyList(); } List<TotalOrderLatch> preparingTransactions = new ArrayList<>(keysLocked.size()); preparingTransactions.addAll(keysLocked.values()); if (isRebalance) { stateTransferInProgress.set(new TotalOrderLatchImpl("StateTransfer-" + topologyId)); } if (trace) { log.tracef("State Transfer start. It will wait for %s", preparingTransactions); } return preparingTransactions; }
java
public final Collection<TotalOrderLatch> notifyStateTransferStart(int topologyId, boolean isRebalance) { if (stateTransferInProgress.get() != null) { return Collections.emptyList(); } List<TotalOrderLatch> preparingTransactions = new ArrayList<>(keysLocked.size()); preparingTransactions.addAll(keysLocked.values()); if (isRebalance) { stateTransferInProgress.set(new TotalOrderLatchImpl("StateTransfer-" + topologyId)); } if (trace) { log.tracef("State Transfer start. It will wait for %s", preparingTransactions); } return preparingTransactions; }
[ "public", "final", "Collection", "<", "TotalOrderLatch", ">", "notifyStateTransferStart", "(", "int", "topologyId", ",", "boolean", "isRebalance", ")", "{", "if", "(", "stateTransferInProgress", ".", "get", "(", ")", "!=", "null", ")", "{", "return", "Collection...
It notifies that a state transfer is about to start. @param topologyId the new topology ID @return the current pending prepares
[ "It", "notifies", "that", "a", "state", "transfer", "is", "about", "to", "start", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java#L123-L136
29,529
infinispan/infinispan
core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java
TotalOrderManager.notifyStateTransferEnd
public final void notifyStateTransferEnd() { TotalOrderLatch block = stateTransferInProgress.getAndSet(null); if (block != null) { block.unBlock(); } if (trace) { log.tracef("State Transfer finish. It will release %s", block); } totalOrderExecutor.checkForReadyTasks(); }
java
public final void notifyStateTransferEnd() { TotalOrderLatch block = stateTransferInProgress.getAndSet(null); if (block != null) { block.unBlock(); } if (trace) { log.tracef("State Transfer finish. It will release %s", block); } totalOrderExecutor.checkForReadyTasks(); }
[ "public", "final", "void", "notifyStateTransferEnd", "(", ")", "{", "TotalOrderLatch", "block", "=", "stateTransferInProgress", ".", "getAndSet", "(", "null", ")", ";", "if", "(", "block", "!=", "null", ")", "{", "block", ".", "unBlock", "(", ")", ";", "}"...
It notifies the end of the state transfer possibly unblock waiting prepares.
[ "It", "notifies", "the", "end", "of", "the", "state", "transfer", "possibly", "unblock", "waiting", "prepares", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/transaction/totalorder/TotalOrderManager.java#L141-L150
29,530
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/configuration/JsonReader.java
JsonReader.readJson
public void readJson(ConfigurationBuilderInfo builderInfo, String json) { readJson(builderInfo, "", Json.read(json)); }
java
public void readJson(ConfigurationBuilderInfo builderInfo, String json) { readJson(builderInfo, "", Json.read(json)); }
[ "public", "void", "readJson", "(", "ConfigurationBuilderInfo", "builderInfo", ",", "String", "json", ")", "{", "readJson", "(", "builderInfo", ",", "\"\"", ",", "Json", ".", "read", "(", "json", ")", ")", ";", "}" ]
Parses a JSON document into the supplied builder. @param builderInfo The configuration builder to use when reading. @param json the JSON document.
[ "Parses", "a", "JSON", "document", "into", "the", "supplied", "builder", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/configuration/JsonReader.java#L25-L27
29,531
infinispan/infinispan
server/integration/endpoint/src/main/java/org/infinispan/server/endpoint/subsystem/EndpointSchema.java
EndpointSchema.format
String format(String pattern) { return String.format(pattern, this.domain, this.major, this.minor); }
java
String format(String pattern) { return String.format(pattern, this.domain, this.major, this.minor); }
[ "String", "format", "(", "String", "pattern", ")", "{", "return", "String", ".", "format", "(", "pattern", ",", "this", ".", "domain", ",", "this", ".", "major", ",", "this", ".", "minor", ")", ";", "}" ]
Formats a string using the specified pattern. @param pattern a formatter pattern @return a formatted string
[ "Formats", "a", "string", "using", "the", "specified", "pattern", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/endpoint/src/main/java/org/infinispan/server/endpoint/subsystem/EndpointSchema.java#L90-L92
29,532
infinispan/infinispan
core/src/main/java/org/infinispan/functional/impl/FunctionalMapImpl.java
FunctionalMapImpl.findDecoratedCache
private DecoratedCache<K, V> findDecoratedCache(Cache<K, V> cache) { if (cache instanceof AbstractDelegatingCache) { if (cache instanceof DecoratedCache) { return ((DecoratedCache<K, V>) cache); } return findDecoratedCache(((AbstractDelegatingCache<K, V>) cache).getDelegate()); } return null; }
java
private DecoratedCache<K, V> findDecoratedCache(Cache<K, V> cache) { if (cache instanceof AbstractDelegatingCache) { if (cache instanceof DecoratedCache) { return ((DecoratedCache<K, V>) cache); } return findDecoratedCache(((AbstractDelegatingCache<K, V>) cache).getDelegate()); } return null; }
[ "private", "DecoratedCache", "<", "K", ",", "V", ">", "findDecoratedCache", "(", "Cache", "<", "K", ",", "V", ">", "cache", ")", "{", "if", "(", "cache", "instanceof", "AbstractDelegatingCache", ")", "{", "if", "(", "cache", "instanceof", "DecoratedCache", ...
Finds the first decorated cache if there are delegates surrounding it otherwise null
[ "Finds", "the", "first", "decorated", "cache", "if", "there", "are", "delegates", "surrounding", "it", "otherwise", "null" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/functional/impl/FunctionalMapImpl.java#L66-L74
29,533
infinispan/infinispan
atomic-factory/src/main/java/org/infinispan/atomic/container/Container.java
Container.onCacheModification
@SuppressWarnings({ "rawtypes", "unchecked" }) @CacheEntryModified @CacheEntryCreated @Deprecated public void onCacheModification(CacheEntryEvent event){ if( !event.getKey().equals(key) ) return; if(event.isPre()) return; try { GenericJBossMarshaller marshaller = new GenericJBossMarshaller(); byte[] bb = (byte[]) event.getValue(); Call call = (Call) marshaller.objectFromByteBuffer(bb); if (log.isDebugEnabled()) log.debugf("Receive %s (isOriginLocal=%s) ", call, event.isOriginLocal()); callExecutor.execute(new AtomicObjectContainerTask(call)); } catch (Exception e) { e.printStackTrace(); } }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) @CacheEntryModified @CacheEntryCreated @Deprecated public void onCacheModification(CacheEntryEvent event){ if( !event.getKey().equals(key) ) return; if(event.isPre()) return; try { GenericJBossMarshaller marshaller = new GenericJBossMarshaller(); byte[] bb = (byte[]) event.getValue(); Call call = (Call) marshaller.objectFromByteBuffer(bb); if (log.isDebugEnabled()) log.debugf("Receive %s (isOriginLocal=%s) ", call, event.isOriginLocal()); callExecutor.execute(new AtomicObjectContainerTask(call)); } catch (Exception e) { e.printStackTrace(); } }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "@", "CacheEntryModified", "@", "CacheEntryCreated", "@", "Deprecated", "public", "void", "onCacheModification", "(", "CacheEntryEvent", "event", ")", "{", "if", "(", "!", "event", ...
Internal use of the listener API. @param event of class CacheEntryModifiedEvent
[ "Internal", "use", "of", "the", "listener", "API", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/atomic-factory/src/main/java/org/infinispan/atomic/container/Container.java#L153-L177
29,534
infinispan/infinispan
core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java
StateTransferManagerImpl.pickConsistentHashFactory
public static ConsistentHashFactory pickConsistentHashFactory(GlobalConfiguration globalConfiguration, Configuration configuration) { ConsistentHashFactory factory = configuration.clustering().hash().consistentHashFactory(); if (factory == null) { CacheMode cacheMode = configuration.clustering().cacheMode(); if (cacheMode.isClustered()) { if (cacheMode.isDistributed()) { if (globalConfiguration.transport().hasTopologyInfo()) { factory = new TopologyAwareSyncConsistentHashFactory(); } else { factory = new SyncConsistentHashFactory(); } } else if (cacheMode.isReplicated() || cacheMode.isInvalidation()) { factory = new SyncReplicatedConsistentHashFactory(); } else if (cacheMode.isScattered()) { factory = new ScatteredConsistentHashFactory(); } else { throw new CacheException("Unexpected cache mode: " + cacheMode); } } } return factory; }
java
public static ConsistentHashFactory pickConsistentHashFactory(GlobalConfiguration globalConfiguration, Configuration configuration) { ConsistentHashFactory factory = configuration.clustering().hash().consistentHashFactory(); if (factory == null) { CacheMode cacheMode = configuration.clustering().cacheMode(); if (cacheMode.isClustered()) { if (cacheMode.isDistributed()) { if (globalConfiguration.transport().hasTopologyInfo()) { factory = new TopologyAwareSyncConsistentHashFactory(); } else { factory = new SyncConsistentHashFactory(); } } else if (cacheMode.isReplicated() || cacheMode.isInvalidation()) { factory = new SyncReplicatedConsistentHashFactory(); } else if (cacheMode.isScattered()) { factory = new ScatteredConsistentHashFactory(); } else { throw new CacheException("Unexpected cache mode: " + cacheMode); } } } return factory; }
[ "public", "static", "ConsistentHashFactory", "pickConsistentHashFactory", "(", "GlobalConfiguration", "globalConfiguration", ",", "Configuration", "configuration", ")", "{", "ConsistentHashFactory", "factory", "=", "configuration", ".", "clustering", "(", ")", ".", "hash", ...
If no ConsistentHashFactory was explicitly configured we choose a suitable one based on cache mode.
[ "If", "no", "ConsistentHashFactory", "was", "explicitly", "configured", "we", "choose", "a", "suitable", "one", "based", "on", "cache", "mode", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java#L131-L152
29,535
infinispan/infinispan
core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java
StateTransferManagerImpl.addPartitioner
private CacheTopology addPartitioner(CacheTopology cacheTopology) { ConsistentHash currentCH = cacheTopology.getCurrentCH(); currentCH = new PartitionerConsistentHash(currentCH, keyPartitioner); ConsistentHash pendingCH = cacheTopology.getPendingCH(); if (pendingCH != null) { pendingCH = new PartitionerConsistentHash(pendingCH, keyPartitioner); } ConsistentHash unionCH = cacheTopology.getUnionCH(); if (unionCH != null) { unionCH = new PartitionerConsistentHash(unionCH, keyPartitioner); } return new CacheTopology(cacheTopology.getTopologyId(), cacheTopology.getRebalanceId(), currentCH, pendingCH, unionCH, cacheTopology.getPhase(), cacheTopology.getActualMembers(), cacheTopology.getMembersPersistentUUIDs()); }
java
private CacheTopology addPartitioner(CacheTopology cacheTopology) { ConsistentHash currentCH = cacheTopology.getCurrentCH(); currentCH = new PartitionerConsistentHash(currentCH, keyPartitioner); ConsistentHash pendingCH = cacheTopology.getPendingCH(); if (pendingCH != null) { pendingCH = new PartitionerConsistentHash(pendingCH, keyPartitioner); } ConsistentHash unionCH = cacheTopology.getUnionCH(); if (unionCH != null) { unionCH = new PartitionerConsistentHash(unionCH, keyPartitioner); } return new CacheTopology(cacheTopology.getTopologyId(), cacheTopology.getRebalanceId(), currentCH, pendingCH, unionCH, cacheTopology.getPhase(), cacheTopology.getActualMembers(), cacheTopology.getMembersPersistentUUIDs()); }
[ "private", "CacheTopology", "addPartitioner", "(", "CacheTopology", "cacheTopology", ")", "{", "ConsistentHash", "currentCH", "=", "cacheTopology", ".", "getCurrentCH", "(", ")", ";", "currentCH", "=", "new", "PartitionerConsistentHash", "(", "currentCH", ",", "keyPar...
Decorates the given cache topology to add a key partitioner. The key partitioner may include support for grouping as well.
[ "Decorates", "the", "given", "cache", "topology", "to", "add", "a", "key", "partitioner", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java#L159-L172
29,536
infinispan/infinispan
server/hotrod/src/main/java/org/infinispan/server/hotrod/LifecycleCallbacks.java
LifecycleCallbacks.registerGlobalTxTable
private void registerGlobalTxTable(GlobalComponentRegistry globalComponentRegistry) { InternalCacheRegistry registry = globalComponentRegistry.getComponent(InternalCacheRegistry.class); ConfigurationBuilder builder = new ConfigurationBuilder(); //we can't lose transactions. distributed cache can lose data is num_owner nodes crash at the same time builder.clustering().cacheMode(globalComponentRegistry.getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL); builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); //persistent? should we keep the transaction after restart? registry.registerInternalCache(GLOBAL_TX_TABLE_CACHE_NAME, builder.build(), EnumSet.noneOf(InternalCacheRegistry.Flag.class)); }
java
private void registerGlobalTxTable(GlobalComponentRegistry globalComponentRegistry) { InternalCacheRegistry registry = globalComponentRegistry.getComponent(InternalCacheRegistry.class); ConfigurationBuilder builder = new ConfigurationBuilder(); //we can't lose transactions. distributed cache can lose data is num_owner nodes crash at the same time builder.clustering().cacheMode(globalComponentRegistry.getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL); builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); //persistent? should we keep the transaction after restart? registry.registerInternalCache(GLOBAL_TX_TABLE_CACHE_NAME, builder.build(), EnumSet.noneOf(InternalCacheRegistry.Flag.class)); }
[ "private", "void", "registerGlobalTxTable", "(", "GlobalComponentRegistry", "globalComponentRegistry", ")", "{", "InternalCacheRegistry", "registry", "=", "globalComponentRegistry", ".", "getComponent", "(", "InternalCacheRegistry", ".", "class", ")", ";", "ConfigurationBuild...
Creates the global transaction internal cache.
[ "Creates", "the", "global", "transaction", "internal", "cache", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/hotrod/src/main/java/org/infinispan/server/hotrod/LifecycleCallbacks.java#L122-L133
29,537
infinispan/infinispan
core/src/main/java/org/infinispan/registry/impl/InternalCacheRegistryImpl.java
InternalCacheRegistryImpl.registerInternalCache
@Override public synchronized void registerInternalCache(String name, Configuration configuration, EnumSet<Flag> flags) { boolean configPresent = cacheManager.getCacheConfiguration(name) != null; // check if it already has been defined. Currently we don't support existing user-defined configuration. if ((flags.contains(Flag.EXCLUSIVE) || !internalCaches.containsKey(name)) && configPresent) { throw log.existingConfigForInternalCache(name); } // Don't redefine if (configPresent) { return; } ConfigurationBuilder builder = new ConfigurationBuilder().read(configuration); builder.jmxStatistics().disable(); // Internal caches must not be included in stats counts GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration(); if (flags.contains(Flag.GLOBAL) && globalConfiguration.isClustered()) { // TODO: choose a merge policy builder.clustering() .cacheMode(CacheMode.REPL_SYNC) .stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(true); } if (flags.contains(Flag.PERSISTENT) && globalConfiguration.globalState().enabled()) { builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true).fetchPersistentState(true); } SecurityActions.defineConfiguration(cacheManager, name, builder.build()); internalCaches.put(name, flags); if (!flags.contains(Flag.USER)) { privateCaches.add(name); } }
java
@Override public synchronized void registerInternalCache(String name, Configuration configuration, EnumSet<Flag> flags) { boolean configPresent = cacheManager.getCacheConfiguration(name) != null; // check if it already has been defined. Currently we don't support existing user-defined configuration. if ((flags.contains(Flag.EXCLUSIVE) || !internalCaches.containsKey(name)) && configPresent) { throw log.existingConfigForInternalCache(name); } // Don't redefine if (configPresent) { return; } ConfigurationBuilder builder = new ConfigurationBuilder().read(configuration); builder.jmxStatistics().disable(); // Internal caches must not be included in stats counts GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration(); if (flags.contains(Flag.GLOBAL) && globalConfiguration.isClustered()) { // TODO: choose a merge policy builder.clustering() .cacheMode(CacheMode.REPL_SYNC) .stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(true); } if (flags.contains(Flag.PERSISTENT) && globalConfiguration.globalState().enabled()) { builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true).fetchPersistentState(true); } SecurityActions.defineConfiguration(cacheManager, name, builder.build()); internalCaches.put(name, flags); if (!flags.contains(Flag.USER)) { privateCaches.add(name); } }
[ "@", "Override", "public", "synchronized", "void", "registerInternalCache", "(", "String", "name", ",", "Configuration", "configuration", ",", "EnumSet", "<", "Flag", ">", "flags", ")", "{", "boolean", "configPresent", "=", "cacheManager", ".", "getCacheConfiguratio...
Synchronized to prevent users from registering the same configuration at the same time
[ "Synchronized", "to", "prevent", "users", "from", "registering", "the", "same", "configuration", "at", "the", "same", "time" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/registry/impl/InternalCacheRegistryImpl.java#L40-L68
29,538
infinispan/infinispan
core/src/main/java/org/infinispan/scattered/impl/ScatteredStateProviderImpl.java
ScatteredStateProviderImpl.replicateAndInvalidate
private CompletableFuture<Void> replicateAndInvalidate(CacheTopology cacheTopology) { Address nextMember = getNextMember(cacheTopology); if (nextMember != null) { HashSet<Address> otherMembers = new HashSet<>(cacheTopology.getActualMembers()); Address localAddress = rpcManager.getAddress(); otherMembers.remove(localAddress); otherMembers.remove(nextMember); IntSet oldSegments; if (cacheTopology.getCurrentCH().getMembers().contains(localAddress)) { oldSegments = IntSets.from(cacheTopology.getCurrentCH().getSegmentsForOwner(localAddress)); oldSegments.retainAll(cacheTopology.getPendingCH().getSegmentsForOwner(localAddress)); } else { log.trace("Local address is not a member of currentCH, returning"); return CompletableFutures.completedNull(); } log.trace("Segments to replicate and invalidate: " + oldSegments); if (oldSegments.isEmpty()) { return CompletableFutures.completedNull(); } // we'll start at 1, so the counter will never drop to 0 until we send all chunks AtomicInteger outboundInvalidations = new AtomicInteger(1); CompletableFuture<Void> outboundTaskFuture = new CompletableFuture<>(); OutboundTransferTask outboundTransferTask = new OutboundTransferTask(nextMember, oldSegments, cacheTopology.getCurrentCH().getNumSegments(), chunkSize, cacheTopology.getTopologyId(), keyPartitioner, task -> { if (outboundInvalidations.decrementAndGet() == 0) { outboundTaskFuture.complete(null); } }, chunks -> invalidateChunks(chunks, otherMembers, outboundInvalidations, outboundTaskFuture, cacheTopology), OutboundTransferTask::defaultMapEntryFromDataContainer, OutboundTransferTask::defaultMapEntryFromStore, dataContainer, persistenceManager, rpcManager, commandsFactory, entryFactory, timeout, cacheName, true, true); outboundTransferTask.execute(executorService); return outboundTaskFuture; } else { return CompletableFutures.completedNull(); } }
java
private CompletableFuture<Void> replicateAndInvalidate(CacheTopology cacheTopology) { Address nextMember = getNextMember(cacheTopology); if (nextMember != null) { HashSet<Address> otherMembers = new HashSet<>(cacheTopology.getActualMembers()); Address localAddress = rpcManager.getAddress(); otherMembers.remove(localAddress); otherMembers.remove(nextMember); IntSet oldSegments; if (cacheTopology.getCurrentCH().getMembers().contains(localAddress)) { oldSegments = IntSets.from(cacheTopology.getCurrentCH().getSegmentsForOwner(localAddress)); oldSegments.retainAll(cacheTopology.getPendingCH().getSegmentsForOwner(localAddress)); } else { log.trace("Local address is not a member of currentCH, returning"); return CompletableFutures.completedNull(); } log.trace("Segments to replicate and invalidate: " + oldSegments); if (oldSegments.isEmpty()) { return CompletableFutures.completedNull(); } // we'll start at 1, so the counter will never drop to 0 until we send all chunks AtomicInteger outboundInvalidations = new AtomicInteger(1); CompletableFuture<Void> outboundTaskFuture = new CompletableFuture<>(); OutboundTransferTask outboundTransferTask = new OutboundTransferTask(nextMember, oldSegments, cacheTopology.getCurrentCH().getNumSegments(), chunkSize, cacheTopology.getTopologyId(), keyPartitioner, task -> { if (outboundInvalidations.decrementAndGet() == 0) { outboundTaskFuture.complete(null); } }, chunks -> invalidateChunks(chunks, otherMembers, outboundInvalidations, outboundTaskFuture, cacheTopology), OutboundTransferTask::defaultMapEntryFromDataContainer, OutboundTransferTask::defaultMapEntryFromStore, dataContainer, persistenceManager, rpcManager, commandsFactory, entryFactory, timeout, cacheName, true, true); outboundTransferTask.execute(executorService); return outboundTaskFuture; } else { return CompletableFutures.completedNull(); } }
[ "private", "CompletableFuture", "<", "Void", ">", "replicateAndInvalidate", "(", "CacheTopology", "cacheTopology", ")", "{", "Address", "nextMember", "=", "getNextMember", "(", "cacheTopology", ")", ";", "if", "(", "nextMember", "!=", "null", ")", "{", "HashSet", ...
that this node keeps from previous topology.
[ "that", "this", "node", "keeps", "from", "previous", "topology", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/scattered/impl/ScatteredStateProviderImpl.java#L56-L95
29,539
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/CollectionFactory.java
CollectionFactory.makeSet
@SafeVarargs public static <T> Set<T> makeSet(T... entries) { return new HashSet<>(Arrays.asList(entries)); }
java
@SafeVarargs public static <T> Set<T> makeSet(T... entries) { return new HashSet<>(Arrays.asList(entries)); }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "makeSet", "(", "T", "...", "entries", ")", "{", "return", "new", "HashSet", "<>", "(", "Arrays", ".", "asList", "(", "entries", ")", ")", ";", "}" ]
Create a Set backed by the specified array. @param entries the array by which the list will be backed @param <T> type of elements @return a set view of the specified array
[ "Create", "a", "Set", "backed", "by", "the", "specified", "array", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/CollectionFactory.java#L193-L196
29,540
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/io/ExposedByteArrayOutputStream.java
ExposedByteArrayOutputStream.getNewBufferSize
public final int getNewBufferSize(int curSize, int minNewSize) { if (curSize <= maxDoublingSize) return Math.max(curSize << 1, minNewSize); else return Math.max(curSize + (curSize >> 2), minNewSize); }
java
public final int getNewBufferSize(int curSize, int minNewSize) { if (curSize <= maxDoublingSize) return Math.max(curSize << 1, minNewSize); else return Math.max(curSize + (curSize >> 2), minNewSize); }
[ "public", "final", "int", "getNewBufferSize", "(", "int", "curSize", ",", "int", "minNewSize", ")", "{", "if", "(", "curSize", "<=", "maxDoublingSize", ")", "return", "Math", ".", "max", "(", "curSize", "<<", "1", ",", "minNewSize", ")", ";", "else", "re...
Gets the number of bytes to which the internal buffer should be resized. @param curSize the current number of bytes @param minNewSize the minimum number of bytes required @return the size to which the internal buffer should be resized
[ "Gets", "the", "number", "of", "bytes", "to", "which", "the", "internal", "buffer", "should", "be", "resized", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/io/ExposedByteArrayOutputStream.java#L107-L112
29,541
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.spliterator
public static <E> CloseableSpliterator<E> spliterator(CloseableIterator<? extends E> iterator, long size, int characteristics) { return new CloseableIteratorAsCloseableSpliterator<>(iterator, size, characteristics); }
java
public static <E> CloseableSpliterator<E> spliterator(CloseableIterator<? extends E> iterator, long size, int characteristics) { return new CloseableIteratorAsCloseableSpliterator<>(iterator, size, characteristics); }
[ "public", "static", "<", "E", ">", "CloseableSpliterator", "<", "E", ">", "spliterator", "(", "CloseableIterator", "<", "?", "extends", "E", ">", "iterator", ",", "long", "size", ",", "int", "characteristics", ")", "{", "return", "new", "CloseableIteratorAsClo...
Takes a provided closeable iterator and wraps it appropriately so it can be used as a closeable spliterator that will close the iterator when the spliterator is closed. @param iterator The closeable iterator to change to a spliterator @param size The approximate size of the iterator. If no size is known {@link Long#MAX_VALUE} should be passed @param characteristics The characteristics of the given spliterator as defined on the {@link Spliterator} interface @param <E> The type that is the same between the iterator and spliterator @return A spliterator that when closed will close the provided iterator
[ "Takes", "a", "provided", "closeable", "iterator", "and", "wraps", "it", "appropriately", "so", "it", "can", "be", "used", "as", "a", "closeable", "spliterator", "that", "will", "close", "the", "iterator", "when", "the", "spliterator", "is", "closed", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L29-L32
29,542
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.spliterator
public static <T> CloseableSpliterator<T> spliterator(Spliterator<T> spliterator) { if (spliterator instanceof CloseableSpliterator) { return (CloseableSpliterator<T>) spliterator; } return new SpliteratorAsCloseableSpliterator<>(spliterator); }
java
public static <T> CloseableSpliterator<T> spliterator(Spliterator<T> spliterator) { if (spliterator instanceof CloseableSpliterator) { return (CloseableSpliterator<T>) spliterator; } return new SpliteratorAsCloseableSpliterator<>(spliterator); }
[ "public", "static", "<", "T", ">", "CloseableSpliterator", "<", "T", ">", "spliterator", "(", "Spliterator", "<", "T", ">", "spliterator", ")", "{", "if", "(", "spliterator", "instanceof", "CloseableSpliterator", ")", "{", "return", "(", "CloseableSpliterator", ...
Creates a closeable spliterator from the given spliterator that does nothing when close is called. @param spliterator The spliterator to wrap to allow it to become a closeable spliterator. @param <T> The type of the spliterators @return A spliterator that does nothing when closed
[ "Creates", "a", "closeable", "spliterator", "from", "the", "given", "spliterator", "that", "does", "nothing", "when", "close", "is", "called", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L40-L45
29,543
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.spliterator
public static <R> CloseableSpliterator<R> spliterator(BaseStream<R, Stream<R>> stream) { Spliterator<R> spliterator = stream.spliterator(); if (spliterator instanceof CloseableSpliterator) { return (CloseableSpliterator<R>) spliterator; } return new StreamToCloseableSpliterator<>(stream, spliterator); }
java
public static <R> CloseableSpliterator<R> spliterator(BaseStream<R, Stream<R>> stream) { Spliterator<R> spliterator = stream.spliterator(); if (spliterator instanceof CloseableSpliterator) { return (CloseableSpliterator<R>) spliterator; } return new StreamToCloseableSpliterator<>(stream, spliterator); }
[ "public", "static", "<", "R", ">", "CloseableSpliterator", "<", "R", ">", "spliterator", "(", "BaseStream", "<", "R", ",", "Stream", "<", "R", ">", ">", "stream", ")", "{", "Spliterator", "<", "R", ">", "spliterator", "=", "stream", ".", "spliterator", ...
Creates a closeable spliterator that when closed will close the underlying stream as well @param stream The stream to change into a closeable spliterator @param <R> The type of the stream @return A spliterator that when closed will also close the underlying stream
[ "Creates", "a", "closeable", "spliterator", "that", "when", "closed", "will", "close", "the", "underlying", "stream", "as", "well" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L53-L59
29,544
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.iterator
public static <R> CloseableIterator<R> iterator(BaseStream<R, Stream<R>> stream) { Iterator<R> iterator = stream.iterator(); if (iterator instanceof CloseableIterator) { return (CloseableIterator<R>) iterator; } return new StreamToCloseableIterator<>(stream, iterator); }
java
public static <R> CloseableIterator<R> iterator(BaseStream<R, Stream<R>> stream) { Iterator<R> iterator = stream.iterator(); if (iterator instanceof CloseableIterator) { return (CloseableIterator<R>) iterator; } return new StreamToCloseableIterator<>(stream, iterator); }
[ "public", "static", "<", "R", ">", "CloseableIterator", "<", "R", ">", "iterator", "(", "BaseStream", "<", "R", ",", "Stream", "<", "R", ">", ">", "stream", ")", "{", "Iterator", "<", "R", ">", "iterator", "=", "stream", ".", "iterator", "(", ")", ...
Creates a closeable iterator that when closed will close the underlying stream as well @param stream The stream to change into a closeable iterator @param <R> The type of the stream @return An iterator that when closed will also close the underlying stream
[ "Creates", "a", "closeable", "iterator", "that", "when", "closed", "will", "close", "the", "underlying", "stream", "as", "well" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L67-L73
29,545
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.iterator
public static <E> CloseableIterator<E> iterator(Iterator<? extends E> iterator) { if (iterator instanceof CloseableIterator) { return (CloseableIterator<E>) iterator; } return new IteratorAsCloseableIterator<>(iterator); }
java
public static <E> CloseableIterator<E> iterator(Iterator<? extends E> iterator) { if (iterator instanceof CloseableIterator) { return (CloseableIterator<E>) iterator; } return new IteratorAsCloseableIterator<>(iterator); }
[ "public", "static", "<", "E", ">", "CloseableIterator", "<", "E", ">", "iterator", "(", "Iterator", "<", "?", "extends", "E", ">", "iterator", ")", "{", "if", "(", "iterator", "instanceof", "CloseableIterator", ")", "{", "return", "(", "CloseableIterator", ...
Creates a closeable iterator from the given iterator that does nothing when close is called. @param iterator The iterator to wrap to allow it to become a closeable iterator @param <E> The type of the iterators @return An iterator that does nothing when closed
[ "Creates", "a", "closeable", "iterator", "from", "the", "given", "iterator", "that", "does", "nothing", "when", "close", "is", "called", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L81-L86
29,546
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.stream
public static <E> Stream<E> stream(CloseableSpliterator<E> spliterator, boolean parallel) { Stream<E> stream = StreamSupport.stream(spliterator, parallel); stream.onClose(spliterator::close); return stream; }
java
public static <E> Stream<E> stream(CloseableSpliterator<E> spliterator, boolean parallel) { Stream<E> stream = StreamSupport.stream(spliterator, parallel); stream.onClose(spliterator::close); return stream; }
[ "public", "static", "<", "E", ">", "Stream", "<", "E", ">", "stream", "(", "CloseableSpliterator", "<", "E", ">", "spliterator", ",", "boolean", "parallel", ")", "{", "Stream", "<", "E", ">", "stream", "=", "StreamSupport", ".", "stream", "(", "spliterat...
Creates a stream that when closed will also close the underlying spliterator @param spliterator spliterator to back the stream and subsequently close @param parallel whether or not the returned stream is parallel or not @param <E> the type of the stream @return the stream to use
[ "Creates", "a", "stream", "that", "when", "closed", "will", "also", "close", "the", "underlying", "spliterator" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L95-L99
29,547
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/Closeables.java
Closeables.stream
public static <E> Stream<E> stream(CloseableIterator<E> iterator, boolean parallel, long size, int characteristics) { Stream<E> stream = StreamSupport.stream(Spliterators.spliterator(iterator, size, characteristics), parallel); stream.onClose(iterator::close); return stream; }
java
public static <E> Stream<E> stream(CloseableIterator<E> iterator, boolean parallel, long size, int characteristics) { Stream<E> stream = StreamSupport.stream(Spliterators.spliterator(iterator, size, characteristics), parallel); stream.onClose(iterator::close); return stream; }
[ "public", "static", "<", "E", ">", "Stream", "<", "E", ">", "stream", "(", "CloseableIterator", "<", "E", ">", "iterator", ",", "boolean", "parallel", ",", "long", "size", ",", "int", "characteristics", ")", "{", "Stream", "<", "E", ">", "stream", "=",...
Creates a stream that when closed will also close the underlying iterator @param iterator iterator to back the stream and subsequently close @param parallel whether or not the returned stream is parallel or not @param size the size of the iterator if known, otherwise {@link Long#MAX_VALUE} should be passed. @param characteristics the characteristics of the iterator to be used @param <E> the type of the stream @return the stream to use
[ "Creates", "a", "stream", "that", "when", "closed", "will", "also", "close", "the", "underlying", "iterator" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/Closeables.java#L110-L114
29,548
infinispan/infinispan
core/src/main/java/org/infinispan/statetransfer/OutboundTransferTask.java
OutboundTransferTask.cancelSegments
public void cancelSegments(IntSet cancelledSegments) { if (segments.removeAll(cancelledSegments)) { if (trace) { log.tracef("Cancelling outbound transfer to node %s, segments %s (remaining segments %s)", destination, cancelledSegments, segments); } entriesBySegment.keySet().removeAll(cancelledSegments); // here we do not update accumulatedEntries but this inaccuracy does not cause any harm if (segments.isEmpty()) { cancel(); } } }
java
public void cancelSegments(IntSet cancelledSegments) { if (segments.removeAll(cancelledSegments)) { if (trace) { log.tracef("Cancelling outbound transfer to node %s, segments %s (remaining segments %s)", destination, cancelledSegments, segments); } entriesBySegment.keySet().removeAll(cancelledSegments); // here we do not update accumulatedEntries but this inaccuracy does not cause any harm if (segments.isEmpty()) { cancel(); } } }
[ "public", "void", "cancelSegments", "(", "IntSet", "cancelledSegments", ")", "{", "if", "(", "segments", ".", "removeAll", "(", "cancelledSegments", ")", ")", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"Cancelling outbound transfer to node %...
Cancel some of the segments. If all segments get cancelled then the whole task will be cancelled. @param cancelledSegments segments to cancel.
[ "Cancel", "some", "of", "the", "segments", ".", "If", "all", "segments", "get", "cancelled", "then", "the", "whole", "task", "will", "be", "cancelled", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/OutboundTransferTask.java#L285-L296
29,549
infinispan/infinispan
core/src/main/java/org/infinispan/statetransfer/OutboundTransferTask.java
OutboundTransferTask.cancel
public void cancel() { if (runnableFuture != null && !runnableFuture.isCancelled()) { log.debugf("Cancelling outbound transfer to node %s, segments %s", destination, segments); runnableFuture.cancel(true); } }
java
public void cancel() { if (runnableFuture != null && !runnableFuture.isCancelled()) { log.debugf("Cancelling outbound transfer to node %s, segments %s", destination, segments); runnableFuture.cancel(true); } }
[ "public", "void", "cancel", "(", ")", "{", "if", "(", "runnableFuture", "!=", "null", "&&", "!", "runnableFuture", ".", "isCancelled", "(", ")", ")", "{", "log", ".", "debugf", "(", "\"Cancelling outbound transfer to node %s, segments %s\"", ",", "destination", ...
Cancel the whole task.
[ "Cancel", "the", "whole", "task", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/statetransfer/OutboundTransferTask.java#L301-L306
29,550
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.unmarshallArray
public static <E> E[] unmarshallArray(ObjectInput in, ArrayBuilder<E> builder) throws IOException, ClassNotFoundException { final int size = unmarshallSize(in); if (size == NULL_VALUE) { return null; } final E[] array = Objects.requireNonNull(builder, "ArrayBuilder must be non-null").build(size); for (int i = 0; i < size; ++i) { //noinspection unchecked array[i] = (E) in.readObject(); } return array; }
java
public static <E> E[] unmarshallArray(ObjectInput in, ArrayBuilder<E> builder) throws IOException, ClassNotFoundException { final int size = unmarshallSize(in); if (size == NULL_VALUE) { return null; } final E[] array = Objects.requireNonNull(builder, "ArrayBuilder must be non-null").build(size); for (int i = 0; i < size; ++i) { //noinspection unchecked array[i] = (E) in.readObject(); } return array; }
[ "public", "static", "<", "E", ">", "E", "[", "]", "unmarshallArray", "(", "ObjectInput", "in", ",", "ArrayBuilder", "<", "E", ">", "builder", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "final", "int", "size", "=", "unmarshallSize", "("...
Unmarshall arrays. @param in {@link ObjectInput} to read. @param builder {@link ArrayBuilder} to build the array. @param <E> Array type. @return The populated array. @throws IOException If any of the usual Input/Output related exceptions occur. @throws ClassNotFoundException If the class of a serialized object cannot be found. @see #marshallArray(Object[], ObjectOutput).
[ "Unmarshall", "arrays", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L206-L217
29,551
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.unmarshallSize
public static int unmarshallSize(ObjectInput in) throws IOException { byte b = in.readByte(); if ((b & 0x80) != 0) { return NULL_VALUE; //negative value } int i = b & 0x3F; if ((b & 0x40) == 0) { return i; } int shift = 6; do { b = in.readByte(); i |= (b & 0x7F) << shift; shift += 7; } while ((b & 0x80) != 0); return i; }
java
public static int unmarshallSize(ObjectInput in) throws IOException { byte b = in.readByte(); if ((b & 0x80) != 0) { return NULL_VALUE; //negative value } int i = b & 0x3F; if ((b & 0x40) == 0) { return i; } int shift = 6; do { b = in.readByte(); i |= (b & 0x7F) << shift; shift += 7; } while ((b & 0x80) != 0); return i; }
[ "public", "static", "int", "unmarshallSize", "(", "ObjectInput", "in", ")", "throws", "IOException", "{", "byte", "b", "=", "in", ".", "readByte", "(", ")", ";", "if", "(", "(", "b", "&", "0x80", ")", "!=", "0", ")", "{", "return", "NULL_VALUE", ";",...
Unmarshall an integer. @param in {@link ObjectInput} to read. @return The integer value or {@link #NULL_VALUE} if the original value was negative. @throws IOException If any of the usual Input/Output related exceptions occur. @see #marshallSize(ObjectOutput, int).
[ "Unmarshall", "an", "integer", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L423-L440
29,552
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.marshallIntCollection
public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException { final int size = collection == null ? NULL_VALUE : collection.size(); marshallSize(out, size); if (size <= 0) { return; } for (Integer integer : collection) { out.writeInt(integer); } }
java
public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException { final int size = collection == null ? NULL_VALUE : collection.size(); marshallSize(out, size); if (size <= 0) { return; } for (Integer integer : collection) { out.writeInt(integer); } }
[ "public", "static", "void", "marshallIntCollection", "(", "Collection", "<", "Integer", ">", "collection", ",", "ObjectOutput", "out", ")", "throws", "IOException", "{", "final", "int", "size", "=", "collection", "==", "null", "?", "NULL_VALUE", ":", "collection...
Marshalls a collection of integers. @param collection the collection to marshall. @param out the {@link ObjectOutput} to write to. @throws IOException if an error occurs.
[ "Marshalls", "a", "collection", "of", "integers", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L469-L478
29,553
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.unmarshallIntCollection
public static <T extends Collection<Integer>> T unmarshallIntCollection(ObjectInput in, CollectionBuilder<Integer, T> builder) throws IOException { final int size = unmarshallSize(in); if (size == NULL_VALUE) { return null; } T collection = Objects.requireNonNull(builder, "CollectionBuilder must be non-null").build(size); for (int i = 0; i < size; ++i) { collection.add(in.readInt()); } return collection; }
java
public static <T extends Collection<Integer>> T unmarshallIntCollection(ObjectInput in, CollectionBuilder<Integer, T> builder) throws IOException { final int size = unmarshallSize(in); if (size == NULL_VALUE) { return null; } T collection = Objects.requireNonNull(builder, "CollectionBuilder must be non-null").build(size); for (int i = 0; i < size; ++i) { collection.add(in.readInt()); } return collection; }
[ "public", "static", "<", "T", "extends", "Collection", "<", "Integer", ">", ">", "T", "unmarshallIntCollection", "(", "ObjectInput", "in", ",", "CollectionBuilder", "<", "Integer", ",", "T", ">", "builder", ")", "throws", "IOException", "{", "final", "int", ...
Unmarshalls a collection of integers. @param in the {@link ObjectInput} to read from. @param builder the {@link CollectionBuilder} to build the collection of integer. @param <T> the concrete type of the collection. @return the collection. @throws IOException if an error occurs.
[ "Unmarshalls", "a", "collection", "of", "integers", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L489-L499
29,554
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.isSafeClass
public static boolean isSafeClass(String className, List<String> whitelist) { for (String whiteRegExp : whitelist) { Pattern whitePattern = Pattern.compile(whiteRegExp); Matcher whiteMatcher = whitePattern.matcher(className); if (whiteMatcher.find()) { if (log.isTraceEnabled()) log.tracef("Whitelist match: '%s'", className); return true; } } return false; }
java
public static boolean isSafeClass(String className, List<String> whitelist) { for (String whiteRegExp : whitelist) { Pattern whitePattern = Pattern.compile(whiteRegExp); Matcher whiteMatcher = whitePattern.matcher(className); if (whiteMatcher.find()) { if (log.isTraceEnabled()) log.tracef("Whitelist match: '%s'", className); return true; } } return false; }
[ "public", "static", "boolean", "isSafeClass", "(", "String", "className", ",", "List", "<", "String", ">", "whitelist", ")", "{", "for", "(", "String", "whiteRegExp", ":", "whitelist", ")", "{", "Pattern", "whitePattern", "=", "Pattern", ".", "compile", "(",...
Checks whether class name is matched by the class name white list regular expressions provided. @param className class to verify @param whitelist list of regular expressions to match class name against @return true if the class matched at least one of the regular expressions, false otherwise
[ "Checks", "whether", "class", "name", "is", "matched", "by", "the", "class", "name", "white", "list", "regular", "expressions", "provided", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L509-L522
29,555
infinispan/infinispan
counter/src/main/java/org/infinispan/counter/impl/strong/AbstractStrongCounter.java
AbstractStrongCounter.initCounterState
private synchronized void initCounterState(Long currentValue) { if (weakCounter == null) { weakCounter = currentValue == null ? newCounterValue(configuration) : newCounterValue(currentValue, configuration); } }
java
private synchronized void initCounterState(Long currentValue) { if (weakCounter == null) { weakCounter = currentValue == null ? newCounterValue(configuration) : newCounterValue(currentValue, configuration); } }
[ "private", "synchronized", "void", "initCounterState", "(", "Long", "currentValue", ")", "{", "if", "(", "weakCounter", "==", "null", ")", "{", "weakCounter", "=", "currentValue", "==", "null", "?", "newCounterValue", "(", "configuration", ")", ":", "newCounterV...
Initializes the weak value. @param currentValue The current value.
[ "Initializes", "the", "weak", "value", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/counter/src/main/java/org/infinispan/counter/impl/strong/AbstractStrongCounter.java#L191-L197
29,556
infinispan/infinispan
cli/cli-interpreter/src/main/java/org/infinispan/cli/interpreter/utils/ParserSupport.java
ParserSupport.millis
public static long millis(final String time, final String timeUnit) { return TIMEUNITS.get(timeUnit).toMillis(Long.parseLong(time)); }
java
public static long millis(final String time, final String timeUnit) { return TIMEUNITS.get(timeUnit).toMillis(Long.parseLong(time)); }
[ "public", "static", "long", "millis", "(", "final", "String", "time", ",", "final", "String", "timeUnit", ")", "{", "return", "TIMEUNITS", ".", "get", "(", "timeUnit", ")", ".", "toMillis", "(", "Long", ".", "parseLong", "(", "time", ")", ")", ";", "}"...
Converts a time representation into milliseconds @param time @param timeUnit @return
[ "Converts", "a", "time", "representation", "into", "milliseconds" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/cli/cli-interpreter/src/main/java/org/infinispan/cli/interpreter/utils/ParserSupport.java#L25-L27
29,557
infinispan/infinispan
client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/operations/OperationsFactory.java
OperationsFactory.newPingOperation
public PingOperation newPingOperation(boolean releaseChannel) { return new PingOperation(codec, topologyId, cfg, cacheNameBytes, channelFactory, releaseChannel, this); }
java
public PingOperation newPingOperation(boolean releaseChannel) { return new PingOperation(codec, topologyId, cfg, cacheNameBytes, channelFactory, releaseChannel, this); }
[ "public", "PingOperation", "newPingOperation", "(", "boolean", "releaseChannel", ")", "{", "return", "new", "PingOperation", "(", "codec", ",", "topologyId", ",", "cfg", ",", "cacheNameBytes", ",", "channelFactory", ",", "releaseChannel", ",", "this", ")", ";", ...
Construct a ping request directed to a particular node. @return a ping operation for a particular node @param releaseChannel
[ "Construct", "a", "ping", "request", "directed", "to", "a", "particular", "node", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/operations/OperationsFactory.java#L209-L211
29,558
infinispan/infinispan
core/src/main/java/org/infinispan/persistence/PersistenceUtil.java
PersistenceUtil.count
public static int count(SegmentedAdvancedLoadWriteStore<?, ?> salws, IntSet segments) { Long result = Flowable.fromPublisher(salws.publishKeys(segments, null)).count().blockingGet(); if (result > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return result.intValue(); }
java
public static int count(SegmentedAdvancedLoadWriteStore<?, ?> salws, IntSet segments) { Long result = Flowable.fromPublisher(salws.publishKeys(segments, null)).count().blockingGet(); if (result > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return result.intValue(); }
[ "public", "static", "int", "count", "(", "SegmentedAdvancedLoadWriteStore", "<", "?", ",", "?", ">", "salws", ",", "IntSet", "segments", ")", "{", "Long", "result", "=", "Flowable", ".", "fromPublisher", "(", "salws", ".", "publishKeys", "(", "segments", ","...
Counts how many entries are present in the segmented store. Only the segments provided will have entries counted. @param salws segmented store containing entries @param segments segments to count entries from @return count of entries that are in the provided segments
[ "Counts", "how", "many", "entries", "are", "present", "in", "the", "segmented", "store", ".", "Only", "the", "segments", "provided", "will", "have", "entries", "counted", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/persistence/PersistenceUtil.java#L74-L80
29,559
infinispan/infinispan
query/src/main/java/org/infinispan/query/backend/KeyTransformationHandler.java
KeyTransformationHandler.stringToKey
public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': // this is a String, NOT a Short. For Short see case 'X'. return s.substring(2); case 'I': // This is an Integer return Integer.valueOf(s.substring(2)); case 'Y': // This is a BYTE return Byte.valueOf(s.substring(2)); case 'L': // This is a Long return Long.valueOf(s.substring(2)); case 'X': // This is a SHORT return Short.valueOf(s.substring(2)); case 'D': // This is a Double return Double.valueOf(s.substring(2)); case 'F': // This is a Float return Float.valueOf(s.substring(2)); case 'B': // This is a Boolean, NOT a Byte. For Byte see case 'Y'. return Boolean.valueOf(s.substring(2)); case 'C': // This is a Character return Character.valueOf(s.charAt(2)); case 'U': // This is a java.util.UUID return UUID.fromString(s.substring(2)); case 'A': // This is an array of bytes encoded as a Base64 string return Base64.getDecoder().decode(s.substring(2)); case 'T': // this is a custom Transformable or a type with a registered Transformer int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw log.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); }
java
public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': // this is a String, NOT a Short. For Short see case 'X'. return s.substring(2); case 'I': // This is an Integer return Integer.valueOf(s.substring(2)); case 'Y': // This is a BYTE return Byte.valueOf(s.substring(2)); case 'L': // This is a Long return Long.valueOf(s.substring(2)); case 'X': // This is a SHORT return Short.valueOf(s.substring(2)); case 'D': // This is a Double return Double.valueOf(s.substring(2)); case 'F': // This is a Float return Float.valueOf(s.substring(2)); case 'B': // This is a Boolean, NOT a Byte. For Byte see case 'Y'. return Boolean.valueOf(s.substring(2)); case 'C': // This is a Character return Character.valueOf(s.charAt(2)); case 'U': // This is a java.util.UUID return UUID.fromString(s.substring(2)); case 'A': // This is an array of bytes encoded as a Base64 string return Base64.getDecoder().decode(s.substring(2)); case 'T': // this is a custom Transformable or a type with a registered Transformer int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw log.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); }
[ "public", "Object", "stringToKey", "(", "String", "s", ")", "{", "char", "type", "=", "s", ".", "charAt", "(", "0", ")", ";", "switch", "(", "type", ")", "{", "case", "'", "'", ":", "// this is a String, NOT a Short. For Short see case 'X'.", "return", "s", ...
Converts a Lucene document id from string form back to the original object. @param s the string form of the key @return the key object
[ "Converts", "a", "Lucene", "document", "id", "from", "string", "form", "back", "to", "the", "original", "object", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/backend/KeyTransformationHandler.java#L59-L108
29,560
infinispan/infinispan
query/src/main/java/org/infinispan/query/backend/KeyTransformationHandler.java
KeyTransformationHandler.keyToString
public String keyToString(Object key) { // This string should be in the format of: // "<TYPE>:<KEY>" for internally supported types or "T:<KEY_CLASS>:<KEY>" for custom types // e.g.: // "S:my string key" // "I:75" // "D:5.34" // "B:f" // "T:com.myorg.MyType:STRING_GENERATED_BY_TRANSFORMER_FOR_MY_TYPE" // First going to check if the key is a primitive or a String. Otherwise, check if it's a transformable. // If none of those conditions are satisfied, we'll throw a CacheException. // Using 'X' for Shorts and 'Y' for Bytes because 'S' is used for Strings and 'B' is being used for Booleans. if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); //todo [anistor] need to profile Base64 versus simple hex encoding of the raw bytes if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw log.noTransformerForKey(key.getClass().getName()); } } }
java
public String keyToString(Object key) { // This string should be in the format of: // "<TYPE>:<KEY>" for internally supported types or "T:<KEY_CLASS>:<KEY>" for custom types // e.g.: // "S:my string key" // "I:75" // "D:5.34" // "B:f" // "T:com.myorg.MyType:STRING_GENERATED_BY_TRANSFORMER_FOR_MY_TYPE" // First going to check if the key is a primitive or a String. Otherwise, check if it's a transformable. // If none of those conditions are satisfied, we'll throw a CacheException. // Using 'X' for Shorts and 'Y' for Bytes because 'S' is used for Strings and 'B' is being used for Booleans. if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); //todo [anistor] need to profile Base64 versus simple hex encoding of the raw bytes if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw log.noTransformerForKey(key.getClass().getName()); } } }
[ "public", "String", "keyToString", "(", "Object", "key", ")", "{", "// This string should be in the format of:", "// \"<TYPE>:<KEY>\" for internally supported types or \"T:<KEY_CLASS>:<KEY>\" for custom types", "// e.g.:", "// \"S:my string key\"", "// \"I:75\"", "// \"D:5.34\"", "...
Stringify a key so Lucene can use it as document id. @param key the key @return a string form of the key
[ "Stringify", "a", "key", "so", "Lucene", "can", "use", "it", "as", "document", "id", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/backend/KeyTransformationHandler.java#L127-L171
29,561
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/base/CommandInterceptor.java
CommandInterceptor.invokeNextInterceptor
public final Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable { Object maybeStage = nextInterceptor.visitCommand(ctx, command); if (maybeStage instanceof SimpleAsyncInvocationStage) { return ((InvocationStage) maybeStage).get(); } else { return maybeStage; } }
java
public final Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable { Object maybeStage = nextInterceptor.visitCommand(ctx, command); if (maybeStage instanceof SimpleAsyncInvocationStage) { return ((InvocationStage) maybeStage).get(); } else { return maybeStage; } }
[ "public", "final", "Object", "invokeNextInterceptor", "(", "InvocationContext", "ctx", ",", "VisitableCommand", "command", ")", "throws", "Throwable", "{", "Object", "maybeStage", "=", "nextInterceptor", ".", "visitCommand", "(", "ctx", ",", "command", ")", ";", "...
Invokes the next interceptor in the chain. This is how interceptor implementations should pass a call up the chain to the next interceptor. @param ctx invocation context @param command command to pass up the chain. @return return value of the invocation @throws Throwable in the event of problems
[ "Invokes", "the", "next", "interceptor", "in", "the", "chain", ".", "This", "is", "how", "interceptor", "implementations", "should", "pass", "a", "call", "up", "the", "chain", "to", "the", "next", "interceptor", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/base/CommandInterceptor.java#L117-L124
29,562
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/base/CommandInterceptor.java
CommandInterceptor.handleDefault
@Override protected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable { return invokeNextInterceptor(ctx, command); }
java
@Override protected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable { return invokeNextInterceptor(ctx, command); }
[ "@", "Override", "protected", "Object", "handleDefault", "(", "InvocationContext", "ctx", ",", "VisitableCommand", "command", ")", "throws", "Throwable", "{", "return", "invokeNextInterceptor", "(", "ctx", ",", "command", ")", ";", "}" ]
The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next interceptor in the chain. @param ctx invocation context @param command command to invoke @return return value @throws Throwable in the event of problems
[ "The", "default", "behaviour", "of", "the", "visitXXX", "methods", "which", "is", "to", "ignore", "the", "call", "and", "pass", "the", "call", "up", "to", "the", "next", "interceptor", "in", "the", "chain", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/base/CommandInterceptor.java#L135-L138
29,563
infinispan/infinispan
core/src/main/java/org/infinispan/stream/StreamMarshalling.java
StreamMarshalling.entryToKeyFunction
public static <K, V> Function<Map.Entry<K, V>, K> entryToKeyFunction() { return EntryToKeyFunction.getInstance(); }
java
public static <K, V> Function<Map.Entry<K, V>, K> entryToKeyFunction() { return EntryToKeyFunction.getInstance(); }
[ "public", "static", "<", "K", ",", "V", ">", "Function", "<", "Map", ".", "Entry", "<", "K", ",", "V", ">", ",", "K", ">", "entryToKeyFunction", "(", ")", "{", "return", "EntryToKeyFunction", ".", "getInstance", "(", ")", ";", "}" ]
Provides a function that returns the key of the entry when invoked. @param <K> key type of the entry @param <V> value type of the entry @return a function that when applied to a given entry will return the key
[ "Provides", "a", "function", "that", "returns", "the", "key", "of", "the", "entry", "when", "invoked", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/stream/StreamMarshalling.java#L60-L62
29,564
infinispan/infinispan
core/src/main/java/org/infinispan/stream/StreamMarshalling.java
StreamMarshalling.entryToValueFunction
public static <K, V> Function<Map.Entry<K, V>, V> entryToValueFunction() { return EntryToValueFunction.getInstance(); }
java
public static <K, V> Function<Map.Entry<K, V>, V> entryToValueFunction() { return EntryToValueFunction.getInstance(); }
[ "public", "static", "<", "K", ",", "V", ">", "Function", "<", "Map", ".", "Entry", "<", "K", ",", "V", ">", ",", "V", ">", "entryToValueFunction", "(", ")", "{", "return", "EntryToValueFunction", ".", "getInstance", "(", ")", ";", "}" ]
Provides a function that returns the value of the entry when invoked. @param <K> key type of the entry @param <V> value type of the entry @return a function that when applied to a given entry will return the value
[ "Provides", "a", "function", "that", "returns", "the", "value", "of", "the", "entry", "when", "invoked", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/stream/StreamMarshalling.java#L70-L72
29,565
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/concurrent/ConcurrentWeakKeyHashMap.java
ConcurrentWeakKeyHashMap.hash
private static int hash(int h) { // Spread bits to regularize both segment and index locations, // using variant of single-word Wang/Jenkins hash. h += h << 15 ^ 0xffffcd7d; h ^= h >>> 10; h += h << 3; h ^= h >>> 6; h += (h << 2) + (h << 14); return h ^ h >>> 16; }
java
private static int hash(int h) { // Spread bits to regularize both segment and index locations, // using variant of single-word Wang/Jenkins hash. h += h << 15 ^ 0xffffcd7d; h ^= h >>> 10; h += h << 3; h ^= h >>> 6; h += (h << 2) + (h << 14); return h ^ h >>> 16; }
[ "private", "static", "int", "hash", "(", "int", "h", ")", "{", "// Spread bits to regularize both segment and index locations,", "// using variant of single-word Wang/Jenkins hash.", "h", "+=", "h", "<<", "15", "^", "0xffffcd7d", ";", "h", "^=", "h", ">>>", "10", ";",...
Applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions. This is critical because ConcurrentReferenceHashMap uses power-of-two length hash tables, that otherwise encounter collisions for hashCodes that do not differ in lower or upper bits.
[ "Applies", "a", "supplemental", "hash", "function", "to", "a", "given", "hashCode", "which", "defends", "against", "poor", "quality", "hash", "functions", ".", "This", "is", "critical", "because", "ConcurrentReferenceHashMap", "uses", "power", "-", "of", "-", "t...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/concurrent/ConcurrentWeakKeyHashMap.java#L107-L116
29,566
infinispan/infinispan
core/src/main/java/org/infinispan/factories/components/ComponentMetadataRepo.java
ComponentMetadataRepo.getComponentMetadata
public ComponentMetadata getComponentMetadata(Class<?> componentClass) { ComponentMetadata md = componentMetadataMap.get(componentClass.getName()); if (md == null) { if (componentClass.getSuperclass() != null) { return getComponentMetadata(componentClass.getSuperclass()); } else { return null; } } initMetadata(componentClass, md); return md; }
java
public ComponentMetadata getComponentMetadata(Class<?> componentClass) { ComponentMetadata md = componentMetadataMap.get(componentClass.getName()); if (md == null) { if (componentClass.getSuperclass() != null) { return getComponentMetadata(componentClass.getSuperclass()); } else { return null; } } initMetadata(componentClass, md); return md; }
[ "public", "ComponentMetadata", "getComponentMetadata", "(", "Class", "<", "?", ">", "componentClass", ")", "{", "ComponentMetadata", "md", "=", "componentMetadataMap", ".", "get", "(", "componentClass", ".", "getName", "(", ")", ")", ";", "if", "(", "md", "=="...
Look up metadata for a component class. <p>If the class does not have any metadata, tries to look up the metadata of its superclasses. This is needed for mocks and other classes generated at runtime.</p> <p>Do not use for looking up the metadata of an interface, e.g. to determine the scope of a component that doesn't exist.</p>
[ "Look", "up", "metadata", "for", "a", "component", "class", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/components/ComponentMetadataRepo.java#L109-L122
29,567
infinispan/infinispan
core/src/main/java/org/infinispan/factories/components/ComponentMetadataRepo.java
ComponentMetadataRepo.injectFactoryForComponent
@Deprecated public void injectFactoryForComponent(Class<?> componentType, Class<?> factoryType) { factories.put(componentType.getName(), factoryType.getName()); }
java
@Deprecated public void injectFactoryForComponent(Class<?> componentType, Class<?> factoryType) { factories.put(componentType.getName(), factoryType.getName()); }
[ "@", "Deprecated", "public", "void", "injectFactoryForComponent", "(", "Class", "<", "?", ">", "componentType", ",", "Class", "<", "?", ">", "factoryType", ")", "{", "factories", ".", "put", "(", "componentType", ".", "getName", "(", ")", ",", "factoryType",...
Inject a factory for a given component type. @param componentType Component type that the factory will produce @param factoryType Factory that produces the given type of components @deprecated For testing purposes only.
[ "Inject", "a", "factory", "for", "a", "given", "component", "type", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/factories/components/ComponentMetadataRepo.java#L195-L198
29,568
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java
BaseAsyncInterceptor.setNextInterceptor
@Override public final void setNextInterceptor(AsyncInterceptor nextInterceptor) { this.nextInterceptor = nextInterceptor; this.nextDDInterceptor = nextInterceptor instanceof DDAsyncInterceptor ? (DDAsyncInterceptor) nextInterceptor : null; }
java
@Override public final void setNextInterceptor(AsyncInterceptor nextInterceptor) { this.nextInterceptor = nextInterceptor; this.nextDDInterceptor = nextInterceptor instanceof DDAsyncInterceptor ? (DDAsyncInterceptor) nextInterceptor : null; }
[ "@", "Override", "public", "final", "void", "setNextInterceptor", "(", "AsyncInterceptor", "nextInterceptor", ")", "{", "this", ".", "nextInterceptor", "=", "nextInterceptor", ";", "this", ".", "nextDDInterceptor", "=", "nextInterceptor", "instanceof", "DDAsyncIntercept...
Used internally to set up the interceptor.
[ "Used", "internally", "to", "set", "up", "the", "interceptor", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java#L33-L38
29,569
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java
BaseAsyncInterceptor.invokeNext
public final Object invokeNext(InvocationContext ctx, VisitableCommand command) { try { if (nextDDInterceptor != null) { return command.acceptVisitor(ctx, nextDDInterceptor); } else { return nextInterceptor.visitCommand(ctx, command); } } catch (Throwable throwable) { return new SimpleAsyncInvocationStage(throwable); } }
java
public final Object invokeNext(InvocationContext ctx, VisitableCommand command) { try { if (nextDDInterceptor != null) { return command.acceptVisitor(ctx, nextDDInterceptor); } else { return nextInterceptor.visitCommand(ctx, command); } } catch (Throwable throwable) { return new SimpleAsyncInvocationStage(throwable); } }
[ "public", "final", "Object", "invokeNext", "(", "InvocationContext", "ctx", ",", "VisitableCommand", "command", ")", "{", "try", "{", "if", "(", "nextDDInterceptor", "!=", "null", ")", "{", "return", "command", ".", "acceptVisitor", "(", "ctx", ",", "nextDDInt...
Invoke the next interceptor, possibly with a new command. <p>Use {@link #invokeNextThenApply(InvocationContext, VisitableCommand, InvocationSuccessFunction)} or {@link #invokeNextThenAccept(InvocationContext, VisitableCommand, InvocationSuccessAction)} instead if you need to process the return value of the next interceptor.</p> <p>Note: {@code invokeNext(ctx, command)} does not throw exceptions. In order to handle exceptions from the next interceptors, you <em>must</em> use {@link #invokeNextAndHandle(InvocationContext, VisitableCommand, InvocationFinallyFunction)}, {@link #invokeNextAndFinally(InvocationContext, VisitableCommand, InvocationFinallyAction)}, or {@link #invokeNextAndExceptionally(InvocationContext, VisitableCommand, InvocationExceptionFunction)}.</p>
[ "Invoke", "the", "next", "interceptor", "possibly", "with", "a", "new", "command", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java#L53-L63
29,570
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java
BaseAsyncInterceptor.delayedValue
public static Object delayedValue(CompletionStage<Void> stage, Object syncValue) { if (stage != null) { CompletableFuture<?> future = stage.toCompletableFuture(); if (!future.isDone()) { return asyncValue(stage.thenApply(v -> syncValue)); } if (future.isCompletedExceptionally()) { return asyncValue(stage); } } return syncValue; }
java
public static Object delayedValue(CompletionStage<Void> stage, Object syncValue) { if (stage != null) { CompletableFuture<?> future = stage.toCompletableFuture(); if (!future.isDone()) { return asyncValue(stage.thenApply(v -> syncValue)); } if (future.isCompletedExceptionally()) { return asyncValue(stage); } } return syncValue; }
[ "public", "static", "Object", "delayedValue", "(", "CompletionStage", "<", "Void", ">", "stage", ",", "Object", "syncValue", ")", "{", "if", "(", "stage", "!=", "null", ")", "{", "CompletableFuture", "<", "?", ">", "future", "=", "stage", ".", "toCompletab...
Returns an InvocationStage if the provided CompletionStage is null, not completed or completed via exception. If these are not true the sync value is returned directly. @param stage wait for completion of this if not null @param syncValue sync value to return if stage is complete or as stage value @return invocation stage or sync value
[ "Returns", "an", "InvocationStage", "if", "the", "provided", "CompletionStage", "is", "null", "not", "completed", "or", "completed", "via", "exception", ".", "If", "these", "are", "not", "true", "the", "sync", "value", "is", "returned", "directly", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/BaseAsyncInterceptor.java#L299-L310
29,571
infinispan/infinispan
core/src/main/java/org/infinispan/remoting/transport/AbstractDelegatingTransport.java
AbstractDelegatingTransport.afterInvokeRemotely
protected Map<Address, Response> afterInvokeRemotely(ReplicableCommand command, Map<Address, Response> responseMap) { return responseMap; }
java
protected Map<Address, Response> afterInvokeRemotely(ReplicableCommand command, Map<Address, Response> responseMap) { return responseMap; }
[ "protected", "Map", "<", "Address", ",", "Response", ">", "afterInvokeRemotely", "(", "ReplicableCommand", "command", ",", "Map", "<", "Address", ",", "Response", ">", "responseMap", ")", "{", "return", "responseMap", ";", "}" ]
method invoked after a successful remote invocation. @param command the command invoked remotely. @param responseMap can be null if not response is expected. @return the new response map
[ "method", "invoked", "after", "a", "successful", "remote", "invocation", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/remoting/transport/AbstractDelegatingTransport.java#L169-L171
29,572
infinispan/infinispan
core/src/main/java/org/infinispan/container/impl/DefaultSegmentedDataContainer.java
DefaultSegmentedDataContainer.stop
@Stop(priority = 9999) public void stop() { for (int i = 0; i < maps.length(); ++i) { stopMap(i, false); } }
java
@Stop(priority = 9999) public void stop() { for (int i = 0; i < maps.length(); ++i) { stopMap(i, false); } }
[ "@", "Stop", "(", "priority", "=", "9999", ")", "public", "void", "stop", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maps", ".", "length", "(", ")", ";", "++", "i", ")", "{", "stopMap", "(", "i", ",", "false", ")", ";"...
Priority has to be higher than the clear priority - which is currently 999
[ "Priority", "has", "to", "be", "higher", "than", "the", "clear", "priority", "-", "which", "is", "currently", "999" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/container/impl/DefaultSegmentedDataContainer.java#L79-L84
29,573
infinispan/infinispan
query/src/main/java/org/infinispan/query/dsl/embedded/impl/BaseIckleFilterIndexingServiceProvider.java
BaseIckleFilterIndexingServiceProvider.getEventTypeFromAnnotation
private Event.Type getEventTypeFromAnnotation(Class<? extends Annotation> annotation) { if (annotation == CacheEntryCreated.class) return Event.Type.CACHE_ENTRY_CREATED; if (annotation == CacheEntryModified.class) return Event.Type.CACHE_ENTRY_MODIFIED; if (annotation == CacheEntryRemoved.class) return Event.Type.CACHE_ENTRY_REMOVED; if (annotation == CacheEntryActivated.class) return Event.Type.CACHE_ENTRY_ACTIVATED; if (annotation == CacheEntryInvalidated.class) return Event.Type.CACHE_ENTRY_INVALIDATED; if (annotation == CacheEntryLoaded.class) return Event.Type.CACHE_ENTRY_LOADED; if (annotation == CacheEntryPassivated.class) return Event.Type.CACHE_ENTRY_PASSIVATED; if (annotation == CacheEntryVisited.class) return Event.Type.CACHE_ENTRY_VISITED; if (annotation == CacheEntriesEvicted.class) return Event.Type.CACHE_ENTRY_EVICTED; if (annotation == CacheEntryExpired.class) return Event.Type.CACHE_ENTRY_EXPIRED; return null; }
java
private Event.Type getEventTypeFromAnnotation(Class<? extends Annotation> annotation) { if (annotation == CacheEntryCreated.class) return Event.Type.CACHE_ENTRY_CREATED; if (annotation == CacheEntryModified.class) return Event.Type.CACHE_ENTRY_MODIFIED; if (annotation == CacheEntryRemoved.class) return Event.Type.CACHE_ENTRY_REMOVED; if (annotation == CacheEntryActivated.class) return Event.Type.CACHE_ENTRY_ACTIVATED; if (annotation == CacheEntryInvalidated.class) return Event.Type.CACHE_ENTRY_INVALIDATED; if (annotation == CacheEntryLoaded.class) return Event.Type.CACHE_ENTRY_LOADED; if (annotation == CacheEntryPassivated.class) return Event.Type.CACHE_ENTRY_PASSIVATED; if (annotation == CacheEntryVisited.class) return Event.Type.CACHE_ENTRY_VISITED; if (annotation == CacheEntriesEvicted.class) return Event.Type.CACHE_ENTRY_EVICTED; if (annotation == CacheEntryExpired.class) return Event.Type.CACHE_ENTRY_EXPIRED; return null; }
[ "private", "Event", ".", "Type", "getEventTypeFromAnnotation", "(", "Class", "<", "?", "extends", "Annotation", ">", "annotation", ")", "{", "if", "(", "annotation", "==", "CacheEntryCreated", ".", "class", ")", "return", "Event", ".", "Type", ".", "CACHE_ENTR...
Obtains the event type that corresponds to the given event annotation. @param annotation a CacheEntryXXX annotation @return the event type or {@code null} if the given annotation is not supported
[ "Obtains", "the", "event", "type", "that", "corresponds", "to", "the", "given", "event", "annotation", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/dsl/embedded/impl/BaseIckleFilterIndexingServiceProvider.java#L114-L126
29,574
infinispan/infinispan
server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java
ModelNodes.asEnum
public static <E extends Enum<E>> E asEnum(ModelNode value, Class<E> targetClass) { return asEnum(value, targetClass, null); }
java
public static <E extends Enum<E>> E asEnum(ModelNode value, Class<E> targetClass) { return asEnum(value, targetClass, null); }
[ "public", "static", "<", "E", "extends", "Enum", "<", "E", ">", ">", "E", "asEnum", "(", "ModelNode", "value", ",", "Class", "<", "E", ">", "targetClass", ")", "{", "return", "asEnum", "(", "value", ",", "targetClass", ",", "null", ")", ";", "}" ]
Returns the value of the node as an Enum value, or null if the node is undefined. @param value a model node @return the value of the node as an Enum, or null if the node is undefined.
[ "Returns", "the", "value", "of", "the", "node", "as", "an", "Enum", "value", "or", "null", "if", "the", "node", "is", "undefined", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java#L75-L77
29,575
infinispan/infinispan
server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java
ModelNodes.asModuleIdentifier
public static ModuleIdentifier asModuleIdentifier(ModelNode value, ModuleIdentifier defaultValue) { return value.isDefined() ? ModuleIdentifier.fromString(value.asString()) : defaultValue; }
java
public static ModuleIdentifier asModuleIdentifier(ModelNode value, ModuleIdentifier defaultValue) { return value.isDefined() ? ModuleIdentifier.fromString(value.asString()) : defaultValue; }
[ "public", "static", "ModuleIdentifier", "asModuleIdentifier", "(", "ModelNode", "value", ",", "ModuleIdentifier", "defaultValue", ")", "{", "return", "value", ".", "isDefined", "(", ")", "?", "ModuleIdentifier", ".", "fromString", "(", "value", ".", "asString", "(...
Returns the value of the node as a module identifier, or the specified default if the node is undefined. @param value a model node @return the value of the node as a module identifier, or the specified default if the node is undefined.
[ "Returns", "the", "value", "of", "the", "node", "as", "a", "module", "identifier", "or", "the", "specified", "default", "if", "the", "node", "is", "undefined", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java#L102-L104
29,576
infinispan/infinispan
client/hotrod-client/src/main/java/org/infinispan/client/hotrod/configuration/ConfigurationBuilder.java
ConfigurationBuilder.handleNullMarshaller
private void handleNullMarshaller() { try { // First see if marshalling is in the class path - if so we can use the generic marshaller // We have to use the commons class loader, since marshalling is its dependency Class.forName("org.jboss.marshalling.river.RiverMarshaller", false, Util.class.getClassLoader()); marshallerClass = GenericJBossMarshaller.class; } catch (ClassNotFoundException e) { log.tracef("JBoss Marshalling is not on the class path - Only byte[] instances can be marshalled"); // Otherwise we fall back to a byte[] only marshaller marshaller = BytesOnlyMarshaller.INSTANCE; } }
java
private void handleNullMarshaller() { try { // First see if marshalling is in the class path - if so we can use the generic marshaller // We have to use the commons class loader, since marshalling is its dependency Class.forName("org.jboss.marshalling.river.RiverMarshaller", false, Util.class.getClassLoader()); marshallerClass = GenericJBossMarshaller.class; } catch (ClassNotFoundException e) { log.tracef("JBoss Marshalling is not on the class path - Only byte[] instances can be marshalled"); // Otherwise we fall back to a byte[] only marshaller marshaller = BytesOnlyMarshaller.INSTANCE; } }
[ "private", "void", "handleNullMarshaller", "(", ")", "{", "try", "{", "// First see if marshalling is in the class path - if so we can use the generic marshaller", "// We have to use the commons class loader, since marshalling is its dependency", "Class", ".", "forName", "(", "\"org.jbos...
Method that handles default marshaller - needed as a placeholder
[ "Method", "that", "handles", "default", "marshaller", "-", "needed", "as", "a", "placeholder" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/configuration/ConfigurationBuilder.java#L451-L462
29,577
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/distribution/TxDistributionInterceptor.java
TxDistributionInterceptor.handleTxWriteCommand
private Object handleTxWriteCommand(InvocationContext ctx, AbstractDataWriteCommand command, Object key) throws Throwable { try { if (!ctx.isOriginLocal()) { LocalizedCacheTopology cacheTopology = checkTopologyId(command); // Ignore any remote command when we aren't the owner if (!cacheTopology.isSegmentWriteOwner(command.getSegment())) { return null; } } CacheEntry entry = ctx.lookupEntry(command.getKey()); if (entry == null) { if (isLocalModeForced(command) || command.hasAnyFlag(FlagBitSets.SKIP_REMOTE_LOOKUP) || !needsPreviousValue(ctx, command)) { // in transactional mode, we always need the entry wrapped entryFactory.wrapExternalEntry(ctx, key, null, false, true); } else { // we need to retrieve the value locally regardless of load type; in transactional mode all operations // execute on origin // Also, operations that need value on backup [delta write] need to do the remote lookup even on // non-origin Object result = asyncInvokeNext(ctx, command, remoteGetSingleKey(ctx, command, command.getKey(), true)); return makeStage(result) .andFinally(ctx, command, (rCtx, rCommand, rv, t) -> updateMatcherForRetry((WriteCommand) rCommand)); } } // already wrapped, we can continue return invokeNextAndFinally(ctx, command, (rCtx, rCommand, rv, t) -> updateMatcherForRetry((WriteCommand) rCommand)); } catch (Throwable t) { updateMatcherForRetry(command); throw t; } }
java
private Object handleTxWriteCommand(InvocationContext ctx, AbstractDataWriteCommand command, Object key) throws Throwable { try { if (!ctx.isOriginLocal()) { LocalizedCacheTopology cacheTopology = checkTopologyId(command); // Ignore any remote command when we aren't the owner if (!cacheTopology.isSegmentWriteOwner(command.getSegment())) { return null; } } CacheEntry entry = ctx.lookupEntry(command.getKey()); if (entry == null) { if (isLocalModeForced(command) || command.hasAnyFlag(FlagBitSets.SKIP_REMOTE_LOOKUP) || !needsPreviousValue(ctx, command)) { // in transactional mode, we always need the entry wrapped entryFactory.wrapExternalEntry(ctx, key, null, false, true); } else { // we need to retrieve the value locally regardless of load type; in transactional mode all operations // execute on origin // Also, operations that need value on backup [delta write] need to do the remote lookup even on // non-origin Object result = asyncInvokeNext(ctx, command, remoteGetSingleKey(ctx, command, command.getKey(), true)); return makeStage(result) .andFinally(ctx, command, (rCtx, rCommand, rv, t) -> updateMatcherForRetry((WriteCommand) rCommand)); } } // already wrapped, we can continue return invokeNextAndFinally(ctx, command, (rCtx, rCommand, rv, t) -> updateMatcherForRetry((WriteCommand) rCommand)); } catch (Throwable t) { updateMatcherForRetry(command); throw t; } }
[ "private", "Object", "handleTxWriteCommand", "(", "InvocationContext", "ctx", ",", "AbstractDataWriteCommand", "command", ",", "Object", "key", ")", "throws", "Throwable", "{", "try", "{", "if", "(", "!", "ctx", ".", "isOriginLocal", "(", ")", ")", "{", "Local...
If we are within one transaction we won't do any replication as replication would only be performed at commit time. If the operation didn't originate locally we won't do any replication either.
[ "If", "we", "are", "within", "one", "transaction", "we", "won", "t", "do", "any", "replication", "as", "replication", "would", "only", "be", "performed", "at", "commit", "time", ".", "If", "the", "operation", "didn", "t", "originate", "locally", "we", "won...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/distribution/TxDistributionInterceptor.java#L400-L432
29,578
infinispan/infinispan
query/src/main/java/org/infinispan/query/dsl/embedded/impl/QueryEngine.java
QueryEngine.buildLuceneQuery
protected <E> CacheQuery<E> buildLuceneQuery(IckleParsingResult<TypeMetadata> ickleParsingResult, Map<String, Object> namedParameters, long startOffset, int maxResults, IndexedQueryMode queryMode) { if (log.isDebugEnabled()) { log.debugf("Building Lucene query for : %s", ickleParsingResult.getQueryString()); } if (!isIndexed) { throw log.cannotRunLuceneQueriesIfNotIndexed(cache.getName()); } LuceneQueryParsingResult luceneParsingResult = transformParsingResult(ickleParsingResult, namedParameters); org.apache.lucene.search.Query luceneQuery = makeTypeQuery(luceneParsingResult.getQuery(), luceneParsingResult.getTargetEntityName()); if (log.isDebugEnabled()) { log.debugf("The resulting Lucene query is : %s", luceneQuery.toString()); } CacheQuery<?> cacheQuery = makeCacheQuery(ickleParsingResult, luceneQuery, queryMode, namedParameters); // No need to set sort and projection if BROADCAST, as both are part of the query string already. if (queryMode != IndexedQueryMode.BROADCAST) { if (luceneParsingResult.getSort() != null) { cacheQuery = cacheQuery.sort(luceneParsingResult.getSort()); } if (luceneParsingResult.getProjections() != null) { cacheQuery = cacheQuery.projection(luceneParsingResult.getProjections()); } } if (startOffset >= 0) { cacheQuery = cacheQuery.firstResult((int) startOffset); } if (maxResults > 0) { cacheQuery = cacheQuery.maxResults(maxResults); } return (CacheQuery<E>) cacheQuery; }
java
protected <E> CacheQuery<E> buildLuceneQuery(IckleParsingResult<TypeMetadata> ickleParsingResult, Map<String, Object> namedParameters, long startOffset, int maxResults, IndexedQueryMode queryMode) { if (log.isDebugEnabled()) { log.debugf("Building Lucene query for : %s", ickleParsingResult.getQueryString()); } if (!isIndexed) { throw log.cannotRunLuceneQueriesIfNotIndexed(cache.getName()); } LuceneQueryParsingResult luceneParsingResult = transformParsingResult(ickleParsingResult, namedParameters); org.apache.lucene.search.Query luceneQuery = makeTypeQuery(luceneParsingResult.getQuery(), luceneParsingResult.getTargetEntityName()); if (log.isDebugEnabled()) { log.debugf("The resulting Lucene query is : %s", luceneQuery.toString()); } CacheQuery<?> cacheQuery = makeCacheQuery(ickleParsingResult, luceneQuery, queryMode, namedParameters); // No need to set sort and projection if BROADCAST, as both are part of the query string already. if (queryMode != IndexedQueryMode.BROADCAST) { if (luceneParsingResult.getSort() != null) { cacheQuery = cacheQuery.sort(luceneParsingResult.getSort()); } if (luceneParsingResult.getProjections() != null) { cacheQuery = cacheQuery.projection(luceneParsingResult.getProjections()); } } if (startOffset >= 0) { cacheQuery = cacheQuery.firstResult((int) startOffset); } if (maxResults > 0) { cacheQuery = cacheQuery.maxResults(maxResults); } return (CacheQuery<E>) cacheQuery; }
[ "protected", "<", "E", ">", "CacheQuery", "<", "E", ">", "buildLuceneQuery", "(", "IckleParsingResult", "<", "TypeMetadata", ">", "ickleParsingResult", ",", "Map", "<", "String", ",", "Object", ">", "namedParameters", ",", "long", "startOffset", ",", "int", "m...
Build a Lucene index query.
[ "Build", "a", "Lucene", "index", "query", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/dsl/embedded/impl/QueryEngine.java#L813-L847
29,579
infinispan/infinispan
query/src/main/java/org/infinispan/query/dsl/embedded/impl/QueryEngine.java
QueryEngine.makeTypeQuery
protected org.apache.lucene.search.Query makeTypeQuery(org.apache.lucene.search.Query query, String targetEntityName) { return query; }
java
protected org.apache.lucene.search.Query makeTypeQuery(org.apache.lucene.search.Query query, String targetEntityName) { return query; }
[ "protected", "org", ".", "apache", ".", "lucene", ".", "search", ".", "Query", "makeTypeQuery", "(", "org", ".", "apache", ".", "lucene", ".", "search", ".", "Query", "query", ",", "String", "targetEntityName", ")", "{", "return", "query", ";", "}" ]
Enhances the give query with an extra condition to discriminate on entity type. This is a no-op in embedded mode but other query engines could use it to discriminate if more types are stored in the same index. To be overridden by subclasses as needed.
[ "Enhances", "the", "give", "query", "with", "an", "extra", "condition", "to", "discriminate", "on", "entity", "type", ".", "This", "is", "a", "no", "-", "op", "in", "embedded", "mode", "but", "other", "query", "engines", "could", "use", "it", "to", "disc...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/dsl/embedded/impl/QueryEngine.java#L865-L867
29,580
infinispan/infinispan
core/src/main/java/org/infinispan/interceptors/impl/CacheLoaderInterceptor.java
CacheLoaderInterceptor.loadIfNeeded
protected final CompletionStage<Void> loadIfNeeded(final InvocationContext ctx, Object key, final FlagAffectedCommand cmd) { if (skipLoad(cmd, key, ctx)) { return null; } return loadInContext(ctx, key, cmd); }
java
protected final CompletionStage<Void> loadIfNeeded(final InvocationContext ctx, Object key, final FlagAffectedCommand cmd) { if (skipLoad(cmd, key, ctx)) { return null; } return loadInContext(ctx, key, cmd); }
[ "protected", "final", "CompletionStage", "<", "Void", ">", "loadIfNeeded", "(", "final", "InvocationContext", "ctx", ",", "Object", "key", ",", "final", "FlagAffectedCommand", "cmd", ")", "{", "if", "(", "skipLoad", "(", "cmd", ",", "key", ",", "ctx", ")", ...
Loads from the cache loader the entry for the given key. A found value is loaded into the current context. The method returns whether the value was found or not, or even if the cache loader was checked. @param ctx The current invocation's context @param key The key for the entry to look up @param cmd The command that was called that now wants to query the cache loader @return null or a CompletionStage that when complete all listeners will be notified @throws Throwable
[ "Loads", "from", "the", "cache", "loader", "the", "entry", "for", "the", "given", "key", ".", "A", "found", "value", "is", "loaded", "into", "the", "current", "context", ".", "The", "method", "returns", "whether", "the", "value", "was", "found", "or", "n...
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/impl/CacheLoaderInterceptor.java#L342-L348
29,581
infinispan/infinispan
core/src/main/java/org/infinispan/util/Casting.java
Casting.toSerialSupplierCollect
@SuppressWarnings("unchecked") public static <T, R> SerializableSupplier<Collector<T, ?, R>> toSerialSupplierCollect( SerializableSupplier supplier) { return supplier; }
java
@SuppressWarnings("unchecked") public static <T, R> SerializableSupplier<Collector<T, ?, R>> toSerialSupplierCollect( SerializableSupplier supplier) { return supplier; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ",", "R", ">", "SerializableSupplier", "<", "Collector", "<", "T", ",", "?", ",", "R", ">", ">", "toSerialSupplierCollect", "(", "SerializableSupplier", "supplier", ")", "{", "...
since Java doesn't work as well with nested generics
[ "since", "Java", "doesn", "t", "work", "as", "well", "with", "nested", "generics" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/Casting.java#L13-L17
29,582
infinispan/infinispan
core/src/main/java/org/infinispan/util/Casting.java
Casting.toSupplierCollect
@SuppressWarnings("unchecked") public static <T, R> Supplier<Collector<T, ?, R>> toSupplierCollect(Supplier supplier) { return supplier; }
java
@SuppressWarnings("unchecked") public static <T, R> Supplier<Collector<T, ?, R>> toSupplierCollect(Supplier supplier) { return supplier; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ",", "R", ">", "Supplier", "<", "Collector", "<", "T", ",", "?", ",", "R", ">", ">", "toSupplierCollect", "(", "Supplier", "supplier", ")", "{", "return", "supplier", ";", ...
This is a hack to allow for cast to work properly, since Java doesn't work as well with nested generics
[ "This", "is", "a", "hack", "to", "allow", "for", "cast", "to", "work", "properly", "since", "Java", "doesn", "t", "work", "as", "well", "with", "nested", "generics" ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/Casting.java#L20-L23
29,583
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/RemoveAliasCommand.java
RemoveAliasCommand.removeAliasFromList
private ModelNode removeAliasFromList(ModelNode list, String alias) throws OperationFailedException { // check for empty string if (alias == null || alias.equals("")) return list ; // check for undefined list (AS7-3476) if (!list.isDefined()) { throw InfinispanMessages.MESSAGES.cannotRemoveAliasFromEmptyList(alias); } ModelNode newList = new ModelNode() ; List<ModelNode> listElements = list.asList(); for (ModelNode listElement : listElements) { if (!listElement.asString().equals(alias)) { newList.add().set(listElement); } } return newList ; }
java
private ModelNode removeAliasFromList(ModelNode list, String alias) throws OperationFailedException { // check for empty string if (alias == null || alias.equals("")) return list ; // check for undefined list (AS7-3476) if (!list.isDefined()) { throw InfinispanMessages.MESSAGES.cannotRemoveAliasFromEmptyList(alias); } ModelNode newList = new ModelNode() ; List<ModelNode> listElements = list.asList(); for (ModelNode listElement : listElements) { if (!listElement.asString().equals(alias)) { newList.add().set(listElement); } } return newList ; }
[ "private", "ModelNode", "removeAliasFromList", "(", "ModelNode", "list", ",", "String", "alias", ")", "throws", "OperationFailedException", "{", "// check for empty string", "if", "(", "alias", "==", "null", "||", "alias", ".", "equals", "(", "\"\"", ")", ")", "...
Remove an alias from a LIST ModelNode of existing aliases. @param list LIST ModelNode of aliases @param alias @return LIST ModelNode with the alias removed
[ "Remove", "an", "alias", "from", "a", "LIST", "ModelNode", "of", "existing", "aliases", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/RemoveAliasCommand.java#L98-L118
29,584
infinispan/infinispan
core/src/main/java/org/infinispan/configuration/cache/IndexingConfiguration.java
IndexingConfiguration.indexShareable
public boolean indexShareable() { TypedProperties properties = properties(); boolean hasRamDirectoryProvider = false; for (Object objKey : properties.keySet()) { String key = (String) objKey; if (key.endsWith(DIRECTORY_PROVIDER_KEY)) { String directoryImplementationName = String.valueOf(properties.get(key)).trim(); if (LOCAL_HEAP_DIRECTORY_PROVIDER.equalsIgnoreCase(directoryImplementationName) || RAM_DIRECTORY_PROVIDER.equalsIgnoreCase(directoryImplementationName) || LOCAL_HEAP_DIRECTORY_PROVIDER_FQN.equals(directoryImplementationName)) { hasRamDirectoryProvider = true; } else { return true; } } } return !hasRamDirectoryProvider; }
java
public boolean indexShareable() { TypedProperties properties = properties(); boolean hasRamDirectoryProvider = false; for (Object objKey : properties.keySet()) { String key = (String) objKey; if (key.endsWith(DIRECTORY_PROVIDER_KEY)) { String directoryImplementationName = String.valueOf(properties.get(key)).trim(); if (LOCAL_HEAP_DIRECTORY_PROVIDER.equalsIgnoreCase(directoryImplementationName) || RAM_DIRECTORY_PROVIDER.equalsIgnoreCase(directoryImplementationName) || LOCAL_HEAP_DIRECTORY_PROVIDER_FQN.equals(directoryImplementationName)) { hasRamDirectoryProvider = true; } else { return true; } } } return !hasRamDirectoryProvider; }
[ "public", "boolean", "indexShareable", "(", ")", "{", "TypedProperties", "properties", "=", "properties", "(", ")", ";", "boolean", "hasRamDirectoryProvider", "=", "false", ";", "for", "(", "Object", "objKey", ":", "properties", ".", "keySet", "(", ")", ")", ...
Check if the indexes can be shared. Currently only "ram" based indexes don't allow any sort of sharing. @return false if the index is ram only and thus not shared
[ "Check", "if", "the", "indexes", "can", "be", "shared", ".", "Currently", "only", "ram", "based", "indexes", "don", "t", "allow", "any", "sort", "of", "sharing", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/configuration/cache/IndexingConfiguration.java#L143-L160
29,585
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java
Caches.withinTx
public static <T> T withinTx( AdvancedCache cache, Callable<T> c) throws Exception { // Retrieve transaction manager return withinTx( cache.getTransactionManager(), c ); }
java
public static <T> T withinTx( AdvancedCache cache, Callable<T> c) throws Exception { // Retrieve transaction manager return withinTx( cache.getTransactionManager(), c ); }
[ "public", "static", "<", "T", ">", "T", "withinTx", "(", "AdvancedCache", "cache", ",", "Callable", "<", "T", ">", "c", ")", "throws", "Exception", "{", "// Retrieve transaction manager", "return", "withinTx", "(", "cache", ".", "getTransactionManager", "(", "...
Call an operation within a transaction. This method guarantees that the right pattern is used to make sure that the transaction is always either committed or rollback. @param cache instance whose transaction manager to use @param c callable instance to run within a transaction @param <T> type of callable return @return returns whatever the callable returns @throws Exception if any operation within the transaction fails
[ "Call", "an", "operation", "within", "a", "transaction", ".", "This", "method", "guarantees", "that", "the", "right", "pattern", "is", "used", "to", "make", "sure", "that", "the", "transaction", "is", "always", "either", "committed", "or", "rollback", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java#L54-L59
29,586
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java
Caches.withinTx
public static <T> T withinTx( TransactionManager tm, Callable<T> c) throws Exception { if ( tm == null ) { try { return c.call(); } catch (Exception e) { throw e; } } else { tm.begin(); try { return c.call(); } catch (Exception e) { tm.setRollbackOnly(); throw e; } finally { if ( tm.getStatus() == Status.STATUS_ACTIVE ) { tm.commit(); } else { tm.rollback(); } } } }
java
public static <T> T withinTx( TransactionManager tm, Callable<T> c) throws Exception { if ( tm == null ) { try { return c.call(); } catch (Exception e) { throw e; } } else { tm.begin(); try { return c.call(); } catch (Exception e) { tm.setRollbackOnly(); throw e; } finally { if ( tm.getStatus() == Status.STATUS_ACTIVE ) { tm.commit(); } else { tm.rollback(); } } } }
[ "public", "static", "<", "T", ">", "T", "withinTx", "(", "TransactionManager", "tm", ",", "Callable", "<", "T", ">", "c", ")", "throws", "Exception", "{", "if", "(", "tm", "==", "null", ")", "{", "try", "{", "return", "c", ".", "call", "(", ")", ...
Call an operation within a transaction. This method guarantees that the right pattern is used to make sure that the transaction is always either committed or rollbacked. @param tm transaction manager @param c callable instance to run within a transaction @param <T> type of callable return @return returns whatever the callable returns @throws Exception if any operation within the transaction fails
[ "Call", "an", "operation", "within", "a", "transaction", ".", "This", "method", "guarantees", "that", "the", "right", "pattern", "is", "used", "to", "make", "sure", "that", "the", "transaction", "is", "always", "either", "committed", "or", "rollbacked", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java#L72-L101
29,587
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java
Caches.asyncWriteCache
public static AdvancedCache asyncWriteCache( AdvancedCache cache, Flag extraFlag) { return cache.withFlags( Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP, Flag.FORCE_ASYNCHRONOUS, extraFlag ); }
java
public static AdvancedCache asyncWriteCache( AdvancedCache cache, Flag extraFlag) { return cache.withFlags( Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP, Flag.FORCE_ASYNCHRONOUS, extraFlag ); }
[ "public", "static", "AdvancedCache", "asyncWriteCache", "(", "AdvancedCache", "cache", ",", "Flag", "extraFlag", ")", "{", "return", "cache", ".", "withFlags", "(", "Flag", ".", "SKIP_CACHE_LOAD", ",", "Flag", ".", "SKIP_REMOTE_LOOKUP", ",", "Flag", ".", "FORCE_...
Transform a given cache into a cache that writes cache entries without waiting for them to complete, adding an extra flag. @param cache to be transformed @param extraFlag to add to the returned cache @return a cache that writes asynchronously
[ "Transform", "a", "given", "cache", "into", "a", "cache", "that", "writes", "cache", "entries", "without", "waiting", "for", "them", "to", "complete", "adding", "an", "extra", "flag", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java#L158-L167
29,588
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java
Caches.failSilentWriteCache
public static AdvancedCache failSilentWriteCache(AdvancedCache cache) { return cache.withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP ); }
java
public static AdvancedCache failSilentWriteCache(AdvancedCache cache) { return cache.withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP ); }
[ "public", "static", "AdvancedCache", "failSilentWriteCache", "(", "AdvancedCache", "cache", ")", "{", "return", "cache", ".", "withFlags", "(", "Flag", ".", "FAIL_SILENTLY", ",", "Flag", ".", "ZERO_LOCK_ACQUISITION_TIMEOUT", ",", "Flag", ".", "SKIP_CACHE_LOAD", ",",...
Transform a given cache into a cache that fails silently if cache writes fail. @param cache to be transformed @return a cache that fails silently if cache writes fail
[ "Transform", "a", "given", "cache", "into", "a", "cache", "that", "fails", "silently", "if", "cache", "writes", "fail", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java#L175-L182
29,589
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java
Caches.failSilentReadCache
public static AdvancedCache failSilentReadCache(AdvancedCache cache) { return cache.withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT ); }
java
public static AdvancedCache failSilentReadCache(AdvancedCache cache) { return cache.withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT ); }
[ "public", "static", "AdvancedCache", "failSilentReadCache", "(", "AdvancedCache", "cache", ")", "{", "return", "cache", ".", "withFlags", "(", "Flag", ".", "FAIL_SILENTLY", ",", "Flag", ".", "ZERO_LOCK_ACQUISITION_TIMEOUT", ")", ";", "}" ]
Transform a given cache into a cache that fails silently if cache reads fail. @param cache to be transformed @return a cache that fails silently if cache reads fail
[ "Transform", "a", "given", "cache", "into", "a", "cache", "that", "fails", "silently", "if", "cache", "reads", "fail", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/util/Caches.java#L211-L216
29,590
infinispan/infinispan
extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java
CacheStatisticManager.setTransactionOutcome
public final void setTransactionOutcome(boolean commit, GlobalTransaction globalTransaction, boolean local) { TransactionStatistics txs = getTransactionStatistic(globalTransaction, local); if (txs == null) { log.outcomeOnUnexistingTransaction(globalTransaction == null ? "null" : globalTransaction.globalId(), commit ? "COMMIT" : "ROLLBACK"); return; } txs.setOutcome(commit); }
java
public final void setTransactionOutcome(boolean commit, GlobalTransaction globalTransaction, boolean local) { TransactionStatistics txs = getTransactionStatistic(globalTransaction, local); if (txs == null) { log.outcomeOnUnexistingTransaction(globalTransaction == null ? "null" : globalTransaction.globalId(), commit ? "COMMIT" : "ROLLBACK"); return; } txs.setOutcome(commit); }
[ "public", "final", "void", "setTransactionOutcome", "(", "boolean", "commit", ",", "GlobalTransaction", "globalTransaction", ",", "boolean", "local", ")", "{", "TransactionStatistics", "txs", "=", "getTransactionStatistic", "(", "globalTransaction", ",", "local", ")", ...
Sets the transaction outcome to commit or rollback, depending if the transaction has commit successfully or not respectively. @param commit {@code true} if the transaction has committed successfully. @param globalTransaction the terminated global transaction. @param local {@code true} if measurement occurred in a local context.
[ "Sets", "the", "transaction", "outcome", "to", "commit", "or", "rollback", "depending", "if", "the", "transaction", "has", "commit", "successfully", "or", "not", "respectively", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java#L123-L131
29,591
infinispan/infinispan
extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java
CacheStatisticManager.beginTransaction
public final void beginTransaction(GlobalTransaction globalTransaction, boolean local) { if (local) { //Not overriding the InitialValue method leads me to have "null" at the first invocation of get() TransactionStatistics lts = createTransactionStatisticIfAbsent(globalTransaction, true); if (trace) { log.tracef("Local transaction statistic is already initialized: %s", lts); } } else { TransactionStatistics rts = createTransactionStatisticIfAbsent(globalTransaction, false); if (trace) { log.tracef("Using the remote transaction statistic %s for transaction %s", rts, globalTransaction); } } }
java
public final void beginTransaction(GlobalTransaction globalTransaction, boolean local) { if (local) { //Not overriding the InitialValue method leads me to have "null" at the first invocation of get() TransactionStatistics lts = createTransactionStatisticIfAbsent(globalTransaction, true); if (trace) { log.tracef("Local transaction statistic is already initialized: %s", lts); } } else { TransactionStatistics rts = createTransactionStatisticIfAbsent(globalTransaction, false); if (trace) { log.tracef("Using the remote transaction statistic %s for transaction %s", rts, globalTransaction); } } }
[ "public", "final", "void", "beginTransaction", "(", "GlobalTransaction", "globalTransaction", ",", "boolean", "local", ")", "{", "if", "(", "local", ")", "{", "//Not overriding the InitialValue method leads me to have \"null\" at the first invocation of get()", "TransactionStatis...
Signals the start of a transaction. @param local {@code true} if the transaction is local.
[ "Signals", "the", "start", "of", "a", "transaction", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java#L170-L183
29,592
infinispan/infinispan
extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java
CacheStatisticManager.terminateTransaction
public final void terminateTransaction(GlobalTransaction globalTransaction, boolean local, boolean remote) { TransactionStatistics txs = null; if (local) { txs = removeTransactionStatistic(globalTransaction, true); } if (txs != null) { txs.terminateTransaction(); cacheStatisticCollector.merge(txs); txs = null; } if (remote) { txs = removeTransactionStatistic(globalTransaction, false); } if (txs != null) { txs.terminateTransaction(); cacheStatisticCollector.merge(txs); } }
java
public final void terminateTransaction(GlobalTransaction globalTransaction, boolean local, boolean remote) { TransactionStatistics txs = null; if (local) { txs = removeTransactionStatistic(globalTransaction, true); } if (txs != null) { txs.terminateTransaction(); cacheStatisticCollector.merge(txs); txs = null; } if (remote) { txs = removeTransactionStatistic(globalTransaction, false); } if (txs != null) { txs.terminateTransaction(); cacheStatisticCollector.merge(txs); } }
[ "public", "final", "void", "terminateTransaction", "(", "GlobalTransaction", "globalTransaction", ",", "boolean", "local", ",", "boolean", "remote", ")", "{", "TransactionStatistics", "txs", "=", "null", ";", "if", "(", "local", ")", "{", "txs", "=", "removeTran...
Signals the ending of a transaction. After this, no more statistics are updated for this transaction and the values measured are merged with the cache statistics. @param local {@code true} if the transaction is local. @param remote {@code true} if the transaction is remote.
[ "Signals", "the", "ending", "of", "a", "transaction", ".", "After", "this", "no", "more", "statistics", "are", "updated", "for", "this", "transaction", "and", "the", "values", "measured", "are", "merged", "with", "the", "cache", "statistics", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java#L192-L210
29,593
infinispan/infinispan
query/src/main/java/org/infinispan/query/affinity/FixedShardsDistribution.java
FixedShardsDistribution.populateSegments
private void populateSegments(int[] shardsNumPerServer, List<Set<Integer>> segmentsPerServer, List<Address> nodes) { int shardId = 0; int n = 0; Set<Integer> remainingSegments = new HashSet<>(); for (Address node : nodes) { Collection<Integer> primarySegments = segmentsPerServer.get(n); int shardQuantity = shardsNumPerServer[n]; if (shardQuantity == 0) { remainingSegments.addAll(segmentsPerServer.get(n++)); continue; } shardsPerAddressMap.computeIfAbsent(node, a -> new HashSet<>(shardQuantity)); List<Set<Integer>> segments = this.split(primarySegments, shardsNumPerServer[n++]); for (Collection<Integer> shardSegments : segments) { String id = String.valueOf(shardId++); shardSegments.forEach(seg -> shardPerSegmentMap.put(seg, id)); shardsPerAddressMap.get(node).add(id); addressPerShardMap.put(id, node); } } if (!remainingSegments.isEmpty()) { Iterator<String> shardIterator = Stream.iterate(0, i -> (i + 1) % numShards).map(String::valueOf).iterator(); for (Integer segment : remainingSegments) { shardPerSegmentMap.put(segment, shardIterator.next()); } } }
java
private void populateSegments(int[] shardsNumPerServer, List<Set<Integer>> segmentsPerServer, List<Address> nodes) { int shardId = 0; int n = 0; Set<Integer> remainingSegments = new HashSet<>(); for (Address node : nodes) { Collection<Integer> primarySegments = segmentsPerServer.get(n); int shardQuantity = shardsNumPerServer[n]; if (shardQuantity == 0) { remainingSegments.addAll(segmentsPerServer.get(n++)); continue; } shardsPerAddressMap.computeIfAbsent(node, a -> new HashSet<>(shardQuantity)); List<Set<Integer>> segments = this.split(primarySegments, shardsNumPerServer[n++]); for (Collection<Integer> shardSegments : segments) { String id = String.valueOf(shardId++); shardSegments.forEach(seg -> shardPerSegmentMap.put(seg, id)); shardsPerAddressMap.get(node).add(id); addressPerShardMap.put(id, node); } } if (!remainingSegments.isEmpty()) { Iterator<String> shardIterator = Stream.iterate(0, i -> (i + 1) % numShards).map(String::valueOf).iterator(); for (Integer segment : remainingSegments) { shardPerSegmentMap.put(segment, shardIterator.next()); } } }
[ "private", "void", "populateSegments", "(", "int", "[", "]", "shardsNumPerServer", ",", "List", "<", "Set", "<", "Integer", ">", ">", "segmentsPerServer", ",", "List", "<", "Address", ">", "nodes", ")", "{", "int", "shardId", "=", "0", ";", "int", "n", ...
Associates segments to each shard. @param shardsNumPerServer numbers of shards allocated for each server @param segmentsPerServer the primary owned segments of each server @param nodes the members of the cluster
[ "Associates", "segments", "to", "each", "shard", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/affinity/FixedShardsDistribution.java#L66-L92
29,594
infinispan/infinispan
query/src/main/java/org/infinispan/query/affinity/FixedShardsDistribution.java
FixedShardsDistribution.allocateShardsToNodes
private static int[] allocateShardsToNodes(int numShards, int numNodes, List<Set<Integer>> weightPerServer) { int[] shardsPerServer = new int[numNodes]; Iterator<Integer> cyclicNodeIterator = Stream.iterate(0, i -> (i + 1) % numNodes).iterator(); while (numShards > 0) { int slot = cyclicNodeIterator.next(); if (!weightPerServer.get(slot).isEmpty()) { shardsPerServer[slot]++; numShards--; } } return shardsPerServer; }
java
private static int[] allocateShardsToNodes(int numShards, int numNodes, List<Set<Integer>> weightPerServer) { int[] shardsPerServer = new int[numNodes]; Iterator<Integer> cyclicNodeIterator = Stream.iterate(0, i -> (i + 1) % numNodes).iterator(); while (numShards > 0) { int slot = cyclicNodeIterator.next(); if (!weightPerServer.get(slot).isEmpty()) { shardsPerServer[slot]++; numShards--; } } return shardsPerServer; }
[ "private", "static", "int", "[", "]", "allocateShardsToNodes", "(", "int", "numShards", ",", "int", "numNodes", ",", "List", "<", "Set", "<", "Integer", ">", ">", "weightPerServer", ")", "{", "int", "[", "]", "shardsPerServer", "=", "new", "int", "[", "n...
Allocates shards in a round robin fashion for the servers, ignoring those without segments. @return int[] with the number of shards per server
[ "Allocates", "shards", "in", "a", "round", "robin", "fashion", "for", "the", "servers", "ignoring", "those", "without", "segments", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/query/src/main/java/org/infinispan/query/affinity/FixedShardsDistribution.java#L99-L110
29,595
infinispan/infinispan
core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java
JGroupsTransport.sendCommandToAll
private void sendCommandToAll(ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp) { Message message = new Message(); marshallRequest(message, command, requestId); setMessageFlags(message, deliverOrder, rsvp, true); if (deliverOrder == DeliverOrder.TOTAL) { message.dest(new AnycastAddress()); } send(message); }
java
private void sendCommandToAll(ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp) { Message message = new Message(); marshallRequest(message, command, requestId); setMessageFlags(message, deliverOrder, rsvp, true); if (deliverOrder == DeliverOrder.TOTAL) { message.dest(new AnycastAddress()); } send(message); }
[ "private", "void", "sendCommandToAll", "(", "ReplicableCommand", "command", ",", "long", "requestId", ",", "DeliverOrder", "deliverOrder", ",", "boolean", "rsvp", ")", "{", "Message", "message", "=", "new", "Message", "(", ")", ";", "marshallRequest", "(", "mess...
Send a command to the entire cluster. Doesn't send the command to itself unless {@code deliverOrder == TOTAL}.
[ "Send", "a", "command", "to", "the", "entire", "cluster", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java#L1163-L1173
29,596
infinispan/infinispan
core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java
JGroupsTransport.sendCommand
private void sendCommand(Collection<Address> targets, ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp, boolean checkView) { Objects.requireNonNull(targets); Message message = new Message(); marshallRequest(message, command, requestId); setMessageFlags(message, deliverOrder, rsvp, true); if (deliverOrder == DeliverOrder.TOTAL) { message.dest(new AnycastAddress(toJGroupsAddressList(targets))); send(message); } else { Message copy = message; for (Iterator<Address> it = targets.iterator(); it.hasNext(); ) { Address address = it.next(); if (checkView && !clusterView.contains(address)) continue; if (address.equals(getAddress())) continue; copy.dest(toJGroupsAddress(address)); send(copy); // Send a different Message instance to each target if (it.hasNext()) { copy = copy.copy(true); } } } }
java
private void sendCommand(Collection<Address> targets, ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp, boolean checkView) { Objects.requireNonNull(targets); Message message = new Message(); marshallRequest(message, command, requestId); setMessageFlags(message, deliverOrder, rsvp, true); if (deliverOrder == DeliverOrder.TOTAL) { message.dest(new AnycastAddress(toJGroupsAddressList(targets))); send(message); } else { Message copy = message; for (Iterator<Address> it = targets.iterator(); it.hasNext(); ) { Address address = it.next(); if (checkView && !clusterView.contains(address)) continue; if (address.equals(getAddress())) continue; copy.dest(toJGroupsAddress(address)); send(copy); // Send a different Message instance to each target if (it.hasNext()) { copy = copy.copy(true); } } } }
[ "private", "void", "sendCommand", "(", "Collection", "<", "Address", ">", "targets", ",", "ReplicableCommand", "command", ",", "long", "requestId", ",", "DeliverOrder", "deliverOrder", ",", "boolean", "rsvp", ",", "boolean", "checkView", ")", "{", "Objects", "."...
Send a command to multiple targets. Doesn't send the command to itself unless {@code deliverOrder == TOTAL}.
[ "Send", "a", "command", "to", "multiple", "targets", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java#L1216-L1246
29,597
infinispan/infinispan
server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerConfigurationBuilder.java
CacheContainerConfigurationBuilder.makeGlobalClassLoader
private ClassLoader makeGlobalClassLoader(ModuleLoader moduleLoader, ModuleIdentifier cacheContainerModule, List<ModuleIdentifier> additionalModules) throws ModuleLoadException { Set<ClassLoader> classLoaders = new LinkedHashSet<>(); // use an ordered set to deduplicate possible duplicates! if (cacheContainerModule != null) { classLoaders.add(moduleLoader.loadModule(cacheContainerModule).getClassLoader()); } if (additionalModules != null) { for (ModuleIdentifier additionalModule : additionalModules) { classLoaders.add(moduleLoader.loadModule(additionalModule).getClassLoader()); } } ClassLoader infinispanSubsystemClassloader = CacheContainerConfiguration.class.getClassLoader(); if (classLoaders.isEmpty()) { // use our default CL if nothing was specified by user return infinispanSubsystemClassloader; } if (cacheContainerModule == null) { // do not use the infinispan subsystem classloader if the user specifically requested a different one classLoaders.add(infinispanSubsystemClassloader); } if (classLoaders.size() == 1) { return classLoaders.iterator().next(); } return new AggregatedClassLoader(classLoaders); }
java
private ClassLoader makeGlobalClassLoader(ModuleLoader moduleLoader, ModuleIdentifier cacheContainerModule, List<ModuleIdentifier> additionalModules) throws ModuleLoadException { Set<ClassLoader> classLoaders = new LinkedHashSet<>(); // use an ordered set to deduplicate possible duplicates! if (cacheContainerModule != null) { classLoaders.add(moduleLoader.loadModule(cacheContainerModule).getClassLoader()); } if (additionalModules != null) { for (ModuleIdentifier additionalModule : additionalModules) { classLoaders.add(moduleLoader.loadModule(additionalModule).getClassLoader()); } } ClassLoader infinispanSubsystemClassloader = CacheContainerConfiguration.class.getClassLoader(); if (classLoaders.isEmpty()) { // use our default CL if nothing was specified by user return infinispanSubsystemClassloader; } if (cacheContainerModule == null) { // do not use the infinispan subsystem classloader if the user specifically requested a different one classLoaders.add(infinispanSubsystemClassloader); } if (classLoaders.size() == 1) { return classLoaders.iterator().next(); } return new AggregatedClassLoader(classLoaders); }
[ "private", "ClassLoader", "makeGlobalClassLoader", "(", "ModuleLoader", "moduleLoader", ",", "ModuleIdentifier", "cacheContainerModule", ",", "List", "<", "ModuleIdentifier", ">", "additionalModules", ")", "throws", "ModuleLoadException", "{", "Set", "<", "ClassLoader", "...
Creates an aggregated ClassLoader using the loaders of the cache container module and the optional modules listed under the 'modules' element. @param moduleLoader the ModuleLoader @param cacheContainerModule the (optional) module identifier from the 'module' attribute of the cache-container @param additionalModules the (optional) list of module identifiers from the 'modules' element @return an aggregated ClassLoader if any of the optional 'module' or 'modules' were present, or the ClassLoader of this package otherwise @throws ModuleLoadException if any of the modules failed to load
[ "Creates", "an", "aggregated", "ClassLoader", "using", "the", "loaders", "of", "the", "cache", "container", "module", "and", "the", "optional", "modules", "listed", "under", "the", "modules", "element", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerConfigurationBuilder.java#L291-L314
29,598
infinispan/infinispan
core/src/main/java/org/infinispan/distribution/topologyaware/TopologyInfo.java
TopologyInfo.splitExpectedOwnedSegments
private void splitExpectedOwnedSegments(Collection<? extends Location> locations, float totalOwnedSegments, float totalCapacity) { float remainingCapacity = totalCapacity; float remainingOwned = totalOwnedSegments; // First pass, assign expected owned segments for locations with too little capacity // We know we can do it without a loop because locations are ordered descending by capacity List<Location> remainingLocations = new ArrayList<>(locations); for (ListIterator<Location> it = remainingLocations.listIterator(locations.size()); it.hasPrevious(); ) { Location location = it.previous(); if (remainingOwned < numSegments * remainingLocations.size()) break; // We don't have enough locations, so each location must own at least numSegments segments int minOwned = numSegments; float locationOwned = remainingOwned * location.totalCapacity / remainingCapacity; if (locationOwned > minOwned) break; splitExpectedOwnedSegments2(location.getChildren(), minOwned, location.totalCapacity); remainingCapacity -= location.totalCapacity; remainingOwned -= location.expectedOwnedSegments; it.remove(); } // Second pass, assign expected owned segments for locations with too much capacity // We know we can do it without a loop because locations are ordered descending by capacity for (Iterator<? extends Location> it = remainingLocations.iterator(); it.hasNext(); ) { Location location = it.next(); float maxOwned = computeMaxOwned(remainingOwned, remainingLocations.size()); float locationOwned = remainingOwned * location.totalCapacity / remainingCapacity; if (locationOwned < maxOwned) break; splitExpectedOwnedSegments2(location.getChildren(), maxOwned, location.totalCapacity); remainingCapacity -= location.totalCapacity; remainingOwned -= maxOwned; it.remove(); } // If there were exactly numSegments segments per location, we're finished here if (remainingLocations.isEmpty()) return; // Third pass: If more than numSegments segments per location, split segments between their children // Else spread remaining segments based only on the capacity, rounding down if (remainingLocations.size() * numSegments < remainingOwned) { List<Location> childrenLocations = new ArrayList<>(remainingLocations.size() * 2); for (Location location : remainingLocations) { childrenLocations.addAll(location.getChildren()); } Collections.sort(childrenLocations); splitExpectedOwnedSegments2(childrenLocations, remainingOwned, remainingCapacity); } else { // The allocation algorithm can assign more segments to nodes, so it's ok to miss some segments here float fraction = remainingOwned / remainingCapacity; for (Location location : remainingLocations) { float locationOwned = location.totalCapacity * fraction; splitExpectedOwnedSegments2(location.getChildren(), locationOwned, location.totalCapacity); } } }
java
private void splitExpectedOwnedSegments(Collection<? extends Location> locations, float totalOwnedSegments, float totalCapacity) { float remainingCapacity = totalCapacity; float remainingOwned = totalOwnedSegments; // First pass, assign expected owned segments for locations with too little capacity // We know we can do it without a loop because locations are ordered descending by capacity List<Location> remainingLocations = new ArrayList<>(locations); for (ListIterator<Location> it = remainingLocations.listIterator(locations.size()); it.hasPrevious(); ) { Location location = it.previous(); if (remainingOwned < numSegments * remainingLocations.size()) break; // We don't have enough locations, so each location must own at least numSegments segments int minOwned = numSegments; float locationOwned = remainingOwned * location.totalCapacity / remainingCapacity; if (locationOwned > minOwned) break; splitExpectedOwnedSegments2(location.getChildren(), minOwned, location.totalCapacity); remainingCapacity -= location.totalCapacity; remainingOwned -= location.expectedOwnedSegments; it.remove(); } // Second pass, assign expected owned segments for locations with too much capacity // We know we can do it without a loop because locations are ordered descending by capacity for (Iterator<? extends Location> it = remainingLocations.iterator(); it.hasNext(); ) { Location location = it.next(); float maxOwned = computeMaxOwned(remainingOwned, remainingLocations.size()); float locationOwned = remainingOwned * location.totalCapacity / remainingCapacity; if (locationOwned < maxOwned) break; splitExpectedOwnedSegments2(location.getChildren(), maxOwned, location.totalCapacity); remainingCapacity -= location.totalCapacity; remainingOwned -= maxOwned; it.remove(); } // If there were exactly numSegments segments per location, we're finished here if (remainingLocations.isEmpty()) return; // Third pass: If more than numSegments segments per location, split segments between their children // Else spread remaining segments based only on the capacity, rounding down if (remainingLocations.size() * numSegments < remainingOwned) { List<Location> childrenLocations = new ArrayList<>(remainingLocations.size() * 2); for (Location location : remainingLocations) { childrenLocations.addAll(location.getChildren()); } Collections.sort(childrenLocations); splitExpectedOwnedSegments2(childrenLocations, remainingOwned, remainingCapacity); } else { // The allocation algorithm can assign more segments to nodes, so it's ok to miss some segments here float fraction = remainingOwned / remainingCapacity; for (Location location : remainingLocations) { float locationOwned = location.totalCapacity * fraction; splitExpectedOwnedSegments2(location.getChildren(), locationOwned, location.totalCapacity); } } }
[ "private", "void", "splitExpectedOwnedSegments", "(", "Collection", "<", "?", "extends", "Location", ">", "locations", ",", "float", "totalOwnedSegments", ",", "float", "totalCapacity", ")", "{", "float", "remainingCapacity", "=", "totalCapacity", ";", "float", "rem...
Split totalOwnedSegments segments into the given locations recursively. @param locations List of locations of the same level, sorted descending by capacity factor
[ "Split", "totalOwnedSegments", "segments", "into", "the", "given", "locations", "recursively", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/distribution/topologyaware/TopologyInfo.java#L228-L292
29,599
infinispan/infinispan
counter/src/main/java/org/infinispan/counter/impl/listener/CounterManagerNotificationManager.java
CounterManagerNotificationManager.registerCounter
public void registerCounter(ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener) { if (counters.putIfAbsent(counterName, new Holder(generator, topologyChangeListener)) != null) { throw new IllegalStateException(); } }
java
public void registerCounter(ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener) { if (counters.putIfAbsent(counterName, new Holder(generator, topologyChangeListener)) != null) { throw new IllegalStateException(); } }
[ "public", "void", "registerCounter", "(", "ByteString", "counterName", ",", "CounterEventGenerator", "generator", ",", "TopologyChangeListener", "topologyChangeListener", ")", "{", "if", "(", "counters", ".", "putIfAbsent", "(", "counterName", ",", "new", "Holder", "(...
It registers a new counter created locally. @param counterName The counter's name. @param generator The counter's {@link CounterEvent} generator. @param topologyChangeListener The counter's listener to topology change. It can be {@code null}. @throws IllegalStateException If the counter with that name is already registered.
[ "It", "registers", "a", "new", "counter", "created", "locally", "." ]
7c62b94886c3febb4774ae8376acf2baa0265ab5
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/counter/src/main/java/org/infinispan/counter/impl/listener/CounterManagerNotificationManager.java#L89-L94