use of org.apache.ignite.IgniteEvents in project camel by apache.
the class IgniteEventsEndpoint method createIgniteEvents.
private IgniteEvents createIgniteEvents() {
Ignite ignite = ignite();
IgniteEvents events;
if (clusterGroupExpression == null) {
LOG.info("Ignite Events endpoint for event types {} using no Cluster Group.", this.events);
events = ignite.events();
} else {
ClusterGroup group = clusterGroupExpression.getClusterGroup(ignite);
LOG.info("Ignite Events endpoint for event types {} using Cluster Group: {}.", this.events, group);
events = ignite.events(group);
}
return events;
}
use of org.apache.ignite.IgniteEvents in project ignite by apache.
the class GridEventStorageRuntimeConfigurationSelfTest method getEnabledEvents.
/**
* @param limit Loop limit.
* @param g Grid.
* @param customTypes Array of event types.
* @return Enabled events counted with loop (1..limit) and checks of custom types.
*/
private int[] getEnabledEvents(int limit, Ignite g, int... customTypes) {
Collection<Integer> res = new HashSet<>();
IgniteEvents evts = g.events();
for (int i = 1; i <= limit; i++) {
if (evts.isEnabled(i))
res.add(i);
}
if (customTypes != null) {
for (int i : customTypes) if (evts.isEnabled(i))
res.add(i);
}
return U.toIntArray(res);
}
use of org.apache.ignite.IgniteEvents in project ignite by apache.
the class GridEventStorageRuntimeConfigurationSelfTest method testEnableDisable.
/**
* @throws Exception If failed.
*/
public void testEnableDisable() throws Exception {
inclEvtTypes = null;
try {
Ignite g = startGrid();
IgniteEvents evts = g.events();
evts.enableLocal(EVT_CACHE_OBJECT_PUT);
evts.disableLocal(EVT_CACHE_OBJECT_PUT);
for (int evtType : evts.enabledEvents()) assertFalse(evtType == EVT_CACHE_OBJECT_PUT);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.IgniteEvents in project ignite by apache.
the class IgniteWalReaderTest method testArchiveCompletedEventFired.
/**
* Tests archive completed event is fired.
*
* @throws Exception if failed.
*/
public void testArchiveCompletedEventFired() throws Exception {
final AtomicBoolean evtRecorded = new AtomicBoolean();
final Ignite ignite = startGrid("node0");
ignite.active(true);
final IgniteEvents evts = ignite.events();
if (!evts.isEnabled(EVT_WAL_SEGMENT_ARCHIVED))
assertTrue("nothing to test", false);
evts.localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event e) {
WalSegmentArchivedEvent archComplEvt = (WalSegmentArchivedEvent) e;
long idx = archComplEvt.getAbsWalSegmentIdx();
log.info("Finished archive for segment [" + idx + ", " + archComplEvt.getArchiveFile() + "]: [" + e + "]");
evtRecorded.set(true);
return true;
}
}, EVT_WAL_SEGMENT_ARCHIVED);
putDummyRecords(ignite, 500);
stopGrid("node0");
assertTrue(evtRecorded.get());
}
use of org.apache.ignite.IgniteEvents in project ignite by apache.
the class IgniteWalReaderTest method testFillWalForExactSegmentsCount.
/**
* Tests archive completed event is fired.
*
* @throws Exception if failed.
*/
public void testFillWalForExactSegmentsCount() throws Exception {
customWalMode = WALMode.FSYNC;
final CountDownLatch reqSegments = new CountDownLatch(15);
final Ignite ignite = startGrid("node0");
ignite.active(true);
final IgniteEvents evts = ignite.events();
if (!evts.isEnabled(EVT_WAL_SEGMENT_ARCHIVED))
assertTrue("nothing to test", false);
evts.localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event e) {
WalSegmentArchivedEvent archComplEvt = (WalSegmentArchivedEvent) e;
long idx = archComplEvt.getAbsWalSegmentIdx();
log.info("Finished archive for segment [" + idx + ", " + archComplEvt.getArchiveFile() + "]: [" + e + "]");
reqSegments.countDown();
return true;
}
}, EVT_WAL_SEGMENT_ARCHIVED);
int totalEntries = 0;
while (reqSegments.getCount() > 0) {
final int write = 500;
putAllDummyRecords(ignite, write);
totalEntries += write;
Assert.assertTrue("Too much entries generated, but segments was not become available", totalEntries < 10000);
}
final String subfolderName = genDbSubfolderName(ignite, 0);
stopGrid("node0");
final String workDir = U.defaultWorkDirectory();
final IgniteWalIteratorFactory factory = createWalIteratorFactory(workDir, subfolderName);
scanIterateAndCount(factory, workDir, subfolderName, totalEntries, 0, null, null);
}
Aggregations