use of org.ligoj.app.api.ToolPlugin in project ligoj-api by ligoj.
the class NodeResource method checkNodeStatus.
/**
* Check the status of a node. This method need to be public for the CGLIB proxying.
*
* @param node
* The node identifier.
* @param parameters
* Node parameters used to check the status.
* @return The node status.
*/
public NodeStatus checkNodeStatus(final String node, final Map<String, String> parameters) {
boolean isUp = false;
log.info("Check status of node {}", node);
try {
// Find the plug-in associated to the requested node
final ToolPlugin plugin = locator.getResourceExpected(node, ToolPlugin.class);
// Call service which check status
isUp = plugin.checkStatus(node, parameters);
} catch (final Exception e) {
// NOSONAR
// Do not pollute logs with this failures
// Service is down when an exception is thrown.
log.warn("Check status of node {} failed with {}: {}", node, e.getClass(), e.getMessage());
}
return NodeStatus.getValue(isUp);
}
use of org.ligoj.app.api.ToolPlugin in project ligoj-api by ligoj.
the class NodeResource method checkSubscriptionStatus.
/**
* Check status for a subscription.
*
* @param subscription
* Subscription entity.
* @param parameters
* Parameters of a subscription.
* @return status of given subscription.
*/
public SubscriptionStatusWithData checkSubscriptionStatus(final Subscription subscription, final Map<String, String> parameters) {
final String node = subscription.getNode().getId();
try {
log.info("Check status of a subscription attached to {}...", node);
// Find the plug-in associated to the requested node
final ToolPlugin toolPlugin = locator.getResourceExpected(node, ToolPlugin.class);
// Call service which check status
final SubscriptionStatusWithData status = toolPlugin.checkSubscriptionStatus(subscription.getId(), node, parameters);
status.setNode(node);
log.info("Check status of a subscription attached to {} succeed", node);
return status;
} catch (final Exception e) {
// NOSONAR
// Do not pollute logs with this failures
// Service is down when an exception is thrown, log the error
// without trace
log.warn("Check status of a subscription attached to {} failed : {}", node, e.getMessage());
}
return new SubscriptionStatusWithData(false);
}
Aggregations