use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsManagerImpl method processObsolescence.
/**
* Save dirty obsolescence info to local metastore. Check if statistics need to be refreshed and schedule it.
*
* 1) Get all dirty partition statistics.
* 2) Make separate tasks for each key to avoid saving obsolescence info for removed partition (race).
* 3) Check if partition should be recollected and add it to list in its tables task.
* 4) Submit tasks. Actually obsolescence info will be stored during task processing.
*/
public synchronized void processObsolescence() {
StatisticsUsageState usageState = usageState();
if (usageState != ON || ctx.isStopping()) {
if (log.isDebugEnabled())
log.debug("Skipping obsolescence processing.");
return;
}
if (log.isTraceEnabled())
log.trace("Process statistics obsolescence started.");
List<StatisticsKey> keys = statsRepos.getObsolescenceKeys();
if (F.isEmpty(keys)) {
if (log.isTraceEnabled())
log.trace("No obsolescence info found. Finish obsolescence processing.");
return;
} else {
if (log.isTraceEnabled())
log.trace(String.format("Scheduling obsolescence savings for %d targets", keys.size()));
}
for (StatisticsKey key : keys) {
StatisticsObjectConfiguration cfg = null;
try {
cfg = statCfgMgr.config(key);
} catch (IgniteCheckedException e) {
// No-op/
}
Set<Integer> tasksParts = calculateObsolescencedPartitions(cfg, statsRepos.getObsolescence(key));
GridH2Table tbl = schemaMgr.dataTable(key.schema(), key.obj());
if (tbl == null) {
// Table can be removed earlier, but not already processed. Or somethink goes wrong. Try to reschedule.
if (log.isDebugEnabled())
log.debug(String.format("Got obsolescence statistics for unknown table %s", key));
}
LocalStatisticsGatheringContext ctx = new LocalStatisticsGatheringContext(true, tbl, cfg, tasksParts, null);
statProc.updateLocalStatistics(ctx);
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class ColumnConfigurationViewSupplier method columnConfigurationViewSupplier.
/**
* Statistics column configuration view filterable supplier.
*
* @param filter Filter.
* @return Iterable with selected statistics column configuration views.
*/
public Iterable<StatisticsColumnConfigurationView> columnConfigurationViewSupplier(Map<String, Object> filter) {
String schema = (String) filter.get(StatisticsColumnConfigurationViewWalker.SCHEMA_FILTER);
String name = (String) filter.get(StatisticsColumnConfigurationViewWalker.NAME_FILTER);
Collection<StatisticsObjectConfiguration> configs;
try {
if (!F.isEmpty(schema) && !F.isEmpty(name)) {
StatisticsKey key = new StatisticsKey(schema, name);
StatisticsObjectConfiguration keyCfg = cfgMgr.config(key);
if (keyCfg == null)
return Collections.emptyList();
configs = Collections.singletonList(keyCfg);
} else
configs = cfgMgr.getAllConfig();
} catch (IgniteCheckedException e) {
log.warning("Error while getting statistics configuration: " + e.getMessage(), e);
configs = Collections.emptyList();
}
List<StatisticsColumnConfigurationView> res = new ArrayList<>();
for (StatisticsObjectConfiguration cfg : configs) {
for (StatisticsColumnConfiguration colCfg : cfg.columnsAll().values()) {
if (!colCfg.tombstone())
res.add(new StatisticsColumnConfigurationView(cfg, colCfg));
}
}
return res;
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class CommandProcessor method processAnalyzeCommand.
/**
* Process analyze command.
*
* @param cmd Sql analyze command.
*/
private void processAnalyzeCommand(SqlAnalyzeCommand cmd) throws IgniteCheckedException {
ctx.security().authorize(SecurityPermission.CHANGE_STATISTICS);
IgniteH2Indexing indexing = (IgniteH2Indexing) ctx.query().getIndexing();
StatisticsObjectConfiguration[] objCfgs = cmd.configurations().stream().map(t -> {
if (t.key().schema() == null) {
StatisticsKey key = new StatisticsKey(cmd.schemaName(), t.key().obj());
return new StatisticsObjectConfiguration(key, t.columns().values(), t.maxPartitionObsolescencePercent());
} else
return t;
}).toArray(StatisticsObjectConfiguration[]::new);
indexing.statsManager().collectStatistics(objCfgs);
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class StatisticsConfigurationTest method checkClientNode.
/**
* Start client node and check no store related errors in log.
*
* @throws Exception In case of errors.
*/
@Test
public void checkClientNode() throws Exception {
startGridAndChangeBaseline(0);
createSmallTable(null);
IgniteEx client = startClientGrid("cli");
collectStatistics(SMALL_TARGET);
sql("delete from small");
for (int i = 0; i < 1000; i++) sql(String.format("INSERT INTO small(a, b, c) VALUES(%d, %d, %d)", i, i, i % 10));
StatisticsObjectConfiguration smallCfg = statisticsMgr(0).statisticConfiguration().config(SMALL_KEY);
statisticsMgr(client).refreshStatistics(SMALL_TARGET);
Thread.sleep(100);
StatisticsObjectConfiguration smallCfg2 = statisticsMgr(0).statisticConfiguration().config(SMALL_KEY);
assertNotSame(smallCfg.columns().get("A").version(), smallCfg2.columns().get("A").version());
client.cluster().state(ClusterState.INACTIVE);
client.cluster().state(ClusterState.ACTIVE);
assertFalse(obsolescenceLsnr.check(TIMEOUT));
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class SqlAnalyzeCommand method buildConfig.
/**
* Build statistics object configuration from command arguments.
*
* @param target Statistics target.
* @param params Map of parameter to value strings.
* @return Statistics object configuration.
* @throws IgniteSQLException In case of unexpected parameter.
*/
public StatisticsObjectConfiguration buildConfig(StatisticsTarget target, Map<String, String> params) throws IgniteSQLException {
byte maxChangedRows = getByteOrDefault(params, MAX_CHANGED_PARTITION_ROWS_PERCENT, StatisticsObjectConfiguration.DEFAULT_OBSOLESCENCE_MAX_PERCENT);
StatisticsColumnOverrides overrides = overrides(params);
if (!F.isEmpty(params))
throw new IgniteSQLException("");
List<StatisticsColumnConfiguration> colCfgs = (target.columns() == null) ? Collections.emptyList() : Arrays.stream(target.columns()).map(col -> new StatisticsColumnConfiguration(col, overrides)).collect(Collectors.toList());
return new StatisticsObjectConfiguration(target.key(), colCfgs, maxChangedRows);
}
Aggregations