Search in sources :

Example 1 with GridEventStorageManager

use of org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager 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 2 with GridEventStorageManager

use of org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager in project ignite by apache.

the class GridIoManager method onKernalStop0.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("BusyWait")
@Override
public void onKernalStop0(boolean cancel) {
    // No more communication messages.
    getSpi().setListener(null);
    boolean interrupted = false;
    // Busy wait is intentional.
    while (true) {
        try {
            if (busyLock.writeLock().tryLock(200, TimeUnit.MILLISECONDS))
                break;
            else
                Thread.sleep(200);
        } catch (InterruptedException ignore) {
            // Preserve interrupt status & ignore.
            // Note that interrupted flag is cleared.
            interrupted = true;
        }
    }
    try {
        if (interrupted)
            Thread.currentThread().interrupt();
        GridEventStorageManager evtMgr = ctx.event();
        if (evtMgr != null && discoLsnr != null)
            evtMgr.removeLocalEventListener(discoLsnr);
        stopping = true;
        Set<ReceiverContext> rcvs;
        synchronized (rcvMux) {
            topicTransmissionHnds.clear();
            rcvs = new HashSet<>(rcvCtxs.values());
            rcvCtxs.clear();
        }
        for (ReceiverContext rctx : rcvs) {
            interruptReceiver(rctx, new NodeStoppingException("Local node io manager requested to be stopped: " + ctx.localNodeId()));
        }
    } finally {
        busyLock.writeLock().unlock();
    }
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException)

Example 3 with GridEventStorageManager

use of org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager in project ignite by apache.

the class GridNearReadRepairAbstractFuture method recordConsistencyViolation.

/**
 * @param fixedEntries Fixed map.
 */
protected final void recordConsistencyViolation(Collection<KeyCacheObject> inconsistentKeys, Map<KeyCacheObject, EntryGetResult> fixedEntries, ReadRepairStrategy strategy) {
    GridEventStorageManager evtMgr = ctx.gridEvents();
    if (!evtMgr.isRecordable(EVT_CONSISTENCY_VIOLATION))
        return;
    Map<Object, Map<ClusterNode, CacheConsistencyViolationEvent.EntryInfo>> entries = new HashMap<>();
    for (Map.Entry<ClusterNode, GridPartitionedGetFuture<KeyCacheObject, EntryGetResult>> pair : futs.entrySet()) {
        ClusterNode node = pair.getKey();
        GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut = pair.getValue();
        for (KeyCacheObject key : fut.keys()) {
            if (inconsistentKeys.contains(key)) {
                Map<ClusterNode, CacheConsistencyViolationEvent.EntryInfo> map = entries.computeIfAbsent(ctx.unwrapBinaryIfNeeded(key, !deserializeBinary, false, null), k -> new HashMap<>());
                EntryGetResult res = fut.result().get(key);
                CacheEntryVersion ver = res != null ? res.version() : null;
                Object val = res != null ? ctx.unwrapBinaryIfNeeded(res.value(), !deserializeBinary, false, null) : null;
                boolean primary = primaries.get(key).equals(fut.affNode());
                boolean correct = fixedEntries != null && ((fixedEntries.get(key) != null && fixedEntries.get(key).equals(res)) || (fixedEntries.get(key) == null && res == null));
                map.put(node, new EventEntryInfo(val, ver, primary, correct));
            }
        }
    }
    Map<Object, Object> fixed;
    if (fixedEntries == null)
        fixed = Collections.emptyMap();
    else {
        fixed = new HashMap<>();
        for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fixedEntries.entrySet()) {
            Object key = ctx.unwrapBinaryIfNeeded(entry.getKey(), !deserializeBinary, false, null);
            Object val = entry.getValue() != null ? ctx.unwrapBinaryIfNeeded(entry.getValue().value(), !deserializeBinary, false, null) : null;
            fixed.put(key, val);
        }
    }
    evtMgr.record(new CacheConsistencyViolationEvent(ctx.name(), ctx.discovery().localNode(), "Consistency violation was " + (fixed == null ? "NOT " : "") + "fixed.", entries, fixed, strategy));
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridPartitionedGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CacheEntryVersion(org.apache.ignite.cache.CacheEntryVersion) CacheConsistencyViolationEvent(org.apache.ignite.events.CacheConsistencyViolationEvent) EntryGetResult(org.apache.ignite.internal.processors.cache.EntryGetResult) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 4 with GridEventStorageManager

use of org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager in project ignite by apache.

the class PageMemoryImplTest method createPageMemory.

/**
 * @param throttlingPlc Throttling Policy.
 * @throws Exception If creating mock failed.
 */
