Search in sources :

Example 1 with NoopMetricExporterSpi

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());
}
Also used : HashSet(java.util.HashSet) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) ReadOnlyMetricManager(org.apache.ignite.spi.metric.ReadOnlyMetricManager) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) MetricExporterSpi(org.apache.ignite.spi.metric.MetricExporterSpi) Nullable(org.jetbrains.annotations.Nullable) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with NoopMetricExporterSpi

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);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridKernalContext(org.apache.ignite.internal.GridKernalContext) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) IgniteLogger(org.apache.ignite.IgniteLogger) Test(org.junit.Test)

Example 3 with NoopMetricExporterSpi

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;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) JmxSystemViewExporterSpi(org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)

Example 4 with NoopMetricExporterSpi

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);
}
Also used : 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) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) GridEncryptionManager(org.apache.ignite.internal.managers.encryption.GridEncryptionManager) NoopEncryptionSpi(org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) CacheDiagnosticManager(org.apache.ignite.internal.processors.cache.CacheDiagnosticManager) 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) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 5 with NoopMetricExporterSpi

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);
}
Also used : 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) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) GridEncryptionManager(org.apache.ignite.internal.managers.encryption.GridEncryptionManager) NoopEncryptionSpi(org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) 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) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) File(java.io.File) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Aggregations

NoopMetricExporterSpi (org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi)12 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)11 GridMetricManager (org.apache.ignite.internal.processors.metric.GridMetricManager)9 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)8 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)8 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)7 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)7 PerformanceStatisticsProcessor (org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor)7 JmxSystemViewExporterSpi (org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)6 NoopEncryptionSpi (org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi)6 GridEncryptionManager (org.apache.ignite.internal.managers.encryption.GridEncryptionManager)5 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)5 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)5 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)5 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)5 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)5 CheckpointProgress (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress)5 IgnitePluginProcessor (org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor)5 GridInternalSubscriptionProcessor (org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor)5 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)3