}
return super.invokeOperation(name, parameters);
}
private OperationResult invokeViewQueriesOperation(Configuration parameters) throws InterruptedException {
OperationResult operationResult = new OperationResult();
int batchSize;
PropertySimple batchSizeProp = parameters.getSimple("batchSize");
if (batchSizeProp == null || batchSizeProp.getStringValue() == null) {
batchSize = BATCH_SIZE;
} else {
try {
batchSize = Integer.parseInt(batchSizeProp.getStringValue());
if (batchSize < 1) {
operationResult.setErrorMessage("batchSize property is less than 1");
return operationResult;
}
} catch (NumberFormatException e) {
operationResult.setErrorMessage("batchSize property is not an integer");
return operationResult;
}
}
int timeoutSec;
PropertySimple managementQueryTimeoutProp = parameters.getSimple("managementQueryTimeout");
if (managementQueryTimeoutProp == null || managementQueryTimeoutProp.getStringValue() == null) {
timeoutSec = MANAGEMENT_QUERY_TIMEOUT;
} else {
try {
timeoutSec = Integer.parseInt(managementQueryTimeoutProp.getStringValue());
if (timeoutSec < 1) {
operationResult.setErrorMessage("managementQueryTimeout property is less than 1");
return operationResult;
}
} catch (NumberFormatException e) {
operationResult.setErrorMessage("managementQueryTimeout property is not an integer");
return operationResult;
}
}
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