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.mesos; 020 021import net.jcip.annotations.Immutable; 022import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 023 024import javax.inject.Inject; 025import java.util.Arrays; 026import java.util.List; 027 028/** 029 * Access to the classpath according to the REEF file system standard. 030 */ 031@Immutable 032public final class MesosClasspathProvider implements RuntimeClasspathProvider { 033 private static final String HADOOP_CONF_DIR = System.getenv("HADOOP_CONF_DIR"); 034 private static final String HADOOP_HOME = System.getenv("HADOOP_HOME"); 035 private static final String HADOOP_COMMON_HOME = System.getenv("HADOOP_COMMON_HOME"); 036 private static final String HADOOP_YARN_HOME = System.getenv("HADOOP_YARN_HOME"); 037 private static final String HADOOP_HDFS_HOME = System.getenv("HADOOP_HDFS_HOME"); 038 private static final String HADOOP_MAPRED_HOME = System.getenv("HADOOP_MAPRED_HOME"); 039 040 // Used when we can't get a classpath from Hadoop 041 private static final String[] LEGACY_CLASSPATH_LIST = new String[]{ 042 HADOOP_CONF_DIR, 043 HADOOP_HOME + "/*", 044 HADOOP_HOME + "/lib/*", 045 HADOOP_COMMON_HOME + "/*", 046 HADOOP_COMMON_HOME + "/lib/*", 047 HADOOP_YARN_HOME + "/*", 048 HADOOP_YARN_HOME + "/lib/*", 049 HADOOP_HDFS_HOME + "/*", 050 HADOOP_HDFS_HOME + "/lib/*", 051 HADOOP_MAPRED_HOME + "/*", 052 HADOOP_MAPRED_HOME + "/lib/*", 053 HADOOP_HOME + "/etc/hadoop", 054 HADOOP_HOME + "/share/hadoop/common/*", 055 HADOOP_HOME + "/share/hadoop/common/lib/*", 056 HADOOP_HOME + "/share/hadoop/yarn/*", 057 HADOOP_HOME + "/share/hadoop/yarn/lib/*", 058 HADOOP_HOME + "/share/hadoop/hdfs/*", 059 HADOOP_HOME + "/share/hadoop/hdfs/lib/*", 060 HADOOP_HOME + "/share/hadoop/mapreduce/*", 061 HADOOP_HOME + "/share/hadoop/mapreduce/lib/*" 062 }; 063 private final List<String> classPathPrefix; 064 private final List<String> classPathSuffix; 065 066 @Inject 067 MesosClasspathProvider() { 068 this.classPathPrefix = Arrays.asList(LEGACY_CLASSPATH_LIST); 069 this.classPathSuffix = Arrays.asList(LEGACY_CLASSPATH_LIST); 070 } 071 072 @Override 073 public List<String> getDriverClasspathPrefix() { 074 return this.classPathPrefix; 075 } 076 077 @Override 078 public List<String> getDriverClasspathSuffix() { 079 return this.classPathSuffix; 080 } 081 082 @Override 083 public List<String> getEvaluatorClasspathPrefix() { 084 return this.classPathPrefix; 085 } 086 087 @Override 088 public List<String> getEvaluatorClasspathSuffix() { 089 return this.classPathSuffix; 090 } 091}