Search in sources :

Example 1 with PartitionContainer

use of com.hazelcast.replicatedmap.impl.PartitionContainer 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 2 with PartitionContainer

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

the class CheckReplicaVersionOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    int partitionId = getPartitionId();
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(getPartitionId());
    ConcurrentMap<String, ReplicatedRecordStore> stores = container.getStores();
    for (Map.Entry<String, Long> entry : versions.entrySet()) {
        String name = entry.getKey();
        Long version = entry.getValue();
        ReplicatedRecordStore store = stores.get(name);
        if (store == null) {
            if (logger.isFineEnabled()) {
                logger.fine("Missing store on the replica ! map: " + name + " owner version:" + version + " partitionId=" + partitionId);
            }
            requestDataFromOwner(name);
        } else if (store.isStale(version)) {
            if (logger.isFineEnabled()) {
                logger.fine("Stale replica! map: " + name + " owner version: " + version + " replica version: " + store.getVersion() + " partitionId=" + partitionId);
            }
            requestDataFromOwner(name);
        }
    }
}
Also used : PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Aggregations

ILogger (com.hazelcast.logging.ILogger)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)2 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)2 Address (com.hazelcast.nio.Address)1 RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)1 OperationService (com.hazelcast.spi.OperationService)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1