Search in sources :

Example 1 with DistributedMetaStorage

use of org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage in project ignite by apache.

the class JmxExporterSpiTest method testDistributedMetastorage.

/**
 */
@Test
public void testDistributedMetastorage() throws Exception {
    try (IgniteEx ignite1 = startGrid(1)) {
        DistributedMetaStorage dms = ignite.context().distributedMetastorage();
        String name = "test-distributed-key";
        String val = "test-distributed-value";
        dms.write(name, val);
        TabularDataSupport view = systemView(DISTRIBUTED_METASTORE_VIEW);
        boolean found = false;
        for (int i = 0; i < view.size(); i++) {
            CompositeData row = view.get(new Object[] { i });
            if (row.get("name").equals(name) && row.get("value").equals(val)) {
                found = true;
                break;
            }
        }
        assertTrue(found);
        assertTrue(waitForCondition(() -> {
            TabularDataSupport view1 = systemView(ignite1, DISTRIBUTED_METASTORE_VIEW);
            for (int i = 0; i < view1.size(); i++) {
                CompositeData row = view1.get(new Object[] { i });
                if (row.get("name").equals(name) && row.get("value").equals(val))
                    return true;
            }
            return false;
        }, getTestTimeout()));
    }
}
Also used : DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IgniteEx(org.apache.ignite.internal.IgniteEx) CompositeData(javax.management.openmbean.CompositeData) Test(org.junit.Test)

Example 2 with DistributedMetaStorage

use of org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage in project ignite by apache.

the class SystemViewSelfTest method testDistributedMetastorage.

/**
 */
