Search in sources :

Example 51 with NodeEngine

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

the class ObjectMultiMapProxy method put.

@Override
public boolean put(K key, V 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 putInternal(dataKey, dataValue, -1);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Data(com.hazelcast.nio.serialization.Data)

Example 52 with NodeEngine

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

the class ObjectMultiMapProxy method tryLock.

@Override
public boolean tryLock(K key) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    return lockSupport.tryLock(nodeEngine, dataKey);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Data(com.hazelcast.nio.serialization.Data)

Example 53 with NodeEngine

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

the class DefaultRecordStore method clearPartition.

@Override
public void clearPartition(boolean onShutdown) {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
    Indexes indexes = mapContainer.getIndexes();
    if (indexes.hasIndex()) {
        for (Record record : storage.values()) {
            Data key = record.getKey();
            Object value = Records.getValueOrCachedValue(record, serializationService);
            indexes.removeEntryIndex(key, value);
        }
    }
    mapDataStore.reset();
    if (onShutdown) {
        NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
        boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
        if (shouldClear) {
            storage.clear(true);
        }
        storage.destroy(true);
    } else {
        storage.clear(false);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService) Record(com.hazelcast.map.impl.record.Record) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes)

Example 54 with NodeEngine

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

the class MapReduceUtil method notifyRemoteException.

public static void notifyRemoteException(JobSupervisor supervisor, Throwable throwable) {
    MapReduceService mapReduceService = supervisor.getMapReduceService();
    NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    try {
        Address jobOwner = supervisor.getJobOwner();
        if (supervisor.isOwnerNode()) {
            supervisor.notifyRemoteException(jobOwner, throwable);
        } else {
            String name = supervisor.getConfiguration().getName();
            String jobId = supervisor.getConfiguration().getJobId();
            NotifyRemoteExceptionOperation operation = new NotifyRemoteExceptionOperation(name, jobId, throwable);
            OperationService os = nodeEngine.getOperationService();
            os.send(operation, jobOwner);
        }
    } catch (Exception e) {
        ILogger logger = nodeEngine.getLogger(MapReduceUtil.class);
        logger.warning("Could not notify remote map-reduce owner", e);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService) NotifyRemoteExceptionOperation(com.hazelcast.mapreduce.impl.operation.NotifyRemoteExceptionOperation) RemoteMapReduceException(com.hazelcast.mapreduce.RemoteMapReduceException) TimeoutException(java.util.concurrent.TimeoutException)

Example 55 with NodeEngine

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

the class NodeStateTest method shouldReject_NormalOperationExecution_whilePassive.

@Test
public void shouldReject_NormalOperationExecution_whilePassive() throws Exception {
    InvocationTask task = new InvocationTask() {

        @Override
        public void invoke(NodeEngine nodeEngine) throws Exception {
            final CountDownLatch latch = new CountDownLatch(1);
            Operation op = new DummyOperation() {

                @Override
                public void onExecutionFailure(Throwable e) {
                    latch.countDown();
                }

                @Override
                public boolean returnsResponse() {
                    return false;
                }
            };
            nodeEngine.getOperationService().run(op);
            assertOpenEventually(latch);
        }
    };
    testInvocation_whilePassive(task);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Operation(com.hazelcast.spi.Operation) CountDownLatch(java.util.concurrent.CountDownLatch) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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