use of org.apache.ignite.internal.visor.verify.ValidateIndexesCheckSizeIssue in project ignite by apache.
the class GridCommandHandlerIndexingCheckSizeTest method validateCheckSizes.
/**
* Checking whether cache and index size check is correct.
*
* @param node Node.
* @param cacheName Cache name.
* @param rmvByTbl Number of deleted items per table.
* @param cacheSizeExp Function for getting expected cache size.
* @param idxSizeExp Function for getting expected index size.
*/
private void validateCheckSizes(IgniteEx node, String cacheName, Map<String, AtomicInteger> rmvByTbl, Function<AtomicInteger, Integer> cacheSizeExp, Function<AtomicInteger, Integer> idxSizeExp) {
requireNonNull(node);
requireNonNull(cacheName);
requireNonNull(rmvByTbl);
requireNonNull(cacheSizeExp);
requireNonNull(idxSizeExp);
injectTestSystemOut();
assertEquals(EXIT_CODE_OK, execute(CACHE.text(), VALIDATE_INDEXES.text(), cacheName, CHECK_SIZES.argName()));
String out = testOut.toString();
assertContains(log, out, "issues found (listed above)");
assertContains(log, out, "Size check");
Map<String, ValidateIndexesCheckSizeResult> valIdxCheckSizeResults = ((VisorValidateIndexesTaskResult) lastOperationResult).results().get(node.localNode().id()).checkSizeResult();
assertEquals(rmvByTbl.size(), valIdxCheckSizeResults.size());
for (Map.Entry<String, AtomicInteger> rmvByTblEntry : rmvByTbl.entrySet()) {
ValidateIndexesCheckSizeResult checkSizeRes = valIdxCheckSizeResults.entrySet().stream().filter(e -> e.getKey().contains(rmvByTblEntry.getKey())).map(Map.Entry::getValue).findAny().orElse(null);
assertNotNull(checkSizeRes);
assertEquals((int) cacheSizeExp.apply(rmvByTblEntry.getValue()), checkSizeRes.cacheSize());
Collection<ValidateIndexesCheckSizeIssue> issues = checkSizeRes.issues();
assertFalse(issues.isEmpty());
issues.forEach(issue -> {
assertEquals((int) idxSizeExp.apply(rmvByTblEntry.getValue()), issue.indexSize());
Throwable err = issue.error();
assertNotNull(err);
assertEquals("Cache and index size not same.", err.getMessage());
});
}
}
use of org.apache.ignite.internal.visor.verify.ValidateIndexesCheckSizeIssue in project ignite by apache.
the class CacheValidateIndexes method execute.
/**
* {@inheritDoc}
*/
@Override
public Object execute(GridClientConfiguration clientCfg, Logger logger) throws Exception {
VisorValidateIndexesTaskArg taskArg = new VisorValidateIndexesTaskArg(args.caches(), args.nodeId() != null ? Collections.singleton(args.nodeId()) : null, args.checkFirst(), args.checkThrough(), args.checkCrc(), args.checkSizes());
try (GridClient client = Command.startClient(clientCfg)) {
VisorValidateIndexesTaskResult taskRes = executeTaskByNameOnNode(client, "org.apache.ignite.internal.visor.verify.VisorValidateIndexesTask", taskArg, null, clientCfg);
boolean errors = CommandLogger.printErrors(taskRes.exceptions(), "Index validation failed on nodes:", logger);
for (Entry<UUID, VisorValidateIndexesJobResult> nodeEntry : taskRes.results().entrySet()) {
VisorValidateIndexesJobResult jobRes = nodeEntry.getValue();
if (!jobRes.hasIssues())
continue;
errors = true;
logger.info("Index issues found on node " + nodeEntry.getKey() + ":");
for (IndexIntegrityCheckIssue is : jobRes.integrityCheckFailures()) logger.info(INDENT + is);
for (Entry<PartitionKey, ValidateIndexesPartitionResult> e : jobRes.partitionResult().entrySet()) {
ValidateIndexesPartitionResult res = e.getValue();
if (!res.issues().isEmpty()) {
logger.info(INDENT + join(" ", e.getKey(), e.getValue()));
for (IndexValidationIssue is : res.issues()) logger.info(DOUBLE_INDENT + is);
}
}
for (Entry<String, ValidateIndexesPartitionResult> e : jobRes.indexResult().entrySet()) {
ValidateIndexesPartitionResult res = e.getValue();
if (!res.issues().isEmpty()) {
logger.info(INDENT + join(" ", "SQL Index", e.getKey(), e.getValue()));
for (IndexValidationIssue is : res.issues()) logger.info(DOUBLE_INDENT + is);
}
}
for (Entry<String, ValidateIndexesCheckSizeResult> e : jobRes.checkSizeResult().entrySet()) {
ValidateIndexesCheckSizeResult res = e.getValue();
Collection<ValidateIndexesCheckSizeIssue> issues = res.issues();
if (issues.isEmpty())
continue;
logger.info(INDENT + join(" ", "Size check", e.getKey(), res));
for (ValidateIndexesCheckSizeIssue issue : issues) logger.info(DOUBLE_INDENT + issue);
}
}
if (!errors)
logger.info("no issues found.");
else
logger.severe("issues found (listed above).");
logger.info("");
return taskRes;
}
}
Aggregations