Search in sources :

Example 6 with Event

use of com.hazelcast.internal.management.events.Event 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

HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)6 Event (com.hazelcast.internal.management.events.Event)6 WanConsistencyCheckIgnoredEvent (com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent)6 WanSyncIgnoredEvent (com.hazelcast.internal.management.events.WanSyncIgnoredEvent)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)6 LinkedList (java.util.LinkedList)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 Test (org.junit.Test)6 HTTPCommunicator (com.hazelcast.internal.ascii.HTTPCommunicator)3 JsonObject (com.hazelcast.internal.json.JsonObject)3