use of org.apache.ignite.events.ClusterIdUpdatedEvent in project gridgain by gridgain.
the class IgniteClusterIdTagTest method testIdChangedEvent.
/**
* Verifies that event is fired when ID change request sent by user is completed.
*
* @throws Exception If failed.
*/
@Test
public void testIdChangedEvent() throws Exception {
IgniteEx ig = startGrid(0);
UUID generatedId = ig.cluster().id();
AtomicReference<UUID> previousIdFromEvent = new AtomicReference<>(null);
AtomicReference<UUID> newIdFromEvent = new AtomicReference<>(null);
AtomicBoolean evtFired = new AtomicBoolean(false);
ig.events().localListen((evt) -> {
evtFired.set(true);
ClusterIdUpdatedEvent tagUpdatedEvt = (ClusterIdUpdatedEvent) evt;
previousIdFromEvent.set(tagUpdatedEvt.previousId());
newIdFromEvent.set(tagUpdatedEvt.newId());
return true;
}, EventType.EVT_CLUSTER_ID_UPDATED);
ig.cluster().id(CUSTOM_ID_0);
assertTrue(GridTestUtils.waitForCondition(evtFired::get, 10_000));
assertEquals(generatedId, previousIdFromEvent.get());
assertEquals(CUSTOM_ID_0, newIdFromEvent.get());
}
use of org.apache.ignite.events.ClusterIdUpdatedEvent in project gridgain by gridgain.
the class IgniteClusterIdTagTest method testIdChangedEventMultinodeWithRemoteFilter.
/**
* Verifies that event about cluster ID update is fired on remote nodes as well.
*
* @throws Exception If failed.
*/
@Test
public void testIdChangedEventMultinodeWithRemoteFilter() throws Exception {
IgniteEx ig0 = startGrid(0);
IgniteEx ig1 = startGrid(1);
UUID generatedId = ig0.cluster().id();
AtomicReference<UUID> eventNodeId = new AtomicReference<>(null);
AtomicReference<UUID> previousIdFromEvent = new AtomicReference<>(null);
AtomicReference<UUID> newIdFromEvent = new AtomicReference<>(null);
AtomicBoolean evtFired = new AtomicBoolean(false);
ig0.events(ig0.cluster().forRemotes()).remoteListen((IgniteBiPredicate<UUID, Event>) (uuid, event) -> {
eventNodeId.set(uuid);
evtFired.set(true);
ClusterIdUpdatedEvent tagUpdatedEvt = (ClusterIdUpdatedEvent) event;
previousIdFromEvent.set(tagUpdatedEvt.previousId());
newIdFromEvent.set(tagUpdatedEvt.newId());
return true;
}, (IgnitePredicate<Event>) event -> event.type() == EventType.EVT_CLUSTER_ID_UPDATED);
ig0.cluster().id(CUSTOM_ID_0);
assertTrue(GridTestUtils.waitForCondition(evtFired::get, 10_000));
assertEquals(ig1.localNode().id(), eventNodeId.get());
assertEquals(generatedId, previousIdFromEvent.get());
assertEquals(CUSTOM_ID_0, newIdFromEvent.get());
}
Aggregations