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.files;
020
021import net.jcip.annotations.Immutable;
022
023import javax.inject.Inject;
024import java.io.File;
025
026/**
027 * Access to the various places things go according to the REEF file system standard.
028 */
029@Immutable
030public final class REEFFileNames {
031
032  private static final String REEF_BASE_FOLDER = "reef";
033  private static final String GLOBAL_FOLDER = "global";
034  static final String GLOBAL_FOLDER_PATH = REEF_BASE_FOLDER + '/' + GLOBAL_FOLDER;
035  private static final String LOCAL_FOLDER = "local";
036  static final String LOCAL_FOLDER_PATH = REEF_BASE_FOLDER + '/' + LOCAL_FOLDER;
037  private static final String DRIVER_CONFIGURATION_NAME = "driver.conf";
038  private static final String DRIVER_CONFIGURATION_PATH =
039      LOCAL_FOLDER_PATH + '/' + DRIVER_CONFIGURATION_NAME;
040  private static final String EVALUATOR_CONFIGURATION_NAME = "evaluator.conf";
041  private static final String EVALUATOR_CONFIGURATION_PATH =
042      LOCAL_FOLDER_PATH + '/' + EVALUATOR_CONFIGURATION_NAME;
043  private static final String JAR_FILE_SUFFIX = ".jar";
044  private static final String JOB_FOLDER_PREFIX = "reef-job-";
045  private static final String EVALUATOR_FOLDER_PREFIX = "reef-evaluator-";
046  private static final String DRIVER_STDERR = "driver.stderr";
047  private static final String DRIVER_STDOUT = "driver.stdout";
048  private static final String EVALUATOR_STDERR = "evaluator.stderr";
049  private static final String EVALUATOR_STDOUT = "evaluator.stdout";
050
051  @Inject
052  public REEFFileNames() {
053  }
054
055  /**
056   * The name of the REEF folder inside of the working directory of an Evaluator or Driver
057   */
058  public String getREEFFolderName() {
059    return REEF_BASE_FOLDER;
060  }
061
062  /**
063   * @return the folder und which all REEF files are stored.
064   */
065  public File getREEFFolder() {
066    return new File(getREEFFolderName());
067  }
068
069
070  /**
071   * @return the name of the folder inside of REEF_BASE_FOLDER that houses the global files.
072   */
073  public String getGlobalFolderName() {
074    return GLOBAL_FOLDER;
075  }
076
077  /**
078   * @return the path to the global folder: REEF_BASE_FOLDER/GLOBAL_FOLDER
079   */
080  public String getGlobalFolderPath() {
081    return GLOBAL_FOLDER_PATH;
082  }
083
084  /**
085   * @return the folder holding the files global to all containers.
086   */
087  public File getGlobalFolder() {
088    return new File(getREEFFolder(), getGlobalFolderName());
089  }
090
091
092  /**
093   * @return the name of the folder inside of REEF_BASE_FOLDER that houses the local files.
094   */
095  public String getLocalFolderName() {
096    return LOCAL_FOLDER;
097  }
098
099  /**
100   * @return the path to the local folder: REEF_BASE_FOLDER/LOCAL_FOLDER
101   */
102  public String getLocalFolderPath() {
103    return LOCAL_FOLDER_PATH;
104  }
105
106  /**
107   * @return the folder holding the files local to this container.
108   */
109  public File getLocalFolder() {
110    return new File(getREEFFolder(), getLocalFolderName());
111  }
112
113
114  /**
115   * The name under which the driver configuration will be stored in REEF_BASE_FOLDER/LOCAL_FOLDER
116   */
117  public String getDriverConfigurationName() {
118    return DRIVER_CONFIGURATION_NAME;
119  }
120
121  /**
122   * @return The path to the driver configuration: GLOBAL_FOLDER/LOCAL_FOLDER/DRIVER_CONFIGURATION_NAME
123   */
124  public String getDriverConfigurationPath() {
125    return DRIVER_CONFIGURATION_PATH;
126  }
127
128  /**
129   * @return The name under which the driver configuration will be stored in REEF_BASE_FOLDER/LOCAL_FOLDER
130   */
131  public String getEvaluatorConfigurationName() {
132    return EVALUATOR_CONFIGURATION_NAME;
133  }
134
135  /**
136   * @return the path to the evaluator configuration.
137   */
138  public String getEvaluatorConfigurationPath() {
139    return EVALUATOR_CONFIGURATION_PATH;
140  }
141
142  /**
143   * @return The suffix used for JAR files, including the "."
144   */
145  public String getJarFileSuffix() {
146    return JAR_FILE_SUFFIX;
147  }
148
149  /**
150   * The prefix used whenever REEF is asked to create a job folder, on (H)DFS or locally.
151   * <p/>
152   * This prefix is also used with JAR files created to represent a job.
153   */
154  public String getJobFolderPrefix() {
155    return JOB_FOLDER_PREFIX;
156  }
157
158  /**
159   * @return The name used within the current working directory of the driver to redirect standard error to.
160   */
161  public String getDriverStderrFileName() {
162    return DRIVER_STDERR;
163  }
164
165  /**
166   * @return The name used within the current working directory of the driver to redirect standard out to.
167   */
168  public String getDriverStdoutFileName() {
169    return DRIVER_STDOUT;
170  }
171
172  /**
173   * @return The prefix used whenever REEF is asked to create an Evaluator folder, e.g. for staging.
174   */
175  public String getEvaluatorFolderPrefix() {
176    return EVALUATOR_FOLDER_PREFIX;
177  }
178
179  /**
180   * @return The name used within the current working directory of the driver to redirect standard error to.
181   */
182  public String getEvaluatorStderrFileName() {
183    return EVALUATOR_STDERR;
184  }
185
186  /**
187   * @return The name used within the current working directory of the driver to redirect standard out to.
188   */
189  public String getEvaluatorStdoutFileName() {
190    return EVALUATOR_STDOUT;
191  }
192}