Search in sources :

Example 86 with Address

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

the class RequestMapDataOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    Address callerAddress = getCallerAddress();
    int partitionId = getPartitionId();
    NodeEngine nodeEngine = getNodeEngine();
    if (logger.isFineEnabled()) {
        logger.fine("Caller " + callerAddress + " requested copy of replicated map '" + name + "' (partitionId " + partitionId + ") from " + nodeEngine.getThisAddress());
    }
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(partitionId);
    ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
    store.setLoaded(true);
    if (nodeEngine.getThisAddress().equals(callerAddress)) {
        return;
    }
    long version = store.getVersion();
    Set<RecordMigrationInfo> recordSet = getRecordSet(store);
    Operation op = new SyncReplicatedMapDataOperation(name, recordSet, version).setPartitionId(partitionId).setValidateTarget(false);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
Also used : Address(com.hazelcast.cluster.Address) PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Operation(com.hazelcast.spi.impl.operationservice.Operation) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) NodeEngine(com.hazelcast.spi.impl.NodeEngine) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 87 with Address

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

the class ClearOperation method replicateClearOperation.

private void replicateClearOperation(long version) {
    OperationService operationService = getNodeEngine().getOperationService();
    Collection<Address> members = getMemberAddresses();
    for (Address address : members) {
        Operation op = new ClearOperation(mapName, false, version).setPartitionId(getPartitionId()).setValidateTarget(false);
        operationService.createInvocationBuilder(getServiceName(), op, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
    }
}
Also used : Address(com.hazelcast.cluster.Address) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) MutatingOperation(com.hazelcast.spi.impl.operationservice.MutatingOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 88 with Address

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

the class ReplicateUpdateToCallerOperation method publishEvent.

private void publishEvent() {
    ReplicatedMapService service = getService();
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    Address thisAddress = getNodeEngine().getThisAddress();
    Data dataOldValue = getNodeEngine().toData(response.getResponse());
    if (isRemove) {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, null, name, thisAddress);
    } else {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, dataValue, name, thisAddress);
    }
}
Also used : Address(com.hazelcast.cluster.Address) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.internal.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 89 with Address

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

the class SyncStateOperation method run.

@Override
public void run() throws Exception {
    int partitionId = getPartitionId();
    shouldRun = partitionId == MEMBER_BIN;
    if (partitionId >= 0) {
        Address partitionOwner = getNodeEngine().getPartitionService().getPartitionOwner(partitionId);
        shouldRun = shouldRun || getCallerAddress().equals(partitionOwner);
    }
    if (shouldRun) {
        getContainer().syncState(taskName, state, stats, result);
    }
}
Also used : Address(com.hazelcast.cluster.Address)

Example 90 with Address

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

the class MulticastDiscoveryStrategy method discoverNodes.

@Override
public Iterable<DiscoveryNode> discoverNodes() {
    DiscoveryNode discoveryNode;
    MulticastMemberInfo multicastMemberInfo = multicastDiscoveryReceiver.receive();
    if (multicastMemberInfo == null) {
        return null;
    }
    ArrayList<DiscoveryNode> arrayList = new ArrayList<DiscoveryNode>();
    try {
        discoveryNode = new SimpleDiscoveryNode(new Address(multicastMemberInfo.getHost(), multicastMemberInfo.getPort()));
        arrayList.add(discoveryNode);
    } catch (UnknownHostException e) {
        logger.finest(e.getMessage());
    }
    return arrayList;
}
Also used : MulticastMemberInfo(com.hazelcast.spi.discovery.multicast.impl.MulticastMemberInfo) SimpleDiscoveryNode(com.hazelcast.spi.discovery.SimpleDiscoveryNode) DiscoveryNode(com.hazelcast.spi.discovery.DiscoveryNode) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) UnknownHostException(java.net.UnknownHostException) ArrayList(java.util.ArrayList) SimpleDiscoveryNode(com.hazelcast.spi.discovery.SimpleDiscoveryNode)

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