use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.
the class WanOpenSourceAntiEntropyMcEventsTest method testSyncAllREST.
@Test
public void testSyncAllREST() 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.syncMapsOverWAN(hz.getConfig().getClusterName(), "", WAN_REPLICATION_NAME, WAN_PUBLISHER_ID);
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));
assertNull(syncIgnoredEvent.getMapName());
assertEquals(WAN_SYNC_IGNORED, syncIgnoredEvent.getType());
}
use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.
the class WanRESTTest method startInstance.
private void startInstance() {
HazelcastInstance instance = factory.newHazelcastInstance(getConfig());
communicator = new HTTPCommunicator(instance);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.
the class AdvancedNetworkingCommunicationIntegrationTest method testRestCallFailsOnPort.
private void testRestCallFailsOnPort(HazelcastInstance hz, int port) throws IOException {
HTTPCommunicator communicator = new HTTPCommunicator(hz, "/127.0.0.1:" + port);
try {
communicator.getClusterVersion();
fail("REST call should throw SocketException for port " + port);
} catch (SocketException ex) {
// expected
}
}
use of com.hazelcast.internal.ascii.HTTPCommunicator in project hazelcast by hazelcast.
the class RESTClientPhoneHomeTest method setUp.
@Before
public void setUp() {
config = createConfigWithRestEnabled();
instance = factory.newHazelcastInstance(config);
http = new HTTPCommunicator(instance);
stubFor(post(urlPathEqualTo("/ping")).willReturn(aResponse().withStatus(200)));
}
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.getGroupConfig().setName(randomName());
config.setProperty(GroupProperty.REST_ENABLED.getName(), "true");
config.setProperty(GroupProperty.IO_BALANCER_INTERVAL_SECONDS.getName(), "1");
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
HTTPCommunicator communicator = new HTTPCommunicator(instance);
TcpIpConnectionManager connectionManager = (TcpIpConnectionManager) getConnectionManager(instance);
for (int i = 0; i < 100; i++) {
communicator.getClusterInfo();
}
final IOBalancer ioBalancer = connectionManager.getIoBalancer();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
int inHandlerSize = ioBalancer.getInLoadTracker().getHandlers().size();
int outHandlerSize = ioBalancer.getOutLoadTracker().getHandlers().size();
Assert.assertEquals(0, inHandlerSize);
Assert.assertEquals(0, outHandlerSize);
}
});
}
Aggregations