use of org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi in project ignite by apache.
the class Events method storeEvents.
void storeEvents() {
// tag::event-storage[]
MemoryEventStorageSpi eventStorageSpi = new MemoryEventStorageSpi();
eventStorageSpi.setExpireAgeMs(600000);
IgniteConfiguration igniteCfg = new IgniteConfiguration();
igniteCfg.setEventStorageSpi(eventStorageSpi);
Ignite ignite = Ignition.start(igniteCfg);
// end::event-storage[]
IgniteEvents events = ignite.events();
// tag::query-local-events[]
Collection<CacheEvent> cacheEvents = events.localQuery(e -> {
// process the event
return true;
}, EventType.EVT_CACHE_OBJECT_PUT);
// end::query-local-events[]
// tag::query-remote-events[]
Collection<CacheEvent> storedEvents = events.remoteQuery(e -> {
// process the event
return true;
}, 0, EventType.EVT_CACHE_OBJECT_PUT);
// end::query-remote-events[]
ignite.close();
}
use of org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi in project ignite by apache.
the class GridManagerStopSelfTest method testStopEventStorageManager.
/**
* @throws Exception If failed.
*/
@Test
public void testStopEventStorageManager() throws Exception {
EventStorageSpi spi = new MemoryEventStorageSpi();
injectLogger(spi);
ctx.config().setEventStorageSpi(spi);
GridEventStorageManager mgr = new GridEventStorageManager(ctx);
mgr.stop(true);
}
use of org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi in project ignite by apache.
the class IgniteCacheEntryListenerAbstractTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
MemoryEventStorageSpi eventSpi = new MemoryEventStorageSpi();
eventSpi.setExpireCount(50);
cfg.setEventStorageSpi(eventSpi);
return cfg;
}
use of org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi in project ignite by apache.
the class GridAbstractTest method getConfiguration.
/**
* This method should be overridden by subclasses to change configuration parameters.
*
* @param igniteInstanceName Ignite instance name.
* @param rsrcs Resources.
* @throws Exception If failed.
* @return Grid configuration used for starting of grid.
*/
@SuppressWarnings("deprecation")
protected IgniteConfiguration getConfiguration(String igniteInstanceName, IgniteTestResources rsrcs) throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName(igniteInstanceName);
cfg.setGridLogger(rsrcs.getLogger());
cfg.setMarshaller(rsrcs.getMarshaller());
cfg.setNodeId(rsrcs.getNodeId());
cfg.setIgniteHome(rsrcs.getIgniteHome());
cfg.setMBeanServer(rsrcs.getMBeanServer());
cfg.setPeerClassLoadingEnabled(true);
cfg.setMetricsLogFrequency(0);
cfg.setClientMode(IgnitionEx.isClientMode());
cfg.setConnectorConfiguration(null);
TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass()));
commSpi.setTcpNoDelay(true);
cfg.setCommunicationSpi(commSpi);
TcpDiscoverySpi discoSpi = new TestTcpDiscoverySpi();
if (isDebug()) {
cfg.setFailureDetectionTimeout(getTestTimeout() <= 0 ? getDefaultTestTimeout() : getTestTimeout());
cfg.setNetworkTimeout(Long.MAX_VALUE / 3);
} else {
// Set network timeout to 10 sec to avoid unexpected p2p class loading errors.
cfg.setNetworkTimeout(10_000);
cfg.setFailureDetectionTimeout(10_000);
cfg.setClientFailureDetectionTimeout(10_000);
}
// Set metrics update interval to 1 second to speed up tests.
cfg.setMetricsUpdateFrequency(1000);
if (!isMultiJvm()) {
assert sharedStaticIpFinder != null : "Shared static IP finder should be initialized at this point.";
discoSpi.setIpFinder(sharedStaticIpFinder);
} else
discoSpi.setIpFinder(LOCAL_IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
SharedFsCheckpointSpi cpSpi = new SharedFsCheckpointSpi();
Collection<String> paths = new ArrayList<>();
paths.add(getDefaultCheckpointPath(cfg.getMarshaller()));
cpSpi.setDirectoryPaths(paths);
cfg.setCheckpointSpi(cpSpi);
cfg.setEventStorageSpi(new MemoryEventStorageSpi());
cfg.setFailureHandler(getFailureHandler(igniteInstanceName));
return cfg;
}
use of org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi in project ignite by apache.
the class GridFactorySelfTest method checkLifecycleBeans.
/**
* @param igniteInstanceName Ignite instance name.
* @throws Exception If test failed.
*/
private void checkLifecycleBeans(@Nullable String igniteInstanceName) throws Exception {
TestLifecycleBean bean1 = new TestLifecycleBean();
TestLifecycleBean bean2 = new TestLifecycleBean();
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setLifecycleBeans(bean1, bean2);
cfg.setIgniteInstanceName(igniteInstanceName);
cfg.setEventStorageSpi(new MemoryEventStorageSpi());
cfg.setConnectorConfiguration(null);
try (Ignite g = IgniteSpring.start(cfg, new GenericApplicationContext())) {
bean1.checkState(igniteInstanceName, true);
bean2.checkState(igniteInstanceName, true);
}
bean1.checkState(igniteInstanceName, false);
bean2.checkState(igniteInstanceName, false);
checkLifecycleBean(bean1, igniteInstanceName);
checkLifecycleBean(bean2, igniteInstanceName);
}
Aggregations