use of com.continuuity.weave.api.RuntimeSpecification in project weave by continuuity.
the class WeaveSpecificationCodec method deserialize.
@Override
public WeaveSpecification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObj = json.getAsJsonObject();
String name = jsonObj.get("name").getAsString();
Map<String, RuntimeSpecification> runnables = context.deserialize(jsonObj.get("runnables"), new TypeToken<Map<String, RuntimeSpecification>>() {
}.getType());
List<WeaveSpecification.Order> orders = context.deserialize(jsonObj.get("orders"), new TypeToken<List<WeaveSpecification.Order>>() {
}.getType());
JsonElement handler = jsonObj.get("handler");
EventHandlerSpecification eventHandler = null;
if (handler != null && !handler.isJsonNull()) {
eventHandler = context.deserialize(handler, EventHandlerSpecification.class);
}
return new DefaultWeaveSpecification(name, runnables, orders, eventHandler);
}
use of com.continuuity.weave.api.RuntimeSpecification in project weave by continuuity.
the class YarnWeavePreparer method populateRunnableLocalFiles.
/**
* Based on the given {@link WeaveSpecification}, upload LocalFiles to Yarn Cluster.
* @param weaveSpec The {@link WeaveSpecification} for populating resource.
* @param localFiles A Multimap to store runnable name to transformed LocalFiles.
* @throws IOException
*/
private void populateRunnableLocalFiles(WeaveSpecification weaveSpec, Multimap<String, LocalFile> localFiles) throws IOException {
LOG.debug("Populating Runnable LocalFiles");
for (Map.Entry<String, RuntimeSpecification> entry : weaveSpec.getRunnables().entrySet()) {
String runnableName = entry.getKey();
for (LocalFile localFile : entry.getValue().getLocalFiles()) {
Location location;
URI uri = localFile.getURI();
if ("hdfs".equals(uri.getScheme())) {
// Assuming the location factory is HDFS one. If it is not, it will failed, which is the correct behavior.
location = locationFactory.create(uri);
} else {
URL url = uri.toURL();
LOG.debug("Create and copy {} : {}", runnableName, url);
// Preserves original suffix for expansion.
location = copyFromURL(url, createTempLocation(Paths.appendSuffix(url.getFile(), localFile.getName())));
LOG.debug("Done {} : {}", runnableName, url);
}
localFiles.put(runnableName, new DefaultLocalFile(localFile.getName(), location.toURI(), location.lastModified(), location.length(), localFile.isArchive(), localFile.getPattern()));
}
}
LOG.debug("Done Runnable LocalFiles");
}
Aggregations