Search in sources :

Example 6 with LockService

use of com.hazelcast.concurrent.lock.LockService in project hazelcast by hazelcast.

the class MultiMapService method init.

@Override
public void init(final NodeEngine nodeEngine, Properties properties) {
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int partition = 0; partition < partitionCount; partition++) {
        partitionContainers[partition] = new MultiMapPartitionContainer(this, partition);
    }
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        lockService.registerLockStoreConstructor(SERVICE_NAME, new ConstructorFunction<ObjectNamespace, LockStoreInfo>() {

            @Override
            public LockStoreInfo createNew(final ObjectNamespace key) {
                String name = key.getObjectName();
                final MultiMapConfig multiMapConfig = nodeEngine.getConfig().findMultiMapConfig(name);
                return new LockStoreInfo() {

                    @Override
                    public int getBackupCount() {
                        return multiMapConfig.getSyncBackupCount();
                    }

                    @Override
                    public int getAsyncBackupCount() {
                        return multiMapConfig.getAsyncBackupCount();
                    }
                };
            }
        });
    }
}
Also used : LockStoreInfo(com.hazelcast.concurrent.lock.LockStoreInfo) LockService(com.hazelcast.concurrent.lock.LockService) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ObjectNamespace(com.hazelcast.spi.ObjectNamespace) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 7 with LockService

use of com.hazelcast.concurrent.lock.LockService in project hazelcast by hazelcast.

the class DefaultRecordStore method clearPartition.

@Override
public void clearPartition(boolean onShutdown) {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
    Indexes indexes = mapContainer.getIndexes();
    if (indexes.hasIndex()) {
        for (Record record : storage.values()) {
            Data key = record.getKey();
            Object value = Records.getValueOrCachedValue(record, serializationService);
            indexes.removeEntryIndex(key, value);
        }
    }
    mapDataStore.reset();
    if (onShutdown) {
        NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
        boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
        if (shouldClear) {
            storage.clear(true);
        }
        storage.destroy(true);
    } else {
        storage.clear(false);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService) Record(com.hazelcast.map.impl.record.Record) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes)

Example 8 with LockService

use of com.hazelcast.concurrent.lock.LockService in project hazelcast by hazelcast.

the class AbstractRecordStore method createLockStore.

protected LockStore createLockStore() {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService == null) {
        return null;
    }
    return lockService.createLockStore(partitionId, new DefaultObjectNamespace(MapService.SERVICE_NAME, name));
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService)

Aggregations

LockService (com.hazelcast.concurrent.lock.LockService)8 DefaultObjectNamespace (com.hazelcast.spi.DefaultObjectNamespace)4 NodeEngine (com.hazelcast.spi.NodeEngine)4 Data (com.hazelcast.nio.serialization.Data)2 LockResource (com.hazelcast.concurrent.lock.LockResource)1 LockStoreInfo (com.hazelcast.concurrent.lock.LockStoreInfo)1 Config (com.hazelcast.config.Config)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TransactionalMap (com.hazelcast.core.TransactionalMap)1 Node (com.hazelcast.instance.Node)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 Record (com.hazelcast.map.impl.record.Record)1 Indexes (com.hazelcast.query.impl.Indexes)1 ObjectNamespace (com.hazelcast.spi.ObjectNamespace)1 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1