Search in sources :

Example 16 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.

/**
 * Fail all replication operations with the exception that this node is no longer the replica with the sent index
 */
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    NodeEngine nodeEngine = getNodeEngine();
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
        logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
    }
    if (operations != null) {
        PartitionReplica replica = partition.getReplica(replicaIndex);
        Member targetMember = null;
        if (replica != null) {
            ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
            targetMember = clusterService.getMember(replica.address(), replica.uuid());
        }
        Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
        for (Operation op : operations) {
            prepareOperation(op);
            onOperationFailure(op, throwable);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) BackupOperation(com.hazelcast.spi.impl.operationservice.BackupOperation) Member(com.hazelcast.cluster.Member) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException)

Example 17 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class PartitionReplicaSyncRequest method sendResponse.

/**
 * Send a synchronization response to the caller replica containing the replication operations to be executed
 */
private void sendResponse(Collection<Operation> operations, Collection<ChunkSupplier> chunkSuppliers, ServiceNamespace ns) {
    NodeEngine nodeEngine = getNodeEngine();
    PartitionReplicaSyncResponse syncResponse = createResponse(operations, chunkSuppliers, ns);
    Address target = getCallerAddress();
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        logger.finest("Sending sync response to -> " + target + " for partitionId=" + partitionId() + ", replicaIndex=" + getReplicaIndex() + ", namespaces=" + ns);
    }
    // PartitionReplicaSyncResponse is TargetAware and sent directly without invocation system.
    syncResponse.setTarget(target);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.send(syncResponse, target);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 18 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class BasicMapStoreContext method create.

static MapStoreContext create(MapContainer mapContainer) {
    final BasicMapStoreContext context = new BasicMapStoreContext();
    final String mapName = mapContainer.getName();
    final MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final PartitioningStrategy partitioningStrategy = mapContainer.getPartitioningStrategy();
    final MapConfig mapConfig = mapContainer.getMapConfig();
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    final ClassLoader configClassLoader = nodeEngine.getConfigClassLoader();
    // create store.
    final Object store = createStore(mapName, mapStoreConfig, configClassLoader);
    final MapStoreWrapper storeWrapper = new MapStoreWrapper(mapName, store);
    storeWrapper.instrument(nodeEngine);
    context.setMapName(mapName);
    context.setMapStoreConfig(mapStoreConfig);
    context.setPartitioningStrategy(partitioningStrategy);
    context.setMapServiceContext(mapServiceContext);
    context.setStoreWrapper(storeWrapper);
    final MapStoreManager mapStoreManager = createMapStoreManager(context);
    context.setMapStoreManager(mapStoreManager);
    // todo this is user code. it may also block map store creation.
    callLifecycleSupportInit(context);
    return context;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) PartitioningStrategy(com.hazelcast.partition.PartitioningStrategy) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 19 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class BasicMapStoreContext method callLifecycleSupportInit.

private static void callLifecycleSupportInit(MapStoreContext mapStoreContext) {
    final MapStoreWrapper mapStoreWrapper = mapStoreContext.getMapStoreWrapper();
    final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final HazelcastInstance hazelcastInstance = nodeEngine.getHazelcastInstance();
    final MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig();
    final Properties properties = mapStoreConfig.getProperties();
    final String mapName = mapStoreContext.getMapName();
    mapStoreWrapper.init(hazelcastInstance, properties, mapName);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Properties(java.util.Properties) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 20 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class WriteBehindStore method getInMemoryFormat.

private static InMemoryFormat getInMemoryFormat(MapStoreContext mapStoreContext) {
    MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    Config config = nodeEngine.getConfig();
    String mapName = mapStoreContext.getMapName();
    MapConfig mapConfig = config.findMapConfig(mapName);
    return mapConfig.getInMemoryFormat();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9