Search in sources :

Example 46 with ILogger

use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.

the class ReplicateUpdateOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    long currentVersion = store.getVersion();
    long updateVersion = response.getVersion();
    if (currentVersion >= updateVersion) {
        ILogger logger = getLogger();
        if (logger.isFineEnabled()) {
            logger.fine("Rejecting stale update received for replicated map: " + name + "  partitionId=" + getPartitionId() + " current version: " + currentVersion + " update version: " + updateVersion);
        }
        return;
    }
    Object key = store.marshall(dataKey);
    Object value = store.marshall(dataValue);
    if (isRemove) {
        store.removeWithVersion(key, updateVersion);
    } else {
        store.putWithVersion(key, value, ttl, TimeUnit.MILLISECONDS, false, updateVersion);
    }
    publishEvent();
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger)

Example 47 with ILogger

use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.

the class ReplicateUpdateToCallerOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    long currentVersion = store.getVersion();
    long updateVersion = response.getVersion();
    if (currentVersion >= updateVersion) {
        if (logger.isFineEnabled()) {
            logger.fine("Rejecting stale update received for replicated map: " + name + "  partitionId=" + getPartitionId() + " current version: " + currentVersion + " update version: " + updateVersion);
        }
        return;
    }
    Object key = store.marshall(dataKey);
    Object value = store.marshall(dataValue);
    if (isRemove) {
        store.removeWithVersion(key, updateVersion);
    } else {
        store.putWithVersion(key, value, ttl, TimeUnit.MILLISECONDS, true, updateVersion);
    }
    publishEvent();
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger)

Example 48 with ILogger

use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.

the class SyncReplicatedMapDataOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    if (logger.isFineEnabled()) {
        logger.fine("Syncing " + recordSet.size() + " records and version: " + version + " for map: " + name + " partitionId=" + getPartitionId() + " from: " + getCallerAddress() + " to: " + getNodeEngine().getThisAddress());
    }
    ReplicatedMapService service = getService();
    AbstractReplicatedRecordStore store = (AbstractReplicatedRecordStore) service.getReplicatedRecordStore(name, true, getPartitionId());
    InternalReplicatedMapStorage<K, V> newStorage = new InternalReplicatedMapStorage<K, V>();
    for (RecordMigrationInfo record : recordSet) {
        K key = (K) store.marshall(record.getKey());
        V value = (V) store.marshall(record.getValue());
        ReplicatedRecord<K, V> replicatedRecord = buildReplicatedRecord(key, value, record.getTtl());
        ReplicatedRecord oldRecord = store.getReplicatedRecord(key);
        if (oldRecord != null) {
            replicatedRecord.setHits(oldRecord.getHits());
        }
        newStorage.put(key, replicatedRecord);
        if (record.getTtl() > 0) {
            store.scheduleTtlEntry(record.getTtl(), key, value);
        }
    }
    newStorage.syncVersion(version);
    AtomicReference<InternalReplicatedMapStorage<K, V>> storageRef = store.getStorageRef();
    storageRef.set(newStorage);
    store.setLoaded(true);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) AbstractReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) InternalReplicatedMapStorage(com.hazelcast.replicatedmap.impl.record.InternalReplicatedMapStorage) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)

Example 49 with ILogger

use of com.hazelcast.logging.ILogger 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)

Example 50 with ILogger

use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.

the class BeforePromotionOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        logger.finest("Running before promotion for " + getPartitionMigrationEvent());
    }
    PartitionMigrationEvent event = getPartitionMigrationEvent();
    for (MigrationAwareService service : getMigrationAwareServices()) {
        try {
            service.beforeMigration(event);
        } catch (Throwable e) {
            logger.warning("While promoting " + getPartitionMigrationEvent(), e);
        }
    }
}
Also used : PartitionMigrationEvent(com.hazelcast.spi.PartitionMigrationEvent) MigrationAwareService(com.hazelcast.spi.MigrationAwareService) ILogger(com.hazelcast.logging.ILogger)

Aggregations

ILogger (com.hazelcast.logging.ILogger)76 Address (com.hazelcast.nio.Address)19 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)11 Node (com.hazelcast.instance.Node)10 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)10 NodeEngine (com.hazelcast.spi.NodeEngine)10 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)9 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)6 OperationService (com.hazelcast.spi.OperationService)6 IOException (java.io.IOException)4 Before (org.junit.Before)4 JsonObject (com.eclipsesource.json.JsonObject)3 ClientAwsConfig (com.hazelcast.client.config.ClientAwsConfig)3 Connection (com.hazelcast.nio.Connection)3 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)3 Operation (com.hazelcast.spi.Operation)3 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)3 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)3 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)2 ClusterState (com.hazelcast.cluster.ClusterState)2