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);
}
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());
}
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);
}
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);
}
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;
}
}
Aggregations