Search in sources :

Example 96 with Address

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

the class ClientQueryCacheContextTest method testInvokerWrapper_invokeOnTarget_whenRequestIsNull_thenThrowException.

@Test(expected = NullPointerException.class)
public void testInvokerWrapper_invokeOnTarget_whenRequestIsNull_thenThrowException() {
    Address address = new Address();
    context.getInvokerWrapper().invokeOnTarget(null, address);
}
Also used : Address(com.hazelcast.nio.Address) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 97 with Address

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

the class ClientPartitionLostListenerTest method test_portableMapPartitionLostEvent_serialization.

@Test
public void test_portableMapPartitionLostEvent_serialization() throws IOException {
    final Address source = new Address();
    final PortablePartitionLostEvent event = new PortablePartitionLostEvent(1, 2, source);
    final PortableWriter writer = mock(PortableWriter.class);
    final ObjectDataOutput output = mock(ObjectDataOutput.class);
    when(writer.getRawDataOutput()).thenReturn(output);
    event.writePortable(writer);
    verify(writer).writeInt("p", 1);
    verify(writer).writeInt("l", 2);
    verify(output).writeObject(source);
}
Also used : PortablePartitionLostEvent(com.hazelcast.spi.impl.PortablePartitionLostEvent) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) Address(com.hazelcast.nio.Address) HazelcastTestSupport.getAddress(com.hazelcast.test.HazelcastTestSupport.getAddress) PortableWriter(com.hazelcast.nio.serialization.PortableWriter) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 98 with Address

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

the class ProxyManagerTest method testNextAddressToSendCreateRequestOnMultipleLiteMembers.

@Test
public void testNextAddressToSendCreateRequestOnMultipleLiteMembers() {
    final List<HazelcastInstance> instances = createNodes(3, 0);
    final HazelcastInstance client = factory.newHazelcastClient();
    final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
    Set<Address> addresses = new HashSet<Address>();
    final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
    for (int i = 0; i < instances.size() * 100; i++) {
        addresses.add(proxyManager.findNextAddressToSendCreateRequest());
    }
    assertEquals(1, addresses.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) ProxyManager(com.hazelcast.client.spi.ProxyManager) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientTestUtil.getHazelcastClientInstanceImpl(com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 99 with Address

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

the class QuorumTestUtil method getClientConfig.

public static ClientConfig getClientConfig(HazelcastInstance instance) {
    ClientConfig clientConfig = new ClientConfig();
    Address address = getNode(instance).address;
    clientConfig.getNetworkConfig().addAddress(address.getHost() + ":" + address.getPort());
    clientConfig.getGroupConfig().setName(instance.getConfig().getGroupConfig().getName());
    return clientConfig;
}
Also used : Address(com.hazelcast.nio.Address) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 100 with Address

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

the class ClientDiscoverySpiTest method test_discovery_address_translator_with_public_ip.

@Test
public void test_discovery_address_translator_with_public_ip() throws Exception {
    String xmlFileName = "hazelcast-client-discovery-spi-test.xml";
    InputStream xmlResource = ClientDiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    ClientConfig clientConfig = new XmlClientConfigBuilder(xmlResource).build();
    ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
    DiscoveryConfig discoveryConfig = networkConfig.getDiscoveryConfig();
    DiscoveryServiceProvider provider = new DefaultDiscoveryServiceProvider();
    DiscoveryService discoveryService = provider.newDiscoveryService(buildDiscoveryServiceSettings(discoveryConfig));
    AddressTranslator translator = new DiscoveryAddressTranslator(discoveryService, true);
    Address publicAddress = new Address("127.0.0.1", 50001);
    Address privateAddress = new Address("127.0.0.1", 1);
    // Enforce refresh of the internal mapping
    assertEquals(publicAddress, translator.translate(privateAddress));
}
Also used : Address(com.hazelcast.nio.Address) InputStream(java.io.InputStream) DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) AddressTranslator(com.hazelcast.client.connection.AddressTranslator) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) ClientConfig(com.hazelcast.client.config.ClientConfig) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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