use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsConfigurationManager method refreshStatistics.
/**
* Refresh local statistic for specified database objects on the cluster.
*
* @param targets DB objects to statistics update.
*/
public void refreshStatistics(List<StatisticsTarget> targets) {
if (log.isDebugEnabled())
log.debug("Drop statistics [targets=" + targets + ']');
for (StatisticsTarget target : targets) {
String key = key2String(target.key());
try {
while (true) {
StatisticsObjectConfiguration oldCfg = distrMetaStorage.read(key);
validateDropRefresh(target, oldCfg);
Set<String> cols;
if (F.isEmpty(target.columns())) {
cols = oldCfg.columns().values().stream().map(StatisticsColumnConfiguration::name).collect(Collectors.toSet());
} else
cols = Arrays.stream(target.columns()).collect(Collectors.toSet());
StatisticsObjectConfiguration newCfg = oldCfg.refresh(cols);
if (distrMetaStorage.compareAndSet(key, oldCfg, newCfg))
break;
}
} catch (IgniteCheckedException ex) {
throw new IgniteSQLException("Error on get or update statistic schema", IgniteQueryErrorCode.UNKNOWN, ex);
}
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsConfigurationManager method updateAllLocalStatistics.
/**
* Scan statistics configuration and update each key it contains.
*/
public void updateAllLocalStatistics() {
try {
distrMetaStorage.iterate(STAT_OBJ_PREFIX, (k, v) -> {
StatisticsObjectConfiguration cfg = (StatisticsObjectConfiguration) v;
updateLocalStatistics(cfg);
});
} catch (IgniteCheckedException e) {
log.warning("Unexpected statistics configuration processing error", e);
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsConfigurationManager method dropAll.
/**
* Drop all local statistics on the cluster.
*/
public void dropAll() {
try {
final List<StatisticsTarget> targetsToRemove = new ArrayList<>();
distrMetaStorage.iterate(STAT_OBJ_PREFIX, (k, v) -> {
StatisticsKey statKey = ((StatisticsObjectConfiguration) v).key();
StatisticsObjectConfiguration cfg = (StatisticsObjectConfiguration) v;
if (!F.isEmpty(cfg.columns()))
targetsToRemove.add(new StatisticsTarget(statKey, null));
});
dropStatistics(targetsToRemove, false);
} catch (IgniteCheckedException e) {
throw new IgniteSQLException("Unexpected exception drop all statistics", IgniteQueryErrorCode.UNKNOWN, e);
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsConfigurationManager method updateStatistics.
/**
* Update local statistic for specified database objects on the cluster.
* Each node will scan local primary partitions to collect and update local statistic.
*
* @param targets DB objects to statistics update.
*/
public void updateStatistics(StatisticsObjectConfiguration... targets) {
if (log.isDebugEnabled())
log.debug("Update statistics [targets=" + targets + ']');
for (StatisticsObjectConfiguration target : targets) {
GridH2Table tbl = schemaMgr.dataTable(target.key().schema(), target.key().obj());
validate(target, tbl);
List<StatisticsColumnConfiguration> colCfgs;
if (F.isEmpty(target.columns()))
colCfgs = Arrays.stream(tbl.getColumns()).filter(c -> c.getColumnId() >= QueryUtils.DEFAULT_COLUMNS_COUNT).map(c -> new StatisticsColumnConfiguration(c.getName(), null)).collect(Collectors.toList());
else
colCfgs = new ArrayList<>(target.columns().values());
StatisticsObjectConfiguration newCfg = new StatisticsObjectConfiguration(target.key(), colCfgs, target.maxPartitionObsolescencePercent());
try {
while (true) {
String key = key2String(newCfg.key());
StatisticsObjectConfiguration oldCfg = distrMetaStorage.read(key);
StatisticsObjectConfiguration resultCfg = (oldCfg == null) ? newCfg : StatisticsObjectConfiguration.merge(oldCfg, newCfg);
if (distrMetaStorage.compareAndSet(key, oldCfg, resultCfg))
break;
}
} catch (IgniteCheckedException ex) {
throw new IgniteSQLException("Error on get or update statistic schema", IgniteQueryErrorCode.UNKNOWN, ex);
}
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsConfigurationManager method dropStatistics.
/**
* Drop local statistic for specified database objects on the cluster.
* Remove local aggregated and partitioned statistics that are stored at the local metastorage.
*
* @param targets DB objects to update statistics by.
* @param validate if {@code true} - validate statistics existence, otherwise - just try to remove.
*/
public void dropStatistics(List<StatisticsTarget> targets, boolean validate) {
if (log.isDebugEnabled())
log.debug("Drop statistics [targets=" + targets + ']');
for (StatisticsTarget target : targets) {
String key = key2String(target.key());
try {
while (true) {
StatisticsObjectConfiguration oldCfg = distrMetaStorage.read(key);
if (validate)
validateDropRefresh(target, oldCfg);
if (oldCfg == null)
return;
Set<String> dropColNames = (target.columns() == null) ? Collections.emptySet() : Arrays.stream(target.columns()).collect(Collectors.toSet());
StatisticsObjectConfiguration newCfg = oldCfg.dropColumns(dropColNames);
if (oldCfg.equals(newCfg))
break;
if (distrMetaStorage.compareAndSet(key, oldCfg, newCfg))
break;
}
} catch (IgniteCheckedException ex) {
throw new IgniteSQLException("Error on get or update statistic schema", IgniteQueryErrorCode.UNKNOWN, ex);
}
}
}
Aggregations