use of com.continuuity.weave.api.WeaveRunResources in project weave by continuuity.
the class ResourceReportCodec method serialize.
@Override
public JsonElement serialize(ResourceReport src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject json = new JsonObject();
json.addProperty("appMasterId", src.getApplicationId());
json.add("appMasterResources", context.serialize(src.getAppMasterResources(), new TypeToken<WeaveRunResources>() {
}.getType()));
json.add("runnableResources", context.serialize(src.getResources(), new TypeToken<Map<String, Collection<WeaveRunResources>>>() {
}.getType()));
return json;
}
use of com.continuuity.weave.api.WeaveRunResources in project weave by continuuity.
the class DefaultResourceReport method removeRunnableResources.
/**
* Remove the resource corresponding to the given runnable and container.
*
* @param runnableName name of runnable.
* @param containerId container id of the runnable.
*/
public void removeRunnableResources(String runnableName, String containerId) {
WeaveRunResources toRemove = null;
// report a little more complex, and this does not need to be terribly fast.
for (WeaveRunResources resources : usedResources.get(runnableName)) {
if (resources.getContainerId().equals(containerId)) {
toRemove = resources;
break;
}
}
usedResources.remove(runnableName, toRemove);
}
use of com.continuuity.weave.api.WeaveRunResources in project weave by continuuity.
the class ApplicationMasterService method initRunningContainers.
private RunningContainers initRunningContainers(ContainerId appMasterContainerId, String appMasterHost) throws Exception {
WeaveRunResources appMasterResources = new DefaultWeaveRunResources(0, appMasterContainerId.toString(), Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_VIRTUAL_CORES)), Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_MEMORY_MB)), appMasterHost);
String appId = appMasterContainerId.getApplicationAttemptId().getApplicationId().toString();
return new RunningContainers(appId, appMasterResources);
}
use of com.continuuity.weave.api.WeaveRunResources in project weave by continuuity.
the class RunningContainers method start.
void start(String runnableName, ContainerInfo containerInfo, WeaveContainerLauncher launcher) {
containerLock.lock();
try {
int instanceId = getStartInstanceId(runnableName);
RunId runId = getRunId(runnableName, instanceId);
WeaveContainerController controller = launcher.start(runId, instanceId, WeaveContainerMain.class, "$HADOOP_CONF_DIR");
containers.put(runnableName, containerInfo.getId(), controller);
WeaveRunResources resources = new DefaultWeaveRunResources(instanceId, containerInfo.getId(), containerInfo.getVirtualCores(), containerInfo.getMemoryMB(), containerInfo.getHost().getHostName());
resourceReport.addRunResources(runnableName, resources);
if (startSequence.isEmpty() || !runnableName.equals(startSequence.peekLast())) {
startSequence.addLast(runnableName);
}
containerChange.signalAll();
} finally {
containerLock.unlock();
}
}
use of com.continuuity.weave.api.WeaveRunResources in project weave by continuuity.
the class ResourceReportCodec method deserialize.
@Override
public ResourceReport deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObj = json.getAsJsonObject();
String appMasterId = jsonObj.get("appMasterId").getAsString();
WeaveRunResources masterResources = context.deserialize(jsonObj.get("appMasterResources"), WeaveRunResources.class);
Map<String, Collection<WeaveRunResources>> resources = context.deserialize(jsonObj.get("runnableResources"), new TypeToken<Map<String, Collection<WeaveRunResources>>>() {
}.getType());
return new DefaultResourceReport(appMasterId, masterResources, resources);
}
Aggregations