Search in sources :

Example 86 with NodeEngine

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

the class TransactionLogTest method prepare_targetAwareRecord.

@Test
public void prepare_targetAwareRecord() throws Exception {
    OperationService operationService = mock(OperationService.class);
    NodeEngine nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getOperationService()).thenReturn(operationService);
    TransactionLog log = new TransactionLog();
    Address target = new Address(InetAddress.getLocalHost(), 5000);
    TargetAwareTransactionLogRecord targetRecord = mock(TargetAwareTransactionLogRecord.class);
    when(targetRecord.getTarget()).thenReturn(target);
    DummyTargetOperation targetOperation = new DummyTargetOperation();
    when(targetRecord.newPrepareOperation()).thenReturn(targetOperation);
    log.add(targetRecord);
    log.prepare(nodeEngine);
    verify(operationService, times(1)).invokeOnTarget(targetOperation.getServiceName(), targetOperation, target);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) InetAddress(java.net.InetAddress) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 87 with NodeEngine

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

the class TransactionLogTest method rollback_partitionSpecificRecord.

@Test
public void rollback_partitionSpecificRecord() throws Exception {
    OperationService operationService = mock(OperationService.class);
    NodeEngine nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getOperationService()).thenReturn(operationService);
    TransactionLog log = new TransactionLog();
    TransactionLogRecord partitionRecord = mock(TransactionLogRecord.class);
    Operation partitionOperation = new DummyPartitionOperation();
    when(partitionRecord.newRollbackOperation()).thenReturn(partitionOperation);
    log.add(partitionRecord);
    log.rollback(nodeEngine);
    verify(operationService, times(1)).invokeOnPartition(partitionOperation.getServiceName(), partitionOperation, partitionOperation.getPartitionId());
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 88 with NodeEngine

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

the class TransactionLogTest method rollback_targetAwareRecord.

@Test
public void rollback_targetAwareRecord() throws Exception {
    OperationService operationService = mock(OperationService.class);
    NodeEngine nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getOperationService()).thenReturn(operationService);
    TransactionLog log = new TransactionLog();
    Address target = new Address(InetAddress.getLocalHost(), 5000);
    TargetAwareTransactionLogRecord targetRecord = mock(TargetAwareTransactionLogRecord.class);
    when(targetRecord.getTarget()).thenReturn(target);
    DummyTargetOperation targetOperation = new DummyTargetOperation();
    when(targetRecord.newRollbackOperation()).thenReturn(targetOperation);
    log.add(targetRecord);
    log.rollback(nodeEngine);
    verify(operationService, times(1)).invokeOnTarget(targetOperation.getServiceName(), targetOperation, target);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) InetAddress(java.net.InetAddress) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 89 with NodeEngine

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

the class PeekWrappedP method init.

@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) {
    logger = context.logger();
    outbox = new LoggingOutbox(outbox, peekOutput, peekSnapshot);
    // and also other objects could be mocked or null, such as jetInstance())
    if (context instanceof ProcCtx) {
        ProcCtx c = (ProcCtx) context;
        NodeEngine nodeEngine = ((HazelcastInstanceImpl) c.jetInstance().getHazelcastInstance()).node.nodeEngine;
        ILogger newLogger = nodeEngine.getLogger(createLoggerName(wrapped.getClass().getName(), c.vertexName(), c.globalProcessorIndex()));
        context = new ProcCtx(c.jetInstance(), c.getSerializationService(), newLogger, c.vertexName(), c.globalProcessorIndex(), c.processingGuarantee(), c.localParallelism(), c.totalParallelism());
    }
    super.init(outbox, context);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ProcCtx(com.hazelcast.jet.impl.execution.init.Contexts.ProcCtx) ILogger(com.hazelcast.logging.ILogger)

Example 90 with NodeEngine

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

the class Networking method createFlowControlPacket.

private byte[] createFlowControlPacket(Address member) throws IOException {
    try (BufferObjectDataOutput out = createObjectDataOutput(nodeEngine)) {
        final boolean[] hasData = { false };
        Map<Long, ExecutionContext> executionContexts = jobExecutionService.getExecutionContextsFor(member);
        out.writeInt(executionContexts.size());
        executionContexts.forEach((execId, exeCtx) -> uncheckRun(() -> {
            out.writeLong(execId);
            out.writeInt(exeCtx.receiverMap().values().stream().mapToInt(Map::size).sum());
            exeCtx.receiverMap().forEach((vertexId, ordinalToSenderToTasklet) -> ordinalToSenderToTasklet.forEach((ordinal, senderToTasklet) -> uncheckRun(() -> {
                out.writeInt(vertexId);
                out.writeInt(ordinal);
                out.writeInt(senderToTasklet.get(member).updateAndGetSendSeqLimitCompressed());
                hasData[0] = true;
            })));
        }));
        return hasData[0] ? out.toByteArray() : EMPTY_BYTES;
    }
}
Also used : Util.createObjectDataOutput(com.hazelcast.jet.impl.util.Util.createObjectDataOutput) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Util.getMemberConnection(com.hazelcast.jet.impl.util.Util.getMemberConnection) ScheduledFuture(java.util.concurrent.ScheduledFuture) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) Util.createObjectDataInput(com.hazelcast.jet.impl.util.Util.createObjectDataInput) Util.getRemoteMembers(com.hazelcast.jet.impl.util.Util.getRemoteMembers) Util.uncheckRun(com.hazelcast.jet.impl.util.Util.uncheckRun) FLAG_JET_FLOW_CONTROL(com.hazelcast.nio.Packet.FLAG_JET_FLOW_CONTROL) Address(com.hazelcast.nio.Address) SenderTasklet(com.hazelcast.jet.impl.execution.SenderTasklet) IOException(java.io.IOException) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) NodeEngine(com.hazelcast.spi.NodeEngine) ExceptionUtil.sneakyThrow(com.hazelcast.jet.impl.util.ExceptionUtil.sneakyThrow) Util.idToString(com.hazelcast.jet.impl.util.Util.idToString) Connection(com.hazelcast.nio.Connection) ILogger(com.hazelcast.logging.ILogger) Map(java.util.Map) FLAG_URGENT(com.hazelcast.nio.Packet.FLAG_URGENT) BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) Optional(java.util.Optional) BufferObjectDataInput(com.hazelcast.nio.BufferObjectDataInput) Packet(com.hazelcast.nio.Packet) BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)163 Data (com.hazelcast.nio.serialization.Data)50 OperationService (com.hazelcast.spi.OperationService)30 Address (com.hazelcast.nio.Address)25 ILogger (com.hazelcast.logging.ILogger)20 Operation (com.hazelcast.spi.Operation)14 IPartitionService (com.hazelcast.spi.partition.IPartitionService)14 Member (com.hazelcast.core.Member)12 Future (java.util.concurrent.Future)12 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)11 Test (org.junit.Test)10 InitializingObject (com.hazelcast.spi.InitializingObject)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)8 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)8 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)7