Search in sources :

Example 6 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class ReplicationOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    int mapSize = in.readInt();
    migrationData = createHashMap(mapSize);
    for (int i = 0; i < mapSize; i++) {
        final ObjectNamespace namespace = in.readObject();
        final RingbufferContainer container = new RingbufferContainer(namespace, getPartitionId());
        container.readData(in);
        migrationData.put(namespace, container);
    }
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 7 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class ReplicationOperation method run.

@Override
public void run() {
    final RingbufferService service = getService();
    for (Map.Entry<ObjectNamespace, RingbufferContainer> entry : migrationData.entrySet()) {
        final ObjectNamespace ns = entry.getKey();
        final RingbufferContainer ringbuffer = entry.getValue();
        service.addRingbuffer(getPartitionId(), ringbuffer, getRingbufferConfig(service, ns));
    }
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 8 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class PartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    final NodeEngine nodeEngine = mapService.getMapServiceContext().getNodeEngine();
    final LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        final ObjectNamespace namespace = MapService.getObjectNamespace(name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 9 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class WriteBehindStateHolder method prepare.

void prepare(PartitionContainer container, Collection<ServiceNamespace> namespaces, int replicaIndex) {
    int size = namespaces.size();
    flushSequences = createHashMap(size);
    delayedEntries = createHashMap(size);
    reservationsByTxnIdPerMap = createHashMap(size);
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace mapNamespace = (ObjectNamespace) namespace;
        String mapName = mapNamespace.getObjectName();
        RecordStore recordStore = container.getRecordStore(mapName);
        if (recordStore == null) {
            continue;
        }
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex || !mapContainer.getMapStoreContext().isWriteBehindMapStoreEnabled()) {
            continue;
        }
        WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
        reservationsByTxnIdPerMap.put(mapName, mapDataStore.getTxnReservedCapacityCounter().getReservedCapacityCountPerTxnId());
        WriteBehindQueue<DelayedEntry> writeBehindQueue = mapDataStore.getWriteBehindQueue();
        List<DelayedEntry> entries = writeBehindQueue.asList();
        if (entries == null || entries.isEmpty()) {
            continue;
        }
        delayedEntries.put(mapName, entries);
        flushSequences.put(mapName, new ArrayDeque<>(mapDataStore.getFlushSequences()));
    }
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) DelayedEntries.newAddedDelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntries.newAddedDelayedEntry) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) MapContainer(com.hazelcast.map.impl.MapContainer) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 10 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class AbstractRingBufferOperation method getRingBufferContainerOrNull.

/**
 * Returns an {@link RingbufferContainer} or null if one doesn't exist.
 * <p>
 * If it does it also calls the {@link RingbufferContainer#cleanup()} before returning
 * the container. This will currently remove any expired items.
 *
 * @return the ringbuffer container
 */
RingbufferContainer getRingBufferContainerOrNull() {
    final RingbufferService service = getService();
    final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(name);
    RingbufferContainer ringbuffer = service.getContainerOrNull(getPartitionId(), ns);
    if (ringbuffer != null) {
        ringbuffer.cleanup();
    }
    return ringbuffer;
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Aggregations

ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)28 RingbufferContainer (com.hazelcast.ringbuffer.impl.RingbufferContainer)12 RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)10 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 DistributedObjectNamespace (com.hazelcast.internal.services.DistributedObjectNamespace)7 Test (org.junit.Test)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Config (com.hazelcast.config.Config)4 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)3 Map (java.util.Map)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ListenerConfig (com.hazelcast.config.ListenerConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)2 LockSupportService (com.hazelcast.internal.locksupport.LockSupportService)2 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)2