Search in sources :

Example 1 with NodeEngine

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

the class ObjectMultiMapProxy method remove.

@Override
public boolean remove(Object key, Object value) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
    final NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    Data dataValue = nodeEngine.toData(value);
    return removeInternal(dataKey, dataValue);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Data(com.hazelcast.nio.serialization.Data)

Example 2 with NodeEngine

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

the class AbstractJoiner method sendSplitBrainJoinMessage.

protected SplitBrainJoinMessage sendSplitBrainJoinMessage(Address target) {
    if (logger.isFineEnabled()) {
        logger.fine("Sending SplitBrainJoinMessage to " + target);
    }
    Connection conn = node.connectionManager.getOrConnect(target, true);
    long timeout = SPLIT_BRAIN_CONN_TIMEOUT;
    while (conn == null) {
        timeout -= SPLIT_BRAIN_SLEEP_TIME;
        if (timeout < 0) {
            return null;
        }
        try {
            //noinspection BusyWait
            Thread.sleep(SPLIT_BRAIN_SLEEP_TIME);
        } catch (InterruptedException e) {
            EmptyStatement.ignore(e);
            return null;
        }
        conn = node.connectionManager.getConnection(target);
    }
    NodeEngine nodeEngine = node.nodeEngine;
    Future future = nodeEngine.getOperationService().createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, new SplitBrainMergeValidationOperation(node.createSplitBrainJoinMessage()), target).setTryCount(1).invoke();
    try {
        return (SplitBrainJoinMessage) future.get(SPLIT_BRAIN_JOIN_CHECK_TIMEOUT_SECONDS, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
        logger.fine("Timeout during join check!", e);
    } catch (Exception e) {
        logger.warning("Error during join check!", e);
    }
    return null;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) SplitBrainMergeValidationOperation(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation) Connection(com.hazelcast.nio.Connection) Future(java.util.concurrent.Future) TimeoutException(java.util.concurrent.TimeoutException) MemberLeftException(com.hazelcast.core.MemberLeftException) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with NodeEngine

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

the class DefaultNodeExtension method createMapService.

private <T> T createMapService() {
    ConstructorFunction<NodeEngine, MapService> constructor = getDefaultMapServiceConstructor();
    NodeEngineImpl nodeEngine = node.getNodeEngine();
    return (T) constructor.createNew(nodeEngine);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapService(com.hazelcast.map.impl.MapService)

Example 4 with NodeEngine

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

the class PostJoinOperation method beforeRun.

@Override
public void beforeRun() throws Exception {
    if (operations != null && operations.length > 0) {
        final NodeEngine nodeEngine = getNodeEngine();
        final int len = operations.length;
        for (int i = 0; i < len; i++) {
            final Operation op = operations[i];
            op.setNodeEngine(nodeEngine);
            op.setOperationResponseHandler(new OperationResponseHandler() {

                @Override
                public void sendResponse(Operation op, Object obj) {
                    if (obj instanceof Throwable) {
                        Throwable t = (Throwable) obj;
                        ILogger logger = nodeEngine.getLogger(op.getClass());
                        logger.warning("Error while running post-join operation: " + t.getClass().getSimpleName() + ": " + t.getMessage());
                        if (logger.isFineEnabled()) {
                            logger.fine("Error while running post-join operation: ", t);
                        }
                    }
                }
            });
            OperationAccessor.setCallerAddress(op, getCallerAddress());
            OperationAccessor.setConnection(op, getConnection());
            operations[i] = op;
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.Operation) UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Example 5 with NodeEngine

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

the class ReplicaSyncResponse method run.

@Override
public void run() throws Exception {
    NodeEngine nodeEngine = getNodeEngine();
    InternalPartitionServiceImpl partitionService = getService();
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
    InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(partitionId);
    Address thisAddress = nodeEngine.getThisAddress();
    int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
    try {
        if (replicaIndex == currentReplicaIndex) {
            executeTasks();
        } else {
            nodeNotOwnsBackup(partition);
        }
        if (tasks != null) {
            tasks.clear();
        }
    } finally {
        postProcessReplicaSync(partitionService, currentReplicaIndex);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) InternalPartitionImpl(com.hazelcast.internal.partition.impl.InternalPartitionImpl) PartitionStateManager(com.hazelcast.internal.partition.impl.PartitionStateManager)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)75 Data (com.hazelcast.nio.serialization.Data)23 Address (com.hazelcast.nio.Address)14 ILogger (com.hazelcast.logging.ILogger)13 OperationService (com.hazelcast.spi.OperationService)9 IPartitionService (com.hazelcast.spi.partition.IPartitionService)9 Map (java.util.Map)7 Operation (com.hazelcast.spi.Operation)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 IPartition (com.hazelcast.spi.partition.IPartition)5 Member (com.hazelcast.core.Member)4 SenderTasklet (com.hazelcast.jet.impl.execution.SenderTasklet)4 Collection (java.util.Collection)4 AtomicReferenceContainer (com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer)3 IFunction (com.hazelcast.core.IFunction)3 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)3 JetInstance (com.hazelcast.jet.JetInstance)3 JobConfig (com.hazelcast.jet.config.JobConfig)3 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)3 Util.getJetInstance (com.hazelcast.jet.impl.util.Util.getJetInstance)3