java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
private void start() throws IOException {
    Preconditions.checkArgument(numMasters > 0, "Need at least one master");

    // Start the control shell and the communication channel to it.
    List<String> commandLine = Lists.newArrayList(
        TestUtils.findBinary("kudu"),
        "test",
        "mini_cluster",
        "--serialization=pb");
    LOG.info("Starting process: {}", commandLine);
    ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
    miniCluster = processBuilder.start();
    miniClusterStdin = new DataOutputStream(miniCluster.getOutputStream());
    miniClusterStdout = new DataInputStream(miniCluster.getInputStream());

    // Set up a thread that logs stderr from the control shell; this will
    // include all cluster logging.
    ProcessInputStreamLogPrinterRunnable printer =
        new ProcessInputStreamLogPrinterRunnable(miniCluster.getErrorStream());
    miniClusterErrorPrinter = new Thread(printer);
    miniClusterErrorPrinter.setDaemon(true);
    miniClusterErrorPrinter.setName("cluster stderr printer");
    miniClusterErrorPrinter.start();

    // Create and start the cluster.
    sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setCreateCluster(CreateClusterRequestPB.newBuilder()
            .setNumMasters(numMasters)
            .setNumTservers(numTservers)
            .setEnableKerberos(enableKerberos)
            .addAllExtraMasterFlags(extraMasterFlags)
            .addAllExtraTserverFlags(extraTserverFlags)
            .setMiniKdcOptions(kdcOptionsPb)
            .setClusterRoot(clusterRoot)
            .build())
        .build());
    sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setStartCluster(StartClusterRequestPB.newBuilder().build())
        .build());

    // If the cluster is Kerberized, retrieve the KDC's environment variables
    // and adapt them into certain security-related system properties.
    if (enableKerberos) {
      ControlShellResponsePB resp = sendRequestToCluster(
          ControlShellRequestPB.newBuilder()
          .setGetKdcEnvVars(GetKDCEnvVarsRequestPB.newBuilder().build())
          .build());
      for (Map.Entry<String, String> e : resp.getGetKdcEnvVars().getEnvVarsMap().entrySet()) {
        if (e.getKey().equals("KRB5_CONFIG")) {
          System.setProperty("java.security.krb5.conf", e.getValue());
        } else if (e.getKey().equals("KRB5CCNAME")) {
          System.setProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY, e.getValue());
        }
      }
    }

    // Initialize the maps of masters and tservers.
    ControlShellResponsePB resp = sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setGetMasters(GetMastersRequestPB.newBuilder().build())
        .build());
    for (DaemonInfoPB info : resp.getGetMasters().getMastersList()) {
      DaemonInfo d = new DaemonInfo();
      d.id = info.getId();
      d.isRunning = true;
      masters.put(hostAndPortFromPB(info.getBoundRpcAddress()), d);
    }
    resp = sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setGetTservers(GetTServersRequestPB.newBuilder().build())
        .build());
    for (DaemonInfoPB info : resp.getGetTservers().getTserversList()) {
      DaemonInfo d = new DaemonInfo();
      d.id = info.getId();
      d.isRunning = true;
      tservers.put(hostAndPortFromPB(info.getBoundRpcAddress()), d);
    }
  }
/**
   * Starts this Kudu cluster.
   * @throws IOException if something went wrong in transit
   */
Starts this Kudu cluster.
@throws IOException if something went wrong in transit
Starts this Kudu cluster . @throws IOException if something went wrong in transit
private void start() throws IOException {
    Preconditions.checkArgument(numMasters > 0, "Need at least one master");
    List<String> commandLine = Lists.newArrayList(
        TestUtils.findBinary("kudu"),
        "test",
        "mini_cluster",
        "--serialization=pb");
    LOG.info("Starting process: {}", commandLine);
    ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
    miniCluster = processBuilder.start();
    miniClusterStdin = new DataOutputStream(miniCluster.getOutputStream());
    miniClusterStdout = new DataInputStream(miniCluster.getInputStream());
    ProcessInputStreamLogPrinterRunnable printer =
        new ProcessInputStreamLogPrinterRunnable(miniCluster.getErrorStream());
    miniClusterErrorPrinter = new Thread(printer);
    miniClusterErrorPrinter.setDaemon(true);
    miniClusterErrorPrinter.setName("cluster stderr printer");
    miniClusterErrorPrinter.start();
    sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setCreateCluster(CreateClusterRequestPB.newBuilder()
            .setNumMasters(numMasters)
            .setNumTservers(numTservers)
            .setEnableKerberos(enableKerberos)
            .addAllExtraMasterFlags(extraMasterFlags)
            .addAllExtraTserverFlags(extraTserverFlags)
            .setMiniKdcOptions(kdcOptionsPb)
            .setClusterRoot(clusterRoot)
            .build())
        .build());
    sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setStartCluster(StartClusterRequestPB.newBuilder().build())
        .build());
    if (enableKerberos) {
      ControlShellResponsePB resp = sendRequestToCluster(
          ControlShellRequestPB.newBuilder()
          .setGetKdcEnvVars(GetKDCEnvVarsRequestPB.newBuilder().build())
          .build());
      for (Map.Entry<String, String> e : resp.getGetKdcEnvVars().getEnvVarsMap().entrySet()) {
        if (e.getKey().equals("KRB5_CONFIG")) {
          System.setProperty("java.security.krb5.conf", e.getValue());
        } else if (e.getKey().equals("KRB5CCNAME")) {
          System.setProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY, e.getValue());
        }
      }
    }
    ControlShellResponsePB resp = sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setGetMasters(GetMastersRequestPB.newBuilder().build())
        .build());
    for (DaemonInfoPB info : resp.getGetMasters().getMastersList()) {
      DaemonInfo d = new DaemonInfo();
      d.id = info.getId();
      d.isRunning = true;
      masters.put(hostAndPortFromPB(info.getBoundRpcAddress()), d);
    }
    resp = sendRequestToCluster(
        ControlShellRequestPB.newBuilder()
        .setGetTservers(GetTServersRequestPB.newBuilder().build())
        .build());
    for (DaemonInfoPB info : resp.getGetTservers().getTserversList()) {
      DaemonInfo d = new DaemonInfo();
      d.id = info.getId();
      d.isRunning = true;
      tservers.put(hostAndPortFromPB(info.getBoundRpcAddress()), d);
    }
  }
