idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
24,300
public static void mlock ( Pointer addr , long len ) { int res = Delegate . mlock ( addr , new NativeLong ( len ) ) ; if ( res != 0 ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Mlock failed probably because of insufficient privileges, errno:" + errno . strerror ( ) + ", return value:" + res ) ; } } else {...
Lock the given region . Does not report failures .
24,301
public static void munlock ( Pointer addr , long len ) { if ( Delegate . munlock ( addr , new NativeLong ( len ) ) != 0 ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "munlocking failed with errno:" + errno . strerror ( ) ) ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "munlocking region" ) ; ...
Unlock the given region . Does not report failures .
24,302
public JsonTypeDefinition projectionType ( String ... properties ) { if ( this . getType ( ) instanceof Map < ? , ? > ) { Map < ? , ? > type = ( Map < ? , ? > ) getType ( ) ; Arrays . sort ( properties ) ; Map < String , Object > newType = new LinkedHashMap < String , Object > ( ) ; for ( String prop : properties ) new...
Get the type created by selecting only a subset of properties from this type . The type must be a map for this to work
24,303
private void writeBufferedValsToStorage ( ) { List < Versioned < byte [ ] > > obsoleteVals = storageEngine . multiVersionPut ( currBufferedKey , currBufferedVals ) ; if ( logger . isDebugEnabled ( ) && obsoleteVals . size ( ) > 0 ) { logger . debug ( "updateEntries (Streaming multi-version-put) rejected these versions ...
Persists the current set of versions buffered for the current key into storage using the multiVersionPut api
24,304
public synchronized boolean acquireRebalancingPermit ( int nodeId ) { boolean added = rebalancePermits . add ( nodeId ) ; logger . info ( "Acquiring rebalancing permit for node id " + nodeId + ", returned: " + added ) ; return added ; }
Acquire a permit for a particular node id so as to allow rebalancing
24,305
public synchronized void releaseRebalancingPermit ( int nodeId ) { boolean removed = rebalancePermits . remove ( nodeId ) ; logger . info ( "Releasing rebalancing permit for node id " + nodeId + ", returned: " + removed ) ; if ( ! removed ) throw new VoldemortException ( new IllegalStateException ( "Invalid state, must...
Release the rebalancing permit for a particular node id
24,306
private void swapROStores ( List < String > swappedStoreNames , boolean useSwappedStoreNames ) { try { for ( StoreDefinition storeDef : metadataStore . getStoreDefList ( ) ) { if ( storeDef . getType ( ) . compareTo ( ReadOnlyStorageConfiguration . TYPE_NAME ) == 0 ) { if ( useSwappedStoreNames && ! swappedStoreNames ....
Goes through all the RO Stores in the plan and swaps it
24,307
private void changeClusterAndStores ( String clusterKey , final Cluster cluster , String storesKey , final List < StoreDefinition > storeDefs ) { metadataStore . writeLock . lock ( ) ; try { VectorClock updatedVectorClock = ( ( VectorClock ) metadataStore . get ( clusterKey , null ) . get ( 0 ) . getVersion ( ) ) . inc...
Updates the cluster and store metadata atomically
24,308
public int rebalanceNode ( final RebalanceTaskInfo stealInfo ) { final RebalanceTaskInfo info = metadataStore . getRebalancerState ( ) . find ( stealInfo . getDonorId ( ) ) ; if ( info == null ) { throw new VoldemortException ( "Could not find plan " + stealInfo + " in the server state on " + metadataStore . getNodeId ...
This function is responsible for starting the actual async rebalance operation . This is run if this node is the stealer node
24,309
protected void prepForWrite ( SelectionKey selectionKey ) { if ( logger . isTraceEnabled ( ) ) traceInputBufferState ( "About to clear read buffer" ) ; if ( requestHandlerFactory . shareReadWriteBuffer ( ) == false ) { inputStream . clear ( ) ; } if ( logger . isTraceEnabled ( ) ) traceInputBufferState ( "Cleared read ...
Flips the output buffer and lets the Selector know we re ready to write .
24,310
private boolean initRequestHandler ( SelectionKey selectionKey ) { ByteBuffer inputBuffer = inputStream . getBuffer ( ) ; int remaining = inputBuffer . remaining ( ) ; if ( remaining < 3 ) return true ; byte [ ] protoBytes = { inputBuffer . get ( 0 ) , inputBuffer . get ( 1 ) , inputBuffer . get ( 2 ) } ; try { String ...
Returns true if the request should continue .
24,311
public void rememberAndDisableQuota ( ) { for ( Integer nodeId : nodeIds ) { boolean quotaEnforcement = Boolean . parseBoolean ( adminClient . metadataMgmtOps . getRemoteMetadata ( nodeId , MetadataStore . QUOTA_ENFORCEMENT_ENABLED_KEY ) . getValue ( ) ) ; mapNodeToQuotaEnforcingEnabled . put ( nodeId , quotaEnforcemen...
Before cluster management operations i . e . remember and disable quota enforcement settings
24,312
public void resetQuotaAndRecoverEnforcement ( ) { for ( Integer nodeId : nodeIds ) { boolean quotaEnforcement = mapNodeToQuotaEnforcingEnabled . get ( nodeId ) ; adminClient . metadataMgmtOps . updateRemoteMetadata ( Arrays . asList ( nodeId ) , MetadataStore . QUOTA_ENFORCEMENT_ENABLED_KEY , Boolean . toString ( quota...
After cluster management operations i . e . reset quota and recover quota enforcement settings
24,313
public void incrementVersion ( int node , long time ) { if ( node < 0 || node > Short . MAX_VALUE ) throw new IllegalArgumentException ( node + " is outside the acceptable range of node ids." ) ; this . timestamp = time ; Long version = versionMap . get ( ( short ) node ) ; if ( version == null ) { version = 1L ; } els...
Increment the version info associated with the given node
24,314
public VectorClock incremented ( int nodeId , long time ) { VectorClock copyClock = this . clone ( ) ; copyClock . incrementVersion ( nodeId , time ) ; return copyClock ; }
Get new vector clock based on this clock but incremented on index nodeId
24,315
private Map < Integer , Integer > getNodeIdToPrimaryCount ( Cluster cluster ) { Map < Integer , Integer > nodeIdToPrimaryCount = Maps . newHashMap ( ) ; for ( Node node : cluster . getNodes ( ) ) { nodeIdToPrimaryCount . put ( node . getId ( ) , node . getPartitionIds ( ) . size ( ) ) ; } return nodeIdToPrimaryCount ; ...
Go through all nodes and determine how many partition Ids each node hosts .
24,316
private Map < Integer , Integer > getNodeIdToZonePrimaryCount ( Cluster cluster , StoreRoutingPlan storeRoutingPlan ) { Map < Integer , Integer > nodeIdToZonePrimaryCount = Maps . newHashMap ( ) ; for ( Integer nodeId : cluster . getNodeIds ( ) ) { nodeIdToZonePrimaryCount . put ( nodeId , storeRoutingPlan . getZonePri...
Go through all partition IDs and determine which node is first in the replicating node list for every zone . This determines the number of zone primaries each node hosts .
24,317
private Map < Integer , Integer > getNodeIdToNaryCount ( Cluster cluster , StoreRoutingPlan storeRoutingPlan ) { Map < Integer , Integer > nodeIdToNaryCount = Maps . newHashMap ( ) ; for ( int nodeId : cluster . getNodeIds ( ) ) { nodeIdToNaryCount . put ( nodeId , storeRoutingPlan . getZoneNAryPartitionIds ( nodeId ) ...
Go through all node IDs and determine which node
24,318
private String dumpZoneNAryDetails ( StoreRoutingPlan storeRoutingPlan ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "\tDetailed Dump (Zone N-Aries):" ) . append ( Utils . NEWLINE ) ; for ( Node node : storeRoutingPlan . getCluster ( ) . getNodes ( ) ) { int zoneId = node . getZoneId ( ) ; int nodeId = n...
Dumps the partition IDs per node in terms of zone n - ary type .
24,319
private Pair < Double , String > summarizeBalance ( final Map < Integer , Integer > nodeIdToPartitionCount , String title ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "\n" + title + "\n" ) ; Map < Integer , ZoneBalanceStats > zoneToBalanceStats = new HashMap < Integer , ZoneBalanceStats > ( ) ...
Summarizes balance for the given nodeId to PartitionCount .
24,320
private void rebalanceStore ( String storeName , final AdminClient adminClient , RebalanceTaskInfo stealInfo , boolean isReadOnlyStore ) { if ( stealInfo . getPartitionIds ( storeName ) != null && stealInfo . getPartitionIds ( storeName ) . size ( ) > 0 ) { logger . info ( getHeader ( stealInfo ) + "Starting partitions...
Blocking function which completes the migration of one store
24,321
public void recordSyncOpTimeNs ( SocketDestination dest , long opTimeNs ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordSyncOpTimeNs ( null , opTimeNs ) ; recordSyncOpTimeNs ( null , opTimeNs ) ; } else { this . syncOpTimeRequestCounter . addRequest ( opTimeNs ) ; } }
Record operation for sync ops time
24,322
public void recordAsyncOpTimeNs ( SocketDestination dest , long opTimeNs ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordAsyncOpTimeNs ( null , opTimeNs ) ; recordAsyncOpTimeNs ( null , opTimeNs ) ; } else { this . asynOpTimeRequestCounter . addRequest ( opTimeNs ) ; } }
Record operation for async ops time
24,323
public void recordConnectionEstablishmentTimeUs ( SocketDestination dest , long connEstTimeUs ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordConnectionEstablishmentTimeUs ( null , connEstTimeUs ) ; recordConnectionEstablishmentTimeUs ( null , connEstTimeUs ) ; } else { this . connectionEstablishmentReq...
Record the connection establishment time
24,324
public void recordCheckoutTimeUs ( SocketDestination dest , long checkoutTimeUs ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordCheckoutTimeUs ( null , checkoutTimeUs ) ; recordCheckoutTimeUs ( null , checkoutTimeUs ) ; } else { this . checkoutTimeRequestCounter . addRequest ( checkoutTimeUs * Time . NS...
Record the checkout wait time in us
24,325
public void recordCheckoutQueueLength ( SocketDestination dest , int queueLength ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordCheckoutQueueLength ( null , queueLength ) ; recordCheckoutQueueLength ( null , queueLength ) ; } else { this . checkoutQueueLengthHistogram . insert ( queueLength ) ; checkMo...
Record the checkout queue length
24,326
public void recordResourceRequestTimeUs ( SocketDestination dest , long resourceRequestTimeUs ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordResourceRequestTimeUs ( null , resourceRequestTimeUs ) ; recordResourceRequestTimeUs ( null , resourceRequestTimeUs ) ; } else { this . resourceRequestTimeRequest...
Record the resource request wait time in us
24,327
public void recordResourceRequestQueueLength ( SocketDestination dest , int queueLength ) { if ( dest != null ) { getOrCreateNodeStats ( dest ) . recordResourceRequestQueueLength ( null , queueLength ) ; recordResourceRequestQueueLength ( null , queueLength ) ; } else { this . resourceRequestQueueLengthHistogram . inse...
Record the resource request queue length
24,328
public void close ( ) { Iterator < SocketDestination > it = getStatsMap ( ) . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { try { SocketDestination destination = it . next ( ) ; JmxUtils . unregisterMbean ( JmxUtils . createObjectName ( JmxUtils . getPackageName ( ClientRequestExecutor . class ) , "stats_" +...
Unregister all MBeans
24,329
private < T > T request ( ClientRequest < T > delegate , String operationName ) { long startTimeMs = - 1 ; long startTimeNs = - 1 ; if ( logger . isDebugEnabled ( ) ) { startTimeMs = System . currentTimeMillis ( ) ; } ClientRequestExecutor clientRequestExecutor = pool . checkout ( destination ) ; String debugMsgStr = "...
This method handles submitting and then waiting for the request from the server . It uses the ClientRequest API to actually write the request and then read back the response . This implementation will block for a response from the server .
24,330
private < T > void requestAsync ( ClientRequest < T > delegate , NonblockingStoreCallback callback , long timeoutMs , String operationName ) { pool . submitAsync ( this . destination , delegate , callback , timeoutMs , operationName ) ; }
This method handles submitting and then waiting for the request from the server . It uses the ClientRequest API to actually write the request and then read back the response . This implementation will not block for a response from the server .
24,331
@ JmxGetter ( name = "avgFetchKeysNetworkTimeMs" , description = "average time spent on network, for fetch keys" ) public double getAvgFetchKeysNetworkTimeMs ( ) { return networkTimeCounterMap . get ( Operation . FETCH_KEYS ) . getAvgEventValue ( ) / Time . NS_PER_MS ; }
Mbeans for FETCH_KEYS
24,332
@ JmxGetter ( name = "avgFetchEntriesNetworkTimeMs" , description = "average time spent on network, for streaming operations" ) public double getAvgFetchEntriesNetworkTimeMs ( ) { return networkTimeCounterMap . get ( Operation . FETCH_ENTRIES ) . getAvgEventValue ( ) / Time . NS_PER_MS ; }
Mbeans for FETCH_ENTRIES
24,333
@ JmxGetter ( name = "avgUpdateEntriesNetworkTimeMs" , description = "average time spent on network, for streaming operations" ) public double getAvgUpdateEntriesNetworkTimeMs ( ) { return networkTimeCounterMap . get ( Operation . UPDATE_ENTRIES ) . getAvgEventValue ( ) / Time . NS_PER_MS ; }
Mbeans for UPDATE_ENTRIES
24,334
@ JmxGetter ( name = "avgSlopUpdateNetworkTimeMs" , description = "average time spent on network, for streaming operations" ) public double getAvgSlopUpdateNetworkTimeMs ( ) { return networkTimeCounterMap . get ( Operation . SLOP_UPDATE ) . getAvgEventValue ( ) / Time . NS_PER_MS ; }
Mbeans for SLOP_UPDATE
24,335
public static String getJavaClassFromSchemaInfo ( String schemaInfo ) { final String ONLY_JAVA_CLIENTS_SUPPORTED = "Only Java clients are supported currently, so the format of the schema-info should be: <schema-info>java=foo.Bar</schema-info> where foo.Bar is the fully qualified name of the message." ; if ( StringUtils...
Extracts the java class name from the schema info
24,336
public static List < StoreDefinition > filterStores ( List < StoreDefinition > storeDefs , final boolean isReadOnly ) { List < StoreDefinition > filteredStores = Lists . newArrayList ( ) ; for ( StoreDefinition storeDef : storeDefs ) { if ( storeDef . getType ( ) . equals ( ReadOnlyStorageConfiguration . TYPE_NAME ) ==...
Given a list of store definitions filters the list depending on the boolean
24,337
public static List < String > getStoreNames ( List < StoreDefinition > storeDefList ) { List < String > storeList = new ArrayList < String > ( ) ; for ( StoreDefinition def : storeDefList ) { storeList . add ( def . getName ( ) ) ; } return storeList ; }
Given a list of store definitions return a list of store names
24,338
public static Set < String > getStoreNamesSet ( List < StoreDefinition > storeDefList ) { HashSet < String > storeSet = new HashSet < String > ( ) ; for ( StoreDefinition def : storeDefList ) { storeSet . add ( def . getName ( ) ) ; } return storeSet ; }
Given a list of store definitions return a set of store names
24,339
public static HashMap < StoreDefinition , Integer > getUniqueStoreDefinitionsWithCounts ( List < StoreDefinition > storeDefs ) { HashMap < StoreDefinition , Integer > uniqueStoreDefs = Maps . newHashMap ( ) ; for ( StoreDefinition storeDef : storeDefs ) { if ( uniqueStoreDefs . isEmpty ( ) ) { uniqueStoreDefs . put ( s...
Given a list of store definitions find out and return a map of similar store definitions + count of them
24,340
public static boolean isAvroSchema ( String serializerName ) { if ( serializerName . equals ( AVRO_GENERIC_VERSIONED_TYPE_NAME ) || serializerName . equals ( AVRO_GENERIC_TYPE_NAME ) || serializerName . equals ( AVRO_REFLECTIVE_TYPE_NAME ) || serializerName . equals ( AVRO_SPECIFIC_TYPE_NAME ) ) { return true ; } else ...
Determine whether or not a given serializedr is AVRO based
24,341
private static void validateIfAvroSchema ( SerializerDefinition serializerDef ) { if ( serializerDef . getName ( ) . equals ( AVRO_GENERIC_VERSIONED_TYPE_NAME ) || serializerDef . getName ( ) . equals ( AVRO_GENERIC_TYPE_NAME ) ) { SchemaEvolutionValidator . validateAllAvroSchemas ( serializerDef ) ; if ( serializerDef...
If provided with an AVRO schema validates it and checks if there are backwards compatible .
24,342
public synchronized void insert ( long data ) { resetIfNeeded ( ) ; long index = 0 ; if ( data >= this . upperBound ) { index = nBuckets - 1 ; } else if ( data < 0 ) { logger . error ( data + " can't be bucketed because it is negative!" ) ; return ; } else { index = data / step ; } if ( index < 0 || index >= nBuckets )...
Insert a value into the right bucket of the histogram . If the value is larger than any bound insert into the last bucket . If the value is less than zero then ignore it .
24,343
private void checkAndAddNodeStore ( ) { for ( Node node : metadata . getCluster ( ) . getNodes ( ) ) { if ( ! routedStore . getInnerStores ( ) . containsKey ( node . getId ( ) ) ) { if ( ! storeRepository . hasNodeStore ( getName ( ) , node . getId ( ) ) ) { storeRepository . addNodeStore ( node . getId ( ) , createNod...
Check that all nodes in the new cluster have a corresponding entry in storeRepository and innerStores . add a NodeStore if not present is needed as with rebalancing we can add new nodes on the fly .
24,344
public ResourcePoolConfig setTimeout ( long timeout , TimeUnit unit ) { if ( timeout < 0 ) throw new IllegalArgumentException ( "The timeout must be a non-negative number." ) ; this . timeoutNs = TimeUnit . NANOSECONDS . convert ( timeout , unit ) ; return this ; }
The timeout which we block for when a resource is not available
24,345
private byte [ ] assembleValues ( List < Versioned < byte [ ] > > values ) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; DataOutputStream dataStream = new DataOutputStream ( stream ) ; for ( Versioned < byte [ ] > value : values ) { byte [ ] object = value . getValue ( ) ; dataStre...
Store the versioned values
24,346
private List < Versioned < byte [ ] > > disassembleValues ( byte [ ] values ) throws IOException { if ( values == null ) return new ArrayList < Versioned < byte [ ] > > ( 0 ) ; List < Versioned < byte [ ] > > returnList = new ArrayList < Versioned < byte [ ] > > ( ) ; ByteArrayInputStream stream = new ByteArrayInputStr...
Splits up value into multiple versioned values
24,347
protected void statusInfoMessage ( final String tag ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( tag + " : [partition: " + currentPartition + ", partitionFetched: " + currentPartitionFetched + "] for store " + storageEngine . getName ( ) ) ; } }
Simple info message for status
24,348
private int slopSize ( Versioned < Slop > slopVersioned ) { int nBytes = 0 ; Slop slop = slopVersioned . getValue ( ) ; nBytes += slop . getKey ( ) . length ( ) ; nBytes += ( ( VectorClock ) slopVersioned . getVersion ( ) ) . sizeInBytes ( ) ; switch ( slop . getOperation ( ) ) { case PUT : { nBytes += slop . getValue ...
Returns the approximate size of slop to help in throttling
24,349
public < K , V > StoreClient < K , V > getStoreClient ( final String storeName , final InconsistencyResolver < Versioned < V > > resolver ) { return new LazyStoreClient < K , V > ( new Callable < StoreClient < K , V > > ( ) { public StoreClient < K , V > call ( ) throws Exception { Store < K , V , Object > clientStore ...
Creates a REST client used to perform Voldemort operations against the Coordinator
24,350
private static int abs ( int a ) { if ( a >= 0 ) return a ; else if ( a != Integer . MIN_VALUE ) return - a ; return Integer . MAX_VALUE ; }
A modified version of abs that always returns a non - negative value . Math . abs returns Integer . MIN_VALUE if a == Integer . MIN_VALUE and this method returns Integer . MAX_VALUE in that case .
24,351
public Integer getMasterPartition ( byte [ ] key ) { return abs ( hash . hash ( key ) ) % ( Math . max ( 1 , this . partitionToNode . length ) ) ; }
Obtain the master partition for a given key
24,352
protected boolean isSlopDead ( Cluster cluster , Set < String > storeNames , Slop slop ) { if ( ! cluster . getNodeIds ( ) . contains ( slop . getNodeId ( ) ) ) { return true ; } if ( ! storeNames . contains ( slop . getStoreName ( ) ) ) { return true ; } return false ; }
A slop is dead if the destination node or the store does not exist anymore on the cluster .
24,353
protected void handleDeadSlop ( SlopStorageEngine slopStorageEngine , Pair < ByteArray , Versioned < Slop > > keyAndVal ) { Versioned < Slop > versioned = keyAndVal . getSecond ( ) ; if ( voldemortConfig . getAutoPurgeDeadSlops ( ) ) { slopStorageEngine . delete ( keyAndVal . getFirst ( ) , versioned . getVersion ( ) )...
Handle slop for nodes that are no longer part of the cluster . It may not always be the case . For example shrinking a zone or deleting a store .
24,354
public void destroy ( SocketDestination dest , ClientRequestExecutor clientRequestExecutor ) throws Exception { clientRequestExecutor . close ( ) ; int numDestroyed = destroyed . incrementAndGet ( ) ; if ( stats != null ) { stats . incrementCount ( dest , ClientSocketStats . Tracked . CONNECTION_DESTROYED_EVENT ) ; } i...
Close the ClientRequestExecutor .
24,355
@ SuppressWarnings ( "unchecked" ) public static Properties readSingleClientConfigAvro ( String configAvro ) { Properties props = new Properties ( ) ; try { JsonDecoder decoder = new JsonDecoder ( CLIENT_CONFIG_AVRO_SCHEMA , configAvro ) ; GenericDatumReader < Object > datumReader = new GenericDatumReader < Object > ( ...
Parses a string that contains single fat client config string in avro format
24,356
@ SuppressWarnings ( "unchecked" ) public static Map < String , Properties > readMultipleClientConfigAvro ( String configAvro ) { Map < String , Properties > mapStoreToProps = Maps . newHashMap ( ) ; try { JsonDecoder decoder = new JsonDecoder ( CLIENT_CONFIGS_AVRO_SCHEMA , configAvro ) ; GenericDatumReader < Object > ...
Parses a string that contains multiple fat client configs in avro format
24,357
public static String writeSingleClientConfigAvro ( Properties props ) { String avroConfig = "" ; Boolean firstProp = true ; for ( String key : props . stringPropertyNames ( ) ) { if ( firstProp ) { firstProp = false ; } else { avroConfig = avroConfig + ",\n" ; } avroConfig = avroConfig + "\t\t\"" + key + "\": \"" + pro...
Assembles an avro format string of single store config from store properties
24,358
public static String writeMultipleClientConfigAvro ( Map < String , Properties > mapStoreToProps ) { String avroConfig = "" ; Boolean firstStore = true ; for ( String storeName : mapStoreToProps . keySet ( ) ) { if ( firstStore ) { firstStore = false ; } else { avroConfig = avroConfig + ",\n" ; } Properties props = map...
Assembles an avro format string that contains multiple fat client configs from map of store to properties
24,359
public static Boolean compareSingleClientConfigAvro ( String configAvro1 , String configAvro2 ) { Properties props1 = readSingleClientConfigAvro ( configAvro1 ) ; Properties props2 = readSingleClientConfigAvro ( configAvro2 ) ; if ( props1 . equals ( props2 ) ) { return true ; } else { return false ; } }
Compares two avro strings which contains single store configs
24,360
public static Boolean compareMultipleClientConfigAvro ( String configAvro1 , String configAvro2 ) { Map < String , Properties > mapStoreToProps1 = readMultipleClientConfigAvro ( configAvro1 ) ; Map < String , Properties > mapStoreToProps2 = readMultipleClientConfigAvro ( configAvro2 ) ; Set < String > keySet1 = mapStor...
Compares two avro strings which contains multiple store configs
24,361
public static void printHelp ( PrintStream stream ) { stream . println ( ) ; stream . println ( "Voldemort Admin Tool Async-Job Commands" ) ; stream . println ( "---------------------------------------" ) ; stream . println ( "list Get async job list from nodes." ) ; stream . println ( "stop Stop async jobs on one ...
Prints command - line help menu .
24,362
public void removeStorageEngine ( StorageEngine < ByteArray , byte [ ] , byte [ ] > engine ) { String storeName = engine . getName ( ) ; BdbStorageEngine bdbEngine = ( BdbStorageEngine ) engine ; synchronized ( lock ) { if ( useOneEnvPerStore ) { Environment environment = this . environments . get ( storeName ) ; if ( ...
Clean up the environment object for the given storage engine
24,363
@ JmxOperation ( description = "Forcefully invoke the log cleaning" ) public void cleanLogs ( ) { synchronized ( lock ) { try { for ( Environment environment : environments . values ( ) ) { environment . cleanLog ( ) ; } } catch ( DatabaseException e ) { throw new VoldemortException ( e ) ; } } }
Forceful cleanup the logs
24,364
public void update ( StoreDefinition storeDef ) { if ( ! useOneEnvPerStore ) throw new VoldemortException ( "Memory foot print can be set only when using different environments per store" ) ; String storeName = storeDef . getName ( ) ; Environment environment = environments . get ( storeName ) ; if ( ! unreservedStores...
Detect what has changed in the store definition and rewire BDB environments accordingly .
24,365
public static HashMap < Integer , List < Integer > > getBalancedNumberOfPrimaryPartitionsPerNode ( final Cluster nextCandidateCluster , Map < Integer , Integer > targetPartitionsPerZone ) { HashMap < Integer , List < Integer > > numPartitionsPerNode = Maps . newHashMap ( ) ; for ( Integer zoneId : nextCandidateCluster ...
Determines how many primary partitions each node within each zone should have . The list of integers returned per zone is the same length as the number of nodes in that zone .
24,366
public static Pair < HashMap < Node , Integer > , HashMap < Node , Integer > > getDonorsAndStealersForBalance ( final Cluster nextCandidateCluster , Map < Integer , List < Integer > > numPartitionsPerNodePerZone ) { HashMap < Node , Integer > donorNodes = Maps . newHashMap ( ) ; HashMap < Node , Integer > stealerNodes ...
Assign target number of partitions per node to specific node IDs . Then separates Nodes into donorNodes and stealerNodes based on whether the node needs to donate or steal primary partitions .
24,367
public static Cluster repeatedlyBalanceContiguousPartitionsPerZone ( final Cluster nextCandidateCluster , final int maxContiguousPartitionsPerZone ) { System . out . println ( "Looping to evenly balance partitions across zones while limiting contiguous partitions" ) ; int repeatContigBalance = 10 ; Cluster returnCluste...
Loops over cluster and repeatedly tries to break up contiguous runs of partitions . After each phase of breaking up contiguous partitions random partitions are selected to move between zones to balance the number of partitions in each zone . The second phase may re - introduce contiguous partition runs in another zone ...
24,368
public static Cluster balanceContiguousPartitionsPerZone ( final Cluster nextCandidateCluster , final int maxContiguousPartitionsPerZone ) { System . out . println ( "Balance number of contiguous partitions within a zone." ) ; System . out . println ( "numPartitionsPerZone" ) ; for ( int zoneId : nextCandidateCluster ....
Ensures that no more than maxContiguousPartitionsPerZone partitions are contiguous within a single zone .
24,369
public static Cluster swapPartitions ( final Cluster nextCandidateCluster , final int nodeIdA , final int partitionIdA , final int nodeIdB , final int partitionIdB ) { Cluster returnCluster = Cluster . cloneCluster ( nextCandidateCluster ) ; returnCluster = UpdateClusterUtils . createUpdatedCluster ( returnCluster , no...
Swaps two specified partitions .
24,370
public static Cluster swapRandomPartitionsWithinZone ( final Cluster nextCandidateCluster , final int zoneId ) { Cluster returnCluster = Cluster . cloneCluster ( nextCandidateCluster ) ; Random r = new Random ( ) ; List < Integer > nodeIdsInZone = new ArrayList < Integer > ( nextCandidateCluster . getNodeIdsInZone ( zo...
Within a single zone swaps one random partition on one random node with another random partition on different random node .
24,371
public static Cluster randomShufflePartitions ( final Cluster nextCandidateCluster , final int randomSwapAttempts , final int randomSwapSuccesses , final List < Integer > randomSwapZoneIds , List < StoreDefinition > storeDefs ) { List < Integer > zoneIds = null ; if ( randomSwapZoneIds . isEmpty ( ) ) { zoneIds = new A...
Randomly shuffle partitions between nodes within every zone .
24,372
public static Cluster swapGreedyRandomPartitions ( final Cluster nextCandidateCluster , final List < Integer > nodeIds , final int greedySwapMaxPartitionsPerNode , final int greedySwapMaxPartitionsPerZone , List < StoreDefinition > storeDefs ) { System . out . println ( "GreedyRandom : nodeIds:" + nodeIds ) ; Cluster r...
For each node in specified zones tries swapping some minimum number of random partitions per node with some minimum number of random partitions from other specified nodes . Chooses the best swap in each iteration . Large values of the greedSwapMaxPartitions ... arguments make this method equivalent to comparing every p...
24,373
public static Cluster greedyShufflePartitions ( final Cluster nextCandidateCluster , final int greedyAttempts , final int greedySwapMaxPartitionsPerNode , final int greedySwapMaxPartitionsPerZone , List < Integer > greedySwapZoneIds , List < StoreDefinition > storeDefs ) { List < Integer > zoneIds = null ; if ( greedyS...
Within a single zone tries swapping some minimum number of random partitions per node with some minimum number of random partitions from other nodes within the zone . Chooses the best swap in each iteration . Large values of the greedSwapMaxPartitions ... arguments make this method equivalent to comparing every possibl...
24,374
protected void stopInner ( ) { if ( this . nettyServerChannel != null ) { this . nettyServerChannel . close ( ) ; } if ( allChannels != null ) { allChannels . close ( ) . awaitUninterruptibly ( ) ; } this . bootstrap . releaseExternalResources ( ) ; }
Closes the Netty Channel and releases all resources
24,375
protected int parseZoneId ( ) { int result = - 1 ; String zoneIdStr = this . request . getHeader ( RestMessageHeaders . X_VOLD_ZONE_ID ) ; if ( zoneIdStr != null ) { try { int zoneId = Integer . parseInt ( zoneIdStr ) ; if ( zoneId < 0 ) { logger . error ( "ZoneId cannot be negative. Assuming the default zone id." ) ; ...
Retrieve and validate the zone id value from the REST request . X - VOLD - Zone - Id is the zone id header .
24,376
protected void registerRequest ( RestRequestValidator requestValidator , ChannelHandlerContext ctx , MessageEvent messageEvent ) { CompositeVoldemortRequest < ByteArray , byte [ ] > requestObject = requestValidator . constructCompositeVoldemortRequestObject ( ) ; if ( requestObject != null ) { long now = System . curre...
Constructs a valid request and passes it on to the next handler . It also creates the Store object corresponding to the store name specified in the REST request .
24,377
private Pair < Cluster , List < StoreDefinition > > getCurrentClusterState ( ) { Versioned < Cluster > currentVersionedCluster = adminClient . rebalanceOps . getLatestCluster ( Utils . nodeListToNodeIdList ( Lists . newArrayList ( adminClient . getAdminClientCluster ( ) . getNodes ( ) ) ) ) ; Cluster cluster = currentV...
Probe the existing cluster to retrieve the current cluster xml and stores xml .
24,378
private void executePlan ( RebalancePlan rebalancePlan ) { logger . info ( "Starting to execute rebalance Plan!" ) ; int batchCount = 0 ; int partitionStoreCount = 0 ; long totalTimeMs = 0 ; List < RebalanceBatchPlan > entirePlan = rebalancePlan . getPlan ( ) ; int numBatches = entirePlan . size ( ) ; int numPartitionS...
Executes the rebalance plan . Does so batch - by - batch . Between each batch status is dumped to logger . info .
24,379
private void batchStatusLog ( int batchCount , int numBatches , int partitionStoreCount , int numPartitionStores , long totalTimeMs ) { double rate = 1 ; long estimatedTimeMs = 0 ; if ( numPartitionStores > 0 ) { rate = partitionStoreCount / numPartitionStores ; estimatedTimeMs = ( long ) ( totalTimeMs / rate ) - total...
Pretty print a progress update after each batch complete .
24,380
private void executeBatch ( int batchId , final RebalanceBatchPlan batchPlan ) { final Cluster batchCurrentCluster = batchPlan . getCurrentCluster ( ) ; final List < StoreDefinition > batchCurrentStoreDefs = batchPlan . getCurrentStoreDefs ( ) ; final Cluster batchFinalCluster = batchPlan . getFinalCluster ( ) ; final ...
Executes a batch plan .
24,381
private void proxyPause ( ) { logger . info ( "Pausing after cluster state has changed to allow proxy bridges to be established. " + "Will start rebalancing work on servers in " + proxyPauseSec + " seconds." ) ; try { Thread . sleep ( TimeUnit . SECONDS . toMillis ( proxyPauseSec ) ) ; } catch ( InterruptedException e ...
Pause between cluster change in metadata and starting server rebalancing work .
24,382
private void executeSubBatch ( final int batchId , RebalanceBatchPlanProgressBar progressBar , final Cluster batchRollbackCluster , final List < StoreDefinition > batchRollbackStoreDefs , final List < RebalanceTaskInfo > rebalanceTaskPlanList , boolean hasReadOnlyStores , boolean hasReadWriteStores , boolean finishedRe...
The smallest granularity of rebalancing where - in we move partitions for a sub - set of stores . Finally at the end of the movement the node is removed out of rebalance state
24,383
public static ConsistencyLevel determineConsistency ( Map < Value , Set < ClusterNode > > versionNodeSetMap , int replicationFactor ) { boolean fullyConsistent = true ; Value latestVersion = null ; for ( Map . Entry < Value , Set < ClusterNode > > versionNodeSetEntry : versionNodeSetMap . entrySet ( ) ) { Value value =...
Determine the consistency level of a key
24,384
public static void cleanIneligibleKeys ( Map < ByteArray , Map < Value , Set < ClusterNode > > > keyVersionNodeSetMap , int requiredWrite ) { Set < ByteArray > keysToDelete = new HashSet < ByteArray > ( ) ; for ( Map . Entry < ByteArray , Map < Value , Set < ClusterNode > > > entry : keyVersionNodeSetMap . entrySet ( )...
Determine if a key version is invalid by comparing the version s existence and required writes configuration
24,385
public static String keyVersionToString ( ByteArray key , Map < Value , Set < ClusterNode > > versionMap , String storeName , Integer partitionId ) { StringBuilder record = new StringBuilder ( ) ; for ( Map . Entry < Value , Set < ClusterNode > > versionSet : versionMap . entrySet ( ) ) { Value value = versionSet . get...
Convert a key - version - nodeSet information to string
24,386
public void sendResponse ( StoreStats performanceStats , boolean isFromLocalZone , long startTimeInMs ) throws Exception { ChannelBuffer responseContent = ChannelBuffers . dynamicBuffer ( this . responseValue . length ) ; responseContent . writeBytes ( responseValue ) ; HttpResponse response = new DefaultHttpResponse (...
Sends a normal HTTP response containing the serialization information in a XML format
24,387
public FailureDetectorConfig setCluster ( Cluster cluster ) { Utils . notNull ( cluster ) ; this . cluster = cluster ; if ( this . connectionVerifier instanceof AdminConnectionVerifier ) { ( ( AdminConnectionVerifier ) connectionVerifier ) . setCluster ( cluster ) ; } return this ; }
Look at the comments on cluster variable to see why this is problematic
24,388
public synchronized FailureDetectorConfig setNodes ( Collection < Node > nodes ) { Utils . notNull ( nodes ) ; this . nodes = new HashSet < Node > ( nodes ) ; return this ; }
Assigns a list of nodes in the cluster represented by this failure detector configuration .
24,389
public boolean hasNodeWithId ( int nodeId ) { Node node = nodesById . get ( nodeId ) ; if ( node == null ) { return false ; } return true ; }
Given a cluster and a node id checks if the node exists
24,390
public static Cluster cloneCluster ( Cluster cluster ) { return new Cluster ( cluster . getName ( ) , new ArrayList < Node > ( cluster . getNodes ( ) ) , new ArrayList < Zone > ( cluster . getZones ( ) ) ) ; }
Clones the cluster by constructing a new one with same name partition layout and nodes .
24,391
public AdminClient checkout ( ) { if ( isClosed . get ( ) ) { throw new IllegalStateException ( "Pool is closing" ) ; } AdminClient client ; while ( ( client = clientCache . poll ( ) ) != null ) { if ( ! client . isClusterModified ( ) ) { return client ; } else { client . close ( ) ; } } return createAdminClient ( ) ; ...
get an AdminClient from the cache if exists if not create new one and return it . This method is non - blocking .
24,392
public void checkin ( AdminClient client ) { if ( isClosed . get ( ) ) { throw new IllegalStateException ( "Pool is closing" ) ; } if ( client == null ) { throw new IllegalArgumentException ( "client is null" ) ; } boolean isCheckedIn = clientCache . offer ( client ) ; if ( ! isCheckedIn ) { client . close ( ) ; } }
submit the adminClient after usage is completed . Behavior is undefined if checkin is called with objects not retrieved from checkout .
24,393
public void close ( ) { boolean isPreviouslyClosed = isClosed . getAndSet ( true ) ; if ( isPreviouslyClosed ) { return ; } AdminClient client ; while ( ( client = clientCache . poll ( ) ) != null ) { client . close ( ) ; } }
close the AdminPool if no long required . After closed all public methods will throw IllegalStateException
24,394
public static String compressedListOfPartitionsInZone ( final Cluster cluster , int zoneId ) { Map < Integer , Integer > idToRunLength = PartitionBalanceUtils . getMapOfContiguousPartitions ( cluster , zoneId ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "[" ) ; boolean first = true ; Set < Integer > sor...
Compress contiguous partitions into format e - i instead of e f g h i . This helps illustrate contiguous partitions within a zone .
24,395
public static Map < Integer , Integer > getMapOfContiguousPartitions ( final Cluster cluster , int zoneId ) { List < Integer > partitionIds = new ArrayList < Integer > ( cluster . getPartitionIdsInZone ( zoneId ) ) ; Map < Integer , Integer > partitionIdToRunLength = Maps . newHashMap ( ) ; if ( partitionIds . isEmpty ...
Determines run length for each initial partition ID . Note that a contiguous run may wrap around the end of the ring .
24,396
public static Map < Integer , Integer > getMapOfContiguousPartitionRunLengths ( final Cluster cluster , int zoneId ) { Map < Integer , Integer > idToRunLength = getMapOfContiguousPartitions ( cluster , zoneId ) ; Map < Integer , Integer > runLengthToCount = Maps . newHashMap ( ) ; if ( idToRunLength . isEmpty ( ) ) { r...
Determines a histogram of contiguous runs of partitions within a zone . I . e . for each run length of contiguous partitions how many such runs are there .
24,397
public static String getPrettyMapOfContiguousPartitionRunLengths ( final Cluster cluster , int zoneId ) { Map < Integer , Integer > runLengthToCount = getMapOfContiguousPartitionRunLengths ( cluster , zoneId ) ; String prettyHistogram = "[" ; boolean first = true ; Set < Integer > runLengths = new TreeSet < Integer > (...
Pretty prints the output of getMapOfContiguousPartitionRunLengths
24,398
public static String getHotPartitionsDueToContiguity ( final Cluster cluster , int hotContiguityCutoff ) { StringBuilder sb = new StringBuilder ( ) ; for ( int zoneId : cluster . getZoneIds ( ) ) { Map < Integer , Integer > idToRunLength = getMapOfContiguousPartitions ( cluster , zoneId ) ; for ( Integer initialPartiti...
Returns a pretty printed string of nodes that host specific hot partitions where hot is defined as following a contiguous run of partitions of some length in another zone .
24,399
public static String analyzeInvalidMetadataRate ( final Cluster currentCluster , List < StoreDefinition > currentStoreDefs , final Cluster finalCluster , List < StoreDefinition > finalStoreDefs ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Dump of invalid metadata rates per zone" ) . append ( Utils . NE...
Compares current cluster with final cluster . Uses pertinent store defs for each cluster to determine if a node that hosts a zone - primary in the current cluster will no longer host any zone - nary in the final cluster . This check is the precondition for a server returning an invalid metadata exception to a client on...