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 2015/10/19 00:58:55 UTC

[1/8] accumulo git commit: ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

Repository: accumulo
Updated Branches:
  refs/heads/1.6 1ab3827be -> 3f1346c5f
  refs/heads/1.7 0c3dc17e9 -> 6b7333098
  refs/heads/master 6a9e0b50a -> 642b7a95f


ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

The value of this variable is expected to be an Accumulo ClientConfiguration file.
If it's a directory which happens to contain this file, it is silently ignored. We
can try to correct this automatically for users.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3f1346c5
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3f1346c5
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3f1346c5

Branch: refs/heads/1.6
Commit: 3f1346c5f39245bf959647dba1549227e954f171
Parents: 1ab3827
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:19:20 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:30:41 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        | 21 ++++-
 .../core/client/ClientConfigurationTest.java    | 96 ++++++++++++++++++++
 .../core/conf/ClientConfigurationTest.java      | 66 --------------
 3 files changed, 116 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
index 8593d9e..6bccc09 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
@@ -170,8 +170,27 @@ public class ClientConfiguration extends CompositeConfiguration {
     return new ClientConfiguration(propConfig);
   }
 
+  /**
+   * Muck the value of {@code clientConfPath} if it points to a directory by appending
+   * {@code client.conf} to the end of the file path. This is a no-op if the value is not a
+   * directory on the filesystem.
+   *
+   * @param clientConfPath The value of ACCUMULO_CLIENT_CONF_PATH.
+   */
+  static String getClientConfPath(String clientConfPath) {
+    if (null == clientConfPath) {
+      return null;
+    }
+    File filePath = new File(clientConfPath);
+    // If clientConfPath is a directory, tack on the default client.conf file name.
+    if (filePath.exists() && filePath.isDirectory()) {
+      return new File(filePath, "client.conf").toString();
+    }
+    return clientConfPath;
+  }
+
   private static List<String> getDefaultSearchPath() {
-    String clientConfSearchPath = System.getenv("ACCUMULO_CLIENT_CONF_PATH");
+    String clientConfSearchPath = getClientConfPath(System.getenv("ACCUMULO_CLIENT_CONF_PATH"));
     List<String> clientConfPaths;
     if (clientConfSearchPath != null) {
       clientConfPaths = Arrays.asList(clientConfSearchPath.split(File.pathSeparator));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
new file mode 100644
index 0000000..81918cc
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+
+public class ClientConfigurationTest {
+  @Test
+  public void testOverrides() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    assertExpectedConfig(clientConfig);
+  }
+
+  @Test
+  public void testSerialization() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    // sanity check that we're starting with what we're expecting
+    assertExpectedConfig(clientConfig);
+
+    String serialized = clientConfig.serialize();
+    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
+    assertExpectedConfig(deserializedClientConfig);
+  }
+
+  private void assertExpectedConfig(ClientConfiguration clientConfig) {
+    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
+    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
+    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
+    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
+  }
+
+  private ClientConfiguration createConfig() {
+    Configuration first = new PropertiesConfiguration();
+    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
+    Configuration second = new PropertiesConfiguration();
+    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
+    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
+    Configuration third = new PropertiesConfiguration();
+    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
+    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
+    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
+    return new ClientConfiguration(Arrays.asList(first, second, third));
+  }
+
+  @Test
+  public void testConfPath() throws IOException {
+    File target = new File(System.getProperty("user.dir"), "target");
+    assertTrue("'target' build directory does not exist", target.exists());
+    File testDir = new File(target, getClass().getName());
+    if (!testDir.exists()) {
+      assertTrue("Failed to create test dir " + testDir, testDir.mkdirs());
+    }
+
+    File clientConf = new File(testDir, "client.conf");
+    if (!clientConf.exists()) {
+      assertTrue("Failed to create file " + clientConf, clientConf.createNewFile());
+    }
+
+    // A directory should return the path with client.conf appended.
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(testDir.toString()));
+    // A normal file should return itself
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(clientConf.toString()));
+
+    // Something that doesn't exist should return itself (specifially, it shouldn't error)
+    final File missing = new File("foobarbaz12332112");
+    assertEquals(missing.toString(), ClientConfiguration.getClientConfPath(missing.toString()));
+
+    assertNull(ClientConfiguration.getClientConfPath(null));
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
deleted file mode 100644
index 40be70f..0000000
--- a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.conf;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.junit.Test;
-
-public class ClientConfigurationTest {
-  @Test
-  public void testOverrides() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    assertExpectedConfig(clientConfig);
-  }
-
-  @Test
-  public void testSerialization() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    // sanity check that we're starting with what we're expecting
-    assertExpectedConfig(clientConfig);
-
-    String serialized = clientConfig.serialize();
-    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
-    assertExpectedConfig(deserializedClientConfig);
-  }
-
-  private void assertExpectedConfig(ClientConfiguration clientConfig) {
-    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
-    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
-    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
-    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
-  }
-
-  private ClientConfiguration createConfig() {
-    Configuration first = new PropertiesConfiguration();
-    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
-    Configuration second = new PropertiesConfiguration();
-    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
-    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
-    Configuration third = new PropertiesConfiguration();
-    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
-    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
-    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
-    return new ClientConfiguration(Arrays.asList(first, second, third));
-  }
-}


