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.runtime.common.launch;
020
021import org.apache.commons.lang.StringUtils;
022
023import java.io.File;
024import java.util.LinkedList;
025import java.util.List;
026import java.util.logging.Level;
027import java.util.logging.Logger;
028
029/**
030 * A builder for the command line to launch a CLR Evaluator.
031 */
032public class CLRLaunchCommandBuilder implements LaunchCommandBuilder {
033  private static final Logger LOG = Logger.getLogger(CLRLaunchCommandBuilder.class.getName());
034  private static final String EVALUATOR_PATH = "reef/global/Microsoft.Reef.Evaluator.exe";
035
036
037  private String standardErrPath = null;
038  private String standardOutPath = null;
039  private String errorHandlerRID = null;
040  private String launchID = null;
041  private int megaBytes = 0;
042  private String evaluatorConfigurationPath = null;
043
044  @Override
045  public List<String> build() {
046    final List<String> result = new LinkedList<>();
047    File f = new File(EVALUATOR_PATH);
048    if (!f.exists()) {
049      LOG.log(Level.WARNING, "file can NOT be found: {0}", f.getAbsolutePath());
050    }
051    result.add(f.getPath());
052    result.add(errorHandlerRID);
053    result.add(evaluatorConfigurationPath);
054    if ((null != this.standardOutPath) && (!standardOutPath.isEmpty())) {
055      result.add(">" + this.standardOutPath);
056    }
057    if ((null != this.standardErrPath) && (!standardErrPath.isEmpty())) {
058      result.add("2>" + this.standardErrPath);
059    }
060    LOG.log(Level.FINE, "Launch Exe: {0}", StringUtils.join(result, ' '));
061    return result;
062  }
063
064  @Override
065  public CLRLaunchCommandBuilder setErrorHandlerRID(final String errorHandlerRID) {
066    this.errorHandlerRID = errorHandlerRID;
067    return this;
068  }
069
070  @Override
071  public CLRLaunchCommandBuilder setLaunchID(final String launchID) {
072    this.launchID = launchID;
073    return this;
074  }
075
076  @Override
077  public CLRLaunchCommandBuilder setMemory(final int megaBytes) {
078    this.megaBytes = megaBytes;
079    return this;
080  }
081
082  @Override
083  public CLRLaunchCommandBuilder setConfigurationFileName(final String configurationFileName) {
084    this.evaluatorConfigurationPath = configurationFileName;
085    return this;
086  }
087
088  @Override
089  public CLRLaunchCommandBuilder setStandardOut(final String standardOut) {
090    this.standardOutPath = standardOut;
091    return this;
092  }
093
094  @Override
095  public CLRLaunchCommandBuilder setStandardErr(final String standardErr) {
096    this.standardErrPath = standardErr;
097    return this;
098  }
099}