Search in sources :

Example 1 with PluginProvider

use of org.apache.ignite.plugin.PluginProvider in project ignite by apache.

the class PageMemoryImplTest method createPageMemory.

/**
 * @param throttlingPlc Throttling Policy.
 * @throws Exception If creating mock failed.
 */
private PageMemoryImpl createPageMemory(PageMemoryImpl.ThrottlingPolicy throttlingPlc) throws Exception {
    long[] sizes = new long[5];
    for (int i = 0; i < sizes.length; i++) sizes[i] = MAX_SIZE * MB / 4;
    sizes[4] = 5 * MB;
    DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    igniteCfg.setDataStorageConfiguration(new DataStorageConfiguration());
    GridTestKernalContext kernalCtx = new GridTestKernalContext(new GridTestLog4jLogger(), igniteCfg);
    kernalCtx.add(new IgnitePluginProcessor(kernalCtx, igniteCfg, Collections.<PluginProvider>emptyList()));
    GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(kernalCtx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null);
    CheckpointWriteProgressSupplier noThrottle = Mockito.mock(CheckpointWriteProgressSupplier.class);
    Mockito.when(noThrottle.currentCheckpointPagesCount()).thenReturn(1_000_000);
    Mockito.when(noThrottle.evictedPagesCntr()).thenReturn(new AtomicInteger(0));
    Mockito.when(noThrottle.syncedPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    Mockito.when(noThrottle.writtenPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    PageMemoryImpl mem = new PageMemoryImpl(provider, sizes, sharedCtx, 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) {
        }
    }, new CheckpointLockStateChecker() {

        @Override
        public boolean checkpointLockIsHeldByThread() {
            return true;
        }
    }, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration()), throttlingPlc, noThrottle);
    mem.start();
    return mem;
}
Also used : IgnitePluginProcessor(org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor) 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) CheckpointLockStateChecker(org.apache.ignite.internal.processors.cache.persistence.CheckpointLockStateChecker) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) PluginProvider(org.apache.ignite.plugin.PluginProvider) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) CheckpointWriteProgressSupplier(org.apache.ignite.internal.processors.cache.persistence.CheckpointWriteProgressSupplier) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 2 with PluginProvider

use of org.apache.ignite.plugin.PluginProvider in project ignite by apache.

the class ClusterCachesInfo method onKernalStart.

/**
 * @param checkConsistency {@code True} if need check cache configurations consistency.
 * @throws IgniteCheckedException If failed.
 */
public void onKernalStart(boolean checkConsistency) throws IgniteCheckedException {
    if (gridData != null && gridData.conflictErr != null)
        throw new IgniteCheckedException(gridData.conflictErr);
    if (gridData != null && gridData.joinDiscoData != null) {
        CacheJoinNodeDiscoveryData joinDiscoData = gridData.joinDiscoData;
        for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values()) {
            CacheConfiguration locCfg = locCacheInfo.cacheData().config();
            CacheData cacheData = gridData.gridData.caches().get(locCfg.getName());
            if (cacheData != null) {
                if (!F.eq(cacheData.sql(), locCacheInfo.sql())) {
                    throw new IgniteCheckedException("Cache configuration mismatch (local cache was created " + "via " + (locCacheInfo.sql() ? "CREATE TABLE" : "Ignite API") + ", while remote cache " + "was created via " + (cacheData.sql() ? "CREATE TABLE" : "Ignite API") + "): " + locCacheInfo.cacheData().config().getName());
                }
                if (checkConsistency) {
                    checkCache(locCacheInfo, cacheData, cacheData.receivedFrom());
                    ClusterNode rmt = ctx.discovery().node(cacheData.receivedFrom());
                    if (rmt == null) {
                        for (ClusterNode node : ctx.discovery().localJoin().discoCache().serverNodes()) {
                            if (!node.isLocal() && ctx.discovery().cacheAffinityNode(node, locCfg.getName())) {
                                rmt = node;
                                break;
                            }
                        }
                    }
                    if (rmt != null) {
                        for (PluginProvider p : ctx.plugins().allProviders()) {
                            CachePluginContext pluginCtx = new GridCachePluginContext(ctx, locCfg);
                            CachePluginProvider provider = p.createCacheProvider(pluginCtx);
                            if (provider != null)
                                provider.validateRemote(locCfg, cacheData.cacheConfiguration(), rmt);
                        }
                    }
                }
            }
            if (checkConsistency)
                validateStartCacheConfiguration(locCfg);
        }
    }
    gridData = null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCachePluginContext(org.apache.ignite.internal.GridCachePluginContext) CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) GridCachePluginContext(org.apache.ignite.internal.GridCachePluginContext) CachePluginContext(org.apache.ignite.plugin.CachePluginContext) CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) PluginProvider(org.apache.ignite.plugin.PluginProvider) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 3 with PluginProvider

