Search in sources :

Example 76 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class MemberMap method cloneExcluding.

/**
     * Creates clone of source {@code MemberMap}, excluding given members.
     * If source is empty, same map instance will be returned. If excluded members are empty or not present in
     * source, a new map will be created containing the same members with source.
     *
     * @param source         source map
     * @param excludeMembers members to exclude
     * @return clone map
     */
static MemberMap cloneExcluding(MemberMap source, MemberImpl... excludeMembers) {
    if (source.size() == 0) {
        return source;
    }
    Map<Address, MemberImpl> addressMap = new LinkedHashMap<Address, MemberImpl>(source.addressToMemberMap);
    Map<String, MemberImpl> uuidMap = new LinkedHashMap<String, MemberImpl>(source.uuidToMemberMap);
    for (MemberImpl member : excludeMembers) {
        MemberImpl removed = addressMap.remove(member.getAddress());
        if (removed != null) {
            uuidMap.remove(removed.getUuid());
        }
        removed = uuidMap.remove(member.getUuid());
        if (removed != null) {
            addressMap.remove(removed.getAddress());
        }
    }
    return new MemberMap(addressMap, uuidMap);
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) LinkedHashMap(java.util.LinkedHashMap)

Example 77 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class TransactionManagerServiceImpl method memberRemoved.

@Override
public void memberRemoved(MembershipServiceEvent event) {
    MemberImpl member = event.getMember();
    final String uuid = member.getUuid();
    if (nodeEngine.isRunning()) {
        logger.info("Committing/rolling-back alive transactions of " + member + ", UUID: " + uuid);
        nodeEngine.getExecutionService().execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {

            @Override
            public void run() {
                finalizeTransactionsOf(uuid);
            }
        });
    } else if (logger.isFinestEnabled()) {
        logger.finest("Will not commit/roll-back transactions of " + member + ", UUID: " + uuid + " because this member is not running");
    }
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl)

Example 78 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class ReliableMessageListenerRunner method toMessage.

private Message<E> toMessage(ReliableTopicMessage m) {
    MemberImpl member = clusterService.getMember(m.getPublisherAddress());
    E payload = serializationService.toObject(m.getPayload());
    return new Message<E>(topicName, payload, m.getPublishTime(), member);
}
Also used : Message(com.hazelcast.core.Message) MemberImpl(com.hazelcast.instance.MemberImpl)

Example 79 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class SerializationTest method testMemberLeftException_usingMemberImpl.

@Test
public void testMemberLeftException_usingMemberImpl() throws Exception {
    String uuid = UuidUtil.newUnsecureUuidString();
    String host = "127.0.0.1";
    int port = 5000;
    Member member = new MemberImpl(new Address(host, port), MemberVersion.of("3.8.0"), false, uuid, null);
    testMemberLeftException(uuid, host, port, member);
}
Also used : Address(com.hazelcast.nio.Address) InetSocketAddress(java.net.InetSocketAddress) SimpleMemberImpl(com.hazelcast.instance.SimpleMemberImpl) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 80 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class TransactionImpl_OnePhaseTest method setup.

@Before
public void setup() {
    HazelcastInstance hz = createHazelcastInstance();
    operationService = getOperationService(hz);
    logger = mock(ILogger.class);
    txManagerService = mock(TransactionManagerServiceImpl.class);
    txManagerService.commitCount = MwCounter.newMwCounter();
    txManagerService.startCount = MwCounter.newMwCounter();
    txManagerService.rollbackCount = MwCounter.newMwCounter();
    nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getOperationService()).thenReturn(operationService);
    when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl());
    when(nodeEngine.getLogger(TransactionImpl.class)).thenReturn(logger);
    options = new TransactionOptions().setTransactionType(ONE_PHASE);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberImpl(com.hazelcast.instance.MemberImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Aggregations

MemberImpl (com.hazelcast.instance.MemberImpl)86 Address (com.hazelcast.nio.Address)37 Test (org.junit.Test)18 Member (com.hazelcast.core.Member)17 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelTest (com.hazelcast.test.annotation.ParallelTest)14 ArrayList (java.util.ArrayList)12 InetAddress (java.net.InetAddress)9 Future (java.util.concurrent.Future)9 HashSet (java.util.HashSet)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)5 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)5 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)5 ILogger (com.hazelcast.logging.ILogger)5 OperationService (com.hazelcast.spi.OperationService)5 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)5 Before (org.junit.Before)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4