use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class TransactionImpl method replicateTxnLog.
private void replicateTxnLog() {
if (skipBackupLogReplication()) {
return;
}
OperationService operationService = nodeEngine.getOperationService();
ClusterService clusterService = nodeEngine.getClusterService();
List<Future> futures = new ArrayList<Future>(backupAddresses.length);
for (Address backupAddress : backupAddresses) {
if (clusterService.getMember(backupAddress) != null) {
Operation op = createReplicateTxBackupLogOperation();
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, backupAddress);
futures.add(f);
}
}
waitWithDeadline(futures, timeoutMillis, MILLISECONDS, replicationTxExceptionHandler);
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects.
@Test
public void testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects() throws Exception {
HazelcastInstance instance = factory.newHazelcastInstance();
factory.newHazelcastClient();
factory.newHazelcastClient();
Node node = getNode(instance);
Operation operation = new GetConnectedClientsOperation();
OperationService operationService = node.nodeEngine.getOperationService();
Future<Map<String, String>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
Map<String, String> clients = future.get();
assertEquals(2, clients.size());
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class OperationDescriptors method toOperationDesc.
public static String toOperationDesc(Operation op) {
Class<? extends Operation> operationClass = op.getClass();
if (PartitionIteratingOperation.class.isAssignableFrom(operationClass)) {
PartitionIteratingOperation partitionIteratingOperation = (PartitionIteratingOperation) op;
OperationFactory operationFactory = partitionIteratingOperation.getOperationFactory();
String desc = DESCRIPTORS.get(operationFactory.getClass().getName());
if (desc == null) {
desc = PartitionIteratingOperation.class.getSimpleName() + "(" + operationFactory.getClass().getName() + ")";
DESCRIPTORS.put(operationFactory.getClass().getName(), desc);
}
return desc;
} else if (Backup.class.isAssignableFrom(operationClass)) {
Backup backup = (Backup) op;
Operation backupOperation = backup.getBackupOp();
String desc = DESCRIPTORS.get(backupOperation.getClass().getName());
if (desc == null) {
desc = Backup.class.getSimpleName() + "(" + backup.getBackupOp().getClass().getName() + ")";
DESCRIPTORS.put(backupOperation.getClass().getName(), desc);
}
return desc;
} else {
return operationClass.getName();
}
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class PartitionServiceProxy method isClusterSafe.
@Override
public boolean isClusterSafe() {
Collection<Member> members = nodeEngine.getClusterService().getMembers();
if (members == null || members.isEmpty()) {
return true;
}
final Collection<Future<Boolean>> futures = new ArrayList<>(members.size());
for (Member member : members) {
final Address target = member.getAddress();
final Operation operation = new SafeStateCheckOperation();
final Future<Boolean> future = nodeEngine.getOperationService().invokeOnTarget(InternalPartitionService.SERVICE_NAME, operation, target);
futures.add(future);
}
// todo this max wait is appropriate?
final int maxWaitTime = getMaxWaitTime();
Collection<Boolean> results = FutureUtil.returnWithDeadline(futures, maxWaitTime, TimeUnit.SECONDS, exceptionHandler);
if (results.size() != futures.size()) {
return false;
}
for (Boolean result : results) {
if (!result) {
return false;
}
}
return true;
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ReplicaFragmentMigrationState method writeData.
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeInt(namespaces.size());
for (Map.Entry<ServiceNamespace, long[]> e : namespaces.entrySet()) {
out.writeObject(e.getKey());
out.writeLongArray(e.getValue());
}
out.writeInt(migrationOperations.size());
for (Operation operation : migrationOperations) {
out.writeObject(operation);
}
chunkSerDeHelper.writeChunkedOperations(out);
}
Aggregations