예제 #1
0
  public void testRejoinPropogateAdminMode() throws Exception {
    // Reset the VoltFile prefix that may have been set by previous tests in this suite
    org.voltdb.utils.VoltFile.resetSubrootForThisProcess();
    VoltProjectBuilder builder = getBuilderForTest();
    builder.setSecurityEnabled(true);

    LocalCluster cluster =
        new LocalCluster("rejoin.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI, true);
    boolean success = cluster.compileWithAdminMode(builder, 9998, false);
    assertTrue(success);
    MiscUtils.copyFile(
        builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("rejoin.xml"));
    cluster.setHasLocalServer(false);

    cluster.startUp();

    ClientResponse response;
    Client client;

    client = ClientFactory.createClient(m_cconfig);
    client.createConnection("localhost", 9997);

    response = client.callProcedure("@Pause");
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    client.close();

    cluster.shutDownSingleHost(0);
    Thread.sleep(100);

    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = Configuration.getPathToCatalogForTest("rejoin.jar");
    config.m_pathToDeployment = Configuration.getPathToCatalogForTest("rejoin.xml");
    config.m_rejoinToHostAndPort = m_username + ":" + m_password + "@localhost:9996";
    config.m_isRejoinTest = true;
    ServerThread localServer = new ServerThread(config);

    localServer.start();
    localServer.waitForInitialization();

    Thread.sleep(1000);

    assertTrue(VoltDB.instance().getMode() == OperationMode.PAUSED);

    localServer.shutdown();
    cluster.shutDown();
  }
예제 #2
0
  public void testRestoreThenRejoinPropagatesRestore() throws Exception {
    System.out.println("testRestoreThenRejoinThenRestore");
    VoltProjectBuilder builder = getBuilderForTest();
    builder.setSecurityEnabled(true);

    LocalCluster cluster =
        new LocalCluster("rejoin.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI, true);
    ServerThread localServer = null;
    try {
      boolean success = cluster.compileWithAdminMode(builder, 9998, false);
      assertTrue(success);
      MiscUtils.copyFile(
          builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("rejoin.xml"));
      cluster.setHasLocalServer(false);

      cluster.startUp();

      Client client;

      client = ClientFactory.createClient(m_cconfig);
      client.createConnection("localhost");

      deleteTestFiles();

      client.callProcedure("@SnapshotSave", TMPDIR, TESTNONCE, (byte) 1).getResults();

      client.callProcedure("@SnapshotRestore", TMPDIR, TESTNONCE);

      cluster.shutDownSingleHost(0);
      Thread.sleep(1000);

      VoltDB.Configuration config = new VoltDB.Configuration();
      config.m_pathToCatalog = Configuration.getPathToCatalogForTest("rejoin.jar");
      config.m_pathToDeployment = Configuration.getPathToCatalogForTest("rejoin.xml");
      config.m_rejoinToHostAndPort = m_username + ":" + m_password + "@localhost:21213";
      config.m_isRejoinTest = true;
      localServer = new ServerThread(config);

      localServer.start();
      localServer.waitForInitialization();

      Thread.sleep(2000);

      client.close();

      assertTrue(org.voltdb.sysprocs.SnapshotRestore.m_haveDoneRestore);

      client = ClientFactory.createClient(m_cconfig);
      client.createConnection("localhost");

      // Also make sure a catalog update doesn't reset m_haveDoneRestore
      File newCatalog = new File(Configuration.getPathToCatalogForTest("rejoin.jar"));
      File deployment = new File(Configuration.getPathToCatalogForTest("rejoin.xml"));

      VoltTable[] results = client.updateApplicationCatalog(newCatalog, deployment).getResults();
      assertTrue(results.length == 1);

      client.close();

      assertTrue(org.voltdb.sysprocs.SnapshotRestore.m_haveDoneRestore);
    } finally {
      cluster.shutDown();
      if (localServer != null) {
        localServer.shutdown();
      }
    }
  }