This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020package org.apache.reef.bridge.client;
021
022import org.apache.reef.annotations.Unstable;
023import org.apache.reef.annotations.audience.Interop;
024import org.apache.reef.runtime.common.REEFLauncher;
025import org.apache.reef.tang.Tang;
026import org.apache.reef.tang.exceptions.InjectionException;
027
028import java.io.IOException;
029import java.util.logging.Level;
030import java.util.logging.Logger;
031
032/**
033 * This is a bootstrap launcher for YARN for submission of multiruntime jobs from C#. It allows for Java Driver
034 * configuration generation directly on the Driver without need of Java dependency if REST
035 * submission is used. Note that the name of the class must contain "REEFLauncher" for the time
036 * being in order for the Interop code to discover the class.
037 */
038// TODO[JIRA REEF-1382]: This class does things both for client and driver need to split it
039@Unstable
040@Interop(CppFiles = "DriverLauncher.cpp")
041public final class MultiRuntimeYarnBootstrapREEFLauncher {
042  private static final Logger LOG = Logger.getLogger(MultiRuntimeYarnBootstrapREEFLauncher.class.getName());
043
044  public static void main(final String[] args) throws IOException, InjectionException {
045    LOG.log(Level.INFO, "Entering BootstrapLauncher.main().");
046    if (args.length != 2) {
047      final StringBuilder sb = new StringBuilder();
048      sb.append("[ ");
049      for (String arg : args) {
050        sb.append(arg);
051        sb.append(" ");
052      }
053
054      sb.append("]");
055      final String message = "Bootstrap launcher should have two configuration file inputs, one specifying the" +
056          " application submission parameters to be deserialized and the other specifying the job" +
057          " submission parameters to be deserialized to create the YarnDriverConfiguration on the fly." +
058          " Current args are " + sb.toString();
059
060      throw fatal(message, new IllegalArgumentException(message));
061    }
062
063    try {
064      final MultiRuntimeYarnBootstrapDriverConfigGenerator driverConfigurationGenerator =
065          Tang.Factory.getTang().newInjector().getInstance(MultiRuntimeYarnBootstrapDriverConfigGenerator.class);
066      REEFLauncher.main(new String[]{driverConfigurationGenerator.writeDriverConfigurationFile(args[0], args[1])});
067    } catch (final Exception exception) {
068      if (!(exception instanceof RuntimeException)) {
069        throw fatal("Failed to initialize configurations.", exception);
070      }
071
072      throw exception;
073    }
074  }
075
076  private static RuntimeException fatal(final String msg, final Throwable t) {
077    LOG.log(Level.SEVERE, msg, t);
078    return new RuntimeException(msg, t);
079  }
080
081  private MultiRuntimeYarnBootstrapREEFLauncher(){
082  }
083}