@Test
public void testDistributedMetastorage() throws Exception {
    cleanPersistenceDir();
    try (IgniteEx ignite = startGrid(getConfiguration().setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))))) {
        ignite.cluster().state(ClusterState.ACTIVE);
        DistributedMetaStorage dms = ignite.context().distributedMetastorage();
        SystemView<MetastorageView> metaStoreView = ignite.context().systemView().view(DISTRIBUTED_METASTORE_VIEW);
        assertNotNull(metaStoreView);
        String name = "test-distributed-key";
        String val = "test-distributed-value";
        dms.write(name, val);
        MetastorageView testKey = F.find(metaStoreView, null, (IgnitePredicate<? super MetastorageView>) view -> name.equals(view.name()) && val.equals(view.value()));
        assertNotNull(testKey);
    }
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) StripedExecutorTaskView(org.apache.ignite.spi.systemview.view.StripedExecutorTaskView) CountDownLatchView(org.apache.ignite.spi.systemview.view.datastructures.CountDownLatchView) QueueView(org.apache.ignite.spi.systemview.view.datastructures.QueueView) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) ComputeTaskView(org.apache.ignite.spi.systemview.view.ComputeTaskView) Map(java.util.Map) CachePagesListView(org.apache.ignite.spi.systemview.view.CachePagesListView) Cache(javax.cache.Cache) ComputeTask(org.apache.ignite.compute.ComputeTask) SEQUENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEQUENCES_VIEW) NodeAttributeView(org.apache.ignite.spi.systemview.view.NodeAttributeView) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) DEFAULT_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_DS_GROUP_NAME) BaselineNodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeAttributeViewWalker) SystemView(org.apache.ignite.spi.systemview.view.SystemView) TransactionView(org.apache.ignite.spi.systemview.view.TransactionView) AtomicStampedView(org.apache.ignite.spi.systemview.view.datastructures.AtomicStampedView) IgniteSet(org.apache.ignite.IgniteSet) Set(java.util.Set) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) BASELINE_NODES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODES_SYS_VIEW) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) BaselineNodeAttributeView(org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView) LONGS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LONGS_VIEW) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) ClientConnectionView(org.apache.ignite.spi.systemview.view.ClientConnectionView) DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE(org.apache.ignite.configuration.AtomicConfiguration.DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE) ScanQuery(org.apache.ignite.cache.query.ScanQuery) IgniteCompute(org.apache.ignite.IgniteCompute) SETS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SETS_VIEW) GridFunc.alwaysTrue(org.apache.ignite.internal.util.lang.GridFunc.alwaysTrue) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ComputeJob(org.apache.ignite.compute.ComputeJob) DEFAULT_VOLATILE_DS_GROUP_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DEFAULT_VOLATILE_DS_GROUP_NAME) ClusterState(org.apache.ignite.cluster.ClusterState) REFERENCES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.REFERENCES_VIEW) U(org.apache.ignite.internal.util.typedef.internal.U) NODE_METRICS_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_METRICS_SYS_VIEW) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) CACHE_GRP_IO_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_IO_VIEW) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) Lists(com.google.common.collect.Lists) ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult) IgniteClient(org.apache.ignite.client.IgniteClient) IgniteAtomicReference(org.apache.ignite.IgniteAtomicReference) METASTORAGE_CACHE_NAME(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME) IgniteAtomicStamped(org.apache.ignite.IgniteAtomicStamped) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) QUEUES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.QUEUES_VIEW) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) CacheGroupIoView(org.apache.ignite.spi.systemview.view.CacheGroupIoView) Test(org.junit.Test) IgniteQueue(org.apache.ignite.IgniteQueue) AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) Field(java.lang.reflect.Field) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) SCAN_QRY_SYS_VIEW(org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW) NodeMetricsView(org.apache.ignite.spi.systemview.view.NodeMetricsView) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) CachePagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.CachePagesListViewWalker) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_ATTRIBUTES_SYS_VIEW) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteJdbcThinDriver(org.apache.ignite.IgniteJdbcThinDriver) StripedExecutor(org.apache.ignite.internal.util.StripedExecutor) DATA_REGION_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.DATA_REGION_PAGE_LIST_VIEW) Connection(java.sql.Connection) ProtocolVersion(org.apache.ignite.internal.client.thin.ProtocolVersion) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) FiltrableSystemView(org.apache.ignite.spi.systemview.view.FiltrableSystemView) CACHE_GRP_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW) IgniteEx(org.apache.ignite.internal.IgniteEx) METASTORE_VIEW(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) BinaryMetadataView(org.apache.ignite.spi.systemview.view.BinaryMetadataView) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeJobResultPolicy(org.apache.ignite.compute.ComputeJobResultPolicy) ClusterNodeView(org.apache.ignite.spi.systemview.view.ClusterNodeView) LOCKS_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LOCKS_VIEW) NODES_SYS_VIEW(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODES_SYS_VIEW) AtomicReferenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicReferenceView) IgniteLock(org.apache.ignite.IgniteLock) CyclicBarrier(java.util.concurrent.CyclicBarrier) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) ServiceView(org.apache.ignite.spi.systemview.view.ServiceView) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) LATCHES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LATCHES_VIEW) VOLATILE_DATA_REGION_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.VOLATILE_DATA_REGION_NAME) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CU(org.apache.ignite.internal.util.typedef.internal.CU) ACTIVE(org.apache.ignite.transactions.TransactionState.ACTIVE) NodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.NodeAttributeViewWalker) NotNull(org.jetbrains.annotations.NotNull) DummyService(org.apache.ignite.internal.processors.service.DummyService) ContinuousQueryView(org.apache.ignite.spi.systemview.view.ContinuousQueryView) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) CacheView(org.apache.ignite.spi.systemview.view.CacheView) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) SetView(org.apache.ignite.spi.systemview.view.datastructures.SetView) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) AtomicLongView(org.apache.ignite.spi.systemview.view.datastructures.AtomicLongView) IgniteCallable(org.apache.ignite.lang.IgniteCallable) HashSet(java.util.HashSet) SEMAPHORES_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEMAPHORES_VIEW) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) ReentrantLockView(org.apache.ignite.spi.systemview.view.datastructures.ReentrantLockView) GridFunc.identity(org.apache.ignite.internal.util.lang.GridFunc.identity) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ScanQueryView(org.apache.ignite.spi.systemview.view.ScanQueryView) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) STAMPED_VIEW(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.STAMPED_VIEW) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) JdbcConnectionContext(org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) CacheGroupView(org.apache.ignite.spi.systemview.view.CacheGroupView) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Ignition(org.apache.ignite.Ignition) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) BASELINE_NODE_ATTRIBUTES_SYS_VIEW(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODE_ATTRIBUTES_SYS_VIEW) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SemaphoreView(org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 3 with DistributedMetaStorage

use of org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage in project ignite by apache.

the class PerformanceStatisticsProcessor method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    super.start();
    ctx.internalSubscriptionProcessor().registerDistributedMetastorageListener(new DistributedMetastorageLifecycleListener() {

        @Override
        public void onReadyForRead(ReadableDistributedMetaStorage metastorage) {
            metastorage.listen(PERF_STAT_KEY::equals, (key, oldVal, newVal) -> {
                // Skip history on local join.
                if (!ctx.discovery().localJoinFuture().isDone())
                    return;
                onMetastorageUpdate((boolean) newVal);
            });
        }

        @Override
        public void onReadyForWrite(DistributedMetaStorage metastorage) {
            PerformanceStatisticsProcessor.this.metastorage = metastorage;
            try {
                Boolean performanceStatsEnabled = metastorage.read(PERF_STAT_KEY);
                if (performanceStatsEnabled == null)
                    return;
                onMetastorageUpdate(performanceStatsEnabled);
            } catch (IgniteCheckedException e) {
                throw new IgniteException(e);
            }
        }
    });
    rotateProc = new DistributedProcess<>(ctx, PERFORMANCE_STATISTICS_ROTATE, req -> ctx.closure().callLocalSafe(() -> {
        rotateWriter();
        return null;
    }), (id, res, err) -> {
    });
}
Also used : ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) IGNITE_INTERNAL_KEY_PREFIX(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage.IGNITE_INTERNAL_KEY_PREFIX) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) PERFORMANCE_STATISTICS_ROTATE(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.PERFORMANCE_STATISTICS_ROTATE) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) DistributedProcess(org.apache.ignite.internal.util.distributed.DistributedProcess) IgniteFuture(org.apache.ignite.lang.IgniteFuture) GridIntList(org.apache.ignite.internal.util.GridIntList) A(org.apache.ignite.internal.util.typedef.internal.A) IgniteFeatures.allNodesSupports(org.apache.ignite.internal.IgniteFeatures.allNodesSupports) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) UUID(java.util.UUID) Serializable(java.io.Serializable) Consumer(java.util.function.Consumer) EventListener(java.util.EventListener) Nullable(org.jetbrains.annotations.Nullable) GridCacheQueryType(org.apache.ignite.internal.processors.cache.query.GridCacheQueryType) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) IgniteUuid(org.apache.ignite.lang.IgniteUuid) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)