private PageMemoryImpl createPageMemory(int maxSize, PageMemoryImpl.ThrottlingPolicy throttlingPlc, IgnitePageStoreManager mgr, PageStoreWriter replaceWriter, @Nullable IgniteInClosure<FullPageId> cpBufChecker) throws Exception {
    long[] sizes = new long[5];
    for (int i = 0; i < sizes.length; i++) sizes[i] = maxSize * MB / 4;
    sizes[4] = maxSize * MB / 4;
    DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    igniteCfg.setDataStorageConfiguration(new DataStorageConfiguration());
    igniteCfg.setFailureHandler(new NoOpFailureHandler());
    igniteCfg.setEncryptionSpi(new NoopEncryptionSpi());
    igniteCfg.setMetricExporterSpi(new NoopMetricExporterSpi());
    igniteCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
    igniteCfg.setEventStorageSpi(new NoopEventStorageSpi());
    GridTestKernalContext kernalCtx = new GridTestKernalContext(new GridTestLog4jLogger(), igniteCfg);
    kernalCtx.add(new IgnitePluginProcessor(kernalCtx, igniteCfg, Collections.<PluginProvider>emptyList()));
    kernalCtx.add(new GridInternalSubscriptionProcessor(kernalCtx));
    kernalCtx.add(new PerformanceStatisticsProcessor(kernalCtx));
    kernalCtx.add(new GridEncryptionManager(kernalCtx));
    kernalCtx.add(new GridMetricManager(kernalCtx));
    kernalCtx.add(new GridSystemViewManager(kernalCtx));
    kernalCtx.add(new GridEventStorageManager(kernalCtx));
    FailureProcessor failureProc = new FailureProcessor(kernalCtx);
    failureProc.start();
    kernalCtx.add(failureProc);
    GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(kernalCtx, null, null, null, mgr, new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, null);
    CheckpointProgressImpl cl0 = Mockito.mock(CheckpointProgressImpl.class);
    IgniteOutClosure<CheckpointProgress> noThrottle = Mockito.mock(IgniteOutClosure.class);
    Mockito.when(noThrottle.apply()).thenReturn(cl0);
    Mockito.when(cl0.currentCheckpointPagesCount()).thenReturn(1_000_000);
    Mockito.when(cl0.evictedPagesCounter()).thenReturn(new AtomicInteger(0));
    Mockito.when(cl0.syncedPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    Mockito.when(cl0.writtenPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    PageMemoryImpl mem = cpBufChecker == null ? new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, replaceWriter, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {

        @Override
        public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
        }
    }, () -> true, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration(), kernalCtx), throttlingPlc, noThrottle) : new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, replaceWriter, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {

        @Override
        public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
        }
    }, () -> true, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration(), kernalCtx), throttlingPlc, noThrottle) {

        @Override
        public FullPageId pullPageFromCpBuffer() {
            FullPageId pageId = super.pullPageFromCpBuffer();
            cpBufChecker.apply(pageId);
            return pageId;
        }
    };
    mem.metrics().enableMetrics();
    mem.start();
    return mem;
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) NoOpFailureHandler(org.apache.ignite.failure.NoOpFailureHandler) IgnitePluginProcessor(org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor) CheckpointProgress(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) NoopEventStorageSpi(org.apache.ignite.spi.eventstorage.NoopEventStorageSpi) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CheckpointProgressImpl(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgressImpl) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) GridEncryptionManager(org.apache.ignite.internal.managers.encryption.GridEncryptionManager) NoopEncryptionSpi(org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) PluginProvider(org.apache.ignite.plugin.PluginProvider) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) JmxSystemViewExporterSpi(org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi) PerformanceStatisticsProcessor(org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor) GridInClosure3X(org.apache.ignite.internal.util.lang.GridInClosure3X) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) FailureProcessor(org.apache.ignite.internal.processors.failure.FailureProcessor) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 5 with GridEventStorageManager

use of org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager in project ignite by apache.

the class IgfsUtils method sendEvents.

/**
 * Sends a series of event.
 *
 * @param kernalCtx Kernal context.
 * @param path The path of the created file.
 * @param newPath New path.
 * @param type The type of event to send.
 */
public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, IgfsPath newPath, int type) {
    assert kernalCtx != null;
    assert path != null;
    GridEventStorageManager evts = kernalCtx.event();
    ClusterNode locNode = kernalCtx.discovery().localNode();
    if (evts.isRecordable(type)) {
        if (newPath == null)
            evts.record(new IgfsEvent(path, locNode, type));
        else
            evts.record(new IgfsEvent(path, newPath, locNode, type));
    }
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgfsEvent(org.apache.ignite.events.IgfsEvent)

Aggregations

GridEventStorageManager (org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager)13 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 GridInternalSubscriptionProcessor (org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 IgfsEvent (org.apache.ignite.events.IgfsEvent)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)3 DiscoveryLocalJoinData (org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData)3 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)3 GridEncryptionManager (org.apache.ignite.internal.managers.encryption.GridEncryptionManager)3 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)3 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)3 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 DecimalFormat (java.text.DecimalFormat)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 IgniteSystemProperties.getBoolean (org.apache.ignite.IgniteSystemProperties.getBoolean)2