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()));
}
}
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);
}
}
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) -> {
});
}
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);
}
});
}
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;
}
});
}
Aggregations