[4/8] accumulo git commit: Merge branch '1.6' into 1.7

Posted by el...@apache.org.
Merge branch '1.6' into 1.7

Conflicts:
	core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/208a1032
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/208a1032
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/208a1032

Branch: refs/heads/1.7
Commit: 208a10322579cf726e7ec1eb5227ee4e09303681
Parents: 0c3dc17 3f1346c
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:41:13 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:41:13 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        |  21 +++-
 .../core/client/ClientConfigurationTest.java    | 105 ++++++-------------
 2 files changed, 51 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/208a1032/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------


[7/8] accumulo git commit: ACCUMULO-4027 Commit checkstyle autoformatting.

Posted by el...@apache.org.
ACCUMULO-4027 Commit checkstyle autoformatting.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/6b733309
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/6b733309
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/6b733309

Branch: refs/heads/1.7
Commit: 6b73330985727ed2a5012ebae53afa00bcad9711
Parents: 208a103
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:58:01 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:58:01 2015 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/client/ClientConfiguration.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b733309/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
index 649df00..d5bf920 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
@@ -244,11 +244,11 @@ public class ClientConfiguration extends CompositeConfiguration {
   }
 
   /**
-   * Muck the value of {@code clientConfPath} if it points to a directory by appending
-   * {@code client.conf} to the end of the file path. This is a no-op if the value is not a
-   * directory on the filesystem.
+   * Muck the value of {@code clientConfPath} if it points to a directory by appending {@code client.conf} to the end of the file path. This is a no-op if the
+   * value is not a directory on the filesystem.
    *
-   * @param clientConfPath The value of ACCUMULO_CLIENT_CONF_PATH.
+   * @param clientConfPath
+   *          The value of ACCUMULO_CLIENT_CONF_PATH.
    */
   static String getClientConfPath(String clientConfPath) {
     if (null == clientConfPath) {


[5/8] accumulo git commit: Merge branch '1.6' into 1.7

Posted by el...@apache.org.
Merge branch '1.6' into 1.7

Conflicts:
	core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/208a1032
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/208a1032
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/208a1032

Branch: refs/heads/master
Commit: 208a10322579cf726e7ec1eb5227ee4e09303681
Parents: 0c3dc17 3f1346c
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:41:13 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:41:13 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        |  21 +++-
 .../core/client/ClientConfigurationTest.java    | 105 ++++++-------------
 2 files changed, 51 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/208a1032/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------


[2/8] accumulo git commit: ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

Posted by el...@apache.org.
ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

The value of this variable is expected to be an Accumulo ClientConfiguration file.
If it's a directory which happens to contain this file, it is silently ignored. We
can try to correct this automatically for users.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3f1346c5
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3f1346c5
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3f1346c5

Branch: refs/heads/1.7
Commit: 3f1346c5f39245bf959647dba1549227e954f171
Parents: 1ab3827
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:19:20 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:30:41 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        | 21 ++++-
 .../core/client/ClientConfigurationTest.java    | 96 ++++++++++++++++++++
 .../core/conf/ClientConfigurationTest.java      | 66 --------------
 3 files changed, 116 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
index 8593d9e..6bccc09 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
@@ -170,8 +170,27 @@ public class ClientConfiguration extends CompositeConfiguration {
     return new ClientConfiguration(propConfig);
   }
 
+  /**
+   * Muck the value of {@code clientConfPath} if it points to a directory by appending
+   * {@code client.conf} to the end of the file path. This is a no-op if the value is not a
+   * directory on the filesystem.
+   *
+   * @param clientConfPath The value of ACCUMULO_CLIENT_CONF_PATH.
+   */
+  static String getClientConfPath(String clientConfPath) {
+    if (null == clientConfPath) {
+      return null;
+    }
+    File filePath = new File(clientConfPath);
+    // If clientConfPath is a directory, tack on the default client.conf file name.
+    if (filePath.exists() && filePath.isDirectory()) {
+      return new File(filePath, "client.conf").toString();
+    }
+    return clientConfPath;
+  }
+
   private static List<String> getDefaultSearchPath() {
-    String clientConfSearchPath = System.getenv("ACCUMULO_CLIENT_CONF_PATH");
+    String clientConfSearchPath = getClientConfPath(System.getenv("ACCUMULO_CLIENT_CONF_PATH"));
     List<String> clientConfPaths;
     if (clientConfSearchPath != null) {
       clientConfPaths = Arrays.asList(clientConfSearchPath.split(File.pathSeparator));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
new file mode 100644
index 0000000..81918cc
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+
+public class ClientConfigurationTest {
+  @Test
+  public void testOverrides() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    assertExpectedConfig(clientConfig);
+  }
+
+  @Test
+  public void testSerialization() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    // sanity check that we're starting with what we're expecting
+    assertExpectedConfig(clientConfig);
+
+    String serialized = clientConfig.serialize();
+    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
+    assertExpectedConfig(deserializedClientConfig);
+  }
+
+  private void assertExpectedConfig(ClientConfiguration clientConfig) {
+    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
+    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
+    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
+    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
+  }
+
+  private ClientConfiguration createConfig() {
+    Configuration first = new PropertiesConfiguration();
+    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
+    Configuration second = new PropertiesConfiguration();
+    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
+    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
+    Configuration third = new PropertiesConfiguration();
+    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
+    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
+    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
+    return new ClientConfiguration(Arrays.asList(first, second, third));
+  }
+
+  @Test
+  public void testConfPath() throws IOException {
+    File target = new File(System.getProperty("user.dir"), "target");
+    assertTrue("'target' build directory does not exist", target.exists());
+    File testDir = new File(target, getClass().getName());
+    if (!testDir.exists()) {
+      assertTrue("Failed to create test dir " + testDir, testDir.mkdirs());
+    }
+
+    File clientConf = new File(testDir, "client.conf");
+    if (!clientConf.exists()) {
+      assertTrue("Failed to create file " + clientConf, clientConf.createNewFile());
+    }
+
+    // A directory should return the path with client.conf appended.
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(testDir.toString()));
+    // A normal file should return itself
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(clientConf.toString()));
+
+    // Something that doesn't exist should return itself (specifially, it shouldn't error)
+    final File missing = new File("foobarbaz12332112");
+    assertEquals(missing.toString(), ClientConfiguration.getClientConfPath(missing.toString()));
+
+    assertNull(ClientConfiguration.getClientConfPath(null));
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
deleted file mode 100644
index 40be70f..0000000
--- a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.conf;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.junit.Test;
-
-public class ClientConfigurationTest {
-  @Test
-  public void testOverrides() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    assertExpectedConfig(clientConfig);
-  }
-
-  @Test
-  public void testSerialization() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    // sanity check that we're starting with what we're expecting
-    assertExpectedConfig(clientConfig);
-
-    String serialized = clientConfig.serialize();
-    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
-    assertExpectedConfig(deserializedClientConfig);
-  }
-
-  private void assertExpectedConfig(ClientConfiguration clientConfig) {
-    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
-    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
-    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
-    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
-  }
-
-  private ClientConfiguration createConfig() {
-    Configuration first = new PropertiesConfiguration();
-    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
-    Configuration second = new PropertiesConfiguration();
-    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
-    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
-    Configuration third = new PropertiesConfiguration();
-    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
-    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
-    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
-    return new ClientConfiguration(Arrays.asList(first, second, third));
-  }
-}


