Author: vinodkv
Date: Wed Jun 2 08:22:26 2010
New Revision: 950414
URL: http://svn.apache.org/viewvc?rev=950414&view=rev
Log:
MAPREDUCE-572. If #link is missing from uri format of -cacheArchive then streaming does not
throw error. Contributed by Amareshwari Sriramadasu.
Added:
hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/filecache/TestURIFragments.java
Modified:
hadoop/mapreduce/trunk/CHANGES.txt
hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/filecache/TrackerDistributedCacheManager.java
Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=950414&r1=950413&r2=950414&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Wed Jun 2 08:22:26 2010
@@ -35,6 +35,10 @@ Trunk (unreleased changes)
MAPREDUCE-1785. Add streaming config option for not emitting the key.
(Eli Collins via sharad)
+ MAPREDUCE-572. If #link is missing from uri format of -cacheArchive
+ then streaming does not throw error. (Amareshwari Sriramadasu via
+ vinodkv)
+
OPTIMIZATIONS
MAPREDUCE-1354. Enhancements to JobTracker for better performance and
Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/filecache/TrackerDistributedCacheManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/filecache/TrackerDistributedCacheManager.java?rev=950414&r1=950413&r2=950414&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/filecache/TrackerDistributedCacheManager.java
(original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/filecache/TrackerDistributedCacheManager.java
Wed Jun 2 08:22:26 2010
@@ -768,43 +768,46 @@ public class TrackerDistributedCacheMana
* @param uriFiles The uri array of urifiles
* @param uriArchives the uri array of uri archives
*/
- public static boolean checkURIs(URI[] uriFiles, URI[] uriArchives){
- if ((uriFiles == null) && (uriArchives == null)){
+ public static boolean checkURIs(URI[] uriFiles, URI[] uriArchives) {
+ if ((uriFiles == null) && (uriArchives == null)) {
return true;
}
- if (uriFiles != null){
- for (int i = 0; i < uriFiles.length; i++){
- String frag1 = uriFiles[i].getFragment();
- if (frag1 == null)
+ // check if fragment is null for any uri
+ // also check if there are any conflicts in fragment names
+ Set<String> fragments = new HashSet<String>();
+
+ // iterate over file uris
+ if (uriFiles != null) {
+ for (int i = 0; i < uriFiles.length; i++) {
+ String fragment = uriFiles[i].getFragment();
+ if (fragment == null) {
return false;
- for (int j=i+1; j < uriFiles.length; j++){
- String frag2 = uriFiles[j].getFragment();
- if (frag2 == null)
- return false;
- if (frag1.equalsIgnoreCase(frag2))
- return false;
}
- if (uriArchives != null){
- for (int j = 0; j < uriArchives.length; j++){
- String frag2 = uriArchives[j].getFragment();
- if (frag2 == null){
- return false;
- }
- if (frag1.equalsIgnoreCase(frag2))
- return false;
- for (int k=j+1; k < uriArchives.length; k++){
- String frag3 = uriArchives[k].getFragment();
- if (frag3 == null)
- return false;
- if (frag2.equalsIgnoreCase(frag3))
- return false;
- }
- }
+ String lowerCaseFragment = fragment.toLowerCase();
+ if (fragments.contains(lowerCaseFragment)) {
+ return false;
}
+ fragments.add(lowerCaseFragment);
+ }
+ }
+
+ // iterate over archive uris
+ if (uriArchives != null) {
+ for (int i = 0; i < uriArchives.length; i++) {
+ String fragment = uriArchives[i].getFragment();
+ if (fragment == null) {
+ return false;
+ }
+ String lowerCaseFragment = fragment.toLowerCase();
+ if (fragments.contains(lowerCaseFragment)) {
+ return false;
+ }
+ fragments.add(lowerCaseFragment);
}
}
return true;
}
+
/**
* This is to check the public/private visibility of the archives to be
* localized.
Added: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/filecache/TestURIFragments.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/filecache/TestURIFragments.java?rev=950414&view=auto
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/filecache/TestURIFragments.java
(added)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/filecache/TestURIFragments.java
Wed Jun 2 08:22:26 2010
@@ -0,0 +1,115 @@
+/**
+ * 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.mapreduce.filecache;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class TestURIFragments {
+
+ /**
+ * Tests {@link TrackerDistributedCacheManager#checkURIs(URI[], URI[]).
+ */
+ @Test
+ public void testURIs() throws URISyntaxException {
+ assertTrue(TrackerDistributedCacheManager.checkURIs(null, null));
+
+ // uris with no fragments
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] { new URI(
+ "file://foo/bar/myCacheFile.txt") }, null));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(null,
+ new URI[] { new URI("file://foo/bar/myCacheArchive.txt") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file"),
+ new URI("file://foo/bar/myCacheFile2.txt") }, null));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(null, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] { new URI(
+ "file://foo/bar/myCacheFile.txt") }, new URI[] { new URI(
+ "file://foo/bar/myCacheArchive.txt") }));
+
+ // conflicts in fragment names
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file"),
+ new URI("file://foo/bar/myCacheFile2.txt#file") }, null));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(null, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] { new URI(
+ "file://foo/bar/myCacheFile.txt#cache") }, new URI[] { new URI(
+ "file://foo/bar/myCacheArchive.txt#cache") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#file2") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file"),
+ new URI("file://foo/bar/myCacheFile2.txt#file") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive1"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#cache") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#cache"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+
+ // test ignore case
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file"),
+ new URI("file://foo/bar/myCacheFile2.txt#FILE") }, null));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(null, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive"),
+ new URI("file://foo/bar/myCacheArchive2.txt#ARCHIVE") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] { new URI(
+ "file://foo/bar/myCacheFile.txt#cache") }, new URI[] { new URI(
+ "file://foo/bar/myCacheArchive.txt#CACHE") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#file2") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#ARCHIVE"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#FILE"),
+ new URI("file://foo/bar/myCacheFile2.txt#file") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive1"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+ assertFalse(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#CACHE") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#cache"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+
+ // allowed uri combinations
+ assertTrue(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#file2") }, null));
+ assertTrue(TrackerDistributedCacheManager.checkURIs(null, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive1"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+ assertTrue(TrackerDistributedCacheManager.checkURIs(new URI[] {
+ new URI("file://foo/bar/myCacheFile1.txt#file1"),
+ new URI("file://foo/bar/myCacheFile2.txt#file2") }, new URI[] {
+ new URI("file://foo/bar/myCacheArchive1.txt#archive1"),
+ new URI("file://foo/bar/myCacheArchive2.txt#archive2") }));
+ }
+}
|