Example 4 with DistributedMetaStorage

use of org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage in project ignite by apache.

the class DistributedConfigurationProcessor method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    GridInternalSubscriptionProcessor isp = ctx.internalSubscriptionProcessor();
    isp.registerDistributedMetastorageListener(new DistributedMetastorageLifecycleListener() {

        @Override
        public void onReadyForRead(ReadableDistributedMetaStorage metastorage) {
            distributedMetastorage = ctx.distributedMetastorage();
            // Listener for handling of cluster wide change of specific properties. Do local update.
            distributedMetastorage.listen((key) -> key.startsWith(DIST_CONF_PREFIX), (String key, Serializable oldVal, Serializable newVal) -> {
                DistributedChangeableProperty prop = props.get(toPropertyKey(key));
                if (prop != null)
                    prop.localUpdate(newVal);
            });
            // Switch to actualize action and actualize already registered properties.
            switchCurrentActionTo(ACTUALIZE);
            // Register and actualize properties waited for this service.
            isp.getDistributedConfigurationListeners().forEach(listener -> listener.onReadyToRegister(DistributedConfigurationProcessor.this));
        }

        @Override
        public void onReadyForWrite(DistributedMetaStorage metastorage) {
            // Switch to cluster wide update action and do it on already registered properties.
            switchCurrentActionTo(CLUSTER_WIDE_UPDATE);
            isp.getDistributedConfigurationListeners().forEach(DistributedConfigurationLifecycleListener::onReadyToWrite);
        }
    });
}
Also used : ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) Arrays(java.util.Arrays) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Collectors(java.util.stream.Collectors) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) Serializable(java.io.Serializable) GridKernalContext(org.apache.ignite.internal.GridKernalContext) REGISTER(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.REGISTER) List(java.util.List) Map(java.util.Map) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) ACTUALIZE(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.ACTUALIZE) CLUSTER_WIDE_UPDATE(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.CLUSTER_WIDE_UPDATE) Serializable(java.io.Serializable) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)

