public static void main()

in twill-yarn/src/main/java/org/apache/twill/internal/container/TwillContainerMain.java [68:108]


  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.TWILL_ZK_CONNECT);
    File twillSpecFile = new File(Constants.Files.TWILL_SPEC);
    RunId appRunId = RunIds.fromString(System.getenv(EnvKeys.TWILL_APP_RUN_ID));
    RunId runId = RunIds.fromString(System.getenv(EnvKeys.TWILL_RUN_ID));
    String runnableName = System.getenv(EnvKeys.TWILL_RUNNABLE_NAME);
    int instanceId = Integer.parseInt(System.getenv(EnvKeys.TWILL_INSTANCE_ID));
    int instanceCount = Integer.parseInt(System.getenv(EnvKeys.TWILL_INSTANCE_COUNT));

    ZKClientService zkClientService = createZKClient(zkConnectStr, System.getenv(EnvKeys.TWILL_APP_NAME));
    ZKDiscoveryService discoveryService = new ZKDiscoveryService(zkClientService);

    ZKClient appRunZkClient = getAppRunZKClient(zkClientService, appRunId);

    TwillSpecification twillSpec = loadTwillSpec(twillSpecFile);
    
    TwillRunnableSpecification runnableSpec = twillSpec.getRunnables().get(runnableName).getRunnableSpecification();
    ContainerInfo containerInfo = new EnvContainerInfo();
    Arguments arguments = decodeArgs();
    BasicTwillContext context = new BasicTwillContext(
      runId, appRunId, containerInfo.getHost(),
      arguments.getRunnableArguments().get(runnableName).toArray(new String[0]),
      arguments.getArguments().toArray(new String[0]),
      runnableSpec, instanceId, discoveryService, discoveryService, appRunZkClient,
      instanceCount, containerInfo.getMemoryMB(), containerInfo.getVirtualCores()
    );

    ZKClient containerZKClient = getContainerZKClient(zkClientService, appRunId, runnableName);
    Configuration conf = new YarnConfiguration(new HdfsConfiguration(new Configuration()));
    Service service = new TwillContainerService(context, containerInfo, containerZKClient,
                                                runId, runnableSpec, getClassLoader(),
                                                createAppLocation(conf));
    new TwillContainerMain().doMain(
      service,
      new LogFlushService(),
      zkClientService,
      new TwillZKPathService(containerZKClient, runId));
  }