Search in sources :

Example 6 with IgniteEvents

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;
}
Also used : IgniteEvents(org.apache.ignite.IgniteEvents) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite)

Example 7 with IgniteEvents

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEvents(org.apache.ignite.IgniteEvents) HashSet(java.util.HashSet)

Example 8 with IgniteEvents

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();
    }
}
Also used : IgniteEvents(org.apache.ignite.IgniteEvents) Ignite(org.apache.ignite.Ignite)

Example 9 with IgniteEvents

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteEvents(org.apache.ignite.IgniteEvents) Event(org.apache.ignite.events.Event) WalSegmentArchivedEvent(org.apache.ignite.events.WalSegmentArchivedEvent) Ignite(org.apache.ignite.Ignite) WalSegmentArchivedEvent(org.apache.ignite.events.WalSegmentArchivedEvent)

Example 10 with IgniteEvents

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);
}
Also used : IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) IgniteEvents(org.apache.ignite.IgniteEvents) Event(org.apache.ignite.events.Event) WalSegmentArchivedEvent(org.apache.ignite.events.WalSegmentArchivedEvent) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) WalSegmentArchivedEvent(org.apache.ignite.events.WalSegmentArchivedEvent)

Aggregations

IgniteEvents (org.apache.ignite.IgniteEvents)13 Event (org.apache.ignite.events.Event)8 Ignite (org.apache.ignite.Ignite)7 UUID (java.util.UUID)4 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 JobEvent (org.apache.ignite.events.JobEvent)3 WalSegmentArchivedEvent (org.apache.ignite.events.WalSegmentArchivedEvent)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)2 HashSet (java.util.HashSet)1 Random (java.util.Random)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 IgniteException (org.apache.ignite.IgniteException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ClusterTopologyException (org.apache.ignite.cluster.ClusterTopologyException)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteWalIteratorFactory (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory)1 GridConcurrentHashSet (org.apache.ignite.internal.util.GridConcurrentHashSet)1