public void addStoreDefinition(StoreDefinition storeDef) {
        // acquire write lock
        writeLock.lock();

        try {
            // Check if store already exists
            if(this.storeNames.contains(storeDef.getName())) {
                throw new VoldemortException("Store already exists !");
            }

            // Check for backwards compatibility
            StoreDefinitionUtils.validateSchemaAsNeeded(storeDef);

            // Otherwise add to the STORES directory
            StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
            String storeDefStr = mapper.writeStore(storeDef);
            Versioned<String> versionedValueStr = new Versioned<String>(storeDefStr);
            this.storeDefinitionsStorageEngine.put(storeDef.getName(), versionedValueStr, null);

            // Update the metadata cache
            this.metadataCache.put(storeDef.getName(), new Versioned<Object>(storeDefStr));

            // Re-initialize the store definitions. This is primarily required
            // to re-create the value for key: 'stores.xml'. This is necessary
            // for backwards compatibility.
            initStoreDefinitions(null);

            updateRoutingStrategies(getCluster(), getStoreDefList());
        } finally {
            writeLock.unlock();
        }
    }
public void addStoreDefinition ( StoreDefinition storeDef ) { writeLock . lock ( ) ; try { if ( this . storeNames . contains ( storeDef . getName ( ) ) ) { throw new VoldemortException ( "Store already exists !" ) ; } StoreDefinitionUtils . validateSchemaAsNeeded ( storeDef ) ; StoreDefinitionsMapper mapper = new StoreDefinitionsMapper ( ) ; String storeDefStr = mapper . writeStore ( storeDef ) ; Versioned < String > versionedValueStr = new Versioned < String > ( storeDefStr ) ; this . storeDefinitionsStorageEngine . put ( storeDef . getName ( ) , versionedValueStr , null ) ; this . metadataCache . put ( storeDef . getName ( ) , new Versioned < Object > ( storeDefStr ) ) ; initStoreDefinitions ( null ) ; updateRoutingStrategies ( getCluster ( ) , getStoreDefList ( ) ) ; } finally { writeLock . unlock ( ) ; } }
Function to add a new Store to the Metadata store. This involves

1. Create a new entry in the ConfigurationStorageEngine for STORES.

2. Update the metadata cache.

3. Re-create the 'stores.xml' key

@param storeDef defines the new store to be created