use of com.datatorrent.stram.StreamingContainerAgent in project apex-core by apache.
the class StramWebServices method getContainer.
@GET
@Path(PATH_PHYSICAL_PLAN_CONTAINERS + "/{containerId}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getContainer(@PathParam("containerId") String containerId) throws Exception {
init();
ContainerInfo ci = null;
if (containerId.equals(System.getenv(ApplicationConstants.Environment.CONTAINER_ID.toString()))) {
ci = dagManager.getAppMasterContainerInfo();
} else {
for (ContainerInfo containerInfo : dagManager.getCompletedContainerInfo()) {
if (containerInfo.id.equals(containerId)) {
ci = containerInfo;
}
}
if (ci == null) {
StreamingContainerAgent sca = dagManager.getContainerAgent(containerId);
if (sca == null) {
throw new NotFoundException();
}
ci = sca.getContainerInfo();
}
}
return new JSONObject(objectMapper.writeValueAsString(ci));
}
use of com.datatorrent.stram.StreamingContainerAgent in project apex-core by apache.
the class StramWebServices method listContainers.
@GET
@Path(PATH_PHYSICAL_PLAN_CONTAINERS)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject listContainers(@QueryParam("states") String states) throws Exception {
init();
Set<String> stateSet = null;
if (states != null) {
stateSet = new HashSet<>();
stateSet.addAll(Arrays.asList(StringUtils.split(states, ',')));
}
ContainersInfo ci = new ContainersInfo();
for (ContainerInfo containerInfo : dagManager.getCompletedContainerInfo()) {
if (stateSet == null || stateSet.contains(containerInfo.state)) {
ci.add(containerInfo);
}
}
Collection<StreamingContainerAgent> containerAgents = dagManager.getContainerAgents();
// add itself (app master container)
ContainerInfo appMasterContainerInfo = dagManager.getAppMasterContainerInfo();
if (stateSet == null || stateSet.contains(appMasterContainerInfo.state)) {
ci.add(appMasterContainerInfo);
}
for (StreamingContainerAgent sca : containerAgents) {
ContainerInfo containerInfo = sca.getContainerInfo();
if (stateSet == null || stateSet.contains(containerInfo.state)) {
ci.add(containerInfo);
}
}
// To get around the nasty JAXB problem for lists
return new JSONObject(objectMapper.writeValueAsString(ci));
}
use of com.datatorrent.stram.StreamingContainerAgent in project apex-core by apache.
the class StramWebServices method getContainerStackTrace.
@GET
@Path(PATH_PHYSICAL_PLAN_CONTAINERS + "/{containerId}/" + PATH_STACKTRACE)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getContainerStackTrace(@PathParam("containerId") String containerId) throws Exception {
init();
if (containerId.equals(System.getenv(ApplicationConstants.Environment.CONTAINER_ID.toString()))) {
return StramUtils.getStackTrace();
}
StreamingContainerAgent sca = dagManager.getContainerAgent(containerId);
if (sca == null) {
throw new NotFoundException("Container not found.");
}
if (!sca.getContainerInfo().state.equals("ACTIVE")) {
throw new NotFoundException("Container is not active.");
}
for (int i = 0; i < STACK_TRACE_ATTEMPTS; ++i) {
String result = sca.getStackTrace();
if (result != null) {
return new JSONObject(result);
}
Thread.sleep(STACK_TRACE_WAIT_TIME);
}
throw new TimeoutException("Not able to get the stack trace");
}
Aggregations