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 */
019package org.apache.reef.examples.hello;
020
021import org.apache.reef.client.DriverConfiguration;
022import org.apache.reef.client.DriverLauncher;
023import org.apache.reef.client.LauncherStatus;
024import org.apache.reef.runtime.mesos.client.MesosClientConfiguration;
025import org.apache.reef.tang.Configuration;
026import org.apache.reef.tang.exceptions.BindException;
027import org.apache.reef.tang.exceptions.InjectionException;
028
029import java.util.logging.Level;
030import java.util.logging.Logger;
031
032/**
033 * The Client for running HelloREEF on Mesos.
034 */
035public final class HelloREEFMesos {
036  private static final Logger LOG = Logger.getLogger(HelloREEFMesos.class.getName());
037
038  /**
039   * Mesos Master IP address and port number.
040   * Change it to the master location of your cluster environment if needed
041   */
042  private static final String MASTER_IP = "localhost:5050";
043
044  /**
045   * @return the configuration of the runtime
046   */
047  private static Configuration getRuntimeConfiguration() {
048    return MesosClientConfiguration.CONF
049        .set(MesosClientConfiguration.MASTER_IP, MASTER_IP)
050        .build();
051  }
052
053  /**
054   * @return the configuration of the HelloREEF driver.
055   */
056  private static Configuration getDriverConfiguration() {
057    return DriverConfiguration.CONF
058        .set(DriverConfiguration.GLOBAL_LIBRARIES,
059            HelloREEFMesos.class.getProtectionDomain().getCodeSource().getLocation().getFile())
060        .set(DriverConfiguration.DRIVER_IDENTIFIER, "HelloREEF")
061        .set(DriverConfiguration.ON_DRIVER_STARTED, HelloDriver.StartHandler.class)
062        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, HelloDriver.EvaluatorAllocatedHandler.class)
063        .build();
064  }
065
066  /**
067   * MASTER_IP  is set to "localhost:5050".
068   * You may change it to suit your cluster environment.
069   *
070   * @param args command line parameters.
071   * @throws BindException      configuration error.
072   * @throws InjectionException configuration error.
073   */
074  public static void main(final String[] args) throws BindException, InjectionException {
075    final Configuration runtimeConf = getRuntimeConfiguration();
076    final Configuration driverConf = getDriverConfiguration();
077
078    final LauncherStatus status = DriverLauncher
079        .getLauncher(runtimeConf)
080        .run(driverConf);
081    LOG.log(Level.INFO, "REEF job completed: {0}", status);
082  }
083
084  /**
085   * Empty private constructor to prohibit instantiation of utility class.
086   */
087  private HelloREEFMesos() {
088  }
089}