Search in sources :

Example 91 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MapChunk method writeWriteBehindState.

private void writeWriteBehindState(ObjectDataOutput out, RecordStore recordStore) throws IOException {
    MapContainer mapContainer = recordStore.getMapContainer();
    MapConfig mapConfig = mapContainer.getMapConfig();
    if (mapConfig.getTotalBackupCount() < getReplicaIndex() || !mapContainer.getMapStoreContext().isWriteBehindMapStoreEnabled()) {
        // we don't have hasWriteBehindState
        out.writeBoolean(false);
        return;
    }
    // we have hasWriteBehindState
    out.writeBoolean(true);
    MapServiceContext mapServiceContext = recordStore.getMapContainer().getMapServiceContext();
    WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
    // write delayed entries
    List<DelayedEntry> delayedEntries = mapDataStore.getWriteBehindQueue().asList();
    out.writeInt(delayedEntries.size());
    for (DelayedEntry e : delayedEntries) {
        Data key = mapServiceContext.toData(e.getKey());
        Data value = mapServiceContext.toData(e.getValue());
        long expirationTime = e.getExpirationTime();
        IOUtil.writeData(out, key);
        IOUtil.writeData(out, value);
        out.writeLong(expirationTime);
        out.writeLong(e.getStoreTime());
        out.writeInt(e.getPartitionId());
        out.writeLong(e.getSequence());
        UUIDSerializationUtil.writeUUID(out, e.getTxnId());
    }
    // write sequences
    Deque<WriteBehindStore.Sequence> sequences = new ArrayDeque<>(mapDataStore.getFlushSequences());
    out.writeInt(sequences.size());
    for (WriteBehindStore.Sequence sequence : sequences) {
        out.writeLong(sequence.getSequence());
        out.writeBoolean(sequence.isFullFlush());
    }
    // write txn reservations
    Map<UUID, Long> reservationsByTxnId = mapDataStore.getTxnReservedCapacityCounter().getReservedCapacityCountPerTxnId();
    out.writeInt(reservationsByTxnId.size());
    for (Map.Entry<UUID, Long> counterByTxnId : reservationsByTxnId.entrySet()) {
        writeUUID(out, counterByTxnId.getKey());
        out.writeLong(counterByTxnId.getValue());
    }
}
Also used : Data(com.hazelcast.internal.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) DelayedEntries.newAddedDelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntries.newAddedDelayedEntry) MapContainer(com.hazelcast.map.impl.MapContainer) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) ArrayDeque(java.util.ArrayDeque) MapConfig(com.hazelcast.config.MapConfig) UUIDSerializationUtil.readUUID(com.hazelcast.internal.util.UUIDSerializationUtil.readUUID) UUID(java.util.UUID) UUIDSerializationUtil.writeUUID(com.hazelcast.internal.util.UUIDSerializationUtil.writeUUID) Map(java.util.Map) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap)

Example 92 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class PostJoinMapOperation method createQueryCaches.

private void createQueryCaches() {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    for (AccumulatorInfo info : infoList) {
        addAccumulatorInfo(queryCacheContext, info);
        PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrCreate(info.getMapName());
        publisherRegistry.getOrCreate(info.getCacheId());
        // marker listener.
        mapServiceContext.addLocalListenerAdapter((ListenerAdapter<IMapEvent>) event -> {
        }, info.getMapName());
    }
}
Also used : MapDataSerializerHook(com.hazelcast.map.impl.MapDataSerializerHook) Address(com.hazelcast.cluster.Address) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) IMapEvent(com.hazelcast.map.IMapEvent) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ArrayList(java.util.ArrayList) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) Operation(com.hazelcast.spi.impl.operationservice.Operation) Map(java.util.Map) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapInterceptor(com.hazelcast.map.MapInterceptor) TargetAware(com.hazelcast.spi.impl.operationservice.TargetAware) IOException(java.io.IOException) MapService(com.hazelcast.map.impl.MapService) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) AbstractMap(java.util.AbstractMap) List(java.util.List) AccumulatorInfoSupplier(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) Collections(java.util.Collections) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) IMapEvent(com.hazelcast.map.IMapEvent) MapService(com.hazelcast.map.impl.MapService) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 93 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class WriteBehindStateHolder method writeData.