[8/8] accumulo git commit: Merge branch '1.7'

Posted by el...@apache.org.
Merge branch '1.7'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/642b7a95
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/642b7a95
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/642b7a95

Branch: refs/heads/master
Commit: 642b7a95f58172a26e2b4def9b016521729f7857
Parents: 6a9e0b5 6b73330
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:58:33 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:58:33 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        |  21 +++-
 .../core/client/ClientConfigurationTest.java    | 105 ++++++-------------
 2 files changed, 51 insertions(+), 75 deletions(-)
----------------------------------------------------------------------



[3/8] accumulo git commit: ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

Posted by el...@apache.org.
ACCUMULO-4027 Convert the value of ACCUMULO_CLIENT_CONF_PATH to a file if it's a directory.

The value of this variable is expected to be an Accumulo ClientConfiguration file.
If it's a directory which happens to contain this file, it is silently ignored. We
can try to correct this automatically for users.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3f1346c5
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3f1346c5
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3f1346c5

Branch: refs/heads/master
Commit: 3f1346c5f39245bf959647dba1549227e954f171
Parents: 1ab3827
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:19:20 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:30:41 2015 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        | 21 ++++-
 .../core/client/ClientConfigurationTest.java    | 96 ++++++++++++++++++++
 .../core/conf/ClientConfigurationTest.java      | 66 --------------
 3 files changed, 116 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
