Search in sources :

Example 31 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class QueueService method dispatchEvent.

@Override
public void dispatchEvent(QueueEvent event, ItemListener listener) {
    final MemberImpl member = nodeEngine.getClusterService().getMember(event.caller);
    ItemEvent itemEvent = new DataAwareItemEvent(event.name, event.eventType, event.data, member, serializationService);
    if (member == null) {
        if (logger.isInfoEnabled()) {
            logger.info("Dropping event " + itemEvent + " from unknown address:" + event.caller);
        }
        return;
    }
    if (event.eventType.equals(ItemEventType.ADDED)) {
        listener.itemAdded(itemEvent);
    } else {
        listener.itemRemoved(itemEvent);
    }
    getLocalQueueStatsImpl(event.name).incrementReceivedEvents();
}
Also used : ItemEvent(com.hazelcast.collection.ItemEvent) DataAwareItemEvent(com.hazelcast.collection.impl.common.DataAwareItemEvent) DataAwareItemEvent(com.hazelcast.collection.impl.common.DataAwareItemEvent) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 32 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class ScheduledExecutorGetAllScheduledMessageTask method accumulateTaskHandlersAsUrnValues.

@SuppressWarnings("unchecked")
private void accumulateTaskHandlersAsUrnValues(List<ScheduledTaskHandler> accumulator, Map<?, ?> taskHandlersMap) {
    ClusterService clusterService = nodeEngine.getClusterService();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    for (Map.Entry<?, ?> entry : taskHandlersMap.entrySet()) {
        MemberImpl owner;
        Object key = entry.getKey();
        if (key instanceof Number) {
            owner = clusterService.getMember(partitionService.getPartitionOwner((Integer) key));
        } else {
            owner = (MemberImpl) key;
        }
        List<ScheduledTaskHandler> handlers = (List<ScheduledTaskHandler>) entry.getValue();
        for (ScheduledTaskHandler handler : handlers) {
            ScheduledTaskHandlerAccessor.setUuid(handler, owner.getUuid());
        }
        accumulator.addAll(handlers);
    }
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) IPartitionService(com.hazelcast.internal.partition.IPartitionService) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) LinkedList(java.util.LinkedList) List(java.util.List) Map(java.util.Map)

Example 33 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class Node method mergeEnvironmentProvidedMemberMetadata.

private void mergeEnvironmentProvidedMemberMetadata() {
    MemberImpl localMember = getLocalMember();
    Map<String, String> metadata = discoveryService.discoverLocalMetadata();
    for (Map.Entry<String, String> entry : metadata.entrySet()) {
        Object value = entry.getValue();
        localMember.setAttribute(entry.getKey(), value.toString());
    }
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Map(java.util.Map) HashMap(java.util.HashMap)

Example 34 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class TransactionImplTest method setup.

@Before
public void setup() {
    HazelcastInstance hz = createHazelcastInstance();
    operationService = getOperationService(hz);
    logger = mock(ILogger.class);
    txManagerService = mock(TransactionManagerServiceImpl.class);
    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.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Example 35 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MemberImplConstructorTest method testConstructor.

@Test
public void testConstructor() {
    HazelcastInstance hz = createHazelcastInstance();
    MemberImpl memberImpl = (MemberImpl) hz.getCluster().getLocalMember();
    MemberImplConstructor constructor = new MemberImplConstructor(MemberImpl.class);
    MemberImpl clonedMemberImpl = (MemberImpl) constructor.createNew(memberImpl);
    assertEquals(memberImpl.localMember(), clonedMemberImpl.localMember());
    assertEquals(memberImpl.isLiteMember(), clonedMemberImpl.isLiteMember());
    assertEquals(memberImpl.getAddress(), clonedMemberImpl.getAddress());
    assertEquals(memberImpl.getSocketAddress(), clonedMemberImpl.getSocketAddress());
    assertEquals(memberImpl.getUuid(), clonedMemberImpl.getUuid());
    assertEquals(memberImpl.getAttributes(), clonedMemberImpl.getAttributes());
    assertEquals(memberImpl.getVersion(), clonedMemberImpl.getVersion());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) MemberImplConstructor(com.hazelcast.test.starter.constructor.MemberImplConstructor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MemberImpl (com.hazelcast.cluster.impl.MemberImpl)123 Address (com.hazelcast.cluster.Address)41 Test (org.junit.Test)37 QuickTest (com.hazelcast.test.annotation.QuickTest)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)32 Member (com.hazelcast.cluster.Member)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 UUID (java.util.UUID)14 ArrayList (java.util.ArrayList)10 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)9 HashMap (java.util.HashMap)9 InetAddress (java.net.InetAddress)8 HashSet (java.util.HashSet)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 Config (com.hazelcast.config.Config)6 Future (java.util.concurrent.Future)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)4 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)4 MembersUpdateOp (com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp)4