@ SuppressWarnings ( "unchecked" ) public void updateStoreDefinitions ( Versioned < byte [ ] > valueBytes ) { // acquire write lock writeLock . lock ( ) ; try { Versioned < String > value = new Versioned < String > ( ByteUtils . getString ( valueBytes . getValue ( ) , "UTF-8" ) , valueBytes . getVersion ( ) ) ; Versioned < Object > valueObject = convertStringToObject ( STORES_KEY , value ) ; StoreDefinitionsMapper mapper = new StoreDefinitionsMapper ( ) ; List < StoreDefinition > storeDefinitions = ( List < StoreDefinition > ) valueObject . getValue ( ) ; // Check for backwards compatibility StoreDefinitionUtils . validateSchemasAsNeeded ( storeDefinitions ) ; StoreDefinitionUtils . validateNewStoreDefsAreNonBreaking ( getStoreDefList ( ) , storeDefinitions ) ; // Go through each store definition and do a corresponding put for ( StoreDefinition storeDef : storeDefinitions ) { if ( ! this . storeNames . contains ( storeDef . getName ( ) ) ) { throw new VoldemortException ( "Cannot update a store which does not exist !" ) ; } String storeDefStr = mapper . writeStore ( storeDef ) ; Versioned < String > versionedValueStr = new Versioned < String > ( storeDefStr , value . getVersion ( ) ) ; this . storeDefinitionsStorageEngine . put ( storeDef . getName ( ) , versionedValueStr , "" ) ; // Update the metadata cache this . metadataCache . put ( storeDef . getName ( ) , new Versioned < Object > ( storeDefStr , value . getVersion ( ) ) ) ; } // Re-initialize the store definitions initStoreDefinitions ( value . getVersion ( ) ) ; // Update routing strategies // TODO: Make this more fine grained.. i.e only update listeners for // a specific store. updateRoutingStrategies ( getCluster ( ) , getStoreDefList ( ) ) ; } finally { writeLock . unlock ( ) ; } }
Function to update store definitions . Unlike the put method this function does not delete any existing state . It only updates the state of the stores specified in the given stores . xml