Search in sources :

Example 6 with DistributedMetaStorage

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

the class GridMetricManager method remove.

/**
 * Removes metric registry.
 *
 * @param regName Metric registry name.
 * @param removeCfg {@code True} if remove metric configurations.
 */
public void remove(String regName, boolean removeCfg) {
    GridCompoundFuture opsFut = new GridCompoundFuture<>();
    registries.computeIfPresent(regName, (key, mreg) -> {
        notifyListeners(mreg, metricRegRemoveLsnrs, log);
        if (!removeCfg)
            return null;
        DistributedMetaStorage metastorage0 = metastorage;
        if (metastorage0 == null)
            return null;
        try {
            for (Metric m : mreg) {
                if (m instanceof HitRateMetric)
                    opsFut.add(metastorage0.removeAsync(metricName(HITRATE_CFG_PREFIX, m.name())));
                else if (m instanceof HistogramMetric)
                    opsFut.add(metastorage0.removeAsync(metricName(HISTOGRAM_CFG_PREFIX, m.name())));
            }
        } catch (IgniteCheckedException e) {
            throw new IgniteException(e);
        }
        return null;
    });
    try {
        opsFut.markInitialized();
        opsFut.get();
    } catch (NodeStoppingException ignored) {
    // No-op.
    } catch (IgniteCheckedException e) {
        log.error("Failed to remove metrics configuration.", e);
    }
}
Also used : DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) IgniteException(org.apache.ignite.IgniteException) HitRateMetric(org.apache.ignite.internal.processors.metric.impl.HitRateMetric) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) Metric(org.apache.ignite.spi.metric.Metric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) HitRateMetric(org.apache.ignite.internal.processors.metric.impl.HitRateMetric) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture)

Example 7 with DistributedMetaStorage

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

the class SystemViewCommandTest method testDistributedMetastorage.

/**
 */
@Test
public void testDistributedMetastorage() throws Exception {
    DistributedMetaStorage dms = ignite0.context().distributedMetastorage();
    String name = "test-distributed-key";
    String val = "test-distributed-value";
    dms.write(name, val);
    assertEquals(1, systemView(ignite0, DISTRIBUTED_METASTORE_VIEW).stream().filter(row -> name.equals(row.get(0)) && val.equals(row.get(1))).count());
    assertTrue(waitForCondition(() -> systemView(ignite1, DISTRIBUTED_METASTORE_VIEW).stream().filter(row -> name.equals(row.get(0)) && val.equals(row.get(1))).count() == 1, getTestTimeout()));
}
Also used : DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Test(org.junit.Test)

Example 8 with DistributedMetaStorage

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

the class SqlViewExporterSpiTest method testDistributedMetastorage.

/**
 */
@Test
public void testDistributedMetastorage() throws Exception {
    DistributedMetaStorage dms = ignite0.context().distributedMetastorage();
    SystemView<MetastorageView> distributedMetaStoreView = ignite0.context().systemView().view(DISTRIBUTED_METASTORE_VIEW);
    assertNotNull(distributedMetaStoreView);
    String name = "test-distributed-key";
    String val = "test-distributed-value";
    dms.write(name, val);
    assertEquals(1, execute(ignite0, "SELECT * FROM SYS.DISTRIBUTED_METASTORAGE WHERE name = ? AND value = ?", name, val).size());
    assertTrue(waitForCondition(() -> execute(ignite1, "SELECT * FROM SYS.DISTRIBUTED_METASTORAGE WHERE name = ? AND value = ?", name, val).size() == 1, getTestTimeout()));
}
Also used : MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

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