InstantiatorResource ir = (InstantiatorResource) svcResource.getResource();
/*
* Make sure the InstantiatorResource has not reached it's
* serviceLimit
*/
ServiceElement sElem = provisionRequest.getServiceElement();
int serviceLimit = ir.getServiceLimit();
int total = ir.getServiceElementCount() + ir.getInProcessCounter();
if (total >= serviceLimit) {
String reason =
String.format("%s reached service limit of [%d] (service element count:%d, in-process:%d), " +
"cannot be used to instantiate [%s/%s]",
ir.getName(),
serviceLimit,
ir.getServiceElementCount(),
ir.getInProcessCounter(),
sElem.getOperationalStringName(),
sElem.getName());
provisionRequest.addFailureReason(reason);
logger.debug(reason);
continue;
}
/*
* Check if the InstantiatorResource doesn't already have the
* maximum amount of services allocated. this is different then
* MaxPerNode
*/
int planned = sElem.getPlanned();
int actual = ir.getServiceElementCount(sElem);
logger.trace("{} has [{}] instance(s), planned [{}] of [{}/{}]",
ir.getName(), actual, planned, sElem.getOperationalStringName(), sElem.getName());
if (actual >= planned) {
String message = String.format("%s has reached service limit of [%s], cannot be used to instantiate [%s/%s]",
ir.getName(), serviceLimit, sElem.getOperationalStringName(), sElem.getName());
provisionRequest.addFailureReason(message);
continue;
}
if (ir.getDynamicEnabled()) {
try {
if (ir.canProvision(provisionRequest)) {
serviceResourceSelected(svcResource);
logger.trace("[{}, service count: {}] has been selected for service [{}/{}]",
ir.getName(), ir.getServiceCount(), sElem.getOperationalStringName(),
sElem.getName());
return (svcResource);
}
} catch (Exception e) {
logger.warn("[{}] during canProvision check for [{}]",
ir.getName(), sElem.getOperationalStringName(), sElem.getName(),
e);
if(e instanceof ProvisionException)
throw (ProvisionException)e;
}
} else {