You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2013/07/31 03:59:48 UTC
[28/50] [abbrv] git commit: ACCUMULO-1518 Patch from David M. Lyle
that allows opening rfiles w/ multiple dots in name.
ACCUMULO-1518 Patch from David M. Lyle that allows opening rfiles w/ multiple dots in name.
git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1493899 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/9b2a56b2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9b2a56b2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9b2a56b2
Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 9b2a56b2f0d538f00e733399396c17fe55322dc8
Parents: 6b11a32
Author: Keith Turner <kt...@apache.org>
Authored: Mon Jun 17 19:36:52 2013 +0000
Committer: Keith Turner <kt...@apache.org>
Committed: Mon Jun 17 19:36:52 2013 +0000
----------------------------------------------------------------------
.../accumulo/core/file/FileOperations.java | 5 +-
.../accumulo/core/file/FileOperationsTest.java | 67 ++++++++++++++++++++
2 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9b2a56b2/src/core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/file/FileOperations.java b/src/core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
index 9f60725..17e540b 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
@@ -44,14 +44,13 @@ class DispatchingFileFactory extends FileOperations {
if (name.startsWith(Constants.MAPFILE_EXTENSION + "_")) {
return new MapFileOperations();
}
-
String[] sp = name.split("\\.");
- if (sp.length != 2) {
+ if (sp.length < 2) {
throw new IllegalArgumentException("File name " + name + " has no extension");
}
- String extension = sp[1];
+ String extension = sp[sp.length - 1];
if (extension.equals(Constants.MAPFILE_EXTENSION) || extension.equals(Constants.MAPFILE_EXTENSION + "_tmp")) {
return new MapFileOperations();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9b2a56b2/src/core/src/test/java/org/apache/accumulo/core/file/FileOperationsTest.java
----------------------------------------------------------------------
diff --git a/src/core/src/test/java/org/apache/accumulo/core/file/FileOperationsTest.java b/src/core/src/test/java/org/apache/accumulo/core/file/FileOperationsTest.java
new file mode 100644
index 0000000..30c667d
--- /dev/null
+++ b/src/core/src/test/java/org/apache/accumulo/core/file/FileOperationsTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.accumulo.core.file;
+
+import static org.junit.Assert.assertFalse;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.file.rfile.RFile;
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.junit.Test;
+
+public class FileOperationsTest {
+
+ public FileOperationsTest() {}
+
+ /**
+ * Test for filenames with +1 dot
+ */
+ @Test
+ public void handlesFilenamesWithMoreThanOneDot() throws IOException {
+
+ Boolean caughtException = false;
+ FileSKVWriter writer = null;
+ String filename = "target/test.file." + RFile.EXTENSION;
+ File testFile = new File(filename);
+ if (testFile.exists()) {
+ FileUtils.forceDelete(testFile);
+ }
+ try {
+ FileOperations fileOperations = FileOperations.getInstance();
+ Configuration conf = new Configuration();
+ FileSystem fs = FileSystem.getLocal(conf);
+ AccumuloConfiguration acuconf = AccumuloConfiguration.getDefaultConfiguration();
+ writer = fileOperations.openWriter(filename, fs, conf, acuconf);
+ writer.close();
+ } catch (Exception ex) {
+ caughtException = true;
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ FileUtils.forceDelete(testFile);
+ }
+
+ assertFalse("Should not throw with more than 1 dot in filename.", caughtException);
+ }
+}