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