Search in sources :

Example 6 with HTTPCommunicator

use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.

the class IOBalancerMemoryLeakTest method testMemoryLeak_with_RestConnections.

@Test
public void testMemoryLeak_with_RestConnections() throws IOException {
    Config config = new Config();
    config.setClusterName(randomName());
    config.getNetworkConfig().getRestApiConfig().setEnabled(true);
    config.setProperty(ClusterProperty.IO_BALANCER_INTERVAL_SECONDS.getName(), "1");
    HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    for (int i = 0; i < 100; i++) {
        communicator.getClusterInfo();
    }
    final IOBalancer ioBalancer = getIoBalancer(instance);
    assertTrueEventually(() -> {
        int inPipelineSize = ioBalancer.getInLoadTracker().getPipelines().size();
        int outPipelineSize = ioBalancer.getOutLoadTracker().getPipelines().size();
        assertEquals(0, inPipelineSize);
        assertEquals(0, outPipelineSize);
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 7 with HTTPCommunicator

use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.

the class AdvancedNetworkingCommunicationIntegrationTest method testRestConnectionToEndpoints.

@Test
public void testRestConnectionToEndpoints() throws IOException {
    Config config = createCompleteMultiSocketConfig();
    HazelcastInstance hz = newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(hz, "/127.0.0.1:" + REST_PORT);
    final String expected = "{\"status\":\"success\"," + "\"version\":\"" + hz.getCluster().getClusterVersion().toString() + "\"}";
    assertEquals(expected, communicator.getClusterVersion());
    testRestCallFailsOnPort(hz, MEMBER_PORT);
    testRestCallFailsOnPort(hz, CLIENT_PORT);
    testRestCallFailsOnPort(hz, WAN1_PORT);
    testRestCallFailsOnPort(hz, MEMCACHE_PORT);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) JoinConfig(com.hazelcast.config.JoinConfig) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 8 with HTTPCommunicator

use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.

the class WanOpenSourceAntiEntropyMcEventsTest method testConsistencyCheckREST.

@Test
public void testConsistencyCheckREST() throws Exception {
    System.setProperty(HAZELCAST_TEST_USE_NETWORK, "true");
    HazelcastInstance hz = createHazelcastInstance(getConfigWithRest());
    HTTPCommunicator communicator = new HTTPCommunicator(hz);
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    ManagementCenterService mcService = nodeEngine.getManagementCenterService();
    List<Event> events = new LinkedList<>();
    CountDownLatch latch = new CountDownLatch(1);
    mcService.setEventListener(event -> {
        events.add(event);
        latch.countDown();
    });
    String jsonResult = communicator.wanMapConsistencyCheck(hz.getConfig().getClusterName(), "", WAN_REPLICATION_NAME, WAN_PUBLISHER_ID, MAP_NAME);
    assertOpenEventually(latch);
    JsonObject result = Json.parse(jsonResult).asObject();
    Event event = events.get(0);
    assertTrue(event instanceof WanConsistencyCheckIgnoredEvent);
    WanConsistencyCheckIgnoredEvent checkIgnoredEvent = (WanConsistencyCheckIgnoredEvent) event;
    assertNotNull(checkIgnoredEvent.getUuid());
    assertNull(result.getString("uuid", null));
    assertEquals(MAP_NAME, checkIgnoredEvent.getMapName());
    assertEquals(WAN_CONSISTENCY_CHECK_IGNORED, checkIgnoredEvent.getType());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) Event(com.hazelcast.internal.management.events.Event) WanConsistencyCheckIgnoredEvent(com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent) WanSyncIgnoredEvent(com.hazelcast.internal.management.events.WanSyncIgnoredEvent) JsonObject(com.hazelcast.internal.json.JsonObject) WanConsistencyCheckIgnoredEvent(com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent) CountDownLatch(java.util.concurrent.CountDownLatch) LinkedList(java.util.LinkedList) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) Test(org.junit.Test)

Example 9 with HTTPCommunicator

use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.

the class WanOpenSourceAntiEntropyMcEventsTest method testSyncREST.

@Test
public void testSyncREST() throws Exception {
    System.setProperty(HAZELCAST_TEST_USE_NETWORK, "true");
    HazelcastInstance hz = createHazelcastInstance(getConfigWithRest());
    HTTPCommunicator communicator = new HTTPCommunicator(hz);
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    ManagementCenterService mcService = nodeEngine.getManagementCenterService();
    List<Event> events = new LinkedList<>();
    CountDownLatch latch = new CountDownLatch(1);
    mcService.setEventListener(event -> {
        events.add(event);
        latch.countDown();
    });
    String jsonResult = communicator.syncMapOverWAN(hz.getConfig().getClusterName(), "", WAN_REPLICATION_NAME, WAN_PUBLISHER_ID, MAP_NAME);
    assertOpenEventually(latch);
    JsonObject result = Json.parse(jsonResult).asObject();
    Event event = events.get(0);
    assertTrue(event instanceof WanSyncIgnoredEvent);
    WanSyncIgnoredEvent syncIgnoredEvent = (WanSyncIgnoredEvent) event;
    assertNotNull(syncIgnoredEvent.getUuid());
    assertNull(result.getString("uuid", null));
    assertEquals(MAP_NAME, syncIgnoredEvent.getMapName());
    assertEquals(WAN_SYNC_IGNORED, syncIgnoredEvent.getType());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) Event(com.hazelcast.internal.management.events.Event) WanConsistencyCheckIgnoredEvent(com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent) WanSyncIgnoredEvent(com.hazelcast.internal.management.events.WanSyncIgnoredEvent) JsonObject(com.hazelcast.internal.json.JsonObject) WanSyncIgnoredEvent(com.hazelcast.internal.management.events.WanSyncIgnoredEvent) CountDownLatch(java.util.concurrent.CountDownLatch) LinkedList(java.util.LinkedList) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) Test(org.junit.Test)

Aggregations

HTTPCommunicator (com.hazelcast.internal.ascii.HTTPCommunicator)9 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 Test (org.junit.Test)6 Config (com.hazelcast.config.Config)3 JsonObject (com.hazelcast.internal.json.JsonObject)3 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)3 Event (com.hazelcast.internal.management.events.Event)3 WanConsistencyCheckIgnoredEvent (com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent)3 WanSyncIgnoredEvent (com.hazelcast.internal.management.events.WanSyncIgnoredEvent)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)3 LinkedList (java.util.LinkedList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 NightlyTest (com.hazelcast.test.annotation.NightlyTest)2 JoinConfig (com.hazelcast.config.JoinConfig)1 TcpIpConnectionManager (com.hazelcast.nio.tcp.TcpIpConnectionManager)1 AssertTask (com.hazelcast.test.AssertTask)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 IOException (java.io.IOException)1 SocketException (java.net.SocketException)1