use of org.apache.ignite.plugin.PluginProvider in project ignite by apache.

the class GridTcpRestProtocol method onProcessorStart.

/**
 * {@inheritDoc}
 */
@Override
public void onProcessorStart() {
    super.onProcessorStart();
    Map<Byte, GridClientMarshaller> marshMap = new HashMap<>();
    ArrayList<PluginProvider> providers = new ArrayList<>(ctx.plugins().allProviders());
    GridClientOptimizedMarshaller optMarsh = new GridClientOptimizedMarshaller(providers);
    marshMap.put(GridClientOptimizedMarshaller.ID, optMarsh);
    marshMap.put(GridClientZipOptimizedMarshaller.ID, new GridClientZipOptimizedMarshaller(optMarsh, providers));
    try {
        IgnitePredicate<String> clsFilter = MarshallerUtils.classNameFilter(getClass().getClassLoader());
        marshMap.put(GridClientJdkMarshaller.ID, new GridClientJdkMarshaller(clsFilter));
    } catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
    lsnr.marshallers(marshMap);
}
Also used : GridClientJdkMarshaller(org.apache.ignite.internal.client.marshaller.jdk.GridClientJdkMarshaller) GridClientMarshaller(org.apache.ignite.internal.client.marshaller.GridClientMarshaller) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PluginProvider(org.apache.ignite.plugin.PluginProvider) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridClientOptimizedMarshaller(org.apache.ignite.internal.client.marshaller.optimized.GridClientOptimizedMarshaller) IgniteException(org.apache.ignite.IgniteException) GridClientZipOptimizedMarshaller(org.apache.ignite.internal.client.marshaller.optimized.GridClientZipOptimizedMarshaller)

Example 4 with PluginProvider

use of org.apache.ignite.plugin.PluginProvider in project ignite by apache.

the class GridProbeCommandTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setConnectorConfiguration(new ConnectorConfiguration());
    if (igniteInstanceName.equals("regular"))
        return cfg;
    else if (igniteInstanceName.equals("delayedStart")) {
        PluginProvider delayedStartPluginProvider = new DelayedStartPluginProvider(triggerPluginStartLatch, triggerRestCmdLatch);
        cfg.setPluginProviders(new PluginProvider[] { delayedStartPluginProvider });
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) AbstractTestPluginProvider(org.apache.ignite.plugin.AbstractTestPluginProvider) PluginProvider(org.apache.ignite.plugin.PluginProvider)

Example 5 with PluginProvider

use of org.apache.ignite.plugin.PluginProvider 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)

Aggregations

PluginProvider (org.apache.ignite.plugin.PluginProvider)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgnitePluginProcessor (org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor)4 HashMap (java.util.HashMap)3 IgniteException (org.apache.ignite.IgniteException)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 GridEventStorageManager (org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager)3 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 DecimalFormat (java.text.DecimalFormat)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IgniteSystemProperties.getBoolean (org.apache.ignite.IgniteSystemProperties.getBoolean)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 GridCheckpointManager (org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager)2 GridCollisionManager (org.apache.ignite.internal.managers.collision.GridCollisionManager)2 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)2 GridDeploymentManager (org.apache.ignite.internal.managers.deployment.GridDeploymentManager)2 DiscoveryLocalJoinData (org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData)2