public boolean installClustersOfClass ( final ODatabaseInternal iDatabase , final OClass iClass , OModifiableDistributedConfiguration cfg ) { final String databaseName = iDatabase . getName ( ) ; if ( iClass . isAbstract ( ) ) return false ; // INIT THE DATABASE IF NEEDED getMessageService ( ) . registerDatabase ( databaseName , cfg ) ; return executeInDistributedDatabaseLock ( databaseName , 20000 , cfg , new OCallable < Boolean , OModifiableDistributedConfiguration > ( ) { @ Override public Boolean call ( final OModifiableDistributedConfiguration lastCfg ) { final Set < String > availableNodes = getAvailableNodeNames ( iDatabase . getName ( ) ) ; final List < String > cluster2Create = clusterAssignmentStrategy . assignClusterOwnershipOfClass ( iDatabase , lastCfg , iClass , availableNodes , true ) ; final Map < OClass , List < String > > cluster2CreateMap = new HashMap < OClass , List < String > > ( 1 ) ; cluster2CreateMap . put ( iClass , cluster2Create ) ; createClusters ( iDatabase , cluster2CreateMap , lastCfg ) ; return true ; } } ) ; }
Guarantees that each class has own master cluster .