Search in sources :

Example 1 with MemoryEventStorageSpi

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();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEvents(org.apache.ignite.IgniteEvents) CacheEvent(org.apache.ignite.events.CacheEvent) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) Ignite(org.apache.ignite.Ignite)

Example 2 with MemoryEventStorageSpi

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);
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) EventStorageSpi(org.apache.ignite.spi.eventstorage.EventStorageSpi) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with MemoryEventStorageSpi

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)

Example 4 with MemoryEventStorageSpi

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) SharedFsCheckpointSpi(org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi) ArrayList(java.util.ArrayList) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 5 with MemoryEventStorageSpi

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);
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) Ignite(org.apache.ignite.Ignite)

Aggregations

MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)16 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)13 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)8 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)5 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Ignite (org.apache.ignite.Ignite)2 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)2 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 ExecutorConfiguration (org.apache.ignite.configuration.ExecutorConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)2 NoOpFailureHandler (org.apache.ignite.failure.NoOpFailureHandler)2 StopNodeFailureHandler (org.apache.ignite.failure.StopNodeFailureHandler)2 StopNodeOrHaltFailureHandler (org.apache.ignite.failure.StopNodeOrHaltFailureHandler)2 PlatformDotNetBinaryConfiguration (org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration)2 EventStorageSpi (org.apache.ignite.spi.eventstorage.EventStorageSpi)2 NoopEventStorageSpi (org.apache.ignite.spi.eventstorage.NoopEventStorageSpi)2