idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
22,200 | public boolean replaceInterceptor ( CommandInterceptor replacingInterceptor , Class < ? extends CommandInterceptor > toBeReplacedInterceptorType ) { return asyncInterceptorChain . replaceInterceptor ( replacingInterceptor , toBeReplacedInterceptorType ) ; } | Replaces an existing interceptor of the given type in the interceptor chain with a new interceptor instance passed as parameter . |
22,201 | public Object invoke ( InvocationContext ctx , VisitableCommand command ) { return asyncInterceptorChain . invoke ( ctx , command ) ; } | Walks the command through the interceptor chain . The received ctx is being passed in . |
22,202 | public List < CommandInterceptor > getInterceptorsWhichExtend ( Class < ? extends CommandInterceptor > interceptorClass ) { ArrayList < CommandInterceptor > list = new ArrayList < > ( asyncInterceptorChain . getInterceptors ( ) . size ( ) ) ; asyncInterceptorChain . getInterceptors ( ) . forEach ( ci -> { if ( interceptorClass . isInstance ( ci ) ) { list . add ( ( CommandInterceptor ) ci ) ; } } ) ; return list ; } | Returns all interceptors which extend the given command interceptor . |
22,203 | public List < CommandInterceptor > getInterceptorsWithClass ( Class clazz ) { ArrayList < CommandInterceptor > list = new ArrayList < > ( asyncInterceptorChain . getInterceptors ( ) . size ( ) ) ; asyncInterceptorChain . getInterceptors ( ) . forEach ( ci -> { if ( clazz == ci . getClass ( ) ) { list . add ( ( CommandInterceptor ) ci ) ; } } ) ; return list ; } | Returns all the interceptors that have the fully qualified name of their class equal with the supplied class name . |
22,204 | 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 != null && innerNodes . length != 0 ) { flags |= HAS_NODES ; } else if ( leafNodes != null && leafNodes . length != 0 ) { flags |= HAS_LEAVES ; } buffer . put ( flags ) ; buffer . putShort ( ( short ) keyParts . length ) ; for ( byte [ ] keyPart : keyParts ) { buffer . putShort ( ( short ) keyPart . length ) ; buffer . put ( keyPart ) ; } if ( innerNodes != null ) { for ( InnerNode innerNode : innerNodes ) { buffer . putLong ( innerNode . offset ) ; buffer . putShort ( innerNode . length ) ; } } else { for ( LeafNode leafNode : leafNodes ) { buffer . putInt ( leafNode . file ) ; buffer . putInt ( leafNode . offset ) ; buffer . putShort ( leafNode . numRecords ) ; } } buffer . flip ( ) ; segment . getIndexFile ( ) . write ( buffer , offset ) ; if ( trace ) { log . tracef ( "Persisted %08x (length %d, %d %s) to %d:%d" , System . identityHashCode ( this ) , length ( ) , innerNodes != null ? innerNodes . length : leafNodes . length , innerNodes != null ? "children" : "leaves" , offset , occupiedSpace ) ; } } | called only internally or for root |
22,205 | 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 . ReadOperation . GET_RECORD ) ; } finally { lock . readLock ( ) . unlock ( ) ; } } | Get record or null if expired |
22,206 | 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 ( ) , IndexNode . ReadOperation . GET_POSITION ) ; } finally { lock . readLock ( ) . unlock ( ) ; } } | Get position or null if expired |
22,207 | 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 . ReadOperation . GET_INFO ) ; } finally { lock . readLock ( ) . unlock ( ) ; } } | Get position + numRecords without expiration |
22,208 | public static < MK , K , V > AtomicMap < K , V > getAtomicMap ( Cache < MK , ? > cache , MK key ) { return getAtomicMap ( cache , key , true ) ; } | Retrieves an atomic map from a given cache stored under a given key . If an atomic map did not exist one is created and registered in an atomic fashion . |
22,209 | public static < MK , K , V > FineGrainedAtomicMap < K , V > getFineGrainedAtomicMap ( Cache < MK , ? > cache , MK key ) { return getFineGrainedAtomicMap ( cache , key , true ) ; } | Retrieves a fine grained atomic map from a given cache stored under a given key . If a fine grained atomic map did not exist one is created and registered in an atomic fashion . |
22,210 | 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 ) ; } | Retrieves an atomic map from a given cache stored under a given key for reading only . The atomic map returned will not support updates and if the map did not in fact exist an empty map is returned . |
22,211 | public static < MK > void removeAtomicMap ( Cache < MK , ? > cache , MK key ) { FineGrainedAtomicMapProxyImpl . removeMap ( ( Cache < Object , Object > ) cache , key ) ; } | Removes the atomic map associated with the given key from the underlying cache . |
22,212 | public < T > T invoke ( Object receiver , CreationalContext < T > creationalContext ) { return invoke ( receiver , creationalContext , null ) ; } | Invoke the method causing all parameters to be injected according to the CDI type safe resolution rules . |
22,213 | 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 . ParameterValue value = new ParameterValueRedefiner . ParameterValue ( i , getParameters ( ) . get ( i ) , getBeanManager ( ) ) ; parameterValues . add ( redefinition . redefineParameterValue ( value ) ) ; } else { parameterValues . add ( getBeanManager ( ) . getInjectableReference ( getParameters ( ) . get ( i ) , creationalContext ) ) ; } } @ SuppressWarnings ( "unchecked" ) T result = ( T ) Reflections . invokeMethod ( true , method . getJavaMember ( ) , receiver , parameterValues . toArray ( Reflections . EMPTY_OBJECT_ARRAY ) ) ; return result ; } | Invoke the method calling the parameter redefiner for each parameter allowing the caller to override the default value obtained via the CDI type safe resolver . |
22,214 | 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 . getExpiryHasThrown ( t ) ; return getDefaultDuration ( ) ; } case ACCESS : try { return policy . getExpiryForAccess ( ) ; } catch ( Throwable t ) { log . getExpiryHasThrown ( t ) ; return null ; } case UPDATE : try { return policy . getExpiryForUpdate ( ) ; } catch ( Throwable t ) { log . getExpiryHasThrown ( t ) ; return null ; } default : throw log . unknownExpiryOperation ( op . toString ( ) ) ; } } | Return expiry for a given cache operation . It returns null when the expiry time cannot be determined in which case clients should not update expiry settings for the cached entry . |
22,215 | 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 . singletonList ( localAddress ) ; return newKeyAffinityService ( cache , forAddresses , keyGenerator , ex , keyBufferSize , start ) ; } | Created an service that only generates keys for the local address . |
22,216 | public static Optional < byte [ ] > readOptRangedBytes ( ByteBuf bf ) { int length = SignedNumeric . decode ( readUnsignedInt ( bf ) ) ; return length < 0 ? Optional . empty ( ) : Optional . of ( readRangedBytes ( bf , length ) ) ; } | Reads optional range of bytes . Negative lengths are translated to None 0 length represents empty Array |
22,217 | public static Optional < String > readOptString ( ByteBuf bf ) { Optional < byte [ ] > bytes = readOptRangedBytes ( bf ) ; return bytes . map ( b -> new String ( b , CharsetUtil . UTF_8 ) ) ; } | Reads an optional String . 0 length is an empty string negative length is translated to None . |
22,218 | public static Optional < Byte > readMaybeByte ( ByteBuf bf ) { if ( bf . readableBytes ( ) >= 1 ) { return Optional . of ( bf . readByte ( ) ) ; } else { bf . resetReaderIndex ( ) ; return Optional . empty ( ) ; } } | Reads a byte if possible . If not present the reader index is reset to the last mark . |
22,219 | 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 ( ) ; } } | Reads a variable long if possible . If not present the reader index is reset to the last mark . |
22,220 | 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 ( ) ; } } | Reads a variable size int if possible . If not present the reader index is reset to the last mark . |
22,221 | 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 ( array ) ; return Optional . of ( array ) ; } else { return Optional . of ( Util . EMPTY_BYTE_ARRAY ) ; } } else { bf . resetReaderIndex ( ) ; return Optional . empty ( ) ; } } else return Optional . empty ( ) ; } | Reads a range of bytes if possible . If not present the reader index is reset to the last mark . |
22,222 | 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 ) ; } ) ; } | Reads a string if possible . If not present the reader index is reset to the last mark . |
22,223 | public void deadlockCheck ( DeadlockChecker deadlockChecker ) { if ( deadlockChecker == null ) { return ; } LockPlaceHolder holder = current ; if ( holder != null ) { for ( LockPlaceHolder pending : pendingRequest ) { pending . checkDeadlock ( deadlockChecker , holder . owner ) ; } } } | It forces a deadlock checking . |
22,224 | private void indexMissingFields ( ) { for ( FieldDescriptor fieldDescriptor : messageContext . getMessageDescriptor ( ) . getFields ( ) ) { if ( ! messageContext . isFieldMarked ( fieldDescriptor . getNumber ( ) ) ) { Object defaultValue = fieldDescriptor . getJavaType ( ) == JavaType . MESSAGE || fieldDescriptor . hasDefaultValue ( ) ? fieldDescriptor . getDefaultValue ( ) : null ; IndexingMetadata indexingMetadata = messageContext . getMessageDescriptor ( ) . getProcessedAnnotation ( IndexingMetadata . INDEXED_ANNOTATION ) ; FieldMapping fieldMapping = indexingMetadata != null ? indexingMetadata . getFieldMapping ( fieldDescriptor . getName ( ) ) : null ; if ( indexingMetadata == null && isLegacyIndexingEnabled || fieldMapping != null && fieldMapping . index ( ) ) { addFieldToDocument ( fieldDescriptor , defaultValue , fieldMapping ) ; } } } } | All fields that were not seen until the end of this message are missing and will be indexed with their default value or null if none was declared . The null value is replaced with a special null token placeholder because Lucene cannot index nulls . |
22,225 | public void addRegion ( InfinispanBaseRegion region ) { allRegions . put ( ByteString . fromString ( region . getCache ( ) . getName ( ) ) , region ) ; } | Add region so that commands can be cleared on shutdown . |
22,226 | public void clearRegions ( Collection < ? extends InfinispanBaseRegion > regions ) { regions . forEach ( region -> allRegions . remove ( ByteString . fromString ( region . getCache ( ) . getName ( ) ) ) ) ; } | Clear all regions from this command factory . |
22,227 | 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 ; } | Defines the site names from the list of sites names defined within backups element to which this cache backups its data . |
22,228 | 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 ( "Failure while registering mbeans" , e ) ; } } | Performs the MBean registration . |
22,229 | protected RocksDB openDatabase ( String location , Options options ) throws IOException , RocksDBException { File dir = new File ( location ) ; dir . mkdirs ( ) ; return RocksDB . open ( options , location ) ; } | Creates database if it doesn t exist . |
22,230 | public static String decodeVersionForSerialization ( short version ) { int major = ( version & MAJOR_MASK ) >> MAJOR_SHIFT ; int minor = ( version & MINOR_MASK ) >> MINOR_SHIFT ; return major + "." + minor ; } | Serialization only looks at major and minor not micro or below . |
22,231 | 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 ( ) ; } | Prints full version information to the standard output . |
22,232 | 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 qualifiers ; } | Returns a new set with |
22,233 | 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 injectionPoint = new ImmutableInjectionPoint ( parameter , beanManager , declaringBean , false , false ) ; injectionPoints . add ( injectionPoint ) ; } return injectionPoints ; } | Given a method and the bean on which the method is declared create a collection of injection points representing the parameters of the method . |
22,234 | public boolean containsAll ( Param < ? > ... ps ) { List < Param < ? > > paramsToCheck = Arrays . asList ( ps ) ; List < Param < ? > > paramsCurrent = Arrays . asList ( params ) ; return paramsCurrent . containsAll ( paramsToCheck ) ; } | Checks whether all the parameters passed in are already present in the current parameters . This method can be used to optimise the decision on whether the parameters collection needs updating at all . |
22,235 | 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 ) ; } | Adds all parameters and returns a new parameter collection . |
22,236 | 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 = ( StatisticsMode ) params [ StatisticsMode . ID ] . get ( ) ; ReplicationMode replicationMode = ( ReplicationMode ) params [ ReplicationMode . ID ] . get ( ) ; long flagsBitSet = 0 ; switch ( persistenceMode ) { case SKIP_PERSIST : flagsBitSet |= FlagBitSets . SKIP_CACHE_STORE ; break ; case SKIP_LOAD : flagsBitSet |= FlagBitSets . SKIP_CACHE_LOAD ; break ; case SKIP : flagsBitSet |= FlagBitSets . SKIP_CACHE_LOAD | FlagBitSets . SKIP_CACHE_STORE ; break ; } switch ( lockingMode ) { case SKIP : flagsBitSet |= FlagBitSets . SKIP_LOCKING ; break ; case TRY_LOCK : flagsBitSet |= FlagBitSets . ZERO_LOCK_ACQUISITION_TIMEOUT ; break ; } switch ( executionMode ) { case LOCAL : flagsBitSet |= FlagBitSets . CACHE_MODE_LOCAL ; break ; case LOCAL_SITE : flagsBitSet |= FlagBitSets . SKIP_XSITE_BACKUP ; break ; } if ( statisticsMode == StatisticsMode . SKIP ) { flagsBitSet |= FlagBitSets . SKIP_STATISTICS ; } switch ( replicationMode ) { case SYNC : flagsBitSet |= FlagBitSets . FORCE_SYNCHRONOUS ; break ; case ASYNC : flagsBitSet |= FlagBitSets . FORCE_ASYNCHRONOUS ; break ; } return flagsBitSet ; } | Bridging method between flags and params provided for efficient checks . |
22,237 | 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 already disposed instance" ) ; } this . instance = bean . create ( ctx ) ; return this ; } | Create the instance |
22,238 | 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 disposed instance" ) ; } this . disposed = true ; bean . destroy ( instance , ctx ) ; return this ; } | destroy the bean |
22,239 | 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 ) { try { b . accept ( segments ) ; } catch ( Throwable e2 ) { try { e1 . addSuppressed ( e2 ) ; } catch ( Throwable ignore ) { } } throw e1 ; } b . accept ( segments ) ; } ; } | Given two SegmentCompletionListener return a SegmentCompletionListener that executes both in sequence even if the first throws an exception and if both throw exceptions add any exceptions thrown by the second as suppressed exceptions of the first . |
22,240 | 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 '%s'" , key ) ; } } | Blocks until a lock is acquired . |
22,241 | 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 released for '%s'" , key ) ; } } | Releases a lock the caller may be holding . This method is idempotent . |
22,242 | public int getTotalLockCount ( ) { int count = 0 ; for ( ReentrantReadWriteLock lock : sharedLocks ) { count += lock . getReadLockCount ( ) ; count += lock . isWriteLocked ( ) ? 1 : 0 ; } return count ; } | Returns the total number of locks held by this class . |
22,243 | 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 ( ) ; try { success = toAcquire . tryLock ( timeout , TimeUnit . MILLISECONDS ) ; if ( ! success ) { if ( trace ) log . tracef ( "Could not acquire lock on %s. Exclusive? %b" , toAcquire , exclusive ) ; break ; } } catch ( InterruptedException e ) { if ( trace ) log . trace ( "Caught InterruptedException while trying to acquire global lock" , e ) ; success = false ; Thread . currentThread ( ) . interrupt ( ) ; } finally { if ( ! success ) { for ( int j = 0 ; j < i ; j ++ ) { Lock toRelease = exclusive ? sharedLocks [ j ] . writeLock ( ) : sharedLocks [ j ] . readLock ( ) ; toRelease . unlock ( ) ; } } } } return success ; } | Acquires RL on all locks aggregated by this StripedLock in the given timeout . |
22,244 | public static < T > Set < T > asSet ( T ... array ) { Set < T > result = new HashSet < T > ( ) ; for ( T a : array ) { result . add ( a ) ; } return result ; } | Create a set from an array . If the array contains duplicate objects the last object in the array will be placed in resultant set . |
22,245 | protected CompletionStage < ValidResponse > singleWriteOnRemotePrimary ( Address target , DataWriteCommand command ) { return rpcManager . invokeCommand ( target , command , SingleResponseCollector . validOnly ( ) , rpcManager . getSyncRpcOptions ( ) ) ; } | This method is called by a non - owner sending write request to the primary owner |
22,246 | 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_PLAIN_TYPE , sourceType . toString ( ) ) ; boolean asString = destinationType . hasStringType ( ) ; Charset sourceCharset = sourceType . getCharset ( ) ; Charset destinationCharset = destinationType . getCharset ( ) ; if ( sourceCharset . equals ( destinationCharset ) ) return convertTextClass ( source , destinationType , asString ) ; byte [ ] byteContent = source instanceof byte [ ] ? ( byte [ ] ) source : source . toString ( ) . getBytes ( sourceCharset ) ; return convertTextClass ( convertCharset ( byteContent , sourceCharset , destinationCharset ) , destinationType , asString ) ; } | Convert text content to a different encoding . |
22,247 | 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 . toString ( ) . getBytes ( sourceType . getCharset ( ) ) ; } | Converts text content to binary . |
22,248 | 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 not conforming to application/x-java-object!" ) ; } Object decoded = decodeObjectContent ( source , sourceMediaType ) ; if ( decoded instanceof byte [ ] ) return ( byte [ ] ) decoded ; if ( decoded instanceof String && isJavaString ( sourceMediaType ) ) return ( ( String ) decoded ) . getBytes ( StandardCharsets . UTF_8 ) ; return marshaller . objectToByteBuffer ( source ) ; } | Converts a java object to a sequence of bytes applying standard java serialization . |
22,249 | public final void rollbackRemoteTransaction ( GlobalTransaction gtx ) { RpcManager rpcManager = cache . getRpcManager ( ) ; CommandsFactory factory = cache . getComponentRegistry ( ) . getCommandsFactory ( ) ; try { RollbackCommand rollbackCommand = factory . buildRollbackCommand ( gtx ) ; rollbackCommand . setTopologyId ( rpcManager . getTopologyId ( ) ) ; CompletionStage < Void > cs = rpcManager . invokeCommandOnAll ( rollbackCommand , validOnly ( ) , rpcManager . getSyncRpcOptions ( ) ) ; factory . initializeReplicableCommand ( rollbackCommand , false ) ; rollbackCommand . invokeAsync ( ) . join ( ) ; cs . toCompletableFuture ( ) . join ( ) ; } catch ( Throwable throwable ) { throw Util . rewrapAsCacheException ( throwable ) ; } finally { forgetTransaction ( gtx , rpcManager , factory ) ; } } | Rollbacks a transaction that is remove in all the cluster members . |
22,250 | public boolean startTransaction ( ) { EmbeddedTransaction tx = new EmbeddedTransaction ( EmbeddedTransactionManager . getInstance ( ) ) ; tx . setXid ( xid ) ; LocalTransaction localTransaction = transactionTable . getOrCreateLocalTransaction ( tx , false , this :: newGlobalTransaction ) ; if ( createGlobalState ( localTransaction . getGlobalTransaction ( ) ) != Status . OK ) { transactionTable . removeLocalTransaction ( localTransaction ) ; return false ; } else { this . tx = tx ; this . localTxInvocationContext = new LocalTxInvocationContext ( localTransaction ) ; perCacheTxTable . createLocalTx ( xid , tx ) ; transactionTable . enlistClientTransaction ( tx , localTransaction ) ; return true ; } } | Starts a transaction . |
22,251 | public int rollback ( ) { loggingDecision ( false ) ; try { tx . rollback ( ) ; } catch ( SystemException e ) { } finally { perCacheTxTable . removeLocalTx ( xid ) ; } loggingCompleted ( false ) ; return XAException . XA_RBROLLBACK ; } | Rollbacks the transaction if an exception happens during the transaction execution . |
22,252 | public int prepare ( boolean onePhaseCommit ) { Status status = loggingPreparing ( ) ; if ( status != Status . OK ) { return XAException . XA_RBROLLBACK ; } boolean prepared = tx . runPrepare ( ) ; if ( prepared ) { if ( onePhaseCommit ) { return onePhaseCommitTransaction ( ) ; } else { status = loggingPrepared ( ) ; return status == Status . OK ? XAResource . XA_OK : XAException . XA_RBROLLBACK ; } } else { loggingCompleted ( false ) ; perCacheTxTable . removeLocalTx ( xid ) ; return XAException . XA_RBROLLBACK ; } } | Prepares the transaction . |
22,253 | public < K , V > AdvancedCache < K , V > decorateCache ( AdvancedCache < K , V > cache ) { return cache . transform ( this :: transform ) ; } | Decorates the cache with the transaction created . |
22,254 | public int onePhaseCommitRemoteTransaction ( GlobalTransaction gtx , List < WriteCommand > modifications ) { RpcManager rpcManager = cache . getRpcManager ( ) ; CommandsFactory factory = cache . getComponentRegistry ( ) . getCommandsFactory ( ) ; try { PrepareCommand command = factory . buildPrepareCommand ( gtx , modifications , true ) ; CompletionStage < Void > cs = rpcManager . invokeCommandOnAll ( command , validOnly ( ) , rpcManager . getSyncRpcOptions ( ) ) ; factory . initializeReplicableCommand ( command , false ) ; command . invokeAsync ( ) . join ( ) ; cs . toCompletableFuture ( ) . join ( ) ; forgetTransaction ( gtx , rpcManager , factory ) ; return loggingCompleted ( true ) == Status . OK ? XAResource . XA_OK : XAException . XAER_RMERR ; } catch ( Throwable throwable ) { return XAException . XAER_RMERR ; } } | Commits a remote 1PC transaction that is already in MARK_COMMIT state |
22,255 | private void forgetTransaction ( GlobalTransaction gtx , RpcManager rpcManager , CommandsFactory factory ) { TxCompletionNotificationCommand cmd = factory . buildTxCompletionNotificationCommand ( xid , gtx ) ; rpcManager . sendToAll ( cmd , DeliverOrder . NONE ) ; perCacheTxTable . removeLocalTx ( xid ) ; globalTxTable . remove ( cacheXid ) ; } | Forgets the transaction cluster - wise and from global and local transaction tables . |
22,256 | 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 ; int entryWrappingPosition = 0 ; for ( AsyncInterceptor ci : interceptors ) { if ( ci instanceof EntryWrappingInterceptor ) { entryWrappingPosition = position ; } position ++ ; } boolean transactional = cache . getCacheConfiguration ( ) . transaction ( ) . transactionMode ( ) . isTransactional ( ) ; BasicComponentRegistry componentRegistry = cache . getComponentRegistry ( ) . getComponent ( BasicComponentRegistry . class ) ; if ( transactional ) { TxInvalidationInterceptor txInvalidationInterceptor = new TxInvalidationInterceptor ( ) ; componentRegistry . replaceComponent ( TxInvalidationInterceptor . class . getName ( ) , txInvalidationInterceptor , true ) ; componentRegistry . getComponent ( TxInvalidationInterceptor . class ) . running ( ) ; chain . replaceInterceptor ( txInvalidationInterceptor , InvalidationInterceptor . class ) ; TxPutFromLoadInterceptor txPutFromLoadInterceptor = new TxPutFromLoadInterceptor ( validator , ByteString . fromString ( cache . getName ( ) ) ) ; componentRegistry . replaceComponent ( TxPutFromLoadInterceptor . class . getName ( ) , txPutFromLoadInterceptor , true ) ; componentRegistry . getComponent ( TxPutFromLoadInterceptor . class ) . running ( ) ; chain . addInterceptor ( txPutFromLoadInterceptor , entryWrappingPosition ) ; } else { NonTxPutFromLoadInterceptor nonTxPutFromLoadInterceptor = new NonTxPutFromLoadInterceptor ( validator , ByteString . fromString ( cache . getName ( ) ) ) ; componentRegistry . replaceComponent ( NonTxPutFromLoadInterceptor . class . getName ( ) , nonTxPutFromLoadInterceptor , true ) ; componentRegistry . getComponent ( NonTxPutFromLoadInterceptor . class ) . running ( ) ; chain . addInterceptor ( nonTxPutFromLoadInterceptor , entryWrappingPosition ) ; NonTxInvalidationInterceptor nonTxInvalidationInterceptor = new NonTxInvalidationInterceptor ( ) ; componentRegistry . replaceComponent ( NonTxInvalidationInterceptor . class . getName ( ) , nonTxInvalidationInterceptor , true ) ; componentRegistry . getComponent ( NonTxInvalidationInterceptor . class ) . running ( ) ; chain . replaceInterceptor ( nonTxInvalidationInterceptor , InvalidationInterceptor . class ) ; LockingInterceptor lockingInterceptor = new LockingInterceptor ( ) ; componentRegistry . replaceComponent ( LockingInterceptor . class . getName ( ) , lockingInterceptor , true ) ; componentRegistry . getComponent ( LockingInterceptor . class ) . running ( ) ; chain . replaceInterceptor ( lockingInterceptor , NonTransactionalLockingInterceptor . class ) ; } log . debugf ( "New interceptor chain is: " , cache . getAsyncInterceptorChain ( ) ) ; CacheCommandInitializer cacheCommandInitializer = componentRegistry . getComponent ( CacheCommandInitializer . class ) . running ( ) ; cacheCommandInitializer . addPutFromLoadValidator ( cache . getName ( ) , validator ) ; } | Besides the call from constructor this should be called only from tests when mocking the validator . |
22,257 | public static PutFromLoadValidator removeFromCache ( AdvancedCache cache ) { AsyncInterceptorChain chain = cache . getAsyncInterceptorChain ( ) ; BasicComponentRegistry cr = cache . getComponentRegistry ( ) . getComponent ( BasicComponentRegistry . class ) ; chain . removeInterceptor ( TxPutFromLoadInterceptor . class ) ; chain . removeInterceptor ( NonTxPutFromLoadInterceptor . class ) ; chain . getInterceptors ( ) . stream ( ) . filter ( BaseInvalidationInterceptor . class :: isInstance ) . findFirst ( ) . map ( AsyncInterceptor :: getClass ) . ifPresent ( invalidationClass -> { InvalidationInterceptor invalidationInterceptor = new InvalidationInterceptor ( ) ; cr . replaceComponent ( InvalidationInterceptor . class . getName ( ) , invalidationInterceptor , true ) ; cr . getComponent ( InvalidationInterceptor . class ) . running ( ) ; chain . replaceInterceptor ( invalidationInterceptor , invalidationClass ) ; } ) ; chain . getInterceptors ( ) . stream ( ) . filter ( LockingInterceptor . class :: isInstance ) . findFirst ( ) . map ( AsyncInterceptor :: getClass ) . ifPresent ( invalidationClass -> { NonTransactionalLockingInterceptor lockingInterceptor = new NonTransactionalLockingInterceptor ( ) ; cr . replaceComponent ( NonTransactionalLockingInterceptor . class . getName ( ) , lockingInterceptor , true ) ; cr . getComponent ( NonTransactionalLockingInterceptor . class ) . running ( ) ; chain . replaceInterceptor ( lockingInterceptor , LockingInterceptor . class ) ; } ) ; CacheCommandInitializer cci = cr . getComponent ( CacheCommandInitializer . class ) . running ( ) ; return cci . removePutFromLoadValidator ( cache . getName ( ) ) ; } | This methods should be called only from tests ; it removes existing validator from the cache structures in order to replace it with new one . |
22,258 | 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 ) { log . tracef ( "Finished invalidating region %s, but there are %d ongoing invalidations" , cache . getName ( ) , regionInvalidations ) ; } } } } | Called when the region invalidation is finished . |
22,259 | public HotRodServerConfigurationBuilder proxyHost ( String proxyHost ) { attributes . attribute ( PROXY_HOST ) . set ( proxyHost ) ; return this ; } | Sets the external address of this node i . e . the address which clients will connect to |
22,260 | 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 = startMultiTypeContext ( false , userContext , eventType , instance ) ; if ( ctx != null ) { ctx . process ( ctx . getRootNode ( ) ) ; ctx . notifySubscribers ( ) ; } } finally { read . unlock ( ) ; } } | Executes the registered filters and notifies each one of them whether it was satisfied or not by the given instance . |
22,261 | 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 instanceof Class < ? > ) { return resolveType ( ( ( Class < ? > ) beanType ) . getGenericSuperclass ( ) , beanType2 , type ) ; } } if ( type instanceof TypeVariable < ? > ) { if ( beanType instanceof ParameterizedType ) { return resolveTypeParameter ( ( ParameterizedType ) beanType , beanType2 , ( TypeVariable < ? > ) type ) ; } if ( beanType instanceof Class < ? > ) { return resolveType ( ( ( Class < ? > ) beanType ) . getGenericSuperclass ( ) , beanType2 , type ) ; } } return type ; } | Gets the actual types by resolving TypeParameters . |
22,262 | 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 ; } | Reads a long stored in variable - length format . Reads between one and nine bytes . Smaller values take fewer bytes . Negative numbers are not supported . |
22,263 | 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 ) ; } | Writes a long in a variable - length format . Writes between one and nine bytes . Smaller values take fewer bytes . Negative numbers are not supported . |
22,264 | 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 ; } | Reads an int stored in variable - length format . Reads between one and five bytes . Smaller values take fewer bytes . Negative numbers are not supported . |
22,265 | 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 ; } | Reads an int stored in variable - length format . Reads between one and nine bytes . Smaller values take fewer bytes . Negative numbers are not supported . |
22,266 | 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 ; } | Writes an int in a variable - length format . Writes between one and nine bytes . Smaller values take fewer bytes . Negative numbers are not supported . |
22,267 | public Object createInstance ( StoreConfiguration storeConfiguration ) { for ( CacheStoreFactory factory : factories ) { Object instance = factory . createInstance ( storeConfiguration ) ; if ( instance != null ) { return instance ; } } throw log . unableToInstantiateClass ( storeConfiguration . getClass ( ) ) ; } | Creates new Object based on configuration . |
22,268 | public void addCacheStoreFactory ( CacheStoreFactory cacheStoreFactory ) { if ( cacheStoreFactory == null ) { throw log . unableToAddNullCustomStore ( ) ; } factories . add ( 0 , cacheStoreFactory ) ; } | Adds a new factory for processing . |
22,269 | public final boolean append ( String commandString , int nesting ) { this . nesting += nesting ; buffer . append ( commandString ) ; return this . nesting == 0 ; } | Appends the new command . |
22,270 | @ Stop ( priority = 110 ) public void stop ( ) { if ( trace ) { log . tracef ( "Stopping LocalTopologyManager on %s" , transport . getAddress ( ) ) ; } running = false ; for ( LocalCacheStatus cache : runningCaches . values ( ) ) { cache . getTopologyUpdatesExecutor ( ) . shutdownNow ( ) ; } withinThreadExecutor . shutdown ( ) ; } | Need to stop after ClusterTopologyManagerImpl and before the JGroupsTransport |
22,271 | public ManagerStatusResponse handleStatusRequest ( int viewId ) { try { waitForView ( viewId , getGlobalTimeout ( ) , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return new ManagerStatusResponse ( Collections . emptyMap ( ) , true ) ; } Map < String , CacheStatusResponse > caches = new HashMap < > ( ) ; synchronized ( runningCaches ) { latestStatusResponseViewId = viewId ; for ( Map . Entry < String , LocalCacheStatus > e : runningCaches . entrySet ( ) ) { String cacheName = e . getKey ( ) ; LocalCacheStatus cacheStatus = runningCaches . get ( cacheName ) ; caches . put ( e . getKey ( ) , new CacheStatusResponse ( cacheStatus . getJoinInfo ( ) , cacheStatus . getCurrentTopology ( ) , cacheStatus . getStableTopology ( ) , cacheStatus . getPartitionHandlingManager ( ) . getAvailabilityMode ( ) ) ) ; } } boolean rebalancingEnabled = true ; ReplicableCommand command = new CacheTopologyControlCommand ( null , CacheTopologyControlCommand . Type . POLICY_GET_STATUS , transport . getAddress ( ) , transport . getViewId ( ) ) ; try { gcr . wireDependencies ( command ) ; SuccessfulResponse response = ( SuccessfulResponse ) command . invoke ( ) ; rebalancingEnabled = ( Boolean ) response . getResponseValue ( ) ; } catch ( Throwable t ) { log . warn ( "Failed to obtain the rebalancing status" , t ) ; } log . debugf ( "Sending cluster status response for view %d" , viewId ) ; return new ManagerStatusResponse ( caches , rebalancingEnabled ) ; } | called by the coordinator |
22,272 | private boolean doHandleTopologyUpdate ( String cacheName , CacheTopology cacheTopology , AvailabilityMode availabilityMode , int viewId , Address sender , LocalCacheStatus cacheStatus ) { try { waitForView ( viewId , cacheStatus . getJoinInfo ( ) . getTimeout ( ) , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { return false ; } synchronized ( cacheStatus ) { if ( cacheTopology == null ) { return true ; } registerPersistentUUID ( cacheTopology ) ; CacheTopology existingTopology = cacheStatus . getCurrentTopology ( ) ; if ( existingTopology != null && cacheTopology . getTopologyId ( ) <= existingTopology . getTopologyId ( ) ) { log . debugf ( "Ignoring late consistent hash update for cache %s, current topology is %s: %s" , cacheName , existingTopology . getTopologyId ( ) , cacheTopology ) ; return false ; } if ( ! updateCacheTopology ( cacheName , cacheTopology , viewId , sender , cacheStatus ) ) return false ; CacheTopologyHandler handler = cacheStatus . getHandler ( ) ; resetLocalTopologyBeforeRebalance ( cacheName , cacheTopology , existingTopology , handler ) ; ConsistentHash currentCH = cacheTopology . getCurrentCH ( ) ; ConsistentHash pendingCH = cacheTopology . getPendingCH ( ) ; ConsistentHash unionCH = null ; if ( pendingCH != null ) { ConsistentHashFactory chf = cacheStatus . getJoinInfo ( ) . getConsistentHashFactory ( ) ; switch ( cacheTopology . getPhase ( ) ) { case READ_NEW_WRITE_ALL : unionCH = chf . union ( pendingCH , currentCH ) ; break ; default : unionCH = chf . union ( currentCH , pendingCH ) ; } } CacheTopology unionTopology = new CacheTopology ( cacheTopology . getTopologyId ( ) , cacheTopology . getRebalanceId ( ) , currentCH , pendingCH , unionCH , cacheTopology . getPhase ( ) , cacheTopology . getActualMembers ( ) , persistentUUIDManager . mapAddresses ( cacheTopology . getActualMembers ( ) ) ) ; unionTopology . logRoutingTableInformation ( ) ; boolean updateAvailabilityModeFirst = availabilityMode != AvailabilityMode . AVAILABLE ; if ( updateAvailabilityModeFirst && availabilityMode != null ) { CompletionStages . join ( cacheStatus . getPartitionHandlingManager ( ) . setAvailabilityMode ( availabilityMode ) ) ; } boolean startConflictResolution = cacheTopology . getPhase ( ) == CacheTopology . Phase . CONFLICT_RESOLUTION ; if ( ! startConflictResolution && ( existingTopology == null || existingTopology . getRebalanceId ( ) != cacheTopology . getRebalanceId ( ) ) && unionCH != null ) { log . tracef ( "This topology update has a pending CH, starting the rebalance now" ) ; handler . rebalance ( unionTopology ) ; } else { handler . updateConsistentHash ( unionTopology ) ; } if ( ! updateAvailabilityModeFirst ) { CompletionStages . join ( cacheStatus . getPartitionHandlingManager ( ) . setAvailabilityMode ( availabilityMode ) ) ; } return true ; } } | Update the cache topology in the LocalCacheStatus and pass it to the CacheTopologyHandler . |
22,273 | @ GuardedBy ( "runningCaches" ) private boolean validateCommandViewId ( CacheTopology cacheTopology , int viewId , Address sender , String cacheName ) { if ( ! sender . equals ( transport . getCoordinator ( ) ) ) { log . debugf ( "Ignoring topology %d for cache %s from old coordinator %s" , cacheTopology . getTopologyId ( ) , cacheName , sender ) ; return false ; } if ( viewId < latestStatusResponseViewId ) { log . debugf ( "Ignoring topology %d for cache %s from view %d received after status request from view %d" , cacheTopology . getTopologyId ( ) , cacheName , viewId , latestStatusResponseViewId ) ; return false ; } return true ; } | Synchronization is required to prevent topology updates while preparing the status response . |
22,274 | public AuthenticationConfigurationBuilder saslProperties ( Map < String , String > saslProperties ) { this . attributes . attribute ( SASL_PROPERTIES ) . set ( saslProperties ) ; return this ; } | Sets the SASL properties |
22,275 | public static < T , R > Collector < T , ? , R > serializableCollector ( SerializableSupplier < Collector < T , ? , R > > supplier ) { return new CollectorSupplier < > ( supplier ) ; } | Creates a collector that is serializable and will upon usage create a collector using the serializable supplier provided by the user . |
22,276 | public RouterConfiguration build ( ) { return new RouterConfiguration ( routingBuilder . build ( ) , hotRodRouterBuilder . build ( ) , restRouterBuilder . build ( ) , singlePortRouterBuilder . build ( ) ) ; } | Returns assembled configuration . |
22,277 | void initialize ( ScheduledExecutorService executor , String cacheName , Configuration cfg ) { this . executor = executor ; this . configuration = cfg ; this . cacheName = cacheName ; } | used only for testing |
22,278 | public static int comparePrimaryPredicates ( boolean isFirstNegated , PrimaryPredicateExpr first , boolean isSecondNegated , PrimaryPredicateExpr second ) { if ( first . getClass ( ) == second . getClass ( ) ) { if ( first instanceof ComparisonExpr ) { ComparisonExpr comparison1 = ( ComparisonExpr ) first ; ComparisonExpr comparison2 = ( ComparisonExpr ) second ; assert comparison1 . getLeftChild ( ) instanceof PropertyValueExpr ; assert comparison1 . getRightChild ( ) instanceof ConstantValueExpr ; assert comparison2 . getLeftChild ( ) instanceof PropertyValueExpr ; assert comparison2 . getRightChild ( ) instanceof ConstantValueExpr ; if ( comparison1 . getLeftChild ( ) . equals ( comparison2 . getLeftChild ( ) ) && comparison1 . getRightChild ( ) . equals ( comparison2 . getRightChild ( ) ) ) { ComparisonExpr . Type cmpType1 = comparison1 . getComparisonType ( ) ; if ( isFirstNegated ) { cmpType1 = cmpType1 . negate ( ) ; } ComparisonExpr . Type cmpType2 = comparison2 . getComparisonType ( ) ; if ( isSecondNegated ) { cmpType2 = cmpType2 . negate ( ) ; } return cmpType1 == cmpType2 ? 0 : ( cmpType1 == cmpType2 . negate ( ) ? 1 : - 1 ) ; } } else if ( first . equals ( second ) ) { return isFirstNegated == isSecondNegated ? 0 : 1 ; } } return - 1 ; } | Checks if two predicates are identical or opposite . |
22,279 | public InterceptorConfigurationBuilder interceptorClass ( Class < ? extends AsyncInterceptor > interceptorClass ) { attributes . attribute ( INTERCEPTOR_CLASS ) . set ( interceptorClass ) ; return this ; } | Class of the new custom interceptor to add to the configuration . |
22,280 | public InterceptorConfigurationBuilder withProperties ( Properties properties ) { attributes . attribute ( PROPERTIES ) . set ( TypedProperties . toTypedProperties ( properties ) ) ; return this ; } | Sets interceptor properties |
22,281 | public InterceptorConfigurationBuilder clearProperties ( ) { TypedProperties properties = attributes . attribute ( PROPERTIES ) . get ( ) ; properties . clear ( ) ; attributes . attribute ( PROPERTIES ) . set ( TypedProperties . toTypedProperties ( properties ) ) ; return this ; } | Clears the interceptor properties |
22,282 | private DirectoryLoaderAdaptor getDirectory ( final String indexName ) { DirectoryLoaderAdaptor adapter = openDirectories . get ( indexName ) ; if ( adapter == null ) { synchronized ( openDirectories ) { adapter = openDirectories . get ( indexName ) ; if ( adapter == null ) { final File path = new File ( this . rootDirectory , indexName ) ; final FSDirectory directory = openLuceneDirectory ( path ) ; adapter = new DirectoryLoaderAdaptor ( directory , indexName , autoChunkSize , affinitySegmentId ) ; openDirectories . put ( indexName , adapter ) ; } } } return adapter ; } | Looks up the Directory adapter if it s already known or attempts to initialize indexes . |
22,283 | private FSDirectory openLuceneDirectory ( final File path ) { try { return FSDirectory . open ( path . toPath ( ) ) ; } catch ( IOException e ) { throw log . exceptionInCacheLoader ( e ) ; } } | Attempts to open a Lucene FSDirectory on the specified path |
22,284 | public static long copyb ( InputStream input , OutputStream output ) throws IOException { if ( ! ( input instanceof BufferedInputStream ) ) { input = new BufferedInputStream ( input ) ; } if ( ! ( output instanceof BufferedOutputStream ) ) { output = new BufferedOutputStream ( output ) ; } long bytes = copy ( input , output , DEFAULT_BUFFER_SIZE ) ; output . flush ( ) ; return bytes ; } | Copy all of the bytes from the input stream to the output stream wrapping streams in buffers as needed . |
22,285 | public BeanBuilder < T > addQualifiers ( Annotation ... qualifiers ) { this . qualifiers . addAll ( Arrays2 . asSet ( qualifiers ) ) ; return this ; } | Add to the qualifiers used for bean creation . |
22,286 | public BeanBuilder < T > addTypes ( Type ... types ) { this . types . addAll ( Arrays2 . asSet ( types ) ) ; return this ; } | Add to the type closure used for bean creation . |
22,287 | public List < EventLog > getEvents ( Instant start , int count , Optional < EventLogCategory > category , Optional < EventLogLevel > level ) { return Collections . emptyList ( ) ; } | The basic event logger doesn t collect anything . |
22,288 | public IndexingConfigurationBuilder enable ( ) { Attribute < Index > index = attributes . attribute ( INDEX ) ; if ( index . get ( ) == Index . NONE ) index . set ( Index . ALL ) ; return this ; } | Enable indexing . |
22,289 | public IndexingConfigurationBuilder enabled ( boolean enabled ) { Attribute < Index > index = attributes . attribute ( INDEX ) ; if ( index . get ( ) == Index . NONE & enabled ) index . set ( Index . ALL ) ; else if ( ! enabled ) index . set ( Index . NONE ) ; return this ; } | Enable or disable indexing . |
22,290 | public IndexingConfigurationBuilder indexLocalOnly ( boolean b ) { if ( b ) attributes . attribute ( INDEX ) . set ( Index . LOCAL ) ; return this ; } | If true only index changes made locally ignoring remote changes . This is useful if indexes are shared across a cluster to prevent redundant indexing of updates . |
22,291 | public IndexingConfigurationBuilder addKeyTransformer ( Class < ? > keyClass , Class < ? > keyTransformerClass ) { Map < Class < ? > , Class < ? > > indexedEntities = keyTransformers ( ) ; indexedEntities . put ( keyClass , keyTransformerClass ) ; attributes . attribute ( KEY_TRANSFORMERS ) . set ( indexedEntities ) ; return this ; } | Registers a transformer for a key class . |
22,292 | @ SuppressWarnings ( "rawtypes" ) protected Class < ? > findClass ( String name ) throws ClassNotFoundException { if ( classCache . containsKey ( name ) ) { return classCache . get ( name ) ; } for ( WeakReference < Bundle > ref : bundles ) { final Bundle bundle = ref . get ( ) ; if ( bundle == null ) continue ; if ( bundle . getState ( ) == Bundle . ACTIVE ) { try { final Class clazz = bundle . loadClass ( name ) ; if ( clazz != null ) { classCache . put ( name , clazz ) ; return clazz ; } } catch ( Exception ignore ) { } } } throw new ClassNotFoundException ( "Could not load requested class : " + name ) ; } | Load the class and break on first found match . |
22,293 | protected URL findResource ( String name ) { if ( resourceCache . containsKey ( name ) ) { return resourceCache . get ( name ) ; } for ( WeakReference < Bundle > ref : bundles ) { final Bundle bundle = ref . get ( ) ; if ( bundle != null && bundle . getState ( ) == Bundle . ACTIVE ) { try { final URL resource = bundle . getResource ( name ) ; if ( resource != null ) { resourceCache . put ( name , resource ) ; return resource ; } } catch ( Exception ignore ) { } } } return null ; } | Load the resource and break on first found match . |
22,294 | @ SuppressWarnings ( "unchecked" ) protected Enumeration < URL > findResources ( String name ) { final List < Enumeration < URL > > enumerations = new ArrayList < > ( ) ; for ( WeakReference < Bundle > ref : bundles ) { final Bundle bundle = ref . get ( ) ; if ( bundle != null && bundle . getState ( ) == Bundle . ACTIVE ) { try { final Enumeration < URL > resources = bundle . getResources ( name ) ; if ( resources != null ) { enumerations . add ( resources ) ; } } catch ( Exception ignore ) { } } } return new Enumeration < URL > ( ) { public boolean hasMoreElements ( ) { for ( Enumeration < URL > enumeration : enumerations ) { if ( enumeration != null && enumeration . hasMoreElements ( ) ) { return true ; } } return false ; } public URL nextElement ( ) { for ( Enumeration < URL > enumeration : enumerations ) { if ( enumeration != null && enumeration . hasMoreElements ( ) ) { return enumeration . nextElement ( ) ; } } throw new NoSuchElementException ( ) ; } } ; } | Load the resources and return an Enumeration |
22,295 | public void stopApplyingState ( int topologyId ) { if ( trace ) log . tracef ( "Stop keeping track of changed keys for state transfer in topology %d" , topologyId ) ; commitManager . stopTrack ( PUT_FOR_STATE_TRANSFER ) ; } | Stops applying incoming state . Also stops tracking updated keys . Should be called at the end of state transfer or when a ClearCommand is committed during state transfer . |
22,296 | @ Start ( priority = 20 ) public void start ( ) { cacheName = cache . wired ( ) . getName ( ) ; isInvalidationMode = configuration . clustering ( ) . cacheMode ( ) . isInvalidation ( ) ; isTransactional = configuration . transaction ( ) . transactionMode ( ) . isTransactional ( ) ; isTotalOrder = configuration . transaction ( ) . transactionProtocol ( ) . isTotalOrder ( ) ; timeout = configuration . clustering ( ) . stateTransfer ( ) . timeout ( ) ; CacheMode mode = configuration . clustering ( ) . cacheMode ( ) ; isFetchEnabled = mode . needsStateTransfer ( ) && ( configuration . clustering ( ) . stateTransfer ( ) . fetchInMemoryState ( ) || configuration . persistence ( ) . fetchPersistentState ( ) ) ; rpcOptions = new RpcOptions ( DeliverOrder . NONE , timeout , TimeUnit . MILLISECONDS ) ; stateRequestExecutor = new LimitedExecutor ( "StateRequest-" + cacheName , stateTransferExecutor , 1 ) ; running = true ; } | Must run after the PersistenceManager |
22,297 | protected void cancelTransfers ( IntSet removedSegments ) { synchronized ( transferMapsLock ) { List < Integer > segmentsToCancel = new ArrayList < > ( removedSegments ) ; while ( ! segmentsToCancel . isEmpty ( ) ) { int segmentId = segmentsToCancel . remove ( 0 ) ; List < InboundTransferTask > inboundTransfers = transfersBySegment . get ( segmentId ) ; if ( inboundTransfers != null ) { for ( InboundTransferTask inboundTransfer : inboundTransfers ) { IntSet cancelledSegments = IntSets . mutableCopyFrom ( removedSegments ) ; cancelledSegments . retainAll ( inboundTransfer . getSegments ( ) ) ; segmentsToCancel . removeAll ( cancelledSegments ) ; transfersBySegment . keySet ( ) . removeAll ( cancelledSegments ) ; inboundTransfer . cancelSegments ( cancelledSegments ) ; if ( inboundTransfer . isCancelled ( ) ) { removeTransfer ( inboundTransfer ) ; } } } } } } | Cancel transfers for segments we no longer own . |
22,298 | private void restartBrokenTransfers ( CacheTopology cacheTopology , IntSet addedSegments ) { Set < Address > members = new HashSet < > ( cacheTopology . getReadConsistentHash ( ) . getMembers ( ) ) ; synchronized ( transferMapsLock ) { for ( Iterator < Map . Entry < Address , List < InboundTransferTask > > > it = transfersBySource . entrySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Map . Entry < Address , List < InboundTransferTask > > entry = it . next ( ) ; Address source = entry . getKey ( ) ; if ( ! members . contains ( source ) ) { if ( trace ) { log . tracef ( "Removing inbound transfers from source %s for cache %s" , source , cacheName ) ; } List < InboundTransferTask > inboundTransfers = entry . getValue ( ) ; it . remove ( ) ; for ( InboundTransferTask inboundTransfer : inboundTransfers ) { if ( trace ) { log . tracef ( "Removing inbound transfers from node %s for segments %s" , source , inboundTransfer . getSegments ( ) ) ; } IntSet unfinishedSegments = inboundTransfer . getUnfinishedSegments ( ) ; inboundTransfer . cancel ( ) ; addedSegments . addAll ( unfinishedSegments ) ; transfersBySegment . keySet ( ) . removeAll ( unfinishedSegments ) ; } } } addedSegments . removeAll ( transfersBySegment . keySet ( ) ) ; } } | Check if any of the existing transfers should be restarted from a different source because the initial source is no longer a member . |
22,299 | final Object visitNonTxDataWriteCommand ( InvocationContext ctx , DataWriteCommand command ) { if ( hasSkipLocking ( command ) || ! shouldLockKey ( command ) ) { return invokeNext ( ctx , command ) ; } LockPromise lockPromise = lockAndRecord ( ctx , command . getKey ( ) , getLockTimeoutMillis ( command ) ) ; return nonTxLockAndInvokeNext ( ctx , command , lockPromise , unlockAllReturnHandler ) ; } | We need this method in here because of putForExternalRead |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.