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 private static final String GLOBAL_FOLDER_PATH = REEF_BASE_FOLDER + '/' + GLOBAL_FOLDER; 035 private static final String LOCAL_FOLDER = "local"; 036 private 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 private static final String DRIVER_HTTP_ENDPOINT_FILE_NAME = "DriverHttpEndpoint.txt"; 051 private static final String BRIDGE_EXE_NAME = "Org.Apache.REEF.Bridge.exe"; 052 private static final String SECURITY_TOKEN_IDENTIFIER_FILE = "SecurityTokenId"; 053 private static final String SECURITY_TOKEN_PASSWORD_FILE = "SecurityTokenPwd"; 054 private static final String YARN_BOOTSTRAP_APP_PARAM_FILE = "yarn-app-parameters.json"; 055 private static final String YARN_BOOTSTRAP_JOB_PARAM_FILE = "yarn-job-parameters.json"; 056 057 @Inject 058 public REEFFileNames() { 059 } 060 061 062 /** 063 * @return the filename of the CPP DLL for the bridge. 064 */ 065 public String getBridgeExeName() { 066 return BRIDGE_EXE_NAME; 067 } 068 069 /** 070 * reef/BRIDGE_EXE_NAME. 071 * 072 * @return the File pointing to the EXE that is the clr driver launcher. 073 */ 074 public File getDriverLauncherExeFile() { 075 return new File(getREEFFolderName(), getBridgeExeName()); 076 } 077 078 /** 079 * The name of the REEF folder inside of the working directory of an Evaluator or Driver. 080 */ 081 public String getREEFFolderName() { 082 return REEF_BASE_FOLDER; 083 } 084 085 /** 086 * @return the folder und which all REEF files are stored. 087 */ 088 public File getREEFFolder() { 089 return new File(getREEFFolderName()); 090 } 091 092 093 /** 094 * @return the name of the folder inside of REEF_BASE_FOLDER that houses the global files. 095 */ 096 public String getGlobalFolderName() { 097 return GLOBAL_FOLDER; 098 } 099 100 /** 101 * @return the path to the global folder: REEF_BASE_FOLDER/GLOBAL_FOLDER 102 */ 103 public String getGlobalFolderPath() { 104 return GLOBAL_FOLDER_PATH; 105 } 106 107 /** 108 * @return the folder holding the files global to all containers. 109 */ 110 public File getGlobalFolder() { 111 return new File(getREEFFolder(), getGlobalFolderName()); 112 } 113 114 115 /** 116 * @return the name of the folder inside of REEF_BASE_FOLDER that houses the local files. 117 */ 118 public String getLocalFolderName() { 119 return LOCAL_FOLDER; 120 } 121 122 /** 123 * @return the path to the local folder: REEF_BASE_FOLDER/LOCAL_FOLDER 124 */ 125 public String getLocalFolderPath() { 126 return LOCAL_FOLDER_PATH; 127 } 128 129 /** 130 * @return the folder holding the files local to this container. 131 */ 132 public File getLocalFolder() { 133 return new File(getREEFFolder(), getLocalFolderName()); 134 } 135 136 137 /** 138 * The name under which the driver configuration will be stored in REEF_BASE_FOLDER/LOCAL_FOLDER. 139 */ 140 public String getDriverConfigurationName() { 141 return DRIVER_CONFIGURATION_NAME; 142 } 143 144 /** 145 * @return The path to the driver configuration: GLOBAL_FOLDER/LOCAL_FOLDER/DRIVER_CONFIGURATION_NAME 146 */ 147 public String getDriverConfigurationPath() { 148 return DRIVER_CONFIGURATION_PATH; 149 } 150 151 /** 152 * @return The name under which the driver configuration will be stored in REEF_BASE_FOLDER/LOCAL_FOLDER 153 */ 154 public String getEvaluatorConfigurationName() { 155 return EVALUATOR_CONFIGURATION_NAME; 156 } 157 158 /** 159 * @return the path to the evaluator configuration. 160 */ 161 public String getEvaluatorConfigurationPath() { 162 return EVALUATOR_CONFIGURATION_PATH; 163 } 164 165 /** 166 * @return The suffix used for JAR files, including the "." 167 */ 168 public String getJarFileSuffix() { 169 return JAR_FILE_SUFFIX; 170 } 171 172 /** 173 * The prefix used whenever REEF is asked to create a job folder, on (H)DFS or locally. 174 * <p> 175 * This prefix is also used with JAR files created to represent a job. 176 */ 177 public String getJobFolderPrefix() { 178 return JOB_FOLDER_PREFIX; 179 } 180 181 /** 182 * @return The name used within the current working directory of the driver to redirect standard error to. 183 */ 184 public String getDriverStderrFileName() { 185 return DRIVER_STDERR; 186 } 187 188 /** 189 * @return The name used within the current working directory of the driver to redirect standard out to. 190 */ 191 public String getDriverStdoutFileName() { 192 return DRIVER_STDOUT; 193 } 194 195 /** 196 * @return The prefix used whenever REEF is asked to create an Evaluator folder, e.g. for staging. 197 */ 198 public String getEvaluatorFolderPrefix() { 199 return EVALUATOR_FOLDER_PREFIX; 200 } 201 202 /** 203 * @return The name used within the current working directory of the driver to redirect standard error to. 204 */ 205 public String getEvaluatorStderrFileName() { 206 return EVALUATOR_STDERR; 207 } 208 209 /** 210 * @return The name used within the current working directory of the driver to redirect standard out to. 211 */ 212 public String getEvaluatorStdoutFileName() { 213 return EVALUATOR_STDOUT; 214 } 215 216 /** 217 * @return File name that contains the dfs path for the DriverHttpEndpoint. 218 */ 219 public String getDriverHttpEndpoint() { 220 return DRIVER_HTTP_ENDPOINT_FILE_NAME; 221 } 222 223 /** 224 * @return File name that contains the security token identifier 225 */ 226 public String getSecurityTokenIdentifierFile() { 227 return SECURITY_TOKEN_IDENTIFIER_FILE; 228 } 229 230 /** 231 * @return File name that contains the security token password 232 */ 233 public String getSecurityTokenPasswordFile() { 234 return SECURITY_TOKEN_PASSWORD_FILE; 235 } 236 237 /** 238 * @return File name the contains the bootstrap application parameters for YARN job submission 239 * without Java dependency. 240 */ 241 public String getYarnBootstrapAppParamFile() { 242 return YARN_BOOTSTRAP_APP_PARAM_FILE; 243 } 244 245 /** 246 * @return File name the contains the bootstrap job parameters for YARN job submission 247 * without Java dependency. 248 */ 249 public String getYarnBootstrapJobParamFile() { 250 return YARN_BOOTSTRAP_JOB_PARAM_FILE; 251 } 252 253 /** 254 * @return Path to the bootstrap application parameters file for YARN job submission without Java dependency. 255 */ 256 public String getYarnBootstrapAppParamFilePath() { 257 return LOCAL_FOLDER_PATH + '/' + getYarnBootstrapAppParamFile(); 258 } 259 260 /** 261 * @return Path to the bootstrap job parameters file for YARN job submission without Java dependency. 262 */ 263 public String getYarnBootstrapJobParamFilePath() { 264 return getYarnBootstrapJobParamFile(); 265 } 266}