Search in sources :

Example 1 with HTTPCommunicator

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

Example 2 with HTTPCommunicator

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator)

Example 3 with HTTPCommunicator

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
    }
}
Also used : SocketException(java.net.SocketException) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator)

Example 4 with HTTPCommunicator

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)));
}
Also used : HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) Before(org.junit.Before)

Example 5 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.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);
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) TcpIpConnectionManager(com.hazelcast.nio.tcp.TcpIpConnectionManager) IOException(java.io.IOException) HTTPCommunicator(com.hazelcast.internal.ascii.HTTPCommunicator) NightlyTest(com.hazelcast.test.annotation.NightlyTest) 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