use of org.ow2.proactive_grid_cloud_portal.cli.json.RmStateView in project scheduling by ow2-proactive.
the class GetNodeInfoCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpGet request = new HttpGet(currentContext.getResourceUrl("monitoring"));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
RmStateView state = readValue(response, RmStateView.class, currentContext);
NodeEventView[] nodeEvents = state.getNodesEvents();
NodeEventView target = null;
for (NodeEventView nodeEvent : nodeEvents) {
if (nodeUrl.equals(nodeEvent.getNodeUrl())) {
target = nodeEvent;
break;
}
}
if (target == null) {
writeLine(currentContext, "Cannot find node: '%s'", nodeUrl);
return;
}
resultStack(currentContext).push(target);
writeLine(currentContext, "%s", target.getNodeInfo());
} else {
handleError("An error occurred while retrieving node info.", response, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.RmStateView in project scheduling by ow2-proactive.
the class ListNodeSourceCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpGet request = new HttpGet(currentContext.getResourceUrl("monitoring"));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
RmStateView state = readValue(response, RmStateView.class, currentContext);
NodeSourceView[] nodeSources = state.getNodeSource();
// filter out all node source events that was removed
// so rm client does not display them
List<NodeSourceView> filtered = new ArrayList<>(nodeSources.length);
for (NodeSourceView nodeSourceEvent : nodeSources) {
if (!nodeSourceEvent.isRemoved()) {
filtered.add(nodeSourceEvent);
}
}
NodeSourceView[] result = new NodeSourceView[filtered.size()];
result = filtered.toArray(result);
resultStack(currentContext).push(result);
if (!currentContext.isSilent()) {
writeLine(currentContext, "%s", StringUtility.string(result));
}
} else {
handleError("An error occurred while retrieving node sources:", response, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.RmStateView in project scheduling by ow2-proactive.
the class ListNodeCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpGet request = new HttpGet(currentContext.getResourceUrl("monitoring"));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
RmStateView state = readValue(response, RmStateView.class, currentContext);
NodeEventView[] nodeEvents = state.getNodesEvents();
NodeEventView[] selectedNodeEvents = null;
if (nodeEvents != null) {
if (nodeSource == null) {
selectedNodeEvents = nodeEvents;
} else {
List<NodeEventView> selectedList = new ArrayList<>();
for (NodeEventView nodeEvent : nodeEvents) {
if (!nodeSource.equals(nodeEvent.getNodeSource())) {
// node source doesn't match
continue;
} else {
selectedList.add(nodeEvent);
}
}
selectedNodeEvents = selectedList.toArray(new NodeEventView[selectedList.size()]);
}
}
// filter out all node events that was removed
// so rm client does not display them
List<NodeEventView> filtered = new ArrayList<>();
for (NodeEventView nodeEvent : selectedNodeEvents) {
if (!nodeEvent.isRemoved()) {
filtered.add(nodeEvent);
}
}
NodeEventView[] result = new NodeEventView[filtered.size()];
result = filtered.toArray(result);
resultStack(currentContext).push(result);
writeLine(currentContext, "%s", StringUtility.string(result));
} else {
handleError("An error occurred while retrieving nodes:", response, currentContext);
}
}
Aggregations