idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
24,400
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 .
24,401
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 .
24,402
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 .
24,403
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 .
24,404
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 .
24,405
public void checkin ( K key , V resource ) { super . checkin ( key , resource ) ; processQueueLoop ( key ) ; }
Check the given resource back into the pool
24,406
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 .
24,407
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 .
24,408
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 .
24,409
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 .
24,410
protected void populateTasksByStealer ( List < StealerBasedRebalanceTask > sbTaskList ) { for ( StealerBasedRebalanceTask task : sbTaskList ) { if ( task . getStealInfos ( ) . size ( ) != 1 ) { throw new VoldemortException ( "StealerBasedRebalanceTasks should have a list of RebalancePartitionsInfo of length 1." ) ; } R...
Go over the task list and create a map of stealerId - > Tasks
24,411
protected synchronized StealerBasedRebalanceTask scheduleNextTask ( boolean executeService ) { if ( doneSignal . getCount ( ) == 0 ) { logger . info ( "All tasks completion signaled... returning" ) ; return null ; } if ( this . numTasksExecuting >= maxParallelRebalancing ) { logger . info ( "Executing more tasks than [...
Schedule at most one task .
24,412
public synchronized void addNodesToWorkerList ( List < Integer > nodeIds ) { nodeIdsWithWork . addAll ( nodeIds ) ; logger . info ( "Node IDs with work: " + nodeIdsWithWork + " Newly added nodes " + nodeIds ) ; }
Add nodes to the workers list
24,413
public synchronized void doneTask ( int stealerId , int donorId ) { removeNodesFromWorkerList ( Arrays . asList ( stealerId , donorId ) ) ; numTasksExecuting -- ; doneSignal . countDown ( ) ; scheduleMoreTasks ( ) ; }
Method must be invoked upon completion of a rebalancing task . It is the task s responsibility to do so .
24,414
private List < Long > collectLongMetric ( String metricGetterName ) { List < Long > vals = new ArrayList < Long > ( ) ; for ( BdbEnvironmentStats envStats : environmentStatsTracked ) { vals . add ( ( Long ) ReflectUtils . callMethod ( envStats , BdbEnvironmentStats . class , metricGetterName , new Class < ? > [ 0 ] , n...
Calls the provided metric getter on all the tracked environments and obtains their values
24,415
public static Iterable < String > toHexStrings ( Iterable < ByteArray > arrays ) { ArrayList < String > ret = new ArrayList < String > ( ) ; for ( ByteArray array : arrays ) ret . add ( ByteUtils . toHexString ( array . get ( ) ) ) ; return ret ; }
Translate the each ByteArray in an iterable into a hexadecimal string
24,416
public void sendResponse ( StoreStats performanceStats , boolean isFromLocalZone , long startTimeInMs ) throws Exception { MimeMessage message = new MimeMessage ( Session . getDefaultInstance ( new Properties ( ) ) ) ; MimeMultipart multiPart = new MimeMultipart ( ) ; ByteArrayOutputStream outputStream = new ByteArrayO...
Sends a multipart response . Each body part represents a versioned value of the given key .
24,417
public String getPublicConfigValue ( String key ) throws ConfigurationException { if ( ! allProps . containsKey ( key ) ) { throw new UndefinedPropertyException ( "The requested config key does not exist." ) ; } if ( restrictedConfigs . contains ( key ) ) { throw new ConfigurationException ( "The requested config key i...
This is a generic function for retrieving any config value . The returned value is the one the server is operating with no matter whether it comes from defaults or from the user - supplied configuration .
24,418
private void checkRateLimit ( String quotaKey , Tracked trackedOp ) { String quotaValue = null ; try { if ( ! metadataStore . getQuotaEnforcingEnabledUnlocked ( ) ) { return ; } quotaValue = quotaStore . cacheGet ( quotaKey ) ; if ( quotaValue == null ) { return ; } float currentRate = getThroughput ( trackedOp ) ; flo...
Ensure the current throughput levels for the tracked operation does not exceed set quota limits . Throws an exception if exceeded quota .
24,419
public synchronized void submitOperation ( int requestId , AsyncOperation operation ) { if ( this . operations . containsKey ( requestId ) ) throw new VoldemortException ( "Request " + requestId + " already submitted to the system" ) ; this . operations . put ( requestId , operation ) ; scheduler . scheduleNow ( operat...
Submit a operations . Throw a run time exception if the operations is already submitted
24,420
public synchronized boolean isComplete ( int requestId , boolean remove ) { if ( ! operations . containsKey ( requestId ) ) throw new VoldemortException ( "No operation with id " + requestId + " found" ) ; if ( operations . get ( requestId ) . getStatus ( ) . isComplete ( ) ) { if ( logger . isDebugEnabled ( ) ) logger...
Check if the an operation is done or not .
24,421
@ JmxOperation ( description = "Retrieve operation status" ) public String getStatus ( int id ) { try { return getOperationStatus ( id ) . toString ( ) ; } catch ( VoldemortException e ) { return "No operation with id " + id + " found" ; } }
Wrap getOperationStatus to avoid throwing exception over JMX
24,422
public List < Integer > getAsyncOperationList ( boolean showCompleted ) { Set < Integer > keySet = ImmutableSet . copyOf ( operations . keySet ( ) ) ; if ( showCompleted ) return new ArrayList < Integer > ( keySet ) ; List < Integer > keyList = new ArrayList < Integer > ( ) ; for ( int key : keySet ) { AsyncOperation o...
Get list of asynchronous operations on this node . By default only the pending operations are returned .
24,423
public String stopAsyncOperation ( int requestId ) { try { stopOperation ( requestId ) ; } catch ( VoldemortException e ) { return e . getMessage ( ) ; } return "Stopping operation " + requestId ; }
Wrapper to avoid throwing an exception over JMX
24,424
public void updateStoreDefinition ( StoreDefinition storeDef ) { this . storeDef = storeDef ; if ( storeDef . hasRetentionPeriod ( ) ) this . retentionTimeMs = storeDef . getRetentionDays ( ) * Time . MS_PER_DAY ; }
Updates the store definition object and the retention time based on the updated store definition
24,425
private List < Versioned < byte [ ] > > filterExpiredEntries ( ByteArray key , List < Versioned < byte [ ] > > vals ) { Iterator < Versioned < byte [ ] > > valsIterator = vals . iterator ( ) ; while ( valsIterator . hasNext ( ) ) { Versioned < byte [ ] > val = valsIterator . next ( ) ; VectorClock clock = ( VectorClock...
Performs the filtering of the expired entries based on retention time . Optionally deletes them also
24,426
private synchronized void flushData ( ) { BufferedWriter writer = null ; try { writer = new BufferedWriter ( new FileWriter ( new File ( this . inputPath ) ) ) ; for ( String key : this . metadataMap . keySet ( ) ) { writer . write ( NEW_PROPERTY_SEPARATOR + key . toString ( ) + "]" + NEW_LINE ) ; writer . write ( this...
Flush the in - memory data to the file
24,427
public static String getSerializedVectorClock ( VectorClock vc ) { VectorClockWrapper vcWrapper = new VectorClockWrapper ( vc ) ; String serializedVC = "" ; try { serializedVC = mapper . writeValueAsString ( vcWrapper ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return serializedVC ; }
Function to serialize the given Vector clock into a string . If something goes wrong it returns an empty string .
24,428
public static String getSerializedVectorClocks ( List < VectorClock > vectorClocks ) { List < VectorClockWrapper > vectorClockWrappers = new ArrayList < VectorClockWrapper > ( ) ; for ( VectorClock vc : vectorClocks ) { vectorClockWrappers . add ( new VectorClockWrapper ( vc ) ) ; } String serializedVC = "" ; try { ser...
Function to serialize the given list of Vector clocks into a string . If something goes wrong it returns an empty string .
24,429
public static String constructSerializerInfoXml ( StoreDefinition storeDefinition ) { Element store = new Element ( StoreDefinitionsMapper . STORE_ELMT ) ; store . addContent ( new Element ( StoreDefinitionsMapper . STORE_NAME_ELMT ) . setText ( storeDefinition . getName ( ) ) ) ; Element keySerializer = new Element ( ...
Given a storedefinition constructs the xml string to be sent out in response to a schemata fetch request
24,430
public void updateMetadataVersions ( ) { Properties versionProps = MetadataVersionStoreUtils . getProperties ( this . systemStoreRepository . getMetadataVersionStore ( ) ) ; Long newVersion = fetchNewVersion ( SystemStoreConstants . CLUSTER_VERSION_KEY , null , versionProps ) ; if ( newVersion != null ) { this . curren...
Fetch the latest versions for cluster metadata
24,431
public static void validateClusterStores ( final Cluster cluster , final List < StoreDefinition > storeDefs ) { for ( StoreDefinition storeDefinition : storeDefs ) { new StoreRoutingPlan ( cluster , storeDefinition ) ; } return ; }
Verify store definitions are congruent with cluster definition .
24,432
public static void validateCurrentFinalCluster ( final Cluster currentCluster , final Cluster finalCluster ) { validateClusterPartitionCounts ( currentCluster , finalCluster ) ; validateClusterNodeState ( currentCluster , finalCluster ) ; return ; }
A final cluster ought to be a super set of current cluster . I . e . existing node IDs ought to map to same server but partition layout can have changed and there may exist new nodes .
24,433
public static void validateInterimFinalCluster ( final Cluster interimCluster , final Cluster finalCluster ) { validateClusterPartitionCounts ( interimCluster , finalCluster ) ; validateClusterZonesSame ( interimCluster , finalCluster ) ; validateClusterNodeCounts ( interimCluster , finalCluster ) ; validateClusterNode...
Interim and final clusters ought to have same partition counts same zones and same node state . Partitions per node may of course differ .
24,434
public static void validateClusterPartitionCounts ( final Cluster lhs , final Cluster rhs ) { if ( lhs . getNumberOfPartitions ( ) != rhs . getNumberOfPartitions ( ) ) throw new VoldemortException ( "Total number of partitions should be equal [ lhs cluster (" + lhs . getNumberOfPartitions ( ) + ") not equal to rhs clus...
Confirms that both clusters have the same number of total partitions .
24,435
public static void validateClusterPartitionState ( final Cluster subsetCluster , final Cluster supersetCluster ) { if ( ! supersetCluster . getNodeIds ( ) . containsAll ( subsetCluster . getNodeIds ( ) ) ) { throw new VoldemortException ( "Superset cluster does not contain all nodes from subset cluster[ subset cluster ...
Confirm that all nodes shared between clusters host exact same partition IDs and that nodes only in the super set cluster have no partition IDs .
24,436
public static void validateClusterZonesSame ( final Cluster lhs , final Cluster rhs ) { Set < Zone > lhsSet = new HashSet < Zone > ( lhs . getZones ( ) ) ; Set < Zone > rhsSet = new HashSet < Zone > ( rhs . getZones ( ) ) ; if ( ! lhsSet . equals ( rhsSet ) ) throw new VoldemortException ( "Zones are not the same [ lhs...
Confirms that both clusters have the same set of zones defined .
24,437
public static void validateClusterNodeCounts ( final Cluster lhs , final Cluster rhs ) { if ( ! lhs . getNodeIds ( ) . equals ( rhs . getNodeIds ( ) ) ) { throw new VoldemortException ( "Node ids are not the same [ lhs cluster node ids (" + lhs . getNodeIds ( ) + ") not equal to rhs cluster node ids (" + rhs . getNodeI...
Confirms that both clusters have the same number of nodes by comparing set of node Ids between clusters .
24,438
public static Cluster vacateZone ( Cluster currentCluster , int dropZoneId ) { Cluster returnCluster = Cluster . cloneCluster ( currentCluster ) ; for ( Integer nodeId : currentCluster . getNodeIdsInZone ( dropZoneId ) ) { for ( Integer partitionId : currentCluster . getNodeById ( nodeId ) . getPartitionIds ( ) ) { int...
Given the current cluster and a zone id that needs to be dropped this method will remove all partitions from the zone that is being dropped and move it to the existing zones . The partitions are moved intelligently so as not to avoid any data movement in the existing zones .
24,439
public static Cluster dropZone ( Cluster intermediateCluster , int dropZoneId ) { Set < Node > survivingNodes = new HashSet < Node > ( ) ; for ( int nodeId : intermediateCluster . getNodeIds ( ) ) { if ( intermediateCluster . getNodeById ( nodeId ) . getZoneId ( ) != dropZoneId ) { survivingNodes . add ( intermediateCl...
Given a interim cluster with a previously vacated zone constructs a new cluster object with the drop zone completely removed
24,440
public static List < Integer > getStolenPrimaryPartitions ( final Cluster currentCluster , final Cluster finalCluster , final int stealNodeId ) { List < Integer > finalList = new ArrayList < Integer > ( finalCluster . getNodeById ( stealNodeId ) . getPartitionIds ( ) ) ; List < Integer > currentList = new ArrayList < I...
For a particular stealer node find all the primary partitions tuples it will steal .
24,441
public static List < StoreDefinition > validateRebalanceStore ( List < StoreDefinition > storeDefList ) { List < StoreDefinition > returnList = new ArrayList < StoreDefinition > ( storeDefList . size ( ) ) ; for ( StoreDefinition def : storeDefList ) { if ( ! def . isView ( ) && ! canRebalanceList . contains ( def . ge...
Given a list of store definitions makes sure that rebalance supports all of them . If not it throws an error .
24,442
public static void dumpClusters ( Cluster currentCluster , Cluster finalCluster , String outputDirName , String filePrefix ) { dumpClusterToFile ( outputDirName , filePrefix + currentClusterFileName , currentCluster ) ; dumpClusterToFile ( outputDirName , filePrefix + finalClusterFileName , finalCluster ) ; }
Given the initial and final cluster dumps it into the output directory
24,443
public static void dumpClusters ( Cluster currentCluster , Cluster finalCluster , String outputDirName ) { dumpClusters ( currentCluster , finalCluster , outputDirName , "" ) ; }
Given the current and final cluster dumps it into the output directory
24,444
public static void dumpClusterToFile ( String outputDirName , String fileName , Cluster cluster ) { if ( outputDirName != null ) { File outputDir = new File ( outputDirName ) ; if ( ! outputDir . exists ( ) ) { Utils . mkdirs ( outputDir ) ; } try { FileUtils . writeStringToFile ( new File ( outputDirName , fileName ) ...
Prints a cluster xml to a file .
24,445
public static void dumpStoreDefsToFile ( String outputDirName , String fileName , List < StoreDefinition > storeDefs ) { if ( outputDirName != null ) { File outputDir = new File ( outputDirName ) ; if ( ! outputDir . exists ( ) ) { Utils . mkdirs ( outputDir ) ; } try { FileUtils . writeStringToFile ( new File ( output...
Prints a stores xml to a file .
24,446
public static void dumpAnalysisToFile ( String outputDirName , String baseFileName , PartitionBalance partitionBalance ) { if ( outputDirName != null ) { File outputDir = new File ( outputDirName ) ; if ( ! outputDir . exists ( ) ) { Utils . mkdirs ( outputDir ) ; } try { FileUtils . writeStringToFile ( new File ( outp...
Prints a balance analysis to a file .
24,447
public static void dumpPlanToFile ( String outputDirName , RebalancePlan plan ) { if ( outputDirName != null ) { File outputDir = new File ( outputDirName ) ; if ( ! outputDir . exists ( ) ) { Utils . mkdirs ( outputDir ) ; } try { FileUtils . writeStringToFile ( new File ( outputDirName , "plan.out" ) , plan . toStrin...
Prints the plan to a file .
24,448
public static List < RebalanceTaskInfo > filterTaskPlanWithStores ( List < RebalanceTaskInfo > existingPlanList , List < StoreDefinition > storeDefs ) { List < RebalanceTaskInfo > plans = Lists . newArrayList ( ) ; List < String > storeNames = StoreDefinitionUtils . getStoreNames ( storeDefs ) ; for ( RebalanceTaskInfo...
Given a list of partition plans and a set of stores copies the store names to every individual plan and creates a new list
24,449
public static void executorShutDown ( ExecutorService executorService , long timeOutSec ) { try { executorService . shutdown ( ) ; executorService . awaitTermination ( timeOutSec , TimeUnit . SECONDS ) ; } catch ( Exception e ) { logger . warn ( "Error while stoping executor service." , e ) ; } }
Wait to shutdown service
24,450
public List < T > resolveConflicts ( List < T > values ) { if ( values . size ( ) > 1 ) return values ; else return Collections . singletonList ( values . get ( 0 ) ) ; }
Arbitrarily resolve the inconsistency by choosing the first object if there is one .
24,451
public static < K , V , T > List < Versioned < V > > get ( Store < K , V , T > storageEngine , K key , T transform ) { Map < K , List < Versioned < V > > > result = storageEngine . getAll ( Collections . singleton ( key ) , Collections . singletonMap ( key , transform ) ) ; if ( result . size ( ) > 0 ) return result . ...
Implements get by delegating to getAll .
24,452
public static < K , V , T > Map < K , List < Versioned < V > > > getAll ( Store < K , V , T > storageEngine , Iterable < K > keys , Map < K , T > transforms ) { Map < K , List < Versioned < V > > > result = newEmptyHashMap ( keys ) ; for ( K key : keys ) { List < Versioned < V > > value = storageEngine . get ( key , tr...
Implements getAll by delegating to get .
24,453
public static < K , V > HashMap < K , V > newEmptyHashMap ( Iterable < ? > iterable ) { if ( iterable instanceof Collection < ? > ) return Maps . newHashMapWithExpectedSize ( ( ( Collection < ? > ) iterable ) . size ( ) ) ; return Maps . newHashMap ( ) ; }
Returns an empty map with expected size matching the iterable size if it s of type Collection . Otherwise an empty map with the default size is returned .
24,454
public static void assertValidMetadata ( ByteArray key , RoutingStrategy routingStrategy , Node currentNode ) { List < Node > nodes = routingStrategy . routeRequest ( key . get ( ) ) ; for ( Node node : nodes ) { if ( node . getId ( ) == currentNode . getId ( ) ) { return ; } } throw new InvalidMetadataException ( "Cli...
Check if the current node is part of routing request based on cluster . xml or throw an exception .
24,455
public static void assertValidNode ( MetadataStore metadataStore , Integer nodeId ) { if ( ! metadataStore . getCluster ( ) . hasNodeWithId ( nodeId ) ) { throw new InvalidMetadataException ( "NodeId " + nodeId + " is not or no longer in this cluster" ) ; } }
Check if the the nodeId is present in the cluster managed by the metadata store or throw an exception .
24,456
@ SuppressWarnings ( "unchecked" ) public static < T > Serializer < T > unsafeGetSerializer ( SerializerFactory serializerFactory , SerializerDefinition serializerDefinition ) { return ( Serializer < T > ) serializerFactory . getSerializer ( serializerDefinition ) ; }
This is a temporary measure until we have a type - safe solution for retrieving serializers from a SerializerFactory . It avoids warnings all over the codebase while making it easy to verify who calls it .
24,457
public static StoreDefinition getStoreDef ( List < StoreDefinition > list , String name ) { for ( StoreDefinition def : list ) if ( def . getName ( ) . equals ( name ) ) return def ; return null ; }
Get a store definition from the given list of store definitions
24,458
public static List < String > getStoreNames ( List < StoreDefinition > list , boolean ignoreViews ) { List < String > storeNameSet = new ArrayList < String > ( ) ; for ( StoreDefinition def : list ) if ( ! def . isView ( ) || ! ignoreViews ) storeNameSet . add ( def . getName ( ) ) ; return storeNameSet ; }
Get the list of store names from a list of store definitions
24,459
private void plan ( ) { final TreeMultimap < Integer , Integer > stealerToStolenPrimaryPartitions = TreeMultimap . create ( ) ; if ( outputDir != null ) RebalanceUtils . dumpClusters ( currentCluster , finalCluster , outputDir ) ; for ( Node stealerNode : finalCluster . getNodes ( ) ) { List < Integer > stolenPrimaryPa...
Create a plan . The plan consists of batches . Each batch involves the movement of no more than batchSize primary partitions . The movement of a single primary partition may require migration of other n - ary replicas and potentially deletions . Migrating a primary or n - ary partition requires migrating one partition ...
24,460
private String storageOverhead ( Map < Integer , Integer > finalNodeToOverhead ) { double maxOverhead = Double . MIN_VALUE ; PartitionBalance pb = new PartitionBalance ( currentCluster , currentStoreDefs ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Per-node store-overhead:" ) . append ( Utils . NEWLINE...
Determines storage overhead and returns pretty printed summary .
24,461
public static Boolean askConfirm ( Boolean confirm , String opDesc ) throws IOException { if ( confirm ) { System . out . println ( "Confirmed " + opDesc + " in command-line." ) ; return true ; } else { System . out . println ( "Are you sure you want to " + opDesc + "? (yes/no)" ) ; BufferedReader buffer = new Buffered...
Utility function that pauses and asks for confirmation on dangerous operations .
24,462
public static List < String > getValueList ( List < String > valuePairs , String delim ) { List < String > valueList = Lists . newArrayList ( ) ; for ( String valuePair : valuePairs ) { String [ ] value = valuePair . split ( delim , 2 ) ; if ( value . length != 2 ) throw new VoldemortException ( "Invalid argument pair:...
Utility function that gives list of values from list of value - pair strings .
24,463
public static < V > Map < V , V > convertListToMap ( List < V > list ) { Map < V , V > map = new HashMap < V , V > ( ) ; if ( list . size ( ) % 2 != 0 ) throw new VoldemortException ( "Failed to convert list to map." ) ; for ( int i = 0 ; i < list . size ( ) ; i += 2 ) { map . put ( list . get ( i ) , list . get ( i + ...
Utility function that converts a list to a map .
24,464
public static AdminClient getAdminClient ( String url ) { ClientConfig config = new ClientConfig ( ) . setBootstrapUrls ( url ) . setConnectionTimeout ( 5 , TimeUnit . SECONDS ) ; AdminClientConfig adminConfig = new AdminClientConfig ( ) . setAdminSocketTimeoutSec ( 5 ) ; return new AdminClient ( adminConfig , config )...
Utility function that constructs AdminClient .
24,465
public static List < Integer > getAllNodeIds ( AdminClient adminClient ) { List < Integer > nodeIds = Lists . newArrayList ( ) ; for ( Integer nodeId : adminClient . getAdminClientCluster ( ) . getNodeIds ( ) ) { nodeIds . add ( nodeId ) ; } return nodeIds ; }
Utility function that fetches node ids .
24,466
public static List < String > getAllUserStoreNamesOnNode ( AdminClient adminClient , Integer nodeId ) { List < String > storeNames = Lists . newArrayList ( ) ; List < StoreDefinition > storeDefinitionList = adminClient . metadataMgmtOps . getRemoteStoreDefList ( nodeId ) . getValue ( ) ; for ( StoreDefinition storeDefi...
Utility function that fetches all stores on a node .
24,467
public static void validateUserStoreNamesOnNode ( AdminClient adminClient , Integer nodeId , List < String > storeNames ) { List < StoreDefinition > storeDefList = adminClient . metadataMgmtOps . getRemoteStoreDefList ( nodeId ) . getValue ( ) ; Map < String , Boolean > existingStoreNames = new HashMap < String , Boole...
Utility function that checks if store names are valid on a node .
24,468
public static List < Integer > getAllPartitions ( AdminClient adminClient ) { List < Integer > partIds = Lists . newArrayList ( ) ; partIds = Lists . newArrayList ( ) ; for ( Node node : adminClient . getAdminClientCluster ( ) . getNodes ( ) ) { partIds . addAll ( node . getPartitionIds ( ) ) ; } return partIds ; }
Utility function that fetches partitions .
24,469
public static List < QuotaType > getQuotaTypes ( List < String > strQuotaTypes ) { if ( strQuotaTypes . size ( ) < 1 ) { throw new VoldemortException ( "Quota type not specified." ) ; } List < QuotaType > quotaTypes ; if ( strQuotaTypes . size ( ) == 1 && strQuotaTypes . get ( 0 ) . equals ( AdminToolUtils . QUOTATYPE_...
Utility function that fetches quota types .
24,470
public static File createDir ( String dir ) { File directory = null ; if ( dir != null ) { directory = new File ( dir ) ; if ( ! ( directory . exists ( ) || directory . mkdir ( ) ) ) { Utils . croak ( "Can't find or create directory " + dir ) ; } } return directory ; }
Utility function that creates directory .
24,471
public static Map < String , StoreDefinition > getSystemStoreDefMap ( ) { Map < String , StoreDefinition > sysStoreDefMap = Maps . newHashMap ( ) ; List < StoreDefinition > storesDefs = SystemStoreConstants . getAllSystemStoreDefs ( ) ; for ( StoreDefinition def : storesDefs ) { sysStoreDefMap . put ( def . getName ( )...
Utility function that fetches system store definitions
24,472
public static Map < String , StoreDefinition > getUserStoreDefMapOnNode ( AdminClient adminClient , Integer nodeId ) { List < StoreDefinition > storeDefinitionList = adminClient . metadataMgmtOps . getRemoteStoreDefList ( nodeId ) . getValue ( ) ; Map < String , StoreDefinition > storeDefinitionMap = Maps . newHashMap ...
Utility function that fetches user defined store definitions
24,473
public static RebalanceTaskInfo decodeRebalanceTaskInfoMap ( VAdminProto . RebalanceTaskInfoMap rebalanceTaskInfoMap ) { RebalanceTaskInfo rebalanceTaskInfo = new RebalanceTaskInfo ( rebalanceTaskInfoMap . getStealerId ( ) , rebalanceTaskInfoMap . getDonorId ( ) , decodeStoreToPartitionIds ( rebalanceTaskInfoMap . getP...
Given a protobuf rebalance - partition info converts it into our rebalance - partition info
24,474
public static RebalanceTaskInfoMap encodeRebalanceTaskInfoMap ( RebalanceTaskInfo stealInfo ) { return RebalanceTaskInfoMap . newBuilder ( ) . setStealerId ( stealInfo . getStealerId ( ) ) . setDonorId ( stealInfo . getDonorId ( ) ) . addAllPerStorePartitionIds ( ProtoUtils . encodeStoreToPartitionsTuple ( stealInfo . ...
Given a rebalance - task info convert it into the protobuf equivalent
24,475
public Versioned < E > getVersionedById ( int id ) { Versioned < VListNode < E > > listNode = getListNode ( id ) ; if ( listNode == null ) throw new IndexOutOfBoundsException ( ) ; return new Versioned < E > ( listNode . getValue ( ) . getValue ( ) , listNode . getVersion ( ) ) ; }
Get the ver
24,476
public E setById ( final int id , final E element ) { VListKey < K > key = new VListKey < K > ( _key , id ) ; UpdateElementById < K , E > updateElementAction = new UpdateElementById < K , E > ( key , element ) ; if ( ! _storeClient . applyUpdate ( updateElementAction ) ) throw new ObsoleteVersionException ( "update fai...
Put the given value to the appropriate id in the stack using the version of the current list node identified by that id .
24,477
private void allClustersEqual ( final List < String > clusterUrls ) { Validate . notEmpty ( clusterUrls , "clusterUrls cannot be null" ) ; if ( clusterUrls . size ( ) == 1 ) return ; AdminClient adminClientLhs = adminClientPerCluster . get ( clusterUrls . get ( 0 ) ) ; Cluster clusterLhs = adminClientLhs . getAdminClie...
Check if all cluster objects in the list are congruent .
24,478
private synchronized JsonSchema getInputPathJsonSchema ( ) throws IOException { if ( inputPathJsonSchema == null ) { inputPathJsonSchema = HadoopUtils . getSchemaFromPath ( getInputPath ( ) ) ; } return inputPathJsonSchema ; }
Get the Json Schema of the input path assuming the path contains just one schema version in all files under that path .
24,479
private synchronized Schema getInputPathAvroSchema ( ) throws IOException { if ( inputPathAvroSchema == null ) { inputPathAvroSchema = AvroUtils . getAvroSchemaFromPath ( getInputPath ( ) ) ; } return inputPathAvroSchema ; }
Get the Avro Schema of the input path assuming the path contains just one schema version in all files under that path .
24,480
public String getRecordSchema ( ) throws IOException { Schema schema = getInputPathAvroSchema ( ) ; String recSchema = schema . toString ( ) ; return recSchema ; }
Get the schema for the Avro Record from the object container file
24,481
public String getKeySchema ( ) throws IOException { Schema schema = getInputPathAvroSchema ( ) ; String keySchema = schema . getField ( keyFieldName ) . schema ( ) . toString ( ) ; return keySchema ; }
Extract schema of the key field
24,482
public String getValueSchema ( ) throws IOException { Schema schema = getInputPathAvroSchema ( ) ; String valueSchema = schema . getField ( valueFieldName ) . schema ( ) . toString ( ) ; return valueSchema ; }
Extract schema of the value field
24,483
private void verifyOrAddStore ( String clusterURL , String keySchema , String valueSchema ) { String newStoreDefXml = VoldemortUtils . getStoreDefXml ( storeName , props . getInt ( BUILD_REPLICATION_FACTOR , 2 ) , props . getInt ( BUILD_REQUIRED_READS , 1 ) , props . getInt ( BUILD_REQUIRED_WRITES , 1 ) , props . getNu...
For each node checks if the store exists and then verifies that the remote schema matches the new one . If the remote store doesn t exist it creates it .
24,484
public void syncInternalStateFromFileSystem ( boolean alsoSyncRemoteState ) { for ( Long version : versionToEnabledMap . keySet ( ) ) { File [ ] existingVersionDirs = ReadOnlyUtils . getVersionDirs ( rootDir , version , version ) ; if ( existingVersionDirs . length == 0 ) { removeVersion ( version , alsoSyncRemoteState...
Compares the StoreVersionManager s internal state with the content on the file - system of the rootDir provided at construction time .
24,485
private void persistDisabledVersion ( long version ) throws PersistenceFailureException { File disabledMarker = getDisabledMarkerFile ( version ) ; try { disabledMarker . createNewFile ( ) ; } catch ( IOException e ) { throw new PersistenceFailureException ( "Failed to create the disabled marker at path: " + disabledMa...
Places a disabled marker file in the directory of the specified version .
24,486
private void persistEnabledVersion ( long version ) throws PersistenceFailureException { File disabledMarker = getDisabledMarkerFile ( version ) ; if ( disabledMarker . exists ( ) ) { if ( ! disabledMarker . delete ( ) ) { throw new PersistenceFailureException ( "Failed to create the disabled marker at path: " + disabl...
Deletes the disabled marker file in the directory of the specified version .
24,487
private File getDisabledMarkerFile ( long version ) throws PersistenceFailureException { File [ ] versionDirArray = ReadOnlyUtils . getVersionDirs ( rootDir , version , version ) ; if ( versionDirArray . length == 0 ) { throw new PersistenceFailureException ( "getDisabledMarkerFile did not find the requested version di...
Gets the . disabled file for a given version of this store . That file may or may not exist .
24,488
public Double getAvgEventValue ( ) { resetIfNeeded ( ) ; synchronized ( this ) { long eventsLastInterval = numEventsLastInterval - numEventsLastLastInterval ; if ( eventsLastInterval > 0 ) return ( ( totalEventValueLastInterval - totalEventValueLastLastInterval ) * 1.0 ) / eventsLastInterval ; else return 0.0 ; } }
Returns the average event value in the current interval
24,489
@ SuppressWarnings ( "unchecked" ) public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; List < String > metaKeys = null ; String url = null ; args = AdminToolUtils . copyArrayAddFirst ( args , "--" + OPT_HEAD_META_CHECK ) ; OptionSet options = parser . parse (...
Parses command - line and checks if metadata is consistent across all nodes .
24,490
@ SuppressWarnings ( "unchecked" ) public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; String url = null ; List < Integer > nodeIds = null ; Boolean allNodes = true ; Boolean confirm = false ; OptionSet options = parser . parse ( args ) ; if ( options . has (...
Parses command - line and removes metadata related to rebalancing .
24,491
public static void doMetaClearRebalance ( AdminClient adminClient , List < Integer > nodeIds ) { AdminToolUtils . assertServerNotInOfflineState ( adminClient , nodeIds ) ; System . out . println ( "Setting " + MetadataStore . SERVER_STATE_KEY + " to " + MetadataStore . VoldemortState . NORMAL_SERVER ) ; doMetaSet ( adm...
Removes metadata related to rebalancing .
24,492
@ SuppressWarnings ( "unchecked" ) public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; List < String > metaKeys = null ; String url = null ; String dir = null ; List < Integer > nodeIds = null ; Boolean allNodes = true ; Boolean verbose = false ; args = Admin...
Parses command - line and gets metadata .
24,493
@ SuppressWarnings ( "unchecked" ) public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; List < String > metaKeys = null ; String url = null ; List < Integer > nodeIds = null ; Boolean allNodes = true ; List < String > storeNames = null ; args = AdminToolUtils ...
Parses command - line and gets read - only metadata .
24,494
public static void doMetaGetRO ( AdminClient adminClient , Collection < Integer > nodeIds , List < String > storeNames , List < String > metaKeys ) throws IOException { for ( String key : metaKeys ) { System . out . println ( "Metadata: " + key ) ; if ( ! key . equals ( KEY_MAX_VERSION ) && ! key . equals ( KEY_CURRENT...
Gets read - only metadata .
24,495
public static void doMetaUpdateVersionsOnStores ( AdminClient adminClient , List < StoreDefinition > oldStoreDefs , List < StoreDefinition > newStoreDefs ) { Set < String > storeNamesUnion = new HashSet < String > ( ) ; Map < String , StoreDefinition > oldStoreDefinitionMap = new HashMap < String , StoreDefinition > ( ...
Updates metadata versions on stores .
24,496
public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; String url = null ; Boolean confirm = false ; OptionSet options = parser . parse ( args ) ; if ( options . has ( AdminParserUtils . OPT_HELP ) ) { printHelp ( System . out ) ; return ; } AdminParserUtils . c...
Parses command - line and synchronizes metadata versions across all nodes .
24,497
public static void executeCommand ( String [ ] args ) throws IOException { OptionParser parser = getParser ( ) ; String url = null ; OptionSet options = parser . parse ( args ) ; if ( options . has ( AdminParserUtils . OPT_HELP ) ) { printHelp ( System . out ) ; return ; } AdminParserUtils . checkRequired ( options , A...
Parses command - line and verifies metadata versions on all the cluster nodes
24,498
private Integer getKeyPartitionId ( byte [ ] key ) { Integer keyPartitionId = storeInstance . getNodesPartitionIdForKey ( nodeId , key ) ; Utils . notNull ( keyPartitionId ) ; return keyPartitionId ; }
Given the key figures out which partition on the local node hosts the key .
24,499
protected boolean isItemAccepted ( byte [ ] key ) { boolean entryAccepted = false ; if ( ! fetchOrphaned ) { if ( isKeyNeeded ( key ) ) { entryAccepted = true ; } } else { if ( ! StoreRoutingPlan . checkKeyBelongsToNode ( key , nodeId , initialCluster , storeDef ) ) { entryAccepted = true ; } } return entryAccepted ; }
Determines if entry is accepted . For normal usage this means confirming that the key is needed . For orphan usage this simply means confirming the key belongs to the node .