_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q23700
DefaultSegmentedDataContainer.stop
train
@Stop(priority = 9999) public void stop() { for (int i = 0; i < maps.length(); ++i) { stopMap(i, false); } }
java
{ "resource": "" }
q23701
BaseIckleFilterIndexingServiceProvider.getEventTypeFromAnnotation
train
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) retur...
java
{ "resource": "" }
q23702
ModelNodes.asEnum
train
public static <E extends Enum<E>> E asEnum(ModelNode value, Class<E> targetClass) { return asEnum(value, targetClass, null); }
java
{ "resource": "" }
q23703
ModelNodes.asModuleIdentifier
train
public static ModuleIdentifier asModuleIdentifier(ModelNode value, ModuleIdentifier defaultValue) { return value.isDefined() ? ModuleIdentifier.fromString(value.asString()) : defaultValue; }
java
{ "resource": "" }
q23704
ConfigurationBuilder.handleNullMarshaller
train
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...
java
{ "resource": "" }
q23705
TxDistributionInterceptor.handleTxWriteCommand
train
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 o...
java
{ "resource": "" }
q23706
QueryEngine.buildLuceneQuery
train
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...
java
{ "resource": "" }
q23707
QueryEngine.makeTypeQuery
train
protected org.apache.lucene.search.Query makeTypeQuery(org.apache.lucene.search.Query query, String targetEntityName) { return query; }
java
{ "resource": "" }
q23708
CacheLoaderInterceptor.loadIfNeeded
train
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
{ "resource": "" }
q23709
Casting.toSerialSupplierCollect
train
@SuppressWarnings("unchecked") public static <T, R> SerializableSupplier<Collector<T, ?, R>> toSerialSupplierCollect( SerializableSupplier supplier) { return supplier; }
java
{ "resource": "" }
q23710
Casting.toSupplierCollect
train
@SuppressWarnings("unchecked") public static <T, R> Supplier<Collector<T, ?, R>> toSupplierCollect(Supplier supplier) { return supplier; }
java
{ "resource": "" }
q23711
RemoveAliasCommand.removeAliasFromList
train
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 InfinispanM...
java
{ "resource": "" }
q23712
IndexingConfiguration.indexShareable
train
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 =...
java
{ "resource": "" }
q23713
Caches.withinTx
train
public static <T> T withinTx( AdvancedCache cache, Callable<T> c) throws Exception { // Retrieve transaction manager return withinTx( cache.getTransactionManager(), c ); }
java
{ "resource": "" }
q23714
Caches.withinTx
train
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; ...
java
{ "resource": "" }
q23715
Caches.asyncWriteCache
train
public static AdvancedCache asyncWriteCache( AdvancedCache cache, Flag extraFlag) { return cache.withFlags( Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP, Flag.FORCE_ASYNCHRONOUS, extraFlag ); }
java
{ "resource": "" }
q23716
Caches.failSilentWriteCache
train
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
{ "resource": "" }
q23717
Caches.failSilentReadCache
train
public static AdvancedCache failSilentReadCache(AdvancedCache cache) { return cache.withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT ); }
java
{ "resource": "" }
q23718
CacheStatisticManager.setTransactionOutcome
train
public final void setTransactionOutcome(boolean commit, GlobalTransaction globalTransaction, boolean local) { TransactionStatistics txs = getTransactionStatistic(globalTransaction, local); if (txs == null) { log.outcomeOnUnexistingTransaction(globalTransaction == null ? "null" : globalTransaction.g...
java
{ "resource": "" }
q23719
CacheStatisticManager.beginTransaction
train
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); ...
java
{ "resource": "" }
q23720
CacheStatisticManager.terminateTransaction
train
public final void terminateTransaction(GlobalTransaction globalTransaction, boolean local, boolean remote) { TransactionStatistics txs = null; if (local) { txs = removeTransactionStatistic(globalTransaction, true); } if (txs != null) { txs.terminateTransaction(); cach...
java
{ "resource": "" }
q23721
FixedShardsDistribution.populateSegments
train
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);...
java
{ "resource": "" }
q23722
FixedShardsDistribution.allocateShardsToNodes
train
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 = cyclicNodeI...
java
{ "resource": "" }
q23723
JGroupsTransport.sendCommandToAll
train
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) { ...
java
{ "resource": "" }
q23724
JGroupsTransport.sendCommand
train
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); ...
java
{ "resource": "" }
q23725
CacheContainerConfigurationBuilder.makeGlobalClassLoader
train
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 (cacheCo...
java
{ "resource": "" }
q23726
TopologyInfo.splitExpectedOwnedSegments
train
private void splitExpectedOwnedSegments(Collection<? extends Location> locations, float totalOwnedSegments, float totalCapacity) { float remainingCapacity = totalCapacity; float remainingOwned = totalOwnedSegments; // First pass, assign expected owned segmen...
java
{ "resource": "" }
q23727
CounterManagerNotificationManager.registerCounter
train
public void registerCounter(ByteString counterName, CounterEventGenerator generator, TopologyChangeListener topologyChangeListener) { if (counters.putIfAbsent(counterName, new Holder(generator, topologyChangeListener)) != null) { throw new IllegalStateException(); } }
java
{ "resource": "" }
q23728
CounterManagerNotificationManager.listenOn
train
public synchronized void listenOn(Cache<CounterKey, CounterValue> cache) throws InterruptedException { if (!topologyListener.registered) { this.cache = cache; topologyListener.register(cache); } if (!listenersRegistered) { this.cache.addListener(valueListener, CounterKeyFilt...
java
{ "resource": "" }
q23729
DirectoryLoaderAdaptor.loadAllEntries
train
protected <K, V> void loadAllEntries(final Set<MarshallableEntry<K, V>> entriesCollector, final int maxEntries, MarshallableEntryFactory<K,V> entryFactory) { int existingElements = entriesCollector.size(); int toLoadElements = maxEntries - existingElements; if (toLoadElements <= 0) { return; ...
java
{ "resource": "" }
q23730
DirectoryLoaderAdaptor.load
train
protected Object load(final IndexScopedKey key) { try { return key.accept(loadVisitor); } catch (Exception e) { throw log.exceptionInCacheLoader(e); } }
java
{ "resource": "" }
q23731
DirectoryLoaderAdaptor.loadIntern
train
private byte[] loadIntern(final ChunkCacheKey key) throws IOException { final String fileName = key.getFileName(); final long chunkId = key.getChunkId(); //needs to be long to upcast following operations int bufferSize = key.getBufferSize(); final long seekTo = chunkId * bufferSize; final ...
java
{ "resource": "" }
q23732
InterceptorChain.asList
train
public List<CommandInterceptor> asList() { ArrayList<CommandInterceptor> list = new ArrayList<>(asyncInterceptorChain.getInterceptors().size()); asyncInterceptorChain.getInterceptors().forEach(ci -> { if (ci instanceof CommandInterceptor) { list.add((CommandInterceptor) ci);...
java
{ "resource": "" }
q23733
InterceptorChain.replaceInterceptor
train
public boolean replaceInterceptor(CommandInterceptor replacingInterceptor, Class<? extends CommandInterceptor> toBeReplacedInterceptorType) { return asyncInterceptorChain.replaceInterceptor(replacingInterceptor, toBeReplacedInterceptorType); }
java
{ "resource": "" }
q23734
InterceptorChain.invoke
train
public Object invoke(InvocationContext ctx, VisitableCommand command) { return asyncInterceptorChain.invoke(ctx, command); }
java
{ "resource": "" }
q23735
InterceptorChain.getInterceptorsWhichExtend
train
public List<CommandInterceptor> getInterceptorsWhichExtend( Class<? extends CommandInterceptor> interceptorClass) { ArrayList<CommandInterceptor> list = new ArrayList<>(asyncInterceptorChain.getInterceptors().size()); asyncInterceptorChain.getInterceptors().forEach(ci -> { if (...
java
{ "resource": "" }
q23736
InterceptorChain.getInterceptorsWithClass
train
public List<CommandInterceptor> getInterceptorsWithClass(Class clazz) { ArrayList<CommandInterceptor> list = new ArrayList<>(asyncInterceptorChain.getInterceptors().size()); asyncInterceptorChain.getInterceptors().forEach(ci -> { if (clazz == ci.getClass()) { list.add((Comma...
java
{ "resource": "" }
q23737
IndexNode.store
train
void store(Index.IndexSpace indexSpace) throws IOException { this.offset = indexSpace.offset; this.occupiedSpace = indexSpace.length; ByteBuffer buffer = ByteBuffer.allocate(length()); buffer.putShort((short) prefix.length); buffer.put(prefix); byte flags = 0; if (innerNodes !=...
java
{ "resource": "" }
q23738
Index.getRecord
train
public EntryRecord getRecord(Object key, byte[] serializedKey) throws IOException { int segment = (key.hashCode() & Integer.MAX_VALUE) % segments.length; lock.readLock().lock(); try { return IndexNode.applyOnLeaf(segments[segment], serializedKey, segments[segment].rootReadLock(), IndexNode.Re...
java
{ "resource": "" }
q23739
Index.getPosition
train
public EntryPosition getPosition(Object key, byte[] serializedKey) throws IOException { int segment = (key.hashCode() & Integer.MAX_VALUE) % segments.length; lock.readLock().lock(); try { return IndexNode.applyOnLeaf(segments[segment], serializedKey, segments[segment].rootReadLock(), IndexNod...
java
{ "resource": "" }
q23740
Index.getInfo
train
public EntryInfo getInfo(Object key, byte[] serializedKey) throws IOException { int segment = (key.hashCode() & Integer.MAX_VALUE) % segments.length; lock.readLock().lock(); try { return IndexNode.applyOnLeaf(segments[segment], serializedKey, segments[segment].rootReadLock(), IndexNode.ReadOp...
java
{ "resource": "" }
q23741
AtomicMapLookup.getAtomicMap
train
public static <MK, K, V> AtomicMap<K, V> getAtomicMap(Cache<MK, ?> cache, MK key) { return getAtomicMap(cache, key, true); }
java
{ "resource": "" }
q23742
AtomicMapLookup.getFineGrainedAtomicMap
train
public static <MK, K, V> FineGrainedAtomicMap<K, V> getFineGrainedAtomicMap(Cache<MK, ?> cache, MK key) { return getFineGrainedAtomicMap(cache, key, true); }
java
{ "resource": "" }
q23743
AtomicMapLookup.getReadOnlyAtomicMap
train
public static <MK, K, V> Map<K, V> getReadOnlyAtomicMap(Cache<MK, ?> cache, MK key) { AtomicMap<K, V> am = getAtomicMap(cache, key, false); if (am == null) return Collections.emptyMap(); else return immutableMapWrap(am); }
java
{ "resource": "" }
q23744
AtomicMapLookup.removeAtomicMap
train
public static <MK> void removeAtomicMap(Cache<MK, ?> cache, MK key) { // This removes any entry from the cache but includes special handling for fine-grained maps FineGrainedAtomicMapProxyImpl.removeMap((Cache<Object, Object>) cache, key); }
java
{ "resource": "" }
q23745
InjectableMethod.invoke
train
public <T> T invoke(Object receiver, CreationalContext<T> creationalContext) { return invoke(receiver, creationalContext, null); }
java
{ "resource": "" }
q23746
InjectableMethod.invoke
train
public <T> T invoke(Object receiver, CreationalContext<T> creationalContext, ParameterValueRedefiner redefinition) { List<Object> parameterValues = new ArrayList<Object>(); for (int i = 0; i < getParameters().size(); i++) { if (redefinition != null) { ParameterValueRedefiner....
java
{ "resource": "" }
q23747
Expiration.getExpiry
train
public static Duration getExpiry(ExpiryPolicy policy, Operation op) { if (policy == null) { return getDefaultDuration(); } switch (op) { case CREATION: try { return policy.getExpiryForCreation(); } catch (Throwable t) { log.getExp...
java
{ "resource": "" }
q23748
KeyAffinityServiceFactory.newLocalKeyAffinityService
train
public static <K, V> KeyAffinityService<K> newLocalKeyAffinityService(Cache<K, V> cache, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize, boolean start) { Address localAddress = cache.getAdvancedCache().getRpcManager().getTransport().getAddress(); Collection<Address> forAddresses = Collections....
java
{ "resource": "" }
q23749
ExtendedByteBuf.readOptRangedBytes
train
public static Optional<byte[]> readOptRangedBytes(ByteBuf bf) { int length = SignedNumeric.decode(readUnsignedInt(bf)); return length < 0 ? Optional.empty() : Optional.of(readRangedBytes(bf, length)); }
java
{ "resource": "" }
q23750
ExtendedByteBuf.readOptString
train
public static Optional<String> readOptString(ByteBuf bf) { Optional<byte[]> bytes = readOptRangedBytes(bf); return bytes.map(b -> new String(b, CharsetUtil.UTF_8)); }
java
{ "resource": "" }
q23751
ExtendedByteBuf.readMaybeByte
train
public static Optional<Byte> readMaybeByte(ByteBuf bf) { if (bf.readableBytes() >= 1) { return Optional.of(bf.readByte()); } else { bf.resetReaderIndex(); return Optional.empty(); } }
java
{ "resource": "" }
q23752
ExtendedByteBuf.readMaybeVLong
train
public static Optional<Long> readMaybeVLong(ByteBuf bf) { if (bf.readableBytes() >= 1) { byte b = bf.readByte(); return read(bf, b, 7, (long) b & 0x7F, 1); } else { bf.resetReaderIndex(); return Optional.empty(); } }
java
{ "resource": "" }
q23753
ExtendedByteBuf.readMaybeVInt
train
public static Optional<Integer> readMaybeVInt(ByteBuf bf) { if (bf.readableBytes() >= 1) { byte b = bf.readByte(); return read(bf, b, 7, b & 0x7F, 1); } else { bf.resetReaderIndex(); return Optional.empty(); } }
java
{ "resource": "" }
q23754
ExtendedByteBuf.readMaybeRangedBytes
train
public static Optional<byte[]> readMaybeRangedBytes(ByteBuf bf) { Optional<Integer> length = readMaybeVInt(bf); if (length.isPresent()) { int l = length.get(); if (bf.readableBytes() >= l) { if (l > 0) { byte[] array = new byte[l]; bf.readBytes(arr...
java
{ "resource": "" }
q23755
ExtendedByteBuf.readMaybeString
train
public static Optional<String> readMaybeString(ByteBuf bf) { Optional<byte[]> bytes = readMaybeRangedBytes(bf); return bytes.map(b -> { if (b.length == 0) return ""; else return new String(b, CharsetUtil.UTF_8); }); }
java
{ "resource": "" }
q23756
InfinispanLock.deadlockCheck
train
public void deadlockCheck(DeadlockChecker deadlockChecker) { if (deadlockChecker == null) { return; //no-op } LockPlaceHolder holder = current; if (holder != null) { for (LockPlaceHolder pending : pendingRequest) { pending.checkDeadlock(deadlockChecker, holder.owner...
java
{ "resource": "" }
q23757
IndexingTagHandler.indexMissingFields
train
private void indexMissingFields() { for (FieldDescriptor fieldDescriptor : messageContext.getMessageDescriptor().getFields()) { if (!messageContext.isFieldMarked(fieldDescriptor.getNumber())) { Object defaultValue = fieldDescriptor.getJavaType() == JavaType.MESSAGE || fieldD...
java
{ "resource": "" }
q23758
CacheCommandFactory.addRegion
train
public void addRegion(InfinispanBaseRegion region) { allRegions.put(ByteString.fromString(region.getCache().getName()), region); }
java
{ "resource": "" }
q23759
CacheCommandFactory.clearRegions
train
public void clearRegions(Collection<? extends InfinispanBaseRegion> regions) { regions.forEach(region -> allRegions.remove(ByteString.fromString(region.getCache().getName()))); }
java
{ "resource": "" }
q23760
SitesConfigurationBuilder.addInUseBackupSite
train
public SitesConfigurationBuilder addInUseBackupSite(String site) { Set<String> sites = attributes.attribute(IN_USE_BACKUP_SITES).get(); sites.add(site); attributes.attribute(IN_USE_BACKUP_SITES).set(sites); return this; }
java
{ "resource": "" }
q23761
ComponentsJmxRegistration.registerMBeans
train
public void registerMBeans(Collection<ResourceDMBean> resourceDMBeans) throws CacheException { try { for (ResourceDMBean resource : resourceDMBeans) JmxUtil.registerMBean(resource, getObjectName(resource), mBeanServer); } catch (Exception e) { throw new CacheException("Fa...
java
{ "resource": "" }
q23762
RocksDBStore.openDatabase
train
protected RocksDB openDatabase(String location, Options options) throws IOException, RocksDBException { File dir = new File(location); dir.mkdirs(); return RocksDB.open(options, location); }
java
{ "resource": "" }
q23763
Version.decodeVersionForSerialization
train
public static String decodeVersionForSerialization(short version) { int major = (version & MAJOR_MASK) >> MAJOR_SHIFT; int minor = (version & MINOR_MASK) >> MINOR_SHIFT; return major + "." + minor; }
java
{ "resource": "" }
q23764
Version.printFullVersionInformation
train
public static void printFullVersionInformation() { System.out.println(INSTANCE.brandname); System.out.println(); System.out.printf("Version: \t%s%n", INSTANCE.version); System.out.printf("Codename: \t%s%n", INSTANCE.codename); System.out.println(); }
java
{ "resource": "" }
q23765
Beans.buildQualifiers
train
public static Set<Annotation> buildQualifiers(Set<Annotation> annotations) { Set<Annotation> qualifiers = new HashSet<Annotation>(annotations); if (annotations.isEmpty()) { qualifiers.add(DefaultLiteral.INSTANCE); } qualifiers.add(AnyLiteral.INSTANCE); return qualifie...
java
{ "resource": "" }
q23766
Beans.createInjectionPoints
train
public static <X> List<InjectionPoint> createInjectionPoints(AnnotatedMethod<X> method, Bean<?> declaringBean, BeanManager beanManager) { List<InjectionPoint> injectionPoints = new ArrayList<InjectionPoint>(); for (AnnotatedParameter<X> parameter : method.getParameters()) { InjectionPoint in...
java
{ "resource": "" }
q23767
Params.containsAll
train
public boolean containsAll(Param<?>... ps) { List<Param<?>> paramsToCheck = Arrays.asList(ps); List<Param<?>> paramsCurrent = Arrays.asList(params); return paramsCurrent.containsAll(paramsToCheck); }
java
{ "resource": "" }
q23768
Params.addAll
train
public Params addAll(Param<?>... ps) { List<Param<?>> paramsToAdd = Arrays.asList(ps); Param<?>[] paramsAll = Arrays.copyOf(params, params.length); paramsToAdd.forEach(p -> paramsAll[p.id()] = p); return new Params(paramsAll); }
java
{ "resource": "" }
q23769
Params.toFlagsBitSet
train
public long toFlagsBitSet() { PersistenceMode persistenceMode = (PersistenceMode) params[PersistenceMode.ID].get(); LockingMode lockingMode = (LockingMode) params[LockingMode.ID].get(); ExecutionMode executionMode = (ExecutionMode) params[ExecutionMode.ID].get(); StatisticsMode statisticsMode = ...
java
{ "resource": "" }
q23770
ContextualReference.create
train
public ContextualReference<T> create(CreationalContext<T> ctx) { if (this.instance != null) { throw new IllegalStateException("Trying to call create() on already constructed instance"); } if (disposed) { throw new IllegalStateException("Trying to call create() on an alrea...
java
{ "resource": "" }
q23771
ContextualReference.destroy
train
public ContextualReference<T> destroy(CreationalContext<T> ctx) { if (this.instance == null) { throw new IllegalStateException("Trying to call destroy() before create() was called"); } if (disposed) { throw new IllegalStateException("Trying to call destroy() on already di...
java
{ "resource": "" }
q23772
AbstractCacheStream.composeWithExceptions
train
protected static Consumer<Supplier<PrimitiveIterator.OfInt>> composeWithExceptions(Consumer<Supplier<PrimitiveIterator.OfInt>> a, Consumer<Supplier<PrimitiveIterator.OfInt>> b) { return (segments) -> { try { a.accept(segments); } catch (Throwable e1) { t...
java
{ "resource": "" }
q23773
StripedLock.acquireLock
train
public void acquireLock(Object key, boolean exclusive) { ReentrantReadWriteLock lock = getLock(key); if (exclusive) { lock.writeLock().lock(); if (trace) log.tracef("WL acquired for '%s'", key); } else { lock.readLock().lock(); if (trace) log.tracef("RL acquired for...
java
{ "resource": "" }
q23774
StripedLock.releaseLock
train
public void releaseLock(Object key) { ReentrantReadWriteLock lock = getLock(key); if (lock.isWriteLockedByCurrentThread()) { lock.writeLock().unlock(); if (trace) log.tracef("WL released for '%s'", key); } else { lock.readLock().unlock(); if (trace) log.tracef("RL r...
java
{ "resource": "" }
q23775
StripedLock.getTotalLockCount
train
public int getTotalLockCount() { int count = 0; for (ReentrantReadWriteLock lock : sharedLocks) { count += lock.getReadLockCount(); count += lock.isWriteLocked() ? 1 : 0; } return count; }
java
{ "resource": "" }
q23776
StripedLock.acquireGlobalLock
train
public boolean acquireGlobalLock(boolean exclusive, long timeout) { log.tracef("About to acquire global lock. Exclusive? %s", exclusive); boolean success = true; for (int i = 0; i < sharedLocks.length; i++) { Lock toAcquire = exclusive ? sharedLocks[i].writeLock() : sharedLocks[i].readLock();...
java
{ "resource": "" }
q23777
Arrays2.asSet
train
public static <T> Set<T> asSet(T... array) { Set<T> result = new HashSet<T>(); for (T a : array) { result.add(a); } return result; }
java
{ "resource": "" }
q23778
ScatteredDistributionInterceptor.singleWriteOnRemotePrimary
train
protected CompletionStage<ValidResponse> singleWriteOnRemotePrimary(Address target, DataWriteCommand command) { return rpcManager.invokeCommand(target, command, SingleResponseCollector.validOnly(), rpcManager.getSyncRpcOptions()); }
java
{ "resource": "" }
q23779
StandardConversions.convertTextToText
train
public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) { if (source == null) return null; if (sourceType == null) throw new NullPointerException("MediaType cannot be null!"); if (!sourceType.match(MediaType.TEXT_PLAIN)) throw log.invalidMediaType(TEXT_PL...
java
{ "resource": "" }
q23780
StandardConversions.convertTextToOctetStream
train
public static byte[] convertTextToOctetStream(Object source, MediaType sourceType) { if (source == null) return null; if (sourceType == null) { throw new NullPointerException("MediaType cannot be null!"); } if (source instanceof byte[]) return (byte[]) source; return source.toStri...
java
{ "resource": "" }
q23781
StandardConversions.convertJavaToOctetStream
train
public static byte[] convertJavaToOctetStream(Object source, MediaType sourceMediaType, Marshaller marshaller) throws IOException, InterruptedException { if (source == null) return null; if (!sourceMediaType.match(MediaType.APPLICATION_OBJECT)) { throw new EncodingException("destination MediaType n...
java
{ "resource": "" }
q23782
PrepareCoordinator.rollbackRemoteTransaction
train
public final void rollbackRemoteTransaction(GlobalTransaction gtx) { RpcManager rpcManager = cache.getRpcManager(); CommandsFactory factory = cache.getComponentRegistry().getCommandsFactory(); try { RollbackCommand rollbackCommand = factory.buildRollbackCommand(gtx); rollbackCommand....
java
{ "resource": "" }
q23783
PrepareCoordinator.startTransaction
train
public boolean startTransaction() { EmbeddedTransaction tx = new EmbeddedTransaction(EmbeddedTransactionManager.getInstance()); tx.setXid(xid); LocalTransaction localTransaction = transactionTable .getOrCreateLocalTransaction(tx, false, this::newGlobalTransaction); if (createGlobalSt...
java
{ "resource": "" }
q23784
PrepareCoordinator.rollback
train
public int rollback() { //log rolling back loggingDecision(false); //perform rollback try { tx.rollback(); } catch (SystemException e) { //ignore exception (heuristic exceptions) //TODO logging } finally { perCacheTxTable.removeLocalTx(xid); ...
java
{ "resource": "" }
q23785
PrepareCoordinator.prepare
train
public int prepare(boolean onePhaseCommit) { Status status = loggingPreparing(); if (status != Status.OK) { //error, marked_*, no_transaction code (other node changed the state). we simply reply with rollback return XAException.XA_RBROLLBACK; } boolean prepared = tx.runPrepare(...
java
{ "resource": "" }
q23786
PrepareCoordinator.decorateCache
train
public <K, V> AdvancedCache<K, V> decorateCache(AdvancedCache<K, V> cache) { return cache.transform(this::transform); }
java
{ "resource": "" }
q23787
PrepareCoordinator.onePhaseCommitRemoteTransaction
train
public int onePhaseCommitRemoteTransaction(GlobalTransaction gtx, List<WriteCommand> modifications) { RpcManager rpcManager = cache.getRpcManager(); CommandsFactory factory = cache.getComponentRegistry().getCommandsFactory(); try { //only pessimistic tx are committed in 1PC and it doesn't use...
java
{ "resource": "" }
q23788
PrepareCoordinator.forgetTransaction
train
private void forgetTransaction(GlobalTransaction gtx, RpcManager rpcManager, CommandsFactory factory) { TxCompletionNotificationCommand cmd = factory.buildTxCompletionNotificationCommand(xid, gtx); rpcManager.sendToAll(cmd, DeliverOrder.NONE); perCacheTxTable.removeLocalTx(xid); globalTxTable.re...
java
{ "resource": "" }
q23789
PutFromLoadValidator.addToCache
train
public static void addToCache(AdvancedCache cache, PutFromLoadValidator validator) { AsyncInterceptorChain chain = cache.getAsyncInterceptorChain(); List<AsyncInterceptor> interceptors = chain.getInterceptors(); log.debugf("Interceptor chain was: ", interceptors); int position = 0; // add inte...
java
{ "resource": "" }
q23790
PutFromLoadValidator.removeFromCache
train
public static PutFromLoadValidator removeFromCache(AdvancedCache cache) { AsyncInterceptorChain chain = cache.getAsyncInterceptorChain(); BasicComponentRegistry cr = cache.getComponentRegistry().getComponent(BasicComponentRegistry.class); chain.removeInterceptor(TxPutFromLoadInterceptor.class); chain.r...
java
{ "resource": "" }
q23791
PutFromLoadValidator.endInvalidatingRegion
train
public void endInvalidatingRegion() { synchronized (this) { if (--regionInvalidations == 0) { regionInvalidationTimestamp = timeSource.nextTimestamp(); if (trace) { log.tracef("Finished invalidating region %s at %d", cache.getName(), regionInvalidationTimestamp); } } else { if (trace) { ...
java
{ "resource": "" }
q23792
HotRodServerConfigurationBuilder.proxyHost
train
@Override public HotRodServerConfigurationBuilder proxyHost(String proxyHost) { attributes.attribute(PROXY_HOST).set(proxyHost); return this; }
java
{ "resource": "" }
q23793
BaseMatcher.match
train
@Override public void match(Object userContext, Object eventType, Object instance) { if (instance == null) { throw new IllegalArgumentException("instance cannot be null"); } read.lock(); try { MatcherEvalContext<TypeMetadata, AttributeMetadata, AttributeId> ctx = startMulti...
java
{ "resource": "" }
q23794
HierarchyDiscovery.resolveType
train
private Type resolveType(Type beanType, Type beanType2, Type type) { if (type instanceof ParameterizedType) { if (beanType instanceof ParameterizedType) { return resolveParameterizedType((ParameterizedType) beanType, (ParameterizedType) type); } if (beanType i...
java
{ "resource": "" }
q23795
UnsignedNumeric.readUnsignedLong
train
public static long readUnsignedLong(ObjectInput in) throws IOException { byte b = in.readByte(); long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = in.readByte(); i |= (b & 0x7FL) << shift; } return i; }
java
{ "resource": "" }
q23796
UnsignedNumeric.writeUnsignedLong
train
public static void writeUnsignedLong(ObjectOutput out, long i) throws IOException { while ((i & ~0x7F) != 0) { out.writeByte((byte) ((i & 0x7f) | 0x80)); i >>>= 7; } out.writeByte((byte) i); }
java
{ "resource": "" }
q23797
UnsignedNumeric.readUnsignedInt
train
public static int readUnsignedInt(byte[] bytes, int offset) { byte b = bytes[offset++]; int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = bytes[offset++]; i |= (b & 0x7FL) << shift; } return i; }
java
{ "resource": "" }
q23798
UnsignedNumeric.readUnsignedLong
train
public static long readUnsignedLong(byte[] bytes, int offset) { byte b = bytes[offset++]; long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = bytes[offset++]; i |= (b & 0x7FL) << shift; } return i; }
java
{ "resource": "" }
q23799
UnsignedNumeric.writeUnsignedLong
train
public static void writeUnsignedLong(byte[] bytes, int offset, long i) { while ((i & ~0x7F) != 0) { bytes[offset++] = (byte) ((i & 0x7f) | 0x80); i >>>= 7; } bytes[offset] = (byte) i; }
java
{ "resource": "" }