public StorageRegistration registerModel ( final long lockPriority , final MetaKey key , final StorageModelProvider < ? , ? > storageProvider ) throws ModelInitializationException { this . modelLock . writeLock ( ) . lock ( ) ; try { testClosed ( ) ; if ( this . modelKeyMap . containsKey ( key ) ) { throw new IllegalArgumentException ( String . format ( "A provider for '%s' is already registered" , key ) ) ; } try { storageProvider . start ( this . context ) ; } catch ( final Exception e ) { throw new ModelInitializationException ( "Failed to start model provider: " + key , e ) ; } final long id = this . counter ++ ; final Entry entry = new Entry ( id , lockPriority , key , storageProvider ) ; this . modelIdMap . put ( id , entry ) ; this . modelKeyMap . put ( key , entry ) ; return new StorageRegistration ( ) { @ Override public void unregister ( ) { unregisterModel ( id ) ; } } ; } finally { this . modelLock . writeLock ( ) . unlock ( ) ; } }
Register a new model with the storage manager