Search in sources :

Example 61 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class ScheduledExecutorServiceProxy method submitOnMemberSync.

@Nonnull
private <V> IScheduledFuture<V> submitOnMemberSync(String taskName, Operation op, Member member) {
    UUID uuid = member.getUuid();
    Address address = member.getAddress();
    getOperationService().invokeOnTarget(getServiceName(), op, address).joinInternal();
    return createFutureProxy(uuid, taskName);
}
Also used : Address(com.hazelcast.cluster.Address) UUID(java.util.UUID) Nonnull(javax.annotation.Nonnull)

Example 62 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class TransactionManagerServiceImpl method pickBackupLogAddresses.

Address[] pickBackupLogAddresses(int durability) {
    if (durability == 0) {
        return EMPTY_ADDRESSES;
    }
    // This should be cleaned up because this is quite a complex approach since it depends on
    // the number of members in the cluster and creates litter.
    ClusterService clusterService = nodeEngine.getClusterService();
    List<MemberImpl> members = new ArrayList<>(clusterService.getMemberImpls());
    members.remove(nodeEngine.getLocalMember());
    int c = Math.min(members.size(), durability);
    shuffle(members);
    Address[] addresses = new Address[c];
    for (int i = 0; i < c; i++) {
        addresses[i] = members.get(i).getAddress();
    }
    return addresses;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList)

Example 63 with Address

use of com.hazelcast.cluster.Address 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);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) PurgeTxBackupLogOperation(com.hazelcast.transaction.impl.operations.PurgeTxBackupLogOperation) ReplicateTxBackupLogOperation(com.hazelcast.transaction.impl.operations.ReplicateTxBackupLogOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) RollbackTxBackupLogOperation(com.hazelcast.transaction.impl.operations.RollbackTxBackupLogOperation) CreateTxBackupLogOperation(com.hazelcast.transaction.impl.operations.CreateTxBackupLogOperation)

Example 64 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class TransactionImpl method rollbackBackupLogs.

private void rollbackBackupLogs() {
    if (!backupLogsCreated) {
        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) {
            Future f = operationService.invokeOnTarget(SERVICE_NAME, createRollbackTxBackupLogOperation(), backupAddress);
            futures.add(f);
        }
    }
    waitWithDeadline(futures, timeoutMillis, MILLISECONDS, rollbackTxExceptionHandler);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 65 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class TransactionLog method invokeAsync.

private void invokeAsync(NodeEngine nodeEngine, BiConsumer callback, TransactionLogRecord record, Operation op) {
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    if (record instanceof TargetAwareTransactionLogRecord) {
        Address target = ((TargetAwareTransactionLogRecord) record).getTarget();
        operationService.invokeOnTarget(op.getServiceName(), op, target);
    } else {
        operationService.invokeOnPartitionAsync(op.getServiceName(), op, op.getPartitionId()).whenCompleteAsync(callback);
    }
}
Also used : Address(com.hazelcast.cluster.Address) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Aggregations

Address (com.hazelcast.cluster.Address)540 Test (org.junit.Test)211 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)178 HazelcastInstance (com.hazelcast.core.HazelcastInstance)92 InetAddress (java.net.InetAddress)75 ArrayList (java.util.ArrayList)66 Member (com.hazelcast.cluster.Member)63 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)54 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)48 Config (com.hazelcast.config.Config)43 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)43 UUID (java.util.UUID)43 ILogger (com.hazelcast.logging.ILogger)37 HashMap (java.util.HashMap)36 Operation (com.hazelcast.spi.impl.operationservice.Operation)35 List (java.util.List)35 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)34 Map (java.util.Map)33 InetSocketAddress (java.net.InetSocketAddress)32