Ejemplo n.º 1
0
 public CCMBridge build() {
   CCMBridge ccm = new CCMBridge();
   ccm.execute(buildCreateCommand());
   ccm.updateConfig(cassandraConfiguration);
   if (start) ccm.start();
   return ccm;
 }
Ejemplo n.º 2
0
    public void discard() {
      if (cluster != null) cluster.close();

      if (cassandraCluster == null) {
        logger.error("No cluster to discard");
      } else if (erroredOut) {
        cassandraCluster.stop();
        logger.info("Error during tests, kept C* logs in " + cassandraCluster.ccmDir);
      } else {
        cassandraCluster.remove();
        cassandraCluster.ccmDir.delete();
      }
    }
Ejemplo n.º 3
0
 /**
  * Waits for a host to be down by pinging the TCP socket directly, without using the Java driver's
  * API.
  */
 public void waitForDown(int node) {
   try {
     InetAddress address = InetAddress.getByName(ipOfNode(node));
     CCMBridge.busyWaitForPort(address, 9042, false);
   } catch (UnknownHostException e) {
     Assert.fail("Unknown host " + ipOfNode(node) + "( node " + node + " of CCMBridge)");
   }
 }
Ejemplo n.º 4
0
  private static void busyWaitForPort(
      InetAddress address, int port, boolean expectedConnectionState) {
    long maxAcceptableWaitTime = TimeUnit.SECONDS.toMillis(10);
    long waitQuantum = TimeUnit.MILLISECONDS.toMillis(500);
    long waitTimeSoFar = 0;
    boolean connectionState = !expectedConnectionState;

    while (connectionState != expectedConnectionState && waitTimeSoFar < maxAcceptableWaitTime) {
      connectionState = CCMBridge.pingPort(address, port);
      try {
        Thread.sleep(waitQuantum);
        waitTimeSoFar += waitQuantum;
      } catch (InterruptedException e) {
        throw new RuntimeException("Interrupted while pinging " + address + ":" + port, e);
      }
    }
  }
Ejemplo n.º 5
0
    public static CCMCluster create(int nbNodesDC1, int nbNodesDC2, Cluster.Builder builder) {
      if (nbNodesDC1 == 0) throw new IllegalArgumentException();

      CCMBridge ccm = CCMBridge.builder("test").withNodes(nbNodesDC1, nbNodesDC2).build();
      return new CCMCluster(ccm, builder, nbNodesDC1 + nbNodesDC2);
    }