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;
022import org.apache.reef.annotations.audience.RuntimeAuthor;
023
024import javax.inject.Inject;
025import java.util.ArrayList;
026import java.util.Arrays;
027import java.util.Collections;
028import java.util.List;
029
030/**
031 * Supplies the classpath to REEF for process (Driver, Evaluator) launches.
032 */
033@Immutable
034@RuntimeAuthor
035public final class ClasspathProvider {
036  private final List<String> driverClasspath;
037  private final List<String> evaluatorClasspath;
038
039
040  @Inject
041  ClasspathProvider(final RuntimeClasspathProvider runtimeClasspathProvider,
042                    final REEFFileNames reefFileNames) {
043    final List<String> baseClasspath = Arrays.asList(
044        reefFileNames.getLocalFolderPath() + "/*",
045        reefFileNames.getGlobalFolderPath() + "/*");
046
047    // Assemble the driver classpath
048    final List<String> runtimeDriverClasspathPrefix = runtimeClasspathProvider.getDriverClasspathPrefix();
049    final List<String> runtimeDriverClasspathSuffix = runtimeClasspathProvider.getDriverClasspathSuffix();
050    final List<String> driverClasspathList = new ArrayList<>(baseClasspath.size() +
051        runtimeDriverClasspathPrefix.size() +
052        runtimeDriverClasspathSuffix.size());
053    driverClasspathList.addAll(runtimeDriverClasspathPrefix);
054    driverClasspathList.addAll(baseClasspath);
055    driverClasspathList.addAll(runtimeDriverClasspathSuffix);
056    this.driverClasspath = Collections.unmodifiableList(driverClasspathList);
057
058    // Assemble the evaluator classpath
059    final List<String> runtimeEvaluatorClasspathPrefix = runtimeClasspathProvider.getEvaluatorClasspathPrefix();
060    final List<String> runtimeEvaluatorClasspathSuffix = runtimeClasspathProvider.getEvaluatorClasspathSuffix();
061    final List<String> evaluatorClasspathList = new ArrayList<>(runtimeEvaluatorClasspathPrefix.size() +
062        baseClasspath.size() +
063        runtimeEvaluatorClasspathSuffix.size());
064    evaluatorClasspathList.addAll(runtimeEvaluatorClasspathPrefix);
065    evaluatorClasspathList.addAll(baseClasspath);
066    evaluatorClasspathList.addAll(runtimeEvaluatorClasspathSuffix);
067    this.evaluatorClasspath = Collections.unmodifiableList(evaluatorClasspathList);
068  }
069
070  /**
071   * @return the classpath to be used for the Driver
072   */
073  public List<String> getDriverClasspath() {
074    return this.driverClasspath;
075  }
076
077  /**
078   * @return the classpath to be used for Evaluators.
079   */
080  public List<String> getEvaluatorClasspath() {
081    return this.evaluatorClasspath;
082  }
083}