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.driver.evaluator;
020
021import org.apache.reef.runtime.common.launch.CLRLaunchCommandBuilder;
022
023import java.util.Collections;
024import java.util.List;
025
026/**
027 * Defines the setup of a CLR process.
028 */
029public final class CLRProcess implements EvaluatorProcess {
030  private final CLRLaunchCommandBuilder commandBuilder = new CLRLaunchCommandBuilder();
031  private boolean optionSet = false;
032
033  /**
034   * Instantiated via CLRProcessFactory.
035   */
036  CLRProcess() {
037  }
038
039  @Override
040  public List<String> getCommandLine() {
041    return commandBuilder
042        .build();
043  }
044
045  @Override
046  public EvaluatorType getType() {
047    return EvaluatorType.CLR;
048  }
049
050  @Override
051  public CLRProcess setMemory(final int megaBytes) {
052    commandBuilder.setMemory(megaBytes);
053    optionSet = true;
054    return this;
055  }
056
057  @Override
058  public boolean isOptionSet() {
059    return optionSet;
060  }
061
062  @Override
063  public CLRProcess setConfigurationFileName(final String configurationFileName) {
064    commandBuilder.setConfigurationFilePaths(Collections.singletonList(configurationFileName));
065    return this;
066  }
067
068  @Override
069  public CLRProcess setStandardOut(final String standardOut) {
070    commandBuilder.setStandardOut(standardOut);
071    return this;
072  }
073
074  @Override
075  public CLRProcess setStandardErr(final String standardErr) {
076    commandBuilder.setStandardErr(standardErr);
077    return this;
078  }
079}