use of com.continuuity.weave.api.WeaveRunnableSpecification in project weave by continuuity.
the class WeaveContainerMain method main.
/**
* Main method for launching a {@link WeaveContainerService} which runs
* a {@link com.continuuity.weave.api.WeaveRunnable}.
*/
public static void main(final String[] args) throws Exception {
// Try to load the secure store from localized file, which AM requested RM to localize it for this container.
loadSecureStore();
String zkConnectStr = System.getenv(EnvKeys.WEAVE_ZK_CONNECT);
File weaveSpecFile = new File(Constants.Files.WEAVE_SPEC);
RunId appRunId = RunIds.fromString(System.getenv(EnvKeys.WEAVE_APP_RUN_ID));
RunId runId = RunIds.fromString(System.getenv(EnvKeys.WEAVE_RUN_ID));
String runnableName = System.getenv(EnvKeys.WEAVE_RUNNABLE_NAME);
int instanceId = Integer.parseInt(System.getenv(EnvKeys.WEAVE_INSTANCE_ID));
int instanceCount = Integer.parseInt(System.getenv(EnvKeys.WEAVE_INSTANCE_COUNT));
ZKClientService zkClientService = ZKClientServices.delegate(ZKClients.reWatchOnExpire(ZKClients.retryOnFailure(ZKClientService.Builder.of(zkConnectStr).build(), RetryStrategies.fixDelay(1, TimeUnit.SECONDS))));
DiscoveryService discoveryService = new ZKDiscoveryService(zkClientService);
WeaveSpecification weaveSpec = loadWeaveSpec(weaveSpecFile);
renameLocalFiles(weaveSpec.getRunnables().get(runnableName));
WeaveRunnableSpecification runnableSpec = weaveSpec.getRunnables().get(runnableName).getRunnableSpecification();
ContainerInfo containerInfo = new EnvContainerInfo();
Arguments arguments = decodeArgs();
BasicWeaveContext context = new BasicWeaveContext(runId, appRunId, containerInfo.getHost(), arguments.getRunnableArguments().get(runnableName).toArray(new String[0]), arguments.getArguments().toArray(new String[0]), runnableSpec, instanceId, discoveryService, instanceCount, containerInfo.getMemoryMB(), containerInfo.getVirtualCores());
Configuration conf = new YarnConfiguration(new HdfsConfiguration(new Configuration()));
Service service = new WeaveContainerService(context, containerInfo, getContainerZKClient(zkClientService, appRunId, runnableName), runId, runnableSpec, getClassLoader(), createAppLocation(conf));
new WeaveContainerMain().doMain(zkClientService, service);
}
use of com.continuuity.weave.api.WeaveRunnableSpecification in project weave by continuuity.
the class RuntimeSpecificationCodec method deserialize.
@Override
public RuntimeSpecification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObj = json.getAsJsonObject();
String name = jsonObj.get("name").getAsString();
WeaveRunnableSpecification runnable = context.deserialize(jsonObj.get("runnable"), WeaveRunnableSpecification.class);
ResourceSpecification resources = context.deserialize(jsonObj.get("resources"), ResourceSpecification.class);
Collection<LocalFile> files = context.deserialize(jsonObj.get("files"), new TypeToken<Collection<LocalFile>>() {
}.getType());
return new DefaultRuntimeSpecification(name, runnable, resources, files);
}
Aggregations