Search in sources :

Example 41 with MemberImpl

use of com.hazelcast.instance.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, nodeEngine.getSerializationService());
    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.core.ItemEvent) DataAwareItemEvent(com.hazelcast.collection.impl.common.DataAwareItemEvent) DataAwareItemEvent(com.hazelcast.collection.impl.common.DataAwareItemEvent) MemberImpl(com.hazelcast.instance.MemberImpl)

Example 42 with MemberImpl

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

the class SerializationTest method testMemberLeftException_withLiteMemberImpl.

@Test
public void testMemberLeftException_withLiteMemberImpl() 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, null, true);
    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 43 with MemberImpl

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

the class SerializationTest method testMemberLeftException.

private void testMemberLeftException(String uuid, String host, int port, Member member) throws Exception {
    MemberLeftException exception = new MemberLeftException(member);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(exception);
    ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    MemberLeftException exception2 = (MemberLeftException) in.readObject();
    MemberImpl member2 = (MemberImpl) exception2.getMember();
    assertEquals(uuid, member2.getUuid());
    assertEquals(host, member2.getAddress().getHost());
    assertEquals(port, member2.getAddress().getPort());
    assertEquals(member.isLiteMember(), member2.isLiteMember());
    assertEquals(member.getVersion(), member2.getVersion());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SimpleMemberImpl(com.hazelcast.instance.SimpleMemberImpl) MemberImpl(com.hazelcast.instance.MemberImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) MemberLeftException(com.hazelcast.core.MemberLeftException) ObjectInputStream(java.io.ObjectInputStream)

Example 44 with MemberImpl

use of com.hazelcast.instance.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.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)

Example 45 with MemberImpl

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

the class MapPublisherCreateMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future> futures) {
    final InternalOperationService operationService = nodeEngine.getOperationService();
    final ClientEndpoint endpoint = getEndpoint();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.createAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, false, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) ClientEndpoint(com.hazelcast.client.ClientEndpoint) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) Predicate(com.hazelcast.query.Predicate)

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