index 8593d9e..6bccc09 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
@@ -170,8 +170,27 @@ public class ClientConfiguration extends CompositeConfiguration {
     return new ClientConfiguration(propConfig);
   }
 
+  /**
+   * Muck the value of {@code clientConfPath} if it points to a directory by appending
+   * {@code client.conf} to the end of the file path. This is a no-op if the value is not a
+   * directory on the filesystem.
+   *
+   * @param clientConfPath The value of ACCUMULO_CLIENT_CONF_PATH.
+   */
+  static String getClientConfPath(String clientConfPath) {
+    if (null == clientConfPath) {
+      return null;
+    }
+    File filePath = new File(clientConfPath);
+    // If clientConfPath is a directory, tack on the default client.conf file name.
+    if (filePath.exists() && filePath.isDirectory()) {
+      return new File(filePath, "client.conf").toString();
+    }
+    return clientConfPath;
+  }
+
   private static List<String> getDefaultSearchPath() {
-    String clientConfSearchPath = System.getenv("ACCUMULO_CLIENT_CONF_PATH");
+    String clientConfSearchPath = getClientConfPath(System.getenv("ACCUMULO_CLIENT_CONF_PATH"));
     List<String> clientConfPaths;
     if (clientConfSearchPath != null) {
       clientConfPaths = Arrays.asList(clientConfSearchPath.split(File.pathSeparator));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
new file mode 100644
index 0000000..81918cc
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+
+public class ClientConfigurationTest {
+  @Test
+  public void testOverrides() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    assertExpectedConfig(clientConfig);
+  }
+
+  @Test
+  public void testSerialization() throws Exception {
+    ClientConfiguration clientConfig = createConfig();
+    // sanity check that we're starting with what we're expecting
+    assertExpectedConfig(clientConfig);
+
+    String serialized = clientConfig.serialize();
+    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
+    assertExpectedConfig(deserializedClientConfig);
+  }
+
+  private void assertExpectedConfig(ClientConfiguration clientConfig) {
+    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
+    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
+    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
+    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
+  }
+
+  private ClientConfiguration createConfig() {
+    Configuration first = new PropertiesConfiguration();
+    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
+    Configuration second = new PropertiesConfiguration();
+    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
+    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
+    Configuration third = new PropertiesConfiguration();
+    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
+    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
+    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
+    return new ClientConfiguration(Arrays.asList(first, second, third));
+  }
+
+  @Test
+  public void testConfPath() throws IOException {
+    File target = new File(System.getProperty("user.dir"), "target");
+    assertTrue("'target' build directory does not exist", target.exists());
+    File testDir = new File(target, getClass().getName());
+    if (!testDir.exists()) {
+      assertTrue("Failed to create test dir " + testDir, testDir.mkdirs());
+    }
+
+    File clientConf = new File(testDir, "client.conf");
+    if (!clientConf.exists()) {
+      assertTrue("Failed to create file " + clientConf, clientConf.createNewFile());
+    }
+
+    // A directory should return the path with client.conf appended.
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(testDir.toString()));
+    // A normal file should return itself
+    assertEquals(clientConf.toString(), ClientConfiguration.getClientConfPath(clientConf.toString()));
+
+    // Something that doesn't exist should return itself (specifially, it shouldn't error)
+    final File missing = new File("foobarbaz12332112");
+    assertEquals(missing.toString(), ClientConfiguration.getClientConfPath(missing.toString()));
+
+    assertNull(ClientConfiguration.getClientConfPath(null));
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f1346c5/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
deleted file mode 100644
index 40be70f..0000000
--- a/core/src/test/java/org/apache/accumulo/core/conf/ClientConfigurationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.conf;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.junit.Test;
-
-public class ClientConfigurationTest {
-  @Test
-  public void testOverrides() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    assertExpectedConfig(clientConfig);
-  }
-
-  @Test
-  public void testSerialization() throws Exception {
-    ClientConfiguration clientConfig = createConfig();
-    // sanity check that we're starting with what we're expecting
-    assertExpectedConfig(clientConfig);
-
-    String serialized = clientConfig.serialize();
-    ClientConfiguration deserializedClientConfig = ClientConfiguration.deserialize(serialized);
-    assertExpectedConfig(deserializedClientConfig);
-  }
-
-  private void assertExpectedConfig(ClientConfiguration clientConfig) {
-    assertEquals("firstZkHosts", clientConfig.get(ClientProperty.INSTANCE_ZK_HOST));
-    assertEquals("secondInstanceName", clientConfig.get(ClientProperty.INSTANCE_NAME));
-    assertEquals("123s", clientConfig.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
-    assertEquals(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getDefaultValue(), clientConfig.get(ClientProperty.RPC_SSL_TRUSTSTORE_TYPE));
-  }
-
-  private ClientConfiguration createConfig() {
-    Configuration first = new PropertiesConfiguration();
-    first.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "firstZkHosts");
-    Configuration second = new PropertiesConfiguration();
-    second.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "secondZkHosts");
-    second.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "secondInstanceName");
-    Configuration third = new PropertiesConfiguration();
-    third.addProperty(ClientProperty.INSTANCE_ZK_HOST.getKey(), "thirdZkHosts");
-    third.addProperty(ClientProperty.INSTANCE_NAME.getKey(), "thirdInstanceName");
-    third.addProperty(ClientProperty.INSTANCE_ZK_TIMEOUT.getKey(), "123s");
-    return new ClientConfiguration(Arrays.asList(first, second, third));
-  }
-}


