idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
148,000 | 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 . |
148,001 | 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 |
148,002 | 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 |
148,003 | 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 |
148,004 | 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 |
148,005 | 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 . |
148,006 | 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 . |
148,007 | 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 |
148,008 | 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 . |
148,009 | 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 . |
148,010 | 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 |
148,011 | 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 |
148,012 | 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 |
148,013 | 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 |
148,014 | 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 |
148,015 | 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 |
148,016 | 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 |
148,017 | 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 |
148,018 | 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 |
148,019 | 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 . |
148,020 | 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 . |
148,021 | @ 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 |
148,022 | @ 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 |
148,023 | @ 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 |
148,024 | @ 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 |
148,025 | 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 |
148,026 | 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 |
148,027 | 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 |
148,028 | 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 |
148,029 | 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 |
148,030 | 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 |
148,031 | 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 . |
148,032 | 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 . |
148,033 | 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 . |
148,034 | 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 |
148,035 | 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 |
148,036 | 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 |
148,037 | 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 |
148,038 | 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 |
148,039 | 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 |
148,040 | 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 . |
148,041 | public Integer getMasterPartition ( byte [ ] key ) { return abs ( hash . hash ( key ) ) % ( Math . max ( 1 , this . partitionToNode . length ) ) ; } | Obtain the master partition for a given key |
148,042 | 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 . |
148,043 | 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 . |
148,044 | 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 . |
148,045 | @ 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 |
148,046 | @ 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 |
148,047 | 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 |
148,048 | 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 |
148,049 | 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 |
148,050 | 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 |
148,051 | 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 . |
148,052 | 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 |
148,053 | @ 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 |
148,054 | 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 . |
148,055 | 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 . |
148,056 | 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 . |
148,057 | 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 ... |
148,058 | 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 . |
148,059 | 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 . |
148,060 | 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 . |
148,061 | 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 . |
148,062 | 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... |
148,063 | 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... |
148,064 | 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 |
148,065 | 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 . |
148,066 | 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 . |
148,067 | 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 . |
148,068 | 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 . |
148,069 | 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 . |
148,070 | 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 . |
148,071 | 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 . |
148,072 | 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 |
148,073 | 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 |
148,074 | 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 |
148,075 | 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 |
148,076 | 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 |
148,077 | 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 |
148,078 | 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 . |
148,079 | 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 |
148,080 | 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 . |
148,081 | 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 . |
148,082 | 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 . |
148,083 | 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 |
148,084 | 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 . |
148,085 | 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 . |
148,086 | 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 . |
148,087 | 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 |
148,088 | 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 . |
148,089 | 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... |
148,090 | public static < K , V > QueuedKeyedResourcePool < K , V > create ( ResourceFactory < K , V > factory , ResourcePoolConfig config ) { return new QueuedKeyedResourcePool < K , V > ( factory , config ) ; } | Create a new queued pool with key type K request type R and value type V . |
148,091 | public static < K , V > QueuedKeyedResourcePool < K , V > create ( ResourceFactory < K , V > factory ) { return create ( factory , new ResourcePoolConfig ( ) ) ; } | Create a new queued pool using the defaults for key of type K request of type R and value of Type V . |
148,092 | public V internalNonBlockingGet ( K key ) throws Exception { Pool < V > resourcePool = getResourcePoolForKey ( key ) ; return attemptNonBlockingCheckout ( key , resourcePool ) ; } | Used only for unit testing . Please do not use this method in other ways . |
148,093 | private AsyncResourceRequest < V > getNextUnexpiredResourceRequest ( Queue < AsyncResourceRequest < V > > requestQueue ) { AsyncResourceRequest < V > resourceRequest = requestQueue . poll ( ) ; while ( resourceRequest != null ) { if ( resourceRequest . getDeadlineNs ( ) < System . nanoTime ( ) ) { resourceRequest . han... | Pops resource requests off the queue until queue is empty or an unexpired resource request is found . Invokes . handleTimeout on all expired resource requests popped off the queue . |
148,094 | private boolean processQueue ( K key ) { Queue < AsyncResourceRequest < V > > requestQueue = getRequestQueueForKey ( key ) ; if ( requestQueue . isEmpty ( ) ) { return false ; } Pool < V > resourcePool = getResourcePoolForKey ( key ) ; V resource = null ; Exception ex = null ; try { resource = attemptNonBlockingCheckou... | Attempts to checkout a resource so that one queued request can be serviced . |
148,095 | public void checkin ( K key , V resource ) { super . checkin ( key , resource ) ; processQueueLoop ( key ) ; } | Check the given resource back into the pool |
148,096 | protected void destroyRequest ( AsyncResourceRequest < V > resourceRequest ) { if ( resourceRequest != null ) { try { Exception e = new UnreachableStoreException ( "Client request was terminated while waiting in the queue." ) ; resourceRequest . handleException ( e ) ; } catch ( Exception ex ) { logger . error ( "Excep... | A safe wrapper to destroy the given resource request . |
148,097 | private void destroyRequestQueue ( Queue < AsyncResourceRequest < V > > requestQueue ) { if ( requestQueue != null ) { AsyncResourceRequest < V > resourceRequest = requestQueue . poll ( ) ; while ( resourceRequest != null ) { destroyRequest ( resourceRequest ) ; resourceRequest = requestQueue . poll ( ) ; } } } | Destroys all resource requests in requestQueue . |
148,098 | public int getRegisteredResourceRequestCount ( K key ) { if ( requestQueueMap . containsKey ( key ) ) { Queue < AsyncResourceRequest < V > > requestQueue = getRequestQueueForExistingKey ( key ) ; if ( requestQueue != null ) { return requestQueue . size ( ) ; } } return 0 ; } | Count the number of queued resource requests for a specific pool . |
148,099 | public int getRegisteredResourceRequestCount ( ) { int count = 0 ; for ( Entry < K , Queue < AsyncResourceRequest < V > > > entry : this . requestQueueMap . entrySet ( ) ) { count += entry . getValue ( ) . size ( ) ; } return count ; } | Count the total number of queued resource requests for all queues . The result is approximate in the face of concurrency since individual queues can change size during the aggregate count . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.