idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,000
void notifyBackupComplete ( ) { int newBackupAcksCompleted = BACKUP_ACKS_RECEIVED . incrementAndGet ( this ) ; Object pendingResponse = this . pendingResponse ; if ( pendingResponse == VOID ) { return ; } int backupAcksExpected = this . backupsAcksExpected ; if ( backupAcksExpected < newBackupAcksCompleted ) { return ;...
this method can be called concurrently
9,001
boolean detectAndHandleTimeout ( long heartbeatTimeoutMillis ) { if ( skipTimeoutDetection ( ) ) { return false ; } HeartbeatTimeout heartbeatTimeout = detectTimeout ( heartbeatTimeoutMillis ) ; if ( heartbeatTimeout == TIMEOUT ) { complete ( HEARTBEAT_TIMEOUT ) ; return true ; } else { return false ; } }
Checks if this Invocation has received a heartbeat in time .
9,002
boolean detectAndHandleBackupTimeout ( long timeoutMillis ) { boolean backupsCompleted = backupsAcksExpected == backupsAcksReceived ; long responseReceivedMillis = pendingResponseReceivedMillis ; long expirationTime = responseReceivedMillis + timeoutMillis ; boolean timeout = expirationTime > 0 && expirationTime < Cloc...
gets called from the monitor - thread
9,003
public Class < ? > handleClassNotFoundException ( String name ) throws ClassNotFoundException { if ( ! enabled ) { throw new ClassNotFoundException ( "User Code Deployment is not enabled. Cannot find class " + name ) ; } return locator . handleClassNotFoundException ( name ) ; }
called by User Code Deployment classloader on this member
9,004
public ScheduledEntry < K , V > get ( K key ) { synchronized ( mutex ) { if ( scheduleType . equals ( ScheduleType . FOR_EACH ) ) { return getByCompositeKey ( key ) ; } Integer second = secondsOfKeys . get ( key ) ; if ( second != null ) { Map < Object , ScheduledEntry < K , V > > entries = scheduledEntries . get ( sec...
in the case of composite keys this method will return only one scheduled entry with no ordering guarantee
9,005
private void scanQuorums ( ) { for ( QuorumImpl quorum : quorums . values ( ) ) { if ( quorum . isHeartbeatAware ( ) ) { this . heartbeatAware = true ; } if ( quorum . isPingAware ( ) ) { this . pingAware = true ; } } }
scan quorums for heartbeat - aware and ping - aware implementations and set corresponding flags
9,006
protected final void initSrcBuffer ( int sizeBytes ) { ChannelOptions config = channel . options ( ) ; src = ( S ) newByteBuffer ( sizeBytes , config . getOption ( DIRECT_BUF ) ) ; }
Initializes the src buffer . Should only be called by InboundHandler implementations that have a ByteBuffer as source .
9,007
public String getQuorumName ( String cacheName ) { CacheConfig cacheConfig = getCacheConfig ( cacheName ) ; if ( cacheConfig == null ) { return null ; } return cacheConfig . getQuorumName ( ) ; }
Gets the name of the quorum associated with specified cache
9,008
AcquireResult acquire ( AcquireInvocationKey key , boolean wait ) { SemaphoreEndpoint endpoint = key . endpoint ( ) ; SessionSemaphoreState state = sessionStates . get ( key . sessionId ( ) ) ; if ( state != null && state . containsInvocation ( endpoint . threadId ( ) , key . invocationUid ( ) ) ) { return new AcquireR...
Assigns permits to the endpoint if sufficient number of permits are available . If there are no sufficient number of permits and the second argument is true a wait key is created and added to the wait queue . Permits are not assigned if the acquire request is a retry of a successful acquire request of a session - aware...
9,009
ReleaseResult change ( SemaphoreEndpoint endpoint , UUID invocationUid , int permits ) { if ( permits == 0 ) { return ReleaseResult . failed ( Collections . < AcquireInvocationKey > emptyList ( ) ) ; } Collection < AcquireInvocationKey > cancelled = cancelWaitKeys ( endpoint , invocationUid ) ; long sessionId = endpoin...
Changes the number of permits by adding the given permit value . Permits are not changed if it is a retry of a previous successful change request of a session - aware proxy . Permits are changed again if it is a retry of a successful change request of a sessionless proxy . If number of permits increase new assignments ...
9,010
protected void onSessionClose ( long sessionId , Map < Long , Object > responses ) { SessionSemaphoreState state = sessionStates . get ( sessionId ) ; if ( state != null ) { if ( state . acquiredPermits > 0 ) { SemaphoreEndpoint endpoint = new SemaphoreEndpoint ( sessionId , 0 ) ; ReleaseResult result = release ( endpo...
Releases permits of the closed session .
9,011
public static long roundCapacity ( long requestedCapacity ) { if ( requestedCapacity > MAX_LONG_CAPACITY ) { throw new IllegalArgumentException ( requestedCapacity + " is greater than max allowed capacity[" + MAX_LONG_CAPACITY + "]." ) ; } return Math . max ( MIN_CAPACITY , QuickMath . nextPowerOfTwo ( requestedCapacit...
Round the capacity to the next allowed value .
9,012
public static int nextCapacity ( int current ) { assert current > 0 && Long . bitCount ( current ) == 1 : "Capacity must be a power of two." ; if ( current < MIN_CAPACITY / 2 ) { current = MIN_CAPACITY / 2 ; } current <<= 1 ; if ( current < 0 ) { throw new RuntimeException ( "Maximum capacity exceeded." ) ; } return cu...
Returns the next possible capacity counting from the current buffers size .
9,013
int getNodeId ( long nanoTime ) { int nodeId = this . nodeId ; if ( nodeId != NODE_ID_OUT_OF_RANGE && nextNodeIdUpdate <= nanoTime ) { int newNodeId = getNodeEngine ( ) . getClusterService ( ) . getMemberListJoinVersion ( ) ; assert newNodeId >= 0 : "newNodeId=" + newNodeId ; newNodeId += nodeIdOffset ; nextNodeIdUpdat...
package - visible for tests
9,014
public static JsonSchemaNode createSchema ( JsonParser parser ) throws IOException { JsonSchemaNode dummy = new JsonSchemaStructNode ( null ) ; JsonSchemaStructNode parent = ( JsonSchemaStructNode ) dummy ; JsonToken currentToken = parser . nextToken ( ) ; int nameLocation = - 1 ; if ( currentToken == null ) { return n...
Creates a description out of a JsonValue . The parser must be pointing to the start of the input .
9,015
private static void checkMapMergePolicyWhenStatisticsAreDisabled ( String mergePolicyClass , List < Class > requiredMergeTypes ) { for ( Class < ? > requiredMergeType : requiredMergeTypes ) { if ( MergingLastStoredTime . class . isAssignableFrom ( requiredMergeType ) || MergingExpirationTime . class . isAssignableFrom ...
Checks if the configured merge policy requires merge types which are just available if map statistics are enabled .
9,016
protected Throwable unwrap ( Throwable throwable ) { if ( throwable instanceof ExecutionException && throwable . getCause ( ) != null ) { return throwable . getCause ( ) ; } return throwable ; }
this method should not be needed ; but there is a difference between client and server how it handles async throwables
9,017
public final boolean complete ( Object value ) { for ( ; ; ) { final Object oldState = state ; if ( isDone ( oldState ) ) { warnIfSuspiciousDoubleCompletion ( oldState , value ) ; return false ; } if ( compareAndSetState ( oldState , value ) ) { onComplete ( ) ; unblockAll ( oldState , defaultExecutor ) ; return true ;...
Can be called multiple times but only the first answer will lead to the future getting triggered . All subsequent complete calls are ignored .
9,018
private void warnIfSuspiciousDoubleCompletion ( Object s0 , Object s1 ) { if ( s0 != s1 && ! ( s0 instanceof CancellationException ) && ! ( s1 instanceof CancellationException ) ) { logger . warning ( String . format ( "Future.complete(Object) on completed future. " + "Request: %s, current value: %s, offered value: %s"...
received a response but before it cleans up itself it receives a HazelcastInstanceNotActiveException
9,019
static < K , V > CacheConfig < K , V > getCacheConfig ( HazelcastClientInstanceImpl client , String cacheName , String simpleCacheName ) { ClientMessage request = CacheGetConfigCodec . encodeRequest ( cacheName , simpleCacheName ) ; try { int partitionId = client . getClientPartitionService ( ) . getPartitionId ( cache...
Gets the cache configuration from the server .
9,020
static < K , V > CacheConfig < K , V > createCacheConfig ( HazelcastClientInstanceImpl client , CacheConfig < K , V > newCacheConfig ) { try { String nameWithPrefix = newCacheConfig . getNameWithPrefix ( ) ; int partitionId = client . getClientPartitionService ( ) . getPartitionId ( nameWithPrefix ) ; Object resolvedCo...
Creates a new cache configuration on Hazelcast members .
9,021
static int validateAndGetArrayQuantifierFromCurrentToken ( String token , String fullPath ) { String quantifier = extractArgumentsFromAttributeName ( token ) ; if ( quantifier == null ) { throw new IllegalArgumentException ( "Malformed quantifier in " + fullPath ) ; } int index = Integer . parseInt ( quantifier ) ; if ...
Extracts and validates the quantifier from the given path token
9,022
static int getPortableArrayCellPosition ( BufferObjectDataInput in , int streamPosition , int cellIndex ) throws IOException { return in . readInt ( streamPosition + cellIndex * Bits . INT_SIZE_IN_BYTES ) ; }
Calculates and reads the position of the Portable object stored in a Portable array under the given index .
9,023
static int getStreamPositionOfTheField ( FieldDefinition fd , BufferObjectDataInput in , int offset ) throws IOException { int pos = in . readInt ( offset + fd . getIndex ( ) * Bits . INT_SIZE_IN_BYTES ) ; short len = in . readShort ( pos ) ; return pos + Bits . SHORT_SIZE_IN_BYTES + len + 1 ; }
Calculates the position of the given field in the portable byte stream
9,024
static int getArrayLengthOfTheField ( FieldDefinition fd , BufferObjectDataInput in , int offset ) throws IOException { int originalPos = in . position ( ) ; try { int pos = getStreamPositionOfTheField ( fd , in , offset ) ; in . position ( pos ) ; return in . readInt ( ) ; } finally { in . position ( originalPos ) ; }...
Reads the length of the given array . It does not validate if the current position is actually an array - has to be taken care of by the caller .
9,025
static void validateFactoryAndClass ( FieldDefinition fd , int factoryId , int classId , String fullPath ) { if ( factoryId != fd . getFactoryId ( ) ) { throw new IllegalArgumentException ( "Invalid factoryId! Expected: " + fd . getFactoryId ( ) + ", Current: " + factoryId + " in path " + fullPath ) ; } if ( classId !=...
Validates if the given factoryId and classId match the ones from the fieldDefinition
9,026
public static List < DiscoveryStrategyConfig > map ( List < AliasedDiscoveryConfig < ? > > aliasedDiscoveryConfigs ) { List < DiscoveryStrategyConfig > result = new ArrayList < DiscoveryStrategyConfig > ( ) ; for ( AliasedDiscoveryConfig config : aliasedDiscoveryConfigs ) { if ( config . isEnabled ( ) ) { result . add ...
Maps aliased discovery strategy configs into discovery strategy configs .
9,027
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public void verify ( ) { int countEnabled = 0 ; if ( getTcpIpConfig ( ) . isEnabled ( ) ) { countEnabled ++ ; } if ( getMulticastConfig ( ) . isEnabled ( ) ) { countEnabled ++ ; } if ( getAwsConfig ( ) . isEnabled ( ) ) { countEnabled ++ ; } if ( getGcpConfig ( ) . is...
Verifies this JoinConfig is valid . At most a single joiner should be active .
9,028
private void verifyDiscoveryProviderConfig ( ) { Collection < DiscoveryStrategyConfig > discoveryStrategyConfigs = discoveryConfig . getDiscoveryStrategyConfigs ( ) ; if ( discoveryStrategyConfigs . size ( ) > 0 ) { if ( getMulticastConfig ( ) . isEnabled ( ) ) { throw new InvalidConfigurationException ( "Multicast and...
Verifies this JoinConfig is valid . When Discovery SPI enabled other discovery methods should be disabled
9,029
protected void removeAllRecordStoresOfAllMaps ( boolean onShutdown , boolean onRecordStoreDestroy ) { for ( PartitionContainer partitionContainer : partitionContainers ) { if ( partitionContainer != null ) { removeRecordStoresFromPartitionMatchingWith ( allRecordStores ( ) , partitionContainer . getPartitionId ( ) , on...
Removes all record stores from all partitions .
9,030
public static void unregisterCacheObject ( String cacheManagerName , String name , boolean stats ) { synchronized ( mBeanServer ) { ObjectName objectName = calculateObjectName ( cacheManagerName , name , stats ) ; Set < ObjectName > registeredObjectNames = mBeanServer . queryNames ( objectName , null ) ; if ( isRegiste...
UnRegisters the mxbean if registered already .
9,031
public MessageFlyweight set ( boolean value ) { buffer . putByte ( index + offset , ( byte ) ( value ? 1 : 0 ) ) ; index += Bits . BYTE_SIZE_IN_BYTES ; return this ; }
region SET Overloads
9,032
public boolean getBoolean ( ) { byte result = buffer . getByte ( index + offset ) ; index += Bits . BYTE_SIZE_IN_BYTES ; return result != 0 ; }
region GET Overloads
9,033
public static long readLongAttribute ( String attributeName , long defaultValue ) { try { String methodName = "get" + attributeName ; OperatingSystemMXBean systemMXBean = OPERATING_SYSTEM_MX_BEAN ; Method method = systemMXBean . getClass ( ) . getMethod ( methodName ) ; method . setAccessible ( true ) ; Object value = ...
Reads a long attribute from OperatingSystemMXBean .
9,034
boolean addCompletedMigration ( MigrationInfo migrationInfo ) { if ( migrationInfo . getStatus ( ) != MigrationStatus . SUCCESS && migrationInfo . getStatus ( ) != MigrationStatus . FAILED ) { throw new IllegalArgumentException ( "Migration doesn't seem completed: " + migrationInfo ) ; } if ( migrationInfo . getInitial...
Adds the migration to the set of completed migrations and increases the completed migration counter . Acquires the partition service lock to update the migrations .
9,035
private void evictCompletedMigrations ( Collection < MigrationInfo > migrations ) { partitionServiceLock . lock ( ) ; try { completedMigrations . removeAll ( migrations ) ; } finally { partitionServiceLock . unlock ( ) ; } }
Evicts completed migrations from the list
9,036
void triggerControlTask ( ) { migrationQueue . clear ( ) ; if ( ! node . getClusterService ( ) . isJoined ( ) ) { logger . fine ( "Node is not joined, will not trigger ControlTask" ) ; return ; } if ( ! node . isMaster ( ) ) { logger . fine ( "Node is not master, will not trigger ControlTask" ) ; return ; } migrationQu...
Clears the migration queue and triggers the control task . Called on the master node .
9,037
void applyMigration ( InternalPartitionImpl partition , MigrationInfo migrationInfo ) { final PartitionReplica [ ] members = Arrays . copyOf ( partition . getReplicas ( ) , InternalPartition . MAX_REPLICA_COUNT ) ; if ( migrationInfo . getSourceCurrentReplicaIndex ( ) > - 1 ) { members [ migrationInfo . getSourceCurren...
Mutates the partition state and applies the migration .
9,038
static Selector newSelector ( ILogger logger ) { checkNotNull ( logger , "logger" ) ; Selector selector ; try { selector = Selector . open ( ) ; } catch ( IOException e ) { throw new HazelcastException ( "Failed to open a Selector" , e ) ; } boolean optimize = Boolean . parseBoolean ( System . getProperty ( "hazelcast....
Creates a new Selector and will optimize it if possible .
9,039
static SelectionKeysSet optimize ( Selector selector , ILogger logger ) { checkNotNull ( selector , "selector" ) ; checkNotNull ( logger , "logger" ) ; try { SelectionKeysSet set = new SelectionKeysSet ( ) ; Class < ? > selectorImplClass = findOptimizableSelectorClass ( selector ) ; if ( selectorImplClass == null ) { r...
Tries to optimize the provided Selector .
9,040
private boolean isTryRecoverSucceeded ( ConcurrentMap < Integer , Long > brokenSequences ) { int numberOfBrokenSequences = brokenSequences . size ( ) ; InvokerWrapper invokerWrapper = context . getInvokerWrapper ( ) ; SubscriberContext subscriberContext = context . getSubscriberContext ( ) ; SubscriberContextSupport su...
This tries to reset cursor position of the accumulator to the supplied sequence if that sequence is still there it will be succeeded otherwise query cache content stays inconsistent .
9,041
@ SuppressWarnings ( "checkstyle:magicnumber" ) private void firstHeartbeat ( long firstHeartbeatEstimateMillis ) { long stdDeviationMillis = firstHeartbeatEstimateMillis / 4 ; heartbeatHistory . add ( firstHeartbeatEstimateMillis - stdDeviationMillis ) ; heartbeatHistory . add ( firstHeartbeatEstimateMillis + stdDevia...
bootstrap with 2 entries with rather high standard deviation
9,042
private double phi ( long timestampMillis ) { long timeDiffMillis ; double meanMillis ; double stdDeviationMillis ; synchronized ( heartbeatHistory ) { long lastTimestampMillis = lastHeartbeatMillis ; if ( lastTimestampMillis == NO_HEARTBEAT_TIMESTAMP ) { return 0.0 ; } timeDiffMillis = timestampMillis - lastTimestampM...
The suspicion level of the accrual failure detector .
9,043
public static List < String > parseDelimitedString ( String value , char delimiter , boolean trim ) { if ( value == null ) { value = "" ; } List < String > list = new ArrayList < String > ( ) ; StringBuilder sb = new StringBuilder ( ) ; int expecting = ( CHAR | DELIMITER | START_QUOTE ) ; for ( int i = 0 ; i < value . ...
Parses delimited string and returns an array containing the tokens . This parser obeys quotes so the delimiter character will be ignored if it is inside of a quote . This method assumes that the quote character is not included in the set of delimiter characters .
9,044
public static void validateResults ( Map < Integer , Object > results ) { for ( Object result : results . values ( ) ) { if ( result != null && result instanceof CacheClearResponse ) { Object response = ( ( CacheClearResponse ) result ) . getResponse ( ) ; if ( response instanceof Throwable ) { ExceptionUtil . sneakyTh...
Cache clear response validator loop on results to validate that no exception exists on the result map . Throws the first exception in the map .
9,045
public static < K , V > void validateNotNull ( K key , V value ) { checkNotNull ( key , NULL_KEY_IS_NOT_ALLOWED ) ; checkNotNull ( value , NULL_VALUE_IS_NOT_ALLOWED ) ; }
Validates that key value pair are both not null .
9,046
public static < K , V > void validateNotNull ( K key , V value1 , V value2 ) { checkNotNull ( key , NULL_KEY_IS_NOT_ALLOWED ) ; checkNotNull ( value1 , NULL_VALUE_IS_NOT_ALLOWED ) ; checkNotNull ( value2 , NULL_VALUE_IS_NOT_ALLOWED ) ; }
Validates that key and multi values are not null .
9,047
public static < K , V > void validateNotNull ( Map < ? extends K , ? extends V > map ) { checkNotNull ( map , "map is null" ) ; boolean containsNullKey = false ; boolean containsNullValue = false ; try { containsNullKey = map . containsKey ( null ) ; } catch ( NullPointerException e ) { ignore ( e ) ; } try { containsN...
This validator ensures that no key or value is null in the provided map .
9,048
public static < K > void validateConfiguredTypes ( CacheConfig cacheConfig , K key ) throws ClassCastException { Class keyType = cacheConfig . getKeyType ( ) ; validateConfiguredKeyType ( keyType , key ) ; }
Validates that the configured key matches the provided key .
9,049
public static < K , V > void validateConfiguredTypes ( CacheConfig cacheConfig , K key , V value ) throws ClassCastException { Class keyType = cacheConfig . getKeyType ( ) ; Class valueType = cacheConfig . getValueType ( ) ; validateConfiguredKeyType ( keyType , key ) ; validateConfiguredValueType ( valueType , value )...
Validates the configured key and value types matches the provided key value types .
9,050
public static < K > void validateConfiguredKeyType ( Class < K > keyType , K key ) throws ClassCastException { if ( Object . class != keyType ) { if ( ! keyType . isAssignableFrom ( key . getClass ( ) ) ) { throw new ClassCastException ( "Key '" + key + "' is not assignable to " + keyType ) ; } } }
Validates the key with key type .
9,051
public static < V > void validateConfiguredValueType ( Class < V > valueType , V value ) throws ClassCastException { if ( Object . class != valueType ) { if ( ! valueType . isAssignableFrom ( value . getClass ( ) ) ) { throw new ClassCastException ( "Value '" + value + "' is not assignable to " + valueType ) ; } } }
Validates the value with value type .
9,052
boolean extendLeaseTime ( String caller , long threadId , long leaseTime ) { if ( ! isLockedBy ( caller , threadId ) ) { return false ; } this . blockReads = true ; if ( expirationTime < Long . MAX_VALUE ) { setExpirationTime ( expirationTime - Clock . currentTimeMillis ( ) + leaseTime ) ; } return true ; }
This method is used to extend the already locked resource in the prepare phase of the transactions . It also marks the resource true to block reads .
9,053
void init ( String path ) { this . path = checkHasText ( path , "path cannot be null or empty" ) ; this . index = 0 ; this . offset = 0 ; this . nextSplit = StringUtil . indexOf ( path , '.' , 0 ) ; this . token = null ; if ( nextSplit == 0 ) { throw new IllegalArgumentException ( "The path cannot begin with a dot: " +...
Inits the cursor with the given path and sets the current position to the first token .
9,054
public void publishInternal ( Object message ) { topicStats . incrementPublishes ( ) ; topicService . publishMessage ( name , message , multithreaded ) ; }
Publishes the message and increases the local statistics for the number of published messages .
9,055
private Version getClusterOrNodeVersion ( ) { if ( node . getClusterService ( ) != null && ! node . getClusterService ( ) . getClusterVersion ( ) . isUnknown ( ) ) { return node . getClusterService ( ) . getClusterVersion ( ) ; } else { String overriddenClusterVersion = node . getProperties ( ) . getString ( GroupPrope...
otherwise if not overridden use current node s codebase version
9,056
public void parse ( String string ) { if ( string == null ) { throw new NullPointerException ( "string is null" ) ; } int bufferSize = Math . max ( MIN_BUFFER_SIZE , Math . min ( DEFAULT_BUFFER_SIZE , string . length ( ) ) ) ; try { parse ( new StringReader ( string ) , bufferSize ) ; } catch ( IOException exception ) ...
Parses the given input string . The input must contain a valid JSON value optionally padded with whitespace .
9,057
private List < Member > getNonLocalReplicaAddresses ( ) { final Collection < Member > dataMembers = nodeEngine . getClusterService ( ) . getMembers ( DATA_MEMBER_SELECTOR ) ; final ArrayList < Member > nonLocalDataMembers = new ArrayList < Member > ( dataMembers ) ; nonLocalDataMembers . remove ( nodeEngine . getLocalM...
Return the list of non - local CRDT replicas in the cluster .
9,058
public void setIndexStats ( Map < String , LocalIndexStatsImpl > indexStats ) { this . mutableIndexStats . clear ( ) ; if ( indexStats != null ) { this . mutableIndexStats . putAll ( indexStats ) ; } }
Sets the per - index stats of this map stats to the given per - index stats .
9,059
private int getMatchingPoint ( String pattern , String itemName ) { int index = pattern . indexOf ( '*' ) ; if ( index == - 1 ) { return - 1 ; } String firstPart = pattern . substring ( 0 , index ) ; if ( ! itemName . startsWith ( firstPart ) ) { return - 1 ; } String secondPart = pattern . substring ( index + 1 ) ; if...
This method returns the higher value the better the matching is .
9,060
private int getMatchingPoint ( String pattern , String itemName ) { int index = pattern . indexOf ( '*' ) ; if ( index == - 1 ) { return - 1 ; } String firstPart = pattern . substring ( 0 , index ) ; int indexFirstPart = itemName . indexOf ( firstPart , 0 ) ; if ( indexFirstPart == - 1 ) { return - 1 ; } String secondP...
This method returns higher values the better the matching is .
9,061
public JsonGetterContext getContext ( String queryPath ) { JsonGetterContext context = internalCache . get ( queryPath ) ; if ( context != null ) { return context ; } context = new JsonGetterContext ( queryPath ) ; JsonGetterContext previousContextValue = internalCache . putIfAbsent ( queryPath , context ) ; if ( previ...
Returns an existing or newly created context for given query path . If maximum cache size is reached then some entries are evicted . The newly created entry is not evicted .
9,062
private void addStatsOfNoDataIncludedMaps ( Map statsPerMap ) { ProxyService proxyService = nodeEngine . getProxyService ( ) ; Collection < String > mapNames = proxyService . getDistributedObjectNames ( SERVICE_NAME ) ; for ( String mapName : mapNames ) { if ( ! statsPerMap . containsKey ( mapName ) ) { statsPerMap . p...
Some maps may have a proxy but no data has been put yet . Think of one created a proxy but not put any data in it . By calling this method we are returning an empty stats object for those maps . This is helpful to monitor those kind of maps .
9,063
private void addReplicaStatsOf ( RecordStore recordStore , LocalMapOnDemandCalculatedStats onDemandStats ) { if ( ! hasRecords ( recordStore ) ) { return ; } long backupEntryCount = 0 ; long backupEntryMemoryCost = 0 ; int totalBackupCount = recordStore . getMapContainer ( ) . getTotalBackupCount ( ) ; for ( int replic...
Calculates and adds replica partition stats .
9,064
private Address getReplicaAddress ( int partitionId , int replicaNumber , int backupCount ) { IPartition partition = partitionService . getPartition ( partitionId ) ; Address replicaAddress = partition . getReplicaAddress ( replicaNumber ) ; if ( replicaAddress == null ) { replicaAddress = waitForReplicaAddress ( repli...
Gets replica address . Waits if necessary .
9,065
private Address waitForReplicaAddress ( int replica , IPartition partition , int backupCount ) { int tryCount = RETRY_COUNT ; Address replicaAddress = null ; while ( replicaAddress == null && partitionService . getMaxAllowedBackupCount ( ) >= backupCount && tryCount -- > 0 ) { sleep ( ) ; replicaAddress = partition . g...
Waits partition table update to get replica address if current replica address is null .
9,066
public static < E1 > ConcurrentConveyorSingleQueue < E1 > concurrentConveyorSingleQueue ( E1 submitterGoneItem , QueuedPipe < E1 > queue ) { return new ConcurrentConveyorSingleQueue < E1 > ( submitterGoneItem , queue ) ; }
Creates a new concurrent conveyor with a single queue .
9,067
public Operation prepareReplicationOperation ( PartitionReplicationEvent event ) { if ( event . getReplicaIndex ( ) > 1 ) { return null ; } List < XATransactionDTO > migrationData = new ArrayList < XATransactionDTO > ( ) ; InternalPartitionService partitionService = nodeEngine . getPartitionService ( ) ; for ( Map . En...
Migration related methods
9,068
private static Method getMethod ( Object source , String methodName , String name ) { try { Method method = source . getClass ( ) . getMethod ( methodName ) ; method . setAccessible ( true ) ; return method ; } catch ( Exception e ) { if ( LOGGER . isFinestEnabled ( ) ) { LOGGER . log ( Level . FINEST , "Unable to regi...
Returns a method from the given source object .
9,069
public void setDiscoveryStrategyConfigs ( List < DiscoveryStrategyConfig > discoveryStrategyConfigs ) { this . discoveryStrategyConfigs = discoveryStrategyConfigs == null ? new ArrayList < DiscoveryStrategyConfig > ( 1 ) : discoveryStrategyConfigs ; }
Sets the strategy configurations for this discovery config .
9,070
static MapKeyLoader . Role assignRole ( boolean isPartitionOwner , boolean isMapNamePartition , boolean isMapNamePartitionFirstReplica ) { if ( isMapNamePartition ) { if ( isPartitionOwner ) { return MapKeyLoader . Role . SENDER ; } else { if ( isMapNamePartitionFirstReplica ) { return MapKeyLoader . Role . SENDER_BACK...
Returns the role for the map key loader based on the passed parameters . The partition owner of the map name partition is the sender . The first replica of the map name partition is the sender backup . Other partition owners are receivers and other partition replicas do not have a role .
9,071
public static String [ ] parseOutCompositeIndexComponents ( String name ) { String [ ] components = COMMA_PATTERN . split ( name , - 1 ) ; if ( components . length == 1 ) { return null ; } if ( components . length > MAX_INDEX_COMPONENTS ) { throw new IllegalArgumentException ( "Too many composite index attributes: " + ...
Parses the given index name into components .
9,072
@ SuppressWarnings ( "unchecked" ) public < P extends DiagnosticsPlugin > P getPlugin ( Class < P > pluginClass ) { return ( P ) pluginsMap . get ( pluginClass ) ; }
Gets the plugin for a given plugin class . This method should be used if the plugin instance is required within some data - structure outside of the Diagnostics .
9,073
public boolean register ( Invocation invocation ) { final long callId ; boolean force = invocation . op . isUrgent ( ) || invocation . isRetryCandidate ( ) ; try { callId = force ? callIdSequence . forceNext ( ) : callIdSequence . next ( ) ; } catch ( HazelcastOverloadException e ) { throw new HazelcastOverloadExceptio...
Registers an invocation .
9,074
public static Permission getPermission ( String name , String serviceName , String ... actions ) { PermissionFactory permissionFactory = PERMISSION_FACTORY_MAP . get ( serviceName ) ; if ( permissionFactory == null ) { throw new IllegalArgumentException ( "No permissions found for service: " + serviceName ) ; } return ...
Creates a permission
9,075
protected final SplitBrainMergeCheckResult sendSplitBrainJoinMessageAndCheckResponse ( Address target , SplitBrainJoinMessage request ) { SplitBrainJoinMessage response = sendSplitBrainJoinMessage ( target , request ) ; return clusterService . getClusterJoinManager ( ) . shouldMerge ( response ) ; }
Sends a split brain join request to the target address and checks the response to see if this node should merge to the target address .
9,076
private SplitBrainJoinMessage sendSplitBrainJoinMessage ( Address target , SplitBrainJoinMessage request ) { if ( logger . isFineEnabled ( ) ) { logger . fine ( "Sending SplitBrainJoinMessage to " + target ) ; } Connection conn = node . getEndpointManager ( MEMBER ) . getOrConnect ( target , true ) ; long timeout = SPL...
Sends a split brain join request to the target address and returns the response .
9,077
public static void setExpirationTimes ( long operationTTLMillis , long operationMaxIdleMillis , Record record , MapConfig mapConfig , boolean consultMapConfig ) { long ttlMillis = pickTTLMillis ( operationTTLMillis , record . getTtl ( ) , mapConfig , consultMapConfig ) ; long maxIdleMillis = pickMaxIdleMillis ( operati...
Updates records TTL and expiration time .
9,078
private static long pickTTLMillis ( long operationTTLMillis , long existingTTLMillis , MapConfig mapConfig , boolean consultMapConfig ) { if ( operationTTLMillis > 0 ) { return checkedTime ( operationTTLMillis ) ; } if ( consultMapConfig && operationTTLMillis < 0 && mapConfig . getTimeToLiveSeconds ( ) > 0 ) { return c...
Decides if TTL millis should to be set on record .
9,079
public static long calculateExpirationWithDelay ( long timeInMillis , long delayMillis , boolean backup ) { checkNotNegative ( timeInMillis , "timeInMillis can't be negative" ) ; if ( backup ) { long delayedTime = timeInMillis + delayMillis ; if ( delayedTime < 0 ) { return Long . MAX_VALUE ; } else { return delayedTim...
On backup partitions this method delays key s expiration .
9,080
AcquireResult acquire ( LockInvocationKey key , boolean wait ) { LockEndpoint endpoint = key . endpoint ( ) ; UUID invocationUid = key . invocationUid ( ) ; RaftLockOwnershipState memorized = ownerInvocationRefUids . get ( Tuple2 . of ( endpoint , invocationUid ) ) ; if ( memorized != null ) { AcquireStatus status = me...
Assigns the lock to the endpoint if the lock is not held . Lock count is incremented if the endpoint already holds the lock . If some other endpoint holds the lock and the second argument is true a wait key is created and added to the wait queue . Lock count is not incremented if the lock request is a retry of the lock...
9,081
protected void onSessionClose ( long sessionId , Map < Long , Object > responses ) { removeInvocationRefUids ( sessionId ) ; if ( owner != null && owner . sessionId ( ) == sessionId ) { ReleaseResult result = doRelease ( owner . endpoint ( ) , newUnsecureUUID ( ) , lockCount ) ; for ( LockInvocationKey key : result . c...
Releases the lock if the current lock holder s session is closed .
9,082
protected Collection < Long > getActivelyAttachedSessions ( ) { return owner != null ? Collections . singleton ( owner . sessionId ( ) ) : Collections . < Long > emptyList ( ) ; }
Returns session id of the current lock holder or an empty collection if the lock is not held
9,083
private boolean containsKeyAndValue ( Object key ) { ReplicatedRecord replicatedRecord = getStorage ( ) . get ( marshall ( key ) ) ; return replicatedRecord != null && replicatedRecord . getValue ( ) != null ; }
IMPORTANT >> Increments hit counter
9,084
public Collection < Map . Entry < Address , List < Integer > > > getPartitions ( PartitionTableView partitionTableView ) { Map < Address , List < Integer > > partitionsMap = new HashMap < Address , List < Integer > > ( ) ; int partitionCount = partitionTableView . getLength ( ) ; for ( int partitionId = 0 ; partitionId...
If any partition does not have an owner this method returns empty collection
9,085
public final void migrateTo ( MemoryAllocator newMalloc ) { baseAddress = move ( baseAddress , capacity ( ) , malloc , newMalloc ) ; malloc = newMalloc ; auxMalloc = null ; }
Migrates the backing memory region to a new allocator freeing the current region . Memory allocated by the new allocator must be accessible by the same accessor as the current one .
9,086
protected final SlotAssignmentResult ensure0 ( long key1 , long key2 ) { assertValid ( ) ; final long size = size ( ) ; if ( size == expansionThreshold ( ) ) { resizeTo ( CapacityUtil . nextCapacity ( capacity ( ) ) ) ; } long slot = keyHash ( key1 , key2 ) & mask ( ) ; while ( isSlotAssigned ( slot ) ) { if ( equal ( ...
These protected final methods will be called from the subclasses
9,087
protected void resizeTo ( long newCapacity ) { final long oldCapacity = capacity ( ) ; final long oldAllocatedSize = HEADER_SIZE + oldCapacity * slotLength ; final MemoryAllocator oldMalloc ; final long oldAddress ; if ( auxMalloc != null ) { final long size = size ( ) ; oldAddress = move ( baseAddress , oldCapacity , ...
Allocates a new slot array with the requested size and moves all the assigned slots from the current array into the new one .
9,088
private long move ( long fromBaseAddress , long capacity , MemoryAllocator fromMalloc , MemoryAllocator toMalloc ) { final long allocatedSize = HEADER_SIZE + capacity * slotLength ; final long toBaseAddress = toMalloc . allocate ( allocatedSize ) + HEADER_SIZE ; mem . copyMemory ( fromBaseAddress - HEADER_SIZE , toBase...
Copies a block from one allocator to another then frees the source block .
9,089
public void addGetTimeNanos ( long duration ) { for ( ; ; ) { long nanos = getCacheTimeTakenNanos ; if ( nanos <= Long . MAX_VALUE - duration ) { if ( GET_CACHE_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , nanos + duration ) ) { return ; } } else { if ( GET_CACHE_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , d...
Increments the getCache time accumulator .
9,090
public void addPutTimeNanos ( long duration ) { for ( ; ; ) { long nanos = putTimeTakenNanos ; if ( nanos <= Long . MAX_VALUE - duration ) { if ( PUT_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , nanos + duration ) ) { return ; } } else { if ( PUT_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , duration ) ) { cle...
Increments the put time accumulator .
9,091
public void addRemoveTimeNanos ( long duration ) { for ( ; ; ) { long nanos = removeTimeTakenNanos ; if ( nanos <= Long . MAX_VALUE - duration ) { if ( REMOVE_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , nanos + duration ) ) { return ; } } else { if ( REMOVE_TIME_TAKEN_NANOS . compareAndSet ( this , nanos , durati...
Increments the remove time accumulator .
9,092
@ SuppressFBWarnings ( "NP_BOOLEAN_RETURN_NULL" ) static Boolean isObjectLayoutCompressedOopsOrNull ( ) { if ( ! UNSAFE_AVAILABLE ) { return null ; } Integer referenceSize = ReferenceSizeEstimator . getReferenceSizeOrNull ( ) ; if ( referenceSize == null ) { return null ; } return referenceSize != UNSAFE . addressSize ...
Fallback when checking CompressedOopsEnabled .
9,093
private static PortablePosition navigateToPathTokenWithoutQuantifier ( PortableNavigatorContext ctx , PortablePathCursor path ) throws IOException { if ( path . isLastToken ( ) ) { return createPositionForReadAccess ( ctx , path ) ; } else { if ( ! navigateContextToNextPortableTokenFromPortableField ( ctx ) ) { return ...
Token without quantifier . It means it s just a simple field not an array .
9,094
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPortableArray ( PortableNavigatorContext ctx , PortablePathCursor path , NavigationFrame frame ) throws IOException { if ( frame == null ) { int len = getArrayLengthOfTheField ( ctx ) ; PortablePosition result = doValidateArrayLengthForAnyQuantifier ...
navigation in PORTABLE array
9,095
private static PortablePosition navigateToPathTokenWithAnyQuantifierInPrimitiveArray ( PortableNavigatorContext ctx , PortablePathCursor path , NavigationFrame frame ) throws IOException { if ( frame == null ) { if ( path . isLastToken ( ) ) { int len = getArrayLengthOfTheField ( ctx ) ; PortablePosition result = doVal...
navigation in PRIMITIVE array
9,096
private static boolean navigateContextToNextPortableTokenFromPortableField ( PortableNavigatorContext ctx ) throws IOException { BufferObjectDataInput in = ctx . getIn ( ) ; int pos = getStreamPositionOfTheField ( ctx ) ; in . position ( pos ) ; boolean isNull = in . readBoolean ( ) ; if ( isNull ) { return false ; } i...
returns true if managed to advance false if advance failed due to null field
9,097
private static void navigateContextToNextPortableTokenFromPortableArrayCell ( PortableNavigatorContext ctx , PortablePathCursor path , int index ) throws IOException { BufferObjectDataInput in = ctx . getIn ( ) ; int pos = getStreamPositionOfTheField ( ctx ) ; in . position ( pos ) ; in . readInt ( ) ; int factoryId = ...
this navigation always succeeds since the caller validates if the index is inbound
9,098
private static PortablePosition createPositionForReadAccess ( PortableNavigatorContext ctx , PortablePathCursor path ) throws IOException { int notArrayCellAccessIndex = - 1 ; return createPositionForReadAccess ( ctx , path , notArrayCellAccessIndex ) ; }
Special case of the position creation where there s no quantifier so the index does not count .
9,099
public String handleCommand ( final String command ) throws InterruptedException { if ( lock . tryLock ( 1 , TimeUnit . SECONDS ) ) { try { return doHandleCommand ( command ) ; } finally { lock . unlock ( ) ; } } return "'" + command + "' execution is timed out!" ; }
Runs a command on the console . Will not run exit quit shutdown their upper - case or mixed case counterparts .