Example 5 with DistributedMetaStorage

use of org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage in project ignite by apache.

the class GridMetricManager method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    for (MetricExporterSpi spi : getSpis()) spi.setMetricRegistry(this);
    startSpi();
    // In case standalone kernal start.
    if (ctx.internalSubscriptionProcessor() == null)
        return;
    ctx.internalSubscriptionProcessor().registerDistributedMetastorageListener(new DistributedMetastorageLifecycleListener() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void onReadyForRead(ReadableDistributedMetaStorage metastorage) {
            roMetastorage = metastorage;
            try {
                metastorage.iterate(HITRATE_CFG_PREFIX, (name, val) -> onHitRateConfigChanged(name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) val));
                metastorage.iterate(HISTOGRAM_CFG_PREFIX, (name, val) -> onHistogramConfigChanged(name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) val));
            } catch (IgniteCheckedException e) {
                throw new IgniteException(e);
            }
            metastorage.listen(n -> n.startsWith(HITRATE_CFG_PREFIX), (name, oldVal, newVal) -> onHitRateConfigChanged(name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) newVal));
            metastorage.listen(n -> n.startsWith(HISTOGRAM_CFG_PREFIX), (name, oldVal, newVal) -> onHistogramConfigChanged(name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) newVal));
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public void onReadyForWrite(DistributedMetaStorage metastorage) {
            GridMetricManager.this.metastorage = metastorage;
        }
    });
}
Also used : ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) Metric(org.apache.ignite.spi.metric.Metric) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) Supplier(java.util.function.Supplier) IgniteUtils.notifyListeners(org.apache.ignite.internal.util.IgniteUtils.notifyListeners) GridKernalContext(org.apache.ignite.internal.GridKernalContext) MemoryMXBean(java.lang.management.MemoryMXBean) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) GridManagerAdapter(org.apache.ignite.internal.managers.GridManagerAdapter) ATTR_PHY_RAM(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteComponentType(org.apache.ignite.internal.IgniteComponentType) MetricExporterSpi(org.apache.ignite.spi.metric.MetricExporterSpi) ManagementFactory(java.lang.management.ManagementFactory) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) MemoryUsage(java.lang.management.MemoryUsage) ReadOnlyMetricManager(org.apache.ignite.spi.metric.ReadOnlyMetricManager) MetricUtils.fromFullName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.fromFullName) DoubleMetricImpl(org.apache.ignite.internal.processors.metric.impl.DoubleMetricImpl) RuntimeMXBean(java.lang.management.RuntimeMXBean) F(org.apache.ignite.internal.util.typedef.F) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) Iterator(java.util.Iterator) A(org.apache.ignite.internal.util.typedef.internal.A) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ThreadMXBean(java.lang.management.ThreadMXBean) Serializable(java.io.Serializable) T2(org.apache.ignite.internal.util.typedef.T2) Consumer(java.util.function.Consumer) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) HitRateMetric(org.apache.ignite.internal.processors.metric.impl.HitRateMetric) NotNull(org.jetbrains.annotations.NotNull) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) MetricExporterSpi(org.apache.ignite.spi.metric.MetricExporterSpi)

Aggregations

DistributedMetaStorage (org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteException (org.apache.ignite.IgniteException)4 ReadableDistributedMetaStorage (org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage)4 Test (org.junit.Test)4 Serializable (java.io.Serializable)3 List (java.util.List)3 Consumer (java.util.function.Consumer)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 DistributedMetastorageLifecycleListener (org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)3 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)2 GridProcessorAdapter (org.apache.ignite.internal.processors.GridProcessorAdapter)2 AtomicLongMetric (org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric)2 HitRateMetric (org.apache.ignite.internal.processors.metric.impl.HitRateMetric)2