Search in sources :

Example 51 with Address

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

the class MemberGroupFactoryTest method createMembers.

private Collection<Member> createMembers() throws UnknownHostException {
    Collection<Member> members = new HashSet<Member>();
    InetAddress fakeAddress = InetAddress.getLocalHost();
    members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5702), VERSION, false));
    return members;
}
Also used : Address(com.hazelcast.nio.Address) InetAddress(java.net.InetAddress) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet)

Example 52 with Address

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

the class ScheduledTaskHandlerImplTest method of_addressConstructor.

@Test
public void of_addressConstructor() throws Exception {
    Address addr = new Address("127.0.0.1", 0);
    ScheduledTaskHandler handler = ScheduledTaskHandlerImpl.of(addr, "Scheduler", "Task");
    String expectedURN = "urn:hzScheduledTaskHandler:127.0.0.1:0-1SchedulerTask";
    assertTrue(handler.isAssignedToMember());
    assertEquals(-1, handler.getPartitionId());
    assertEquals(addr, handler.getAddress());
    assertEquals("Scheduler", handler.getSchedulerName());
    assertEquals("Task", handler.getTaskName());
    assertEquals(expectedURN, handler.toUrn());
}
Also used : Address(com.hazelcast.nio.Address) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 53 with Address

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

the class ScheduledTaskHandlerImplTest method of_withValidAddress.

@Test
public void of_withValidAddress() throws Exception {
    Address addr = new Address("127.0.0.1", 0);
    ScheduledTaskHandler handler = ScheduledTaskHandler.of("urn:hzScheduledTaskHandler:127.0.0.1:0-1SchedulerTask");
    assertTrue(handler.isAssignedToMember());
    assertEquals(-1, handler.getPartitionId());
    assertEquals(addr, handler.getAddress());
    assertEquals("Scheduler", handler.getSchedulerName());
    assertEquals("Task", handler.getTaskName());
}
Also used : Address(com.hazelcast.nio.Address) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 54 with Address

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

the class MockConnectionManager method onClose.

public void onClose(final Connection connection) {
    final Address endPoint = connection.getEndPoint();
    if (mapConnections.remove(endPoint, connection)) {
        logger.info("Removed connection to endpoint: " + endPoint + ", connection: " + connection);
        ioService.getEventService().executeEventCallback(new StripedRunnable() {

            @Override
            public void run() {
                for (ConnectionListener listener : connectionListeners) {
                    listener.connectionRemoved(connection);
                }
            }

            @Override
            public int getKey() {
                return endPoint.hashCode();
            }
        });
    }
}
Also used : StripedRunnable(com.hazelcast.util.executor.StripedRunnable) Address(com.hazelcast.nio.Address) ConnectionListener(com.hazelcast.nio.ConnectionListener)

Example 55 with Address

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

the class ClientCacheMetaDataFetcher method scanMembers.

@Override
protected List<InternalCompletableFuture> scanMembers(List<String> names) {
    Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
    List<InternalCompletableFuture> futures = new ArrayList<InternalCompletableFuture>(members.size());
    for (Member member : members) {
        Address address = member.getAddress();
        ClientMessage message = encodeRequest(names, address);
        ClientInvocation invocation = new ClientInvocation(clientImpl, message, address);
        try {
            futures.add(invocation.invoke());
        } catch (Exception e) {
            if (logger.isWarningEnabled()) {
                logger.warning("Cant fetch invalidation meta-data from address + " + address + " + [" + e.getMessage() + "]");
            }
        }
    }
    return futures;
}
Also used : Address(com.hazelcast.nio.Address) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) ArrayList(java.util.ArrayList) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) Member(com.hazelcast.core.Member) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Address (com.hazelcast.nio.Address)274 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 HashMap (java.util.HashMap)33 ParallelTest (com.hazelcast.test.annotation.ParallelTest)29 Member (com.hazelcast.core.Member)27 ArrayList (java.util.ArrayList)27 Map (java.util.Map)26 ILogger (com.hazelcast.logging.ILogger)25 InetAddress (java.net.InetAddress)25 MemberImpl (com.hazelcast.instance.MemberImpl)21 List (java.util.List)20 HashSet (java.util.HashSet)18 Connection (com.hazelcast.nio.Connection)17 NodeEngine (com.hazelcast.spi.NodeEngine)16 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)16 IOException (java.io.IOException)16 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 IPartitionService (com.hazelcast.spi.partition.IPartitionService)13