Search in sources :

Example 1 with IgniteEvents

use of org.apache.ignite.IgniteEvents in project camel by apache.

the class IgniteEventsEndpoint method createConsumer.

@Override
public Consumer createConsumer(Processor processor) throws Exception {
    // Initialize the Consumer.
    IgniteEvents events = createIgniteEvents();
    IgniteEventsConsumer consumer = new IgniteEventsConsumer(this, processor, events);
    configureConsumer(consumer);
    LOG.info("Created Ignite Events consumer for event types: {}.", events);
    return consumer;
}
Also used : IgniteEvents(org.apache.ignite.IgniteEvents)

Example 2 with IgniteEvents

use of org.apache.ignite.IgniteEvents in project ignite by apache.

the class GridCacheAbstractFullApiSelfTest method doTransformResourceInjection.

/**
     * @param ignite Node.
     * @param cache Cache.
     * @param async Use async API.
     * @param oldAsync Use old async API.
     * @throws Exception If failed.
     */
private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache, boolean async, boolean oldAsync) throws Exception {
    final Collection<ResourceType> required = Arrays.asList(ResourceType.IGNITE_INSTANCE, ResourceType.CACHE_NAME, ResourceType.LOGGER);
    final CacheEventListener lsnr = new CacheEventListener();
    IgniteEvents evts = ignite.events(ignite.cluster());
    UUID opId = evts.remoteListen(lsnr, null, EventType.EVT_CACHE_OBJECT_READ);
    try {
        checkResourceInjectionOnInvoke(cache, required, async, oldAsync);
        checkResourceInjectionOnInvokeAll(cache, required, async, oldAsync);
        checkResourceInjectionOnInvokeAllMap(cache, required, async, oldAsync);
    } finally {
        evts.stopRemoteListen(opId);
    }
}
Also used : IgniteEvents(org.apache.ignite.IgniteEvents) UUID(java.util.UUID)

Example 3 with IgniteEvents

use of org.apache.ignite.IgniteEvents in project ignite by apache.

the class GridEventConsumeSelfTest method testApiAsyncOld.

/**
     * @throws Exception If failed.
     */
public void testApiAsyncOld() throws Exception {
    IgniteEvents evtAsync = grid(0).events().withAsync();
    try {
        evtAsync.stopRemoteListen(null);
        evtAsync.future().get();
    } catch (NullPointerException ignored) {
    // No-op.
    }
    evtAsync.stopRemoteListen(UUID.randomUUID());
    evtAsync.future().get();
    UUID consumeId = null;
    try {
        evtAsync.remoteListen(new P2<UUID, DiscoveryEvent>() {

            @Override
            public boolean apply(UUID uuid, DiscoveryEvent evt) {
                return false;
            }
        }, new P1<DiscoveryEvent>() {

            @Override
            public boolean apply(DiscoveryEvent e) {
                return false;
            }
        }, EVTS_DISCOVERY);
        consumeId = (UUID) evtAsync.future().get();
        assertNotNull(consumeId);
    } finally {
        evtAsync.stopRemoteListen(consumeId);
        evtAsync.future().get();
    }
    try {
        evtAsync.remoteListen(new P2<UUID, DiscoveryEvent>() {

            @Override
            public boolean apply(UUID uuid, DiscoveryEvent evt) {
                return false;
            }
        }, new P1<DiscoveryEvent>() {

            @Override
            public boolean apply(DiscoveryEvent e) {
                return false;
            }
        });
        consumeId = (UUID) evtAsync.future().get();
        assertNotNull(consumeId);
    } finally {
        evtAsync.stopRemoteListen(consumeId);
        evtAsync.future().get();
    }
    try {
        evtAsync.remoteListen(new P2<UUID, Event>() {

            @Override
            public boolean apply(UUID uuid, Event evt) {
                return false;
            }
        }, new P1<Event>() {

            @Override
            public boolean apply(Event e) {
                return false;
            }
        });
        consumeId = (UUID) evtAsync.future().get();
        assertNotNull(consumeId);
    } finally {
        evtAsync.stopRemoteListen(consumeId);
        evtAsync.future().get();
    }
}
Also used : IgniteEvents(org.apache.ignite.IgniteEvents) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) JobEvent(org.apache.ignite.events.JobEvent) Event(org.apache.ignite.events.Event) UUID(java.util.UUID)

Example 4 with IgniteEvents

use of org.apache.ignite.IgniteEvents in project ignite by apache.

the class TcpDiscoveryNodeAttributesUpdateOnReconnectTest method testReconnect.

/**
     * @throws Exception If failed.
     */
public void testReconnect() throws Exception {
    Ignite srv = startGrid("server");
    IgniteEvents evts = srv.events();
    evts.enableLocal(EventType.EVTS_DISCOVERY_ALL);
    evts.localListen(new IgnitePredicate<Event>() {

        @Override
        public boolean apply(Event evt) {
            ClusterNode node = ((DiscoveryEvent) evt).eventNode();
            rejoinAttr = node.attribute("test");
            return true;
        }
    }, EventType.EVT_NODE_JOINED);
    Ignite client = startGrid("client");
    reconnectClientNode(log, client, srv, null);
    assertEquals("2", rejoinAttr);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteEvents(org.apache.ignite.IgniteEvents) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Event(org.apache.ignite.events.Event) Ignite(org.apache.ignite.Ignite)

Example 5 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)

Aggregations

IgniteEvents (org.apache.ignite.IgniteEvents)10 Event (org.apache.ignite.events.Event)5 UUID (java.util.UUID)4 Ignite (org.apache.ignite.Ignite)4 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)4 JobEvent (org.apache.ignite.events.JobEvent)3 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 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)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 GridConcurrentHashSet (org.apache.ignite.internal.util.GridConcurrentHashSet)1 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)1