diff --git hadoop-yarn-project/hadoop-yarn/bin/yarn hadoop-yarn-project/hadoop-yarn/bin/yarn index 207fb4a..bfcb190 100644 --- hadoop-yarn-project/hadoop-yarn/bin/yarn +++ hadoop-yarn-project/hadoop-yarn/bin/yarn @@ -33,6 +33,7 @@ function hadoop_usage echo " resourcemanager run the ResourceManager" echo " resourcemanager -format-state-store deletes the RMStateStore" echo " rmadmin admin tools" + echo " sharedcachemanager run the SharedCacheManager daemon" echo " timelineserver run the timeline server" echo " version print the version" echo " or" @@ -149,6 +150,11 @@ case "${COMMAND}" in JAVA_HEAP_MAX="-Xmx${YARN_TIMELINESERVER_HEAPSIZE}m" fi ;; + sharedcachemanager) + daemon="true" + CLASS='org.apache.hadoop.yarn.server.sharedcachemanager.SharedCacheManager' + YARN_OPTS="$YARN_OPTS $YARN_SHAREDCACHEMANAGER_OPTS" + ;; version) CLASS=org.apache.hadoop.util.VersionInfo hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java index acc4a05..ef15975 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java @@ -1285,6 +1285,28 @@ public static final boolean TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED_DEFAULT = false; + // /////////////////////////////// + // Shared Cache Configs + // /////////////////////////////// + public static final String SHARED_CACHE_PREFIX = "yarn.sharedcache."; + + // common configs + /** whether the shared cache is enabled/disabled */ + public static final String SHARED_CACHE_ENABLED = SHARED_CACHE_PREFIX + + "enabled"; + public static final boolean DEFAULT_SHARED_CACHE_ENABLED = false; + + /** The config key for the shared cache root directory. */ + public static final String SHARED_CACHE_ROOT = SHARED_CACHE_PREFIX + + "root-dir"; + public static final String DEFAULT_SHARED_CACHE_ROOT = "/sharedcache"; + + /** The config key for the level of nested directories before getting to the + * checksum directory. */ + public static final String SHARED_CACHE_NESTED_LEVEL = SHARED_CACHE_PREFIX + + "nested-level"; + public static final int DEFAULT_SHARED_CACHE_NESTED_LEVEL = 3; + //////////////////////////////// // Other Configs //////////////////////////////// diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml index e642d05..866aee7 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml @@ -1310,6 +1310,26 @@ /etc/krb5.keytab + + + Whether the shared cache is enabled + yarn.sharedcache.enabled + false + + + + The root directory for the shared cache + yarn.sharedcache.root-dir + /sharedcache + + + + The level of nested directories before getting to the checksum + directories. It must be non-negative. + yarn.sharedcache.nested-level + 3 + + The interval that the yarn client library uses to poll the diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/sharedcache/CacheStructureUtil.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/sharedcache/CacheStructureUtil.java new file mode 100644 index 0000000..eb37209 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/sharedcache/CacheStructureUtil.java @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcache; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.yarn.conf.YarnConfiguration; + +/** + * A utility class that contains helper methods for dealing with the internal + * shared cache structure. + */ +public class CacheStructureUtil { + + private static final Log LOG = LogFactory.getLog(CacheStructureUtil.class); + + public static int getCacheDepth(Configuration conf) { + int cacheDepth = + conf.getInt(YarnConfiguration.SHARED_CACHE_NESTED_LEVEL, + YarnConfiguration.DEFAULT_SHARED_CACHE_NESTED_LEVEL); + + if (cacheDepth <= 0) { + LOG.warn("Specified cache depth was less than or equal to zero." + + " Using default value instead. Default: " + + YarnConfiguration.DEFAULT_SHARED_CACHE_NESTED_LEVEL + + ", Specified: " + cacheDepth); + cacheDepth = YarnConfiguration.DEFAULT_SHARED_CACHE_NESTED_LEVEL; + } + + return cacheDepth; + } + + public static String getCacheEntryPath(int cacheDepth, String cacheRoot, + String checksum) { + + if (cacheDepth <= 0) { + throw new IllegalArgumentException( + "The cache depth must be greater than 0. Passed value: " + cacheDepth); + } + if (checksum.length() < cacheDepth) { + throw new IllegalArgumentException("The checksum passed was too short: " + + checksum); + } + + // Build the cache entry path to the specified depth. For example, if the + // depth is 3 and the checksum is 3c4f, the path would be: + // SHARED_CACHE_ROOT/3/c/4/3c4f + StringBuilder sb = new StringBuilder(cacheRoot); + for (int i = 0; i < cacheDepth; i++) { + sb.append(Path.SEPARATOR_CHAR); + sb.append(checksum.charAt(i)); + } + sb.append(Path.SEPARATOR_CHAR).append(checksum); + + return sb.toString(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/pom.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/pom.xml new file mode 100644 index 0000000..869298b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/pom.xml @@ -0,0 +1,90 @@ + + + + 4.0.0 + + hadoop-yarn-server + org.apache.hadoop + 3.0.0-SNAPSHOT + + org.apache.hadoop + hadoop-yarn-server-sharedcachemanager + 3.0.0-SNAPSHOT + hadoop-yarn-server-sharedcachemanager + + + + ${project.parent.parent.basedir} + + + + + org.apache.hadoop + hadoop-common + + + org.apache.hadoop + hadoop-yarn-api + + + org.apache.hadoop + hadoop-yarn-common + + + org.apache.hadoop + hadoop-yarn-client + + + junit + junit + test + + + org.mockito + mockito-all + test + + + org.apache.hadoop + hadoop-common + test-jar + test + + + org.apache.hadoop + hadoop-yarn-server-tests + test + test-jar + + + + + + + + + maven-jar-plugin + + + + test-jar + + test-compile + + + + + + diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/AppChecker.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/AppChecker.java new file mode 100644 index 0000000..0f9693b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/AppChecker.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcachemanager; + +import java.util.Collection; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Evolving; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.exceptions.YarnException; + +/** + * An interface for checking whether an app is running so that the cleaner + * service may determine if it can safely remove a cached entry. + */ +@Private +@Evolving +public interface AppChecker { + /** + * Returns whether the app is in an active state. + * + * @return true if the app is found and is not in one of the completed states; + * false otherwise + * @throws YarnException if there is an error in determining the app state + */ + @Private + boolean isApplicationActive(ApplicationId id) throws YarnException; + + /** + * Returns the list of all active apps at the given time. + * + * @return the list of active apps, or an empty list if there is none + * @throws YarnException if there is an error in obtaining the list + */ + @Private + Collection getActiveApplications() throws YarnException; +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/RemoteAppChecker.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/RemoteAppChecker.java new file mode 100644 index 0000000..a8abb76 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/RemoteAppChecker.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcachemanager; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumSet; +import java.util.List; + +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.client.api.YarnClient; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.apache.hadoop.yarn.exceptions.YarnException; + +/** + * An implementation of AppChecker that queries the resource manager remotely to + * determine whether the app is running. + */ +class RemoteAppChecker implements AppChecker { + private static final EnumSet ACTIVE_STATES = + EnumSet.complementOf(EnumSet.of(YarnApplicationState.FINISHED, + YarnApplicationState.FAILED, + YarnApplicationState.KILLED)); + + private final YarnClient client; + + /** + * Creates an instance of RemoteAppChecker. + */ + public static AppChecker create() { + return new RemoteAppChecker(YarnClient.createYarnClient()); + } + + RemoteAppChecker(YarnClient client) { + this.client = client; + } + + public boolean isApplicationActive(ApplicationId id) throws YarnException { + ApplicationReport report = null; + try { + report = client.getApplicationReport(id); + } catch (ApplicationNotFoundException e) { + // the app does not exist + return false; + } catch (IOException e) { + throw new YarnException(e); + } + + if (report == null) { + // the app does not exist + return false; + } + + return ACTIVE_STATES.contains(report.getYarnApplicationState()); + } + + public Collection getActiveApplications() throws YarnException { + try { + List activeApps = new ArrayList(); + List apps = client.getApplications(ACTIVE_STATES); + for (ApplicationReport app: apps) { + activeApps.add(app.getApplicationId()); + } + return activeApps; + } catch (IOException e) { + throw new YarnException(e); + } + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/SharedCacheManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/SharedCacheManager.java new file mode 100644 index 0000000..773b03b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/main/java/org/apache/hadoop/yarn/server/sharedcachemanager/SharedCacheManager.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcachemanager; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.source.JvmMetrics; +import org.apache.hadoop.service.CompositeService; +import org.apache.hadoop.util.ShutdownHookManager; +import org.apache.hadoop.util.StringUtils; +import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler; +import org.apache.hadoop.yarn.conf.YarnConfiguration; + +/** + * This service maintains the shared cache meta data. It handles claiming and + * releasing of resources, all rpc calls from the client to the shared cache + * manager, and administrative commands. It also persists the shared cache meta + * data to a backend store, and cleans up stale entries on a regular basis. + */ +public class SharedCacheManager extends CompositeService { + /** + * Priority of the SharedCacheManager shutdown hook. + */ + public static final int SHUTDOWN_HOOK_PRIORITY = 30; + + private static final Log LOG = LogFactory.getLog(SharedCacheManager.class); + + public SharedCacheManager() { + super("SharedCacheManager"); + } + + @Override + protected void serviceInit(Configuration conf) throws Exception { + super.serviceInit(conf); + } + + @Override + protected void serviceStart() throws Exception { + // Start metrics + DefaultMetricsSystem.initialize("SharedCacheManager"); + JvmMetrics.initSingleton("SharedCacheManager", null); + + super.serviceStart(); + } + + @Override + protected void serviceStop() throws Exception { + + DefaultMetricsSystem.shutdown(); + super.serviceStop(); + } + + public static void main(String[] args) { + Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); + StringUtils.startupShutdownMessage(SharedCacheManager.class, args, LOG); + try { + Configuration conf = new YarnConfiguration(); + SharedCacheManager sharedCacheManager = new SharedCacheManager(); + ShutdownHookManager.get().addShutdownHook( + new CompositeServiceShutdownHook(sharedCacheManager), + SHUTDOWN_HOOK_PRIORITY); + sharedCacheManager.init(conf); + sharedCacheManager.start(); + } catch (Throwable t) { + LOG.fatal("Error starting SharedCacheManager", t); + System.exit(-1); + } + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestRemoteAppChecker.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestRemoteAppChecker.java new file mode 100644 index 0000000..d6118d5 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestRemoteAppChecker.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcachemanager; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; +import org.apache.hadoop.yarn.client.api.YarnClient; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.junit.Test; + +public class TestRemoteAppChecker { + + @Test + public void testNonExistentApp() throws Exception { + YarnClient client = mock(YarnClient.class); + AppChecker appChecker = new RemoteAppChecker(client); + ApplicationId id = ApplicationId.newInstance(1, 1); + + // test for null + when(client.getApplicationReport(id)).thenReturn(null); + assertFalse(appChecker.isApplicationActive(id)); + + // test for ApplicationNotFoundException + when(client.getApplicationReport(id)).thenThrow( + new ApplicationNotFoundException("Throw!")); + assertFalse(appChecker.isApplicationActive(id)); + } + + @Test + public void testRunningApp() throws Exception { + YarnClient client = mock(YarnClient.class); + AppChecker appChecker = new RemoteAppChecker(client); + ApplicationId id = ApplicationId.newInstance(1, 1); + + // create a report and set the state to an active one + ApplicationReport report = new ApplicationReportPBImpl(); + report.setYarnApplicationState(YarnApplicationState.ACCEPTED); + when(client.getApplicationReport(id)).thenReturn(report); + + assertTrue(appChecker.isApplicationActive(id)); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestSharedCacheManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestSharedCacheManager.java new file mode 100644 index 0000000..1d757c3 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-sharedcachemanager/src/test/java/org/apache/hadoop/yarn/server/sharedcachemanager/TestSharedCacheManager.java @@ -0,0 +1,104 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.sharedcachemanager; + +import static org.apache.hadoop.fs.CreateFlag.CREATE; +import static org.apache.hadoop.fs.CreateFlag.OVERWRITE; + +import java.io.IOException; +import java.util.EnumSet; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileContext; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.server.sharedcache.CacheStructureUtil; +import org.junit.After; +import org.junit.Before; + +public class TestSharedCacheManager { + private static final Configuration conf = new YarnConfiguration(); + + private static final FileSystem fs; + + private static final String KEY1 = "abcdefgh"; + private static final String FILE1 = "foo"; + private static final String KEY2 = "ijklmnop"; + private static final String FILE2 = "bar"; + + private static final Path baseDir; + private static final String root; + private static final String path1; + private static final String path2; + + static { + try { + fs = FileSystem.getLocal(conf); + } catch (IOException e) { + throw new RuntimeException(e); + } + + baseDir = + new Path("target", TestSharedCacheManager.class.getSimpleName()) + .makeQualified(fs.getUri(), fs.getWorkingDirectory()); + root = baseDir.toUri().getPath(); + // set the shared cache root + conf.set(YarnConfiguration.SHARED_CACHE_ROOT, root); + + path1 = getFullPath(KEY1, FILE1); + path2 = getFullPath(KEY2, FILE2); + } + + private static String getFullPath(String key, String fileName) { + int cacheDepth = YarnConfiguration.DEFAULT_SHARED_CACHE_NESTED_LEVEL; + return CacheStructureUtil.getCacheEntryPath(cacheDepth, root, key) + + Path.SEPARATOR + fileName; + } + + @Before + public void setUp() throws IOException { + FileContext files = FileContext.getLocalFSFileContext(); + files.mkdir(baseDir, null, true); + // add a couple of directories and files + createFile(new Path(path1), files); + createFile(new Path(path2), files); + } + + @After + public void shutDown() throws IOException { + FileContext files = FileContext.getLocalFSFileContext(); + files.delete(baseDir, true); + } + + private void createFile(Path path, FileContext files) throws IOException { + Path parent = path.getParent(); + files.mkdir(parent, null, true); + FSDataOutputStream out = null; + try { + out = files.create(path, EnumSet.of(CREATE, OVERWRITE)); + out.writeUTF("This is a test"); + } finally { + if (out != null) { + out.close(); + } + } + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/pom.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/pom.xml index b635d10..886773a 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/pom.xml +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/pom.xml @@ -39,6 +39,7 @@ hadoop-yarn-server-nodemanager hadoop-yarn-server-web-proxy hadoop-yarn-server-resourcemanager + hadoop-yarn-server-sharedcachemanager hadoop-yarn-server-tests hadoop-yarn-server-applicationhistoryservice