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);
});
}
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);
}
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());
}
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());
}
Aggregations