accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/3] git commit: Merge branch '1.5.1-SNAPSHOT'
Date Tue, 24 Sep 2013 15:42:18 GMT
Merge branch '1.5.1-SNAPSHOT'

Conflicts:
	minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java


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

Branch: refs/heads/master
Commit: ed3c15737e4e0e5228ca2a26caf03b939db5e7db
Parents: 3de0c1e 915acf9
Author: Josh Elser <elserj@apache.org>
Authored: Tue Sep 24 11:39:04 2013 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Tue Sep 24 11:39:04 2013 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/minicluster/MiniAccumuloCluster.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ed3c1573/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
----------------------------------------------------------------------
diff --cc minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index e41818b,3b4d8a3..8805570
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@@ -319,130 -277,49 +319,130 @@@ public class MiniAccumuloCluster 
     * @throws IllegalStateException
     *           if already started
     */
 -  
    public void start() throws IOException, InterruptedException {
 -    if (zooKeeperProcess != null)
 -      throw new IllegalStateException("Already started");
 -    
 -    Runtime.getRuntime().addShutdownHook(new Thread() {
 -      @Override
 -      public void run() {
 -        try {
 -          MiniAccumuloCluster.this.stop();
 -        } catch (IOException e) {
 -          e.printStackTrace();
 -        } catch (InterruptedException e) {
 -          e.printStackTrace();
 +
 +    if (!initialized) {
 +
 +      Runtime.getRuntime().addShutdownHook(new Thread() {
 +        @Override
 +        public void run() {
 +          try {
 +            MiniAccumuloCluster.this.stop();
 +          } catch (IOException e) {
 +            e.printStackTrace();
 +          } catch (InterruptedException e) {
 +            e.printStackTrace();
 +          }
          }
 +      });
 +    }
 +
 +    if (zooKeeperProcess == null) {
 +      zooKeeperProcess = exec(Main.class, ServerType.ZOOKEEPER, ZooKeeperServerMain.class.getName(),
zooCfgFile.getAbsolutePath());
 +    }
 +
 +    if (!initialized) {
 +      // sleep a little bit to let zookeeper come up before calling init, seems to work
better
 +      UtilWaitThread.sleep(250);
 +      Process initProcess = exec(Initialize.class, "--instance-name", config.getInstanceName(),
"--password", config.getRootPassword());
 +      int ret = initProcess.waitFor();
 +      if (ret != 0) {
-         throw new RuntimeException("Initialize process returned " + ret);
++        throw new RuntimeException("Initialize process returned " + ret + ". Check the logs
in " + config.getLogDir() + " for errors.");
        }
 -    });
 -    
 -    zooKeeperProcess = exec(Main.class, ZooKeeperServerMain.class.getName(), zooCfgFile.getAbsolutePath());
 -    
 -    // sleep a little bit to let zookeeper come up before calling init, seems to work better
 -    UtilWaitThread.sleep(250);
 -    
 -    Process initProcess = exec(Initialize.class, "--instance-name", INSTANCE_NAME, "--password",
config.getRootPassword());
 -    int ret = initProcess.waitFor();
 +      initialized = true;
 +    }
 +
 +    for (int i = tabletServerProcesses.size(); i < config.getNumTservers(); i++) {
 +      tabletServerProcesses.add(exec(TabletServer.class, ServerType.TABLET_SERVER));
 +    }
 +    int ret = 0;
 +    for (int i = 0; i < 5; i++) {
 +      ret = exec(Main.class, SetGoalState.class.getName(), MasterGoalState.NORMAL.toString()).waitFor();
 +      if (ret == 0)
 +        break;
 +      UtilWaitThread.sleep(1000);
 +    }
      if (ret != 0) {
-       throw new RuntimeException("Could not set master goal state, process returned " +
ret);
 -      throw new RuntimeException("Initialize process returned " + ret + ". Check the logs
in " + logDir + " for errors.");
++      throw new RuntimeException("Could not set master goal state, process returned " +
ret + ". Check the logs in " + config.getLogDir() + " for errors.");
      }
 -    
 -    tabletServerProcesses = new Process[config.getNumTservers()];
 -    for (int i = 0; i < config.getNumTservers(); i++) {
 -      tabletServerProcesses[i] = exec(TabletServer.class);
 +    if (masterProcess == null) {
 +      masterProcess = exec(Master.class, ServerType.MASTER);
      }
 -    
 -    masterProcess = exec(Master.class);
 -    
      if (config.shouldRunGC()) {
 -      gcProcess = exec(SimpleGarbageCollector.class);
 +      gcProcess = exec(SimpleGarbageCollector.class, ServerType.GARBAGE_COLLECTOR);
      }
    }
 -  
 +
 +  private List<String> buildRemoteDebugParams(int port) {
 +    return Arrays.asList(new String[] {"-Xdebug", String.format("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=%d",
port)});
 +  }
 +
 +  /**
 +   * @return generated remote debug ports if in debug mode.
 +   * @since 1.6.0
 +   */
 +  public Set<Pair<ServerType,Integer>> getDebugPorts() {
 +    return debugPorts;
 +  }
 +
 +  List<ProcessReference> references(Process... procs) {
 +    List<ProcessReference> result = new ArrayList<ProcessReference>();
 +    for (Process proc : procs) {
 +      result.add(new ProcessReference(proc));
 +    }
 +    return result;
 +  }
 +
 +  public Map<ServerType,Collection<ProcessReference>> getProcesses() {
 +    Map<ServerType,Collection<ProcessReference>> result = new HashMap<ServerType,Collection<ProcessReference>>();
 +    result.put(ServerType.MASTER, references(masterProcess));
 +    result.put(ServerType.TABLET_SERVER, references(tabletServerProcesses.toArray(new Process[0])));
 +    result.put(ServerType.ZOOKEEPER, references(zooKeeperProcess));
 +    if (null != gcProcess) {
 +      result.put(ServerType.GARBAGE_COLLECTOR, references(gcProcess));
 +    }
 +    return result;
 +  }
 +
 +  public void killProcess(ServerType type, ProcessReference proc) throws ProcessNotFoundException,
InterruptedException {
 +    boolean found = false;
 +    switch (type) {
 +      case MASTER:
 +        if (proc.equals(masterProcess)) {
 +          masterProcess.destroy();
 +          masterProcess = null;
 +          found = true;
 +        }
 +        break;
 +      case TABLET_SERVER:
 +        for (Process tserver : tabletServerProcesses) {
 +          if (proc.equals(tserver)) {
 +            tabletServerProcesses.remove(tserver);
 +            tserver.destroy();
 +            found = true;
 +            break;
 +          }
 +        }
 +        break;
 +      case ZOOKEEPER:
 +        if (proc.equals(zooKeeperProcess)) {
 +          zooKeeperProcess.destroy();
 +          zooKeeperProcess = null;
 +          found = true;
 +        }
 +        break;
 +      case GARBAGE_COLLECTOR:
 +        if (proc.equals(gcProcess)) {
 +          gcProcess.destroy();
 +          gcProcess = null;
 +          found= true;
 +        }
 +        break;
 +    }
 +    if (!found)
 +      throw new ProcessNotFoundException();
 +  }
 +
    /**
     * @return Accumulo instance name
     */


Mime
View raw message