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/05/18 21:13:01 UTC
[1/3] accumulo git commit: ACCUMULO-3823 Ensure SetGoalState is
invoked with server ACCUMULO_CONF_DIR
Repository: accumulo
Updated Branches:
refs/heads/1.7 4eda9ec74 -> 965d4a8ae
refs/heads/master 61f927901 -> e163c34b7
ACCUMULO-3823 Ensure SetGoalState is invoked with server ACCUMULO_CONF_DIR
Make some special methods that the start/stop and SetGoalState
calls can use directly to avoid collisions with the methods
that should be using the client-facing ACCUMULO_CONF_DIR.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/965d4a8a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/965d4a8a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/965d4a8a
Branch: refs/heads/1.7
Commit: 965d4a8ae6744efcde3e826c209887d40fabf64d
Parents: 4eda9ec
Author: Josh Elser <el...@apache.org>
Authored: Mon May 18 14:23:29 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon May 18 14:47:40 2015 -0400
----------------------------------------------------------------------
.../standalone/StandaloneAccumuloCluster.java | 12 +++--
.../standalone/StandaloneClusterControl.java | 25 +++++++++
.../StandaloneAccumuloClusterTest.java | 53 ++++++++++++++++++++
3 files changed, 86 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
index 40fcfae..1baa3a1 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.accumulo.cluster.AccumuloCluster;
@@ -31,8 +32,8 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -47,6 +48,9 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(StandaloneAccumuloCluster.class);
+ static final List<ServerType> ALL_SERVER_TYPES = Collections.unmodifiableList(Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER,
+ ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR));
+
private Instance instance;
private ClientConfiguration clientConf;
private String accumuloHome, clientAccumuloConfDir, serverAccumuloConfDir, hadoopConfDir;
@@ -137,9 +141,9 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
// TODO We can check the hosts files, but that requires us to be on a host with the installation. Limitation at the moment.
- control.exec(SetGoalState.class, new String[] {"NORMAL"});
+ control.setGoalState(MasterGoalState.NORMAL.toString());
- for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER, ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+ for (ServerType type : ALL_SERVER_TYPES) {
control.startAllServers(type);
}
}
@@ -150,7 +154,7 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
// TODO We can check the hosts files, but that requires us to be on a host with the installation. Limitation at the moment.
- for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER, ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+ for (ServerType type : ALL_SERVER_TYPES) {
control.stopAllServers(type);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
index b3b1634..8f943e0 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
@@ -16,6 +16,9 @@
*/
package org.apache.accumulo.cluster.standalone;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -30,6 +33,8 @@ import java.util.Map.Entry;
import org.apache.accumulo.cluster.ClusterControl;
import org.apache.accumulo.cluster.RemoteShell;
import org.apache.accumulo.cluster.RemoteShellOptions;
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
+import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.server.util.Admin;
import org.apache.commons.lang.StringUtils;
@@ -147,6 +152,26 @@ public class StandaloneClusterControl implements ClusterControl {
}
}
+ /**
+ * Wrapper around SetGoalState using the "server" <code>ACCUMULO_CONF_DIR</code>
+ *
+ * @param goalState
+ * The goal state to set
+ * @throws IOException
+ * If SetGoalState returns a non-zero result
+ */
+ public void setGoalState(String goalState) throws IOException {
+ checkNotNull(goalState, "Goal state must not be null");
+ checkArgument(MasterGoalState.valueOf(goalState) != null, "Unknown goal state: " + goalState);
+ File confDir = getConfDir();
+ String master = getHosts(new File(confDir, "masters")).get(0);
+ String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + serverAccumuloConfDir, accumuloPath, SetGoalState.class.getName(), goalState};
+ Entry<Integer,String> pair = exec(master, cmd);
+ if (0 != pair.getKey().intValue()) {
+ throw new IOException("SetGoalState did not finish successfully, retcode=" + pair.getKey() + ", stdout=" + pair.getValue());
+ }
+ }
+
@Override
public void startAllServers(ServerType server) throws IOException {
File confDir = getConfDir();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java
new file mode 100644
index 0000000..1c946bb
--- /dev/null
+++ b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.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.accumulo.cluster.standalone;
+
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
+import org.apache.accumulo.minicluster.ServerType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class StandaloneAccumuloClusterTest {
+
+ @Test
+ public void test() throws Exception {
+ StandaloneAccumuloCluster cluster = EasyMock.createMockBuilder(StandaloneAccumuloCluster.class).addMockedMethod("getClusterControl").createMock();
+ StandaloneClusterControl control = EasyMock.createMock(StandaloneClusterControl.class);
+
+ // Return our mocked clustercontrol
+ EasyMock.expect(cluster.getClusterControl()).andReturn(control);
+
+ // `SetGoalState NORMAL` should be called specifically on this method, not via ClusterControl.exec(..)
+ control.setGoalState(MasterGoalState.NORMAL.toString());
+ EasyMock.expectLastCall().once();
+
+ // Start the procs
+ for (ServerType type : StandaloneAccumuloCluster.ALL_SERVER_TYPES) {
+ control.startAllServers(type);
+ }
+
+ // Switch to replay
+ EasyMock.replay(cluster, control);
+
+ // Call start on the cluster
+ cluster.start();
+
+ // Verify the expectations
+ EasyMock.verify(cluster, control);
+ }
+
+}
[2/3] accumulo git commit: ACCUMULO-3823 Ensure SetGoalState is
invoked with server ACCUMULO_CONF_DIR
Posted by el...@apache.org.
ACCUMULO-3823 Ensure SetGoalState is invoked with server ACCUMULO_CONF_DIR
Make some special methods that the start/stop and SetGoalState
calls can use directly to avoid collisions with the methods
that should be using the client-facing ACCUMULO_CONF_DIR.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/965d4a8a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/965d4a8a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/965d4a8a
Branch: refs/heads/master
Commit: 965d4a8ae6744efcde3e826c209887d40fabf64d
Parents: 4eda9ec
Author: Josh Elser <el...@apache.org>
Authored: Mon May 18 14:23:29 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon May 18 14:47:40 2015 -0400
----------------------------------------------------------------------
.../standalone/StandaloneAccumuloCluster.java | 12 +++--
.../standalone/StandaloneClusterControl.java | 25 +++++++++
.../StandaloneAccumuloClusterTest.java | 53 ++++++++++++++++++++
3 files changed, 86 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
index 40fcfae..1baa3a1 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.accumulo.cluster.AccumuloCluster;
@@ -31,8 +32,8 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -47,6 +48,9 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(StandaloneAccumuloCluster.class);
+ static final List<ServerType> ALL_SERVER_TYPES = Collections.unmodifiableList(Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER,
+ ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR));
+
private Instance instance;
private ClientConfiguration clientConf;
private String accumuloHome, clientAccumuloConfDir, serverAccumuloConfDir, hadoopConfDir;
@@ -137,9 +141,9 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
// TODO We can check the hosts files, but that requires us to be on a host with the installation. Limitation at the moment.
- control.exec(SetGoalState.class, new String[] {"NORMAL"});
+ control.setGoalState(MasterGoalState.NORMAL.toString());
- for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER, ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+ for (ServerType type : ALL_SERVER_TYPES) {
control.startAllServers(type);
}
}
@@ -150,7 +154,7 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
// TODO We can check the hosts files, but that requires us to be on a host with the installation. Limitation at the moment.
- for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER, ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+ for (ServerType type : ALL_SERVER_TYPES) {
control.stopAllServers(type);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
index b3b1634..8f943e0 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java
@@ -16,6 +16,9 @@
*/
package org.apache.accumulo.cluster.standalone;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -30,6 +33,8 @@ import java.util.Map.Entry;
import org.apache.accumulo.cluster.ClusterControl;
import org.apache.accumulo.cluster.RemoteShell;
import org.apache.accumulo.cluster.RemoteShellOptions;
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
+import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.server.util.Admin;
import org.apache.commons.lang.StringUtils;
@@ -147,6 +152,26 @@ public class StandaloneClusterControl implements ClusterControl {
}
}
+ /**
+ * Wrapper around SetGoalState using the "server" <code>ACCUMULO_CONF_DIR</code>
+ *
+ * @param goalState
+ * The goal state to set
+ * @throws IOException
+ * If SetGoalState returns a non-zero result
+ */
+ public void setGoalState(String goalState) throws IOException {
+ checkNotNull(goalState, "Goal state must not be null");
+ checkArgument(MasterGoalState.valueOf(goalState) != null, "Unknown goal state: " + goalState);
+ File confDir = getConfDir();
+ String master = getHosts(new File(confDir, "masters")).get(0);
+ String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + serverAccumuloConfDir, accumuloPath, SetGoalState.class.getName(), goalState};
+ Entry<Integer,String> pair = exec(master, cmd);
+ if (0 != pair.getKey().intValue()) {
+ throw new IOException("SetGoalState did not finish successfully, retcode=" + pair.getKey() + ", stdout=" + pair.getValue());
+ }
+ }
+
@Override
public void startAllServers(ServerType server) throws IOException {
File confDir = getConfDir();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/965d4a8a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.java
new file mode 100644
index 0000000..1c946bb
--- /dev/null
+++ b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloClusterTest.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.accumulo.cluster.standalone;
+
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
+import org.apache.accumulo.minicluster.ServerType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class StandaloneAccumuloClusterTest {
+
+ @Test
+ public void test() throws Exception {
+ StandaloneAccumuloCluster cluster = EasyMock.createMockBuilder(StandaloneAccumuloCluster.class).addMockedMethod("getClusterControl").createMock();
+ StandaloneClusterControl control = EasyMock.createMock(StandaloneClusterControl.class);
+
+ // Return our mocked clustercontrol
+ EasyMock.expect(cluster.getClusterControl()).andReturn(control);
+
+ // `SetGoalState NORMAL` should be called specifically on this method, not via ClusterControl.exec(..)
+ control.setGoalState(MasterGoalState.NORMAL.toString());
+ EasyMock.expectLastCall().once();
+
+ // Start the procs
+ for (ServerType type : StandaloneAccumuloCluster.ALL_SERVER_TYPES) {
+ control.startAllServers(type);
+ }
+
+ // Switch to replay
+ EasyMock.replay(cluster, control);
+
+ // Call start on the cluster
+ cluster.start();
+
+ // Verify the expectations
+ EasyMock.verify(cluster, control);
+ }
+
+}
[3/3] 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/e163c34b
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e163c34b
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e163c34b
Branch: refs/heads/master
Commit: e163c34b7794da649dc6056b89d5a4b1f8d910ac
Parents: 61f9279 965d4a8
Author: Josh Elser <el...@apache.org>
Authored: Mon May 18 15:11:26 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon May 18 15:11:26 2015 -0400
----------------------------------------------------------------------
.../standalone/StandaloneAccumuloCluster.java | 12 +++--
.../standalone/StandaloneClusterControl.java | 25 +++++++++
.../StandaloneAccumuloClusterTest.java | 53 ++++++++++++++++++++
3 files changed, 86 insertions(+), 4 deletions(-)
----------------------------------------------------------------------