use of org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi in project ignite by apache.
the class MetricsSelfTest method testAddBeforeRemoveCompletes.
/**
*/
@Test
public void testAddBeforeRemoveCompletes() throws Exception {
MetricExporterSpi checkSpi = new NoopMetricExporterSpi() {
private ReadOnlyMetricManager registry;
private Set<String> names = new HashSet<>();
@Override
public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
registry.addMetricRegistryCreationListener(mreg -> {
assertFalse(mreg.name() + " should be unique", names.contains(mreg.name()));
names.add(mreg.name());
});
registry.addMetricRegistryRemoveListener(mreg -> names.remove(mreg.name()));
}
@Override
public void setMetricRegistry(ReadOnlyMetricManager registry) {
this.registry = registry;
}
};
CountDownLatch rmvStarted = new CountDownLatch(1);
CountDownLatch rmvCompleted = new CountDownLatch(1);
MetricExporterSpi blockingSpi = new NoopMetricExporterSpi() {
private ReadOnlyMetricManager registry;
@Override
public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
registry.addMetricRegistryRemoveListener(mreg -> {
rmvStarted.countDown();
try {
rmvCompleted.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
@Override
public void setMetricRegistry(ReadOnlyMetricManager registry) {
this.registry = registry;
}
};
IgniteConfiguration cfg = new IgniteConfiguration().setMetricExporterSpi(blockingSpi, checkSpi);
GridTestKernalContext ctx = new GridTestKernalContext(log(), cfg);
ctx.start();
// Add metric registry.
ctx.metric().registry("test");
// Removes it async, blockingSpi will block remove procedure.
IgniteInternalFuture rmvFut = runAsync(() -> ctx.metric().remove("test"));
rmvStarted.await();
CountDownLatch addStarted = new CountDownLatch(1);
IgniteInternalFuture addFut = runAsync(() -> {
addStarted.countDown();
ctx.metric().registry("test");
});
// Waiting for creation to start.
addStarted.await();
Thread.sleep(100);
// Complete removal.
rmvCompleted.countDown();
rmvFut.get(getTestTimeout());
addFut.get(getTestTimeout());
}
use of org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi in project ignite by apache.
the class GridManagerMxBeanIllegalArgumentHandleTest method testIllegalStateIsCatch.
/**
* Creates minimal disco manager mock, checks illegal state is not propagated
*/
@Test
public void testIllegalStateIsCatch() {
final IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
final IgniteLogger log = Mockito.mock(IgniteLogger.class);
final GridKernalContext ctx = Mockito.mock(GridKernalContext.class);
when(ctx.config()).thenReturn(cfg);
when(ctx.log(Mockito.anyString())).thenReturn(log);
when(ctx.log(Mockito.any(Class.class))).thenReturn(log);
final GridMetricManager mgr = new GridMetricManager(ctx);
final long nHeapMax = mgr.nonHeapMemoryUsage().getMax();
if (correctSetupOfTestPerformed)
assertEquals(0, nHeapMax);
final long heapMax = mgr.heapMemoryUsage().getMax();
if (correctSetupOfTestPerformed)
assertEquals(0, heapMax);
}
use of org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi in project ignite by apache.
the class StandaloneGridKernalContext method prepareIgniteConfiguration.
/**
* @return Ignite configuration which allows to start requied processors for WAL reader
*/
protected IgniteConfiguration prepareIgniteConfiguration() {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(new StandaloneNoopDiscoverySpi());
cfg.setCommunicationSpi(new StandaloneNoopCommunicationSpi());
final Marshaller marshaller = new BinaryMarshaller();
cfg.setMarshaller(marshaller);
final DataStorageConfiguration pstCfg = new DataStorageConfiguration();
final DataRegionConfiguration regCfg = new DataRegionConfiguration();
regCfg.setPersistenceEnabled(true);
pstCfg.setDefaultDataRegionConfiguration(regCfg);
cfg.setDataStorageConfiguration(pstCfg);
marshaller.setContext(marshallerCtx);
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setGridLogger(log);
return cfg;
}
use of org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi in project ignite by apache.
the class IndexStoragePageMemoryImplTest method memory.
/**
* @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
* new empty page memory.
* @return Page memory instance.
*/
@Override
protected PageMemory memory(boolean clean) throws Exception {
long[] sizes = new long[10];
for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * 1024;
DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, new CacheDiagnosticManager());
IgniteOutClosure<CheckpointProgress> clo = () -> Mockito.mock(CheckpointProgressImpl.class);
return new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
}
use of org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi in project ignite by apache.
the class PageMemoryImplNoLoadTest method memory.
/**
* @return Page memory implementation.
*/
@Override
protected PageMemory memory() throws Exception {
File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
long[] sizes = new long[10];
for (int i = 0; i < sizes.length; i++) sizes[i] = 5 * 1024 * 1024;
DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, null);
IgniteOutClosure<CheckpointProgress> clo = () -> Mockito.mock(CheckpointProgressImpl.class);
return new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
}
Aggregations