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;
}
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);
}
}
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();
}
}
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);
}
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;
}
Aggregations