PropertyList queriesPropertyList = new PropertyList("queries");
operationResult.getComplexResults().put(queriesPropertyList);
ReadChildrenNames readQueryCacheChildrenNames = new ReadChildrenNames(getAddress(), "query-cache");
Result readQueryCacheChildrenNamesResult = getASConnection().execute(readQueryCacheChildrenNames, timeoutSec);
if (!readQueryCacheChildrenNamesResult.isSuccess()) {
operationResult.setErrorMessage("Could not read query-cache children names: "
+ readQueryCacheChildrenNamesResult.getFailureDescription());
return operationResult;
}
@SuppressWarnings("unchecked")
List<String> childrenNames = (List<String>) readQueryCacheChildrenNamesResult.getResult();
// Process children in batches to avoid sending too many queries if the PU has many query-cache nodes
while (!childrenNames.isEmpty()) {
if (context.getComponentInvocationContext().isInterrupted()) {
// Operation canceled or timed out
throw new InterruptedException();
}
List<String> childrenNamesSubList = childrenNames.subList(0, Math.min(batchSize, childrenNames.size()));
// Create batch operation to read N query-cache nodes
CompositeOperation batchOperation = new CompositeOperation();
for (String childrenName : childrenNamesSubList) {
Address address = new Address(getAddress());
address.add("query-cache", childrenName);
ReadResource readQueryCacheResource = new ReadResource(address);
readQueryCacheResource.includeRuntime(true);
batchOperation.addStep(readQueryCacheResource);
}
// Execute batch
Result batchResult = getASConnection().execute(batchOperation, timeoutSec);
if (!batchResult.isSuccess()) {
operationResult.setErrorMessage("Could not read query-cache attributes: "
+ batchResult.getFailureDescription());
return operationResult;
}
// Iterate over batch results
@SuppressWarnings("unchecked")
Map<String, Map> mapResult = (Map<String, Map>) batchResult.getResult();
for (Map stepResult : mapResult.values()) {
PropertyMap queryPropertyMap = new PropertyMap("query");
@SuppressWarnings("unchecked")
Map<String, String> queryCacheAttributes = (Map<String, String>) stepResult.get("result");
for (String queryCacheAttributeName : QUERY_CACHE_ATTRIBUTE_NAMES) {