[6/8] accumulo git commit: ACCUMULO-4027 Commit checkstyle autoformatting.

Posted by el...@apache.org.
ACCUMULO-4027 Commit checkstyle autoformatting.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/6b733309
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/6b733309
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/6b733309

Branch: refs/heads/master
Commit: 6b73330985727ed2a5012ebae53afa00bcad9711
Parents: 208a103
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 18 18:58:01 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 18 18:58:01 2015 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/client/ClientConfiguration.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b733309/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
index 649df00..d5bf920 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java
@@ -244,11 +244,11 @@ public class ClientConfiguration extends CompositeConfiguration {
   }
 
   /**
-   * Muck the value of {@code clientConfPath} if it points to a directory by appending
-   * {@code client.conf} to the end of the file path. This is a no-op if the value is not a
-   * directory on the filesystem.
+   * Muck the value of {@code clientConfPath} if it points to a directory by appending {@code client.conf} to the end of the file path. This is a no-op if the
+   * value is not a directory on the filesystem.
    *
-   * @param clientConfPath The value of ACCUMULO_CLIENT_CONF_PATH.
+   * @param clientConfPath
+   *          The value of ACCUMULO_CLIENT_CONF_PATH.
    */
   static String getClientConfPath(String clientConfPath) {
     if (null == clientConfPath) {