private void start ( ) throws IOException { Preconditions . checkArgument ( numMasters > 0 , "Need at least one master" ) ; List < String > commandLine = Lists . newArrayList ( TestUtils . findBinary ( "kudu" ) , "test" , "mini_cluster" , "--serialization=pb" ) ; LOG . info ( "Starting process: {}" , commandLine ) ; ProcessBuilder processBuilder = new ProcessBuilder ( commandLine ) ; miniCluster = processBuilder . start ( ) ; miniClusterStdin = new DataOutputStream ( miniCluster . getOutputStream ( ) ) ; miniClusterStdout = new DataInputStream ( miniCluster . getInputStream ( ) ) ; ProcessInputStreamLogPrinterRunnable printer = new ProcessInputStreamLogPrinterRunnable ( miniCluster . getErrorStream ( ) ) ; miniClusterErrorPrinter = new Thread ( printer ) ; miniClusterErrorPrinter . setDaemon ( true ) ; miniClusterErrorPrinter . setName ( "cluster stderr printer" ) ; miniClusterErrorPrinter . start ( ) ; sendRequestToCluster ( ControlShellRequestPB . newBuilder ( ) . setCreateCluster ( CreateClusterRequestPB . newBuilder ( ) . setNumMasters ( numMasters ) . setNumTservers ( numTservers ) . setEnableKerberos ( enableKerberos ) . addAllExtraMasterFlags ( extraMasterFlags ) . addAllExtraTserverFlags ( extraTserverFlags ) . setMiniKdcOptions ( kdcOptionsPb ) . setClusterRoot ( clusterRoot ) . build ( ) ) . build ( ) ) ; sendRequestToCluster ( ControlShellRequestPB . newBuilder ( ) . setStartCluster ( StartClusterRequestPB . newBuilder ( ) . build ( ) ) . build ( ) ) ; if ( enableKerberos ) { ControlShellResponsePB resp = sendRequestToCluster ( ControlShellRequestPB . newBuilder ( ) . setGetKdcEnvVars ( GetKDCEnvVarsRequestPB . newBuilder ( ) . build ( ) ) . build ( ) ) ; for ( Map . Entry < String , String > e : resp . getGetKdcEnvVars ( ) . getEnvVarsMap ( ) . entrySet ( ) ) { if ( e . getKey ( ) . equals ( "KRB5_CONFIG" ) ) { System . setProperty ( "java.security.krb5.conf" , e . getValue ( ) ) ; } else if ( e . getKey ( ) . equals ( "KRB5CCNAME" ) ) { System . setProperty ( SecurityUtil . KUDU_TICKETCACHE_PROPERTY , e . getValue ( ) ) ; } } } ControlShellResponsePB resp = sendRequestToCluster ( ControlShellRequestPB . newBuilder ( ) . setGetMasters ( GetMastersRequestPB . newBuilder ( ) . build ( ) ) . build ( ) ) ; for ( DaemonInfoPB info : resp . getGetMasters ( ) . getMastersList ( ) ) { DaemonInfo d = new DaemonInfo ( ) ; d . id = info . getId ( ) ; d . isRunning = true ; masters . put ( hostAndPortFromPB ( info . getBoundRpcAddress ( ) ) , d ) ; } resp = sendRequestToCluster ( ControlShellRequestPB . newBuilder ( ) . setGetTservers ( GetTServersRequestPB . newBuilder ( ) . build ( ) ) . build ( ) ) ; for ( DaemonInfoPB info : resp . getGetTservers ( ) . getTserversList ( ) ) { DaemonInfo d = new DaemonInfo ( ) ; d . id = info . getId ( ) ; d . isRunning = true ; tservers . put ( hostAndPortFromPB ( info . getBoundRpcAddress ( ) ) , d ) ; } }
Starts this Kudu cluster.
Starts this Kudu cluster .
// Start the control shell and the communication channel to it. // Set up a thread that logs stderr from the control shell; this will // include all cluster logging. // Create and start the cluster. // If the cluster is Kerberized, retrieve the KDC's environment variables // and adapt them into certain security-related system properties. // Initialize the maps of masters and tservers.