Search in sources :

Example 6 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class RequestMapDataOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    int partitionId = getPartitionId();
    Address callerAddress = getCallerAddress();
    if (logger.isFineEnabled()) {
        logger.fine("Caller { " + callerAddress + " } requested copy of map: " + name + " partitionId=" + partitionId);
    }
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(partitionId);
    ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
    store.setLoaded(true);
    if (getNodeEngine().getThisAddress().equals(callerAddress)) {
        return;
    }
    long version = store.getVersion();
    Set<RecordMigrationInfo> recordSet = getRecordSet(store);
    SyncReplicatedMapDataOperation op = new SyncReplicatedMapDataOperation(name, recordSet, version);
    op.setPartitionId(partitionId);
    op.setValidateTarget(false);
    OperationService operationService = getNodeEngine().getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
Also used : Address(com.hazelcast.nio.Address) PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)

Example 7 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class SizeOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    int size = 0;
    for (ReplicatedRecordStore store : stores) {
        size += store.size();
    }
    response = size;
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService)

Example 8 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class MergeOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, key);
    store.merge(key, entryView, policy);
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService)

Example 9 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class PutAllOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    int partitionId = getPartitionId();
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    for (int i = 0; i < entries.size(); i++) {
        Data key = entries.getKey(i);
        Data value = entries.getValue(i);
        if (partitionId != partitionService.getPartitionId(key)) {
            continue;
        }
        Object putResult = store.put(key, value);
        Data oldValue = getNodeEngine().toData(putResult);
        eventPublishingService.fireEntryListenerEvent(key, oldValue, value, name, getCallerAddress());
        VersionResponsePair response = new VersionResponsePair(putResult, store.getVersion());
        publishReplicationMessage(key, value, response);
    }
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) IPartitionService(com.hazelcast.spi.partition.IPartitionService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.nio.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 10 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class ReplicateUpdateToCallerOperation method publishEvent.

private void publishEvent() {
    ReplicatedMapService service = getService();
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    Address thisAddress = getNodeEngine().getThisAddress();
    Data dataOldValue = getNodeEngine().toData(response.getResponse());
    if (isRemove) {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, null, name, thisAddress);
    } else {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, dataValue, name, thisAddress);
    }
}
Also used : Address(com.hazelcast.nio.Address) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.nio.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Aggregations

ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)32 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)17 ILogger (com.hazelcast.logging.ILogger)6 Data (com.hazelcast.nio.serialization.Data)6 ReplicatedMapEventPublishingService (com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 Test (org.junit.Test)5 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Config (com.hazelcast.config.Config)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 ArrayList (java.util.ArrayList)3 QueueService (com.hazelcast.collection.impl.queue.QueueService)2 DistributedExecutorService (com.hazelcast.executor.impl.DistributedExecutorService)2 MapService (com.hazelcast.map.impl.MapService)2 MultiMapService (com.hazelcast.multimap.impl.MultiMapService)2 Address (com.hazelcast.nio.Address)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2