@Override
public void writeData(ObjectDataOutput out) throws IOException {
    MapService mapService = mapReplicationOperation.getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    out.writeInt(delayedEntries.size());
    for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) {
        out.writeString(entry.getKey());
        List<DelayedEntry> delayedEntryList = entry.getValue();
        out.writeInt(delayedEntryList.size());
        for (DelayedEntry e : delayedEntryList) {
            Data key = mapServiceContext.toData(e.getKey());
            Data value = mapServiceContext.toData(e.getValue());
            long expirationTime = e.getExpirationTime();
            IOUtil.writeData(out, key);
            IOUtil.writeData(out, value);
            out.writeLong(expirationTime);
            out.writeLong(e.getStoreTime());
            out.writeInt(e.getPartitionId());
            out.writeLong(e.getSequence());
            UUIDSerializationUtil.writeUUID(out, e.getTxnId());
        }
    }
    out.writeInt(flushSequences.size());
    for (Map.Entry<String, Queue<WriteBehindStore.Sequence>> entry : flushSequences.entrySet()) {
        out.writeString(entry.getKey());
        Queue<WriteBehindStore.Sequence> queue = entry.getValue();
        out.writeInt(queue.size());
        for (WriteBehindStore.Sequence sequence : queue) {
            out.writeLong(sequence.getSequence());
            out.writeBoolean(sequence.isFullFlush());
        }
    }
    out.writeInt(reservationsByTxnIdPerMap.size());
    for (Map.Entry<String, Map<UUID, Long>> entry : reservationsByTxnIdPerMap.entrySet()) {
        out.writeString(entry.getKey());
        Map<UUID, Long> reservationsByTxnId = entry.getValue();
        out.writeInt(reservationsByTxnId.size());
        for (Map.Entry<UUID, Long> counterByTxnId : reservationsByTxnId.entrySet()) {
            writeUUID(out, counterByTxnId.getKey());
            out.writeLong(counterByTxnId.getValue());
        }
    }
}
Also used : Data(com.hazelcast.internal.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) DelayedEntries.newAddedDelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntries.newAddedDelayedEntry) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore) ArrayList(java.util.ArrayList) List(java.util.List) MapService(com.hazelcast.map.impl.MapService) UUIDSerializationUtil.readUUID(com.hazelcast.internal.util.UUIDSerializationUtil.readUUID) UUIDSerializationUtil.writeUUID(com.hazelcast.internal.util.UUIDSerializationUtil.writeUUID) UUID(java.util.UUID) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map) WriteBehindQueue(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue) Queue(java.util.Queue)

Example 94 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MadePublishableOperation method getContext.

private QueryCacheContext getContext() {
    MapService service = getService();
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    return mapServiceContext.getQueryCacheContext();
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 95 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class ClientMapInvalidationMetadataDistortionTest method distortRandomPartitionUuid.

private void distortRandomPartitionUuid(HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
    int partitionId = getInt(partitionCount);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    metaDataGenerator.setUuid(partitionId, UuidUtil.newUnsecureUUID());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Aggregations

MapServiceContext (com.hazelcast.map.impl.MapServiceContext)137 MapService (com.hazelcast.map.impl.MapService)111 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)34 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)29 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)25 MapContainer (com.hazelcast.map.impl.MapContainer)22 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)22 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)20 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)15 NodeEngine (com.hazelcast.spi.impl.NodeEngine)14 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)13 Node (com.hazelcast.instance.impl.Node)12 Data (com.hazelcast.internal.serialization.Data)11 Accessors.getNode (com.hazelcast.test.Accessors.getNode)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 Config (com.hazelcast.config.Config)8 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)8