コード例 #1
0
  public void testJDBCConnectionWithNoServersUp() throws Exception {
    // Need to build the URL before killing the cluster or we don't
    // add it to the URL list.
    StringBuilder sb = new StringBuilder();
    sb.append("jdbc:voltdb://");
    final List<String> listeners = m_config.getListenerAddresses();
    for (String listener : listeners) {
      sb.append(listener).append(",");
    }
    String JDBCURL = sb.toString();
    System.out.println("Connecting to JDBC URL: " + JDBCURL);

    // Shutdown the cluster.  Need to do this before connection so that we
    // don't have stale connections in the connection pool
    m_config.shutDown();

    boolean threw = false;
    try {
      connectClients(JDBCURL);
    } catch (Exception e) {
      assertTrue(e.getMessage().contains("Unable to establish"));
      threw = true;
    }
    assertTrue("Connection which should have failed did not.", threw);
  }
コード例 #2
0
ファイル: TestAdHocQueries.java プロジェクト: Sciumo/voltdb
    TestEnv(
        String pathToCatalog,
        String pathToDeployment,
        int siteCount,
        int hostCount,
        int kFactor,
        boolean enableIv2) {
      m_builder = new VoltProjectBuilder();
      try {
        m_builder.addLiteralSchema(
            "create table BLAH ("
                + "IVAL bigint default 0 not null, "
                + "TVAL timestamp default null,"
                + "DVAL decimal default null,"
                + "PRIMARY KEY(IVAL));");
        m_builder.addPartitionInfo("BLAH", "IVAL");
        m_builder.addStmtProcedure("Insert", "INSERT into BLAH values (?, ?, ?);", null);
        m_builder.addStmtProcedure(
            "InsertWithDate",
            "INSERT INTO BLAH VALUES (974599638818488300, '2011-06-24 10:30:26.002', 5);");

        // add more partitioned and replicated tables, PARTED[1-3] and REPED[1-2]
        AdHocQueryTester.setUpSchema(m_builder, pathToCatalog, pathToDeployment);
      } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to set up schema");
      }

      m_cluster =
          new LocalCluster(
              pathToCatalog,
              siteCount,
              hostCount,
              kFactor,
              BackendTarget.NATIVE_EE_JNI,
              LocalCluster.FailureState.ALL_RUNNING,
              m_debug,
              false,
              enableIv2);
      boolean success = m_cluster.compile(m_builder);
      assert (success);

      try {
        MiscUtils.copyFile(m_builder.getPathToDeployment(), pathToDeployment);
      } catch (Exception e) {
        fail(
            String.format(
                "Failed to copy \"%s\" to \"%s\"",
                m_builder.getPathToDeployment(), pathToDeployment));
      }

      m_cluster.setHasLocalServer(true);
    }
コード例 #3
0
ファイル: TestAdHocQueries.java プロジェクト: Sciumo/voltdb
    void setUp() {
      m_cluster.startUp();

      try {
        // do the test
        m_client = ClientFactory.createClient();
        m_client.createConnection("localhost", m_cluster.port(0));
      } catch (UnknownHostException e) {
        e.printStackTrace();
        fail(String.format("Failed to connect to localhost:%d", m_cluster.port(0)));
      } catch (IOException e) {
        e.printStackTrace();
        fail(String.format("Failed to connect to localhost:%d", m_cluster.port(0)));
      }
    }
コード例 #4
0
  public static Test suite() throws IOException {
    // the suite made here will all be using the tests from this class
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestJDBCConnectionFail.class);

    // build up a project builder for the workload
    VoltProjectBuilder project = getBuilderForTest();
    boolean success;
    m_config = new LocalCluster("decimal-default.jar", 4, 5, kfactor, BackendTarget.NATIVE_EE_JNI);
    m_config.setHasLocalServer(true);
    success = m_config.compile(project);
    assertTrue(success);

    // add this config to the set of tests to run
    builder.addServerConfig(m_config);
    return builder;
  }
コード例 #5
0
  public void testRejoinInlineStringBug() throws Exception {
    VoltProjectBuilder builder = getBuilderForTest();

    LocalCluster cluster =
        new LocalCluster("rejoin.jar", 1, 2, 1, BackendTarget.NATIVE_EE_JNI, true);
    boolean success = cluster.compile(builder);
    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");

    ProcedureCallback callback =
        new ProcedureCallback() {

          @Override
          public void clientCallback(ClientResponse clientResponse) throws Exception {
            if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
              System.out.println(clientResponse.getStatusString());
            }
          }
        };

    StringBuffer shortBuffer = new StringBuffer();
    for (int ii = 0; ii < 33; ii++) {
      shortBuffer.append('a');
    }
    String shortString = shortBuffer.toString();

    StringBuffer longBuffer = new StringBuffer();
    for (int ii = 0; ii < 17700; ii++) {
      longBuffer.append('a');
    }
    String longString = longBuffer.toString();

    for (int ii = 0; ii < 119; ii++) {
      client.callProcedure(callback, "InsertInlinedString", ii, shortString, longString);
    }

    shortBuffer.append("aaa");
    client.callProcedure(callback, "InsertInlinedString", 120, shortBuffer.toString(), longString);

    client.drain();
    client.close();

    cluster.shutDownSingleHost(0);
    cluster.recoverOne(0, 1, "localhost");

    cluster.shutDown();
  }
コード例 #6
0
  public void testLocalClusterRecoveringMode() throws Exception {
    VoltProjectBuilder builder = getBuilderForTest();

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

    cluster.startUp();
    Thread.sleep(100);

    cluster.shutDown();

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

    cluster.startUp();
    Thread.sleep(100);

    cluster.shutDown();
  }
コード例 #7
0
  public void testCatalogUpdateAfterRejoin() throws Exception {
    System.out.println("testCatalogUpdateAfterRejoin");
    VoltProjectBuilder builder = getBuilderForTest();

    LocalCluster cluster = new LocalCluster("rejoin.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
    boolean success = cluster.compile(builder);
    assertTrue(success);
    MiscUtils.copyFile(
        builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("rejoin.xml"));

    try {
      cluster.startUp();

      for (int ii = 0; ii < 3; ii++) {
        cluster.shutDownSingleHost(1);
        Thread.sleep(1000);
        cluster.recoverOne(1, 0, "localhost");

        File newCatalog = new File(Configuration.getPathToCatalogForTest("rejoin.jar"));
        File deployment = new File(Configuration.getPathToCatalogForTest("rejoin.xml"));

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

        VoltTable[] results = client.updateApplicationCatalog(newCatalog, deployment).getResults();
        assertTrue(results.length == 1);
        client.close();
      }
    } finally {
      cluster.shutDown();
    }
  }
コード例 #8
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();
  }
コード例 #9
0
ファイル: TestAdHocQueries.java プロジェクト: Sciumo/voltdb
    void tearDown() {
      if (m_client != null) {
        try {
          m_client.close();
        } catch (InterruptedException e) {
          e.printStackTrace();
          fail("Failed to close client");
        }
      }
      m_client = null;

      if (m_cluster != null) {
        try {
          m_cluster.shutDown();
        } catch (InterruptedException e) {
          e.printStackTrace();
          fail("Failed to shut down cluster");
        }
      }
      m_cluster = null;

      // no clue how helpful this is
      System.gc();
    }
コード例 #10
0
  /**
   * Add a sever configuration to the set of configurations we want these tests to run on.
   *
   * @param config A Server Configuration to run this set of tests on.
   */
  public boolean addServerConfig(VoltServerConfig config) {

    final String enabled_configs = System.getenv().get("VOLT_REGRESSIONS");
    System.out.println("VOLT REGRESSIONS ENABLED: " + enabled_configs);

    if (!(enabled_configs == null || enabled_configs.contentEquals("all"))) {
      if (config instanceof LocalCluster) {
        if (config.isHSQL() && !enabled_configs.contains("hsql")) {
          return true;
        }
        if ((config.getNodeCount() == 1) && !enabled_configs.contains("local")) {
          return true;
        }
        if ((config.getNodeCount() > 1) && !enabled_configs.contains("cluster")) {
          return true;
        }
      }
    }

    final String buildType = System.getenv().get("BUILD");
    if (buildType != null) {
      if (buildType.startsWith("memcheck")) {
        if (config instanceof LocalCluster) {
          LocalCluster lc = (LocalCluster) config;
          // don't run valgrind on multi-node clusters without embedded processes
          if ((lc.getNodeCount() > 1) || (lc.m_hasLocalServer == false)) {
            return true;
          }
        }
        if (config.isHSQL()) {
          return true;
        }
      }
    }

    // get the constructor of the test class
    Constructor<?> cons = null;
    try {
      cons = m_testClass.getConstructor(String.class);
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }

    // get the set of test methods
    List<String> methods = getTestMethodNames(m_testClass);

    // add a test case instance for each method for the specified
    // server config
    for (String mname : methods) {
      RegressionSuite rs = null;
      try {
        rs = (RegressionSuite) cons.newInstance(mname);
      } catch (Exception e) {
        e.printStackTrace();
        return false;
      }
      rs.setConfig(config);
      super.addTest(rs);
    }

    return true;
  }
コード例 #11
0
  //
  // Build a list of the tests to be run. Use the regression suite
  // helpers to allow multiple backends.
  // JUnit magic that uses the regression suite helper classes.
  //
  public static Test suite(Class classzz, boolean isCommandLogTest) throws IOException {
    VoltServerConfig config = null;

    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(classzz);

    // Not really using TPCC functionality but need a database.
    // The testLoadMultipartitionTable procedure assumes partitioning
    // on warehouse id.
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addLiteralSchema(
        "CREATE TABLE WAREHOUSE (\n"
            + "  W_ID SMALLINT DEFAULT '0' NOT NULL,\n"
            + "  W_NAME VARCHAR(16) DEFAULT NULL,\n"
            + "  W_STREET_1 VARCHAR(32) DEFAULT NULL,\n"
            + "  W_STREET_2 VARCHAR(32) DEFAULT NULL,\n"
            + "  W_CITY VARCHAR(32) DEFAULT NULL,\n"
            + "  W_STATE VARCHAR(2) DEFAULT NULL,\n"
            + "  W_ZIP VARCHAR(9) DEFAULT NULL,\n"
            + "  W_TAX FLOAT DEFAULT NULL,\n"
            + "  W_YTD FLOAT DEFAULT NULL,\n"
            + "  CONSTRAINT W_PK_TREE PRIMARY KEY (W_ID)\n"
            + ");\n"
            + "CREATE TABLE ITEM (\n"
            + "  I_ID INTEGER DEFAULT '0' NOT NULL,\n"
            + "  I_IM_ID INTEGER DEFAULT NULL,\n"
            + "  I_NAME VARCHAR(32) DEFAULT NULL,\n"
            + "  I_PRICE FLOAT DEFAULT NULL,\n"
            + "  I_DATA VARCHAR(64) DEFAULT NULL,\n"
            + "  CONSTRAINT I_PK_TREE PRIMARY KEY (I_ID)\n"
            + ");\n"
            + "CREATE TABLE NEW_ORDER (\n"
            + "  NO_W_ID SMALLINT DEFAULT '0' NOT NULL\n"
            + ");\n");

    project.addPartitionInfo("WAREHOUSE", "W_ID");
    project.addPartitionInfo("NEW_ORDER", "NO_W_ID");
    project.addProcedures(PROCEDURES);

    // Enable asynchronous logging for test of commandlog test
    if (MiscUtils.isPro() && isCommandLogTest) {
      project.configureLogging(null, null, false, true, FSYNC_INTERVAL_GOLD, null, null);
    }

    /*
     * Create a cluster configuration.
     * Some of the sysproc results come back a little strange when applied to a cluster that is being
     * simulated through LocalCluster -- all the hosts have the same HOSTNAME, just different host ids.
     * So, these tests shouldn't rely on the usual uniqueness of host names in a cluster.
     */
    config =
        new LocalCluster(
            "statistics-cluster.jar",
            StatisticsTestSuiteBase.SITES,
            StatisticsTestSuiteBase.HOSTS,
            StatisticsTestSuiteBase.KFACTOR,
            BackendTarget.NATIVE_EE_JNI);
    ((LocalCluster) config).setHasLocalServer(hasLocalServer);

    if (MiscUtils.isPro() && isCommandLogTest) {
      ((LocalCluster) config).setJavaProperty("LOG_SEGMENT_SIZE", "1");
      ((LocalCluster) config).setJavaProperty("LOG_SEGMENTS", "1");
    }

    boolean success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);

    return builder;
  }
コード例 #12
0
  public void testRejoinDataTransfer() throws Exception {
    System.out.println("testRejoinDataTransfer");
    VoltProjectBuilder builder = getBuilderForTest();
    builder.setSecurityEnabled(true);

    LocalCluster cluster =
        new LocalCluster("rejoin.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI, true);
    boolean success = cluster.compile(builder);
    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");

    response = client.callProcedure("InsertSinglePartition", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("InsertReplicated", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());

    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;
    ServerThread localServer = new ServerThread(config);

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

    Thread.sleep(2000);

    client.close();

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

    //
    // Check that the recovery data transferred
    //
    response = client.callProcedure("SelectBlahSinglePartition", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 0);

    response = client.callProcedure("SelectBlah", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

    response = client.callProcedure("SelectBlahReplicated", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 0);

    //
    //  Try to insert new data
    //
    response = client.callProcedure("InsertSinglePartition", 2);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 3);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("InsertReplicated", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());

    //
    // See that it was inserted
    //
    response = client.callProcedure("SelectBlahSinglePartition", 2);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 2);
    response = client.callProcedure("SelectBlah", 3);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 3);

    response = client.callProcedure("SelectBlahReplicated", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

    //
    // Kill one of the old ones (not the recovered partition)
    //
    cluster.shutDownSingleHost(1);
    Thread.sleep(1000);

    client.close();

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

    //
    // See that the cluster is available and the data is still there.
    //
    response = client.callProcedure("SelectBlahSinglePartition", 2);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 2);

    response = client.callProcedure("SelectBlah", 3);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 3);

    response = client.callProcedure("SelectBlahReplicated", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

    client.close();

    localServer.shutdown();
    cluster.shutDown();
  }
コード例 #13
0
  public void testRejoinWithExport() throws Exception {
    VoltProjectBuilder builder = getBuilderForTest();
    // builder.setTableAsExportOnly("blah", false);
    // builder.setTableAsExportOnly("blah_replicated", false);
    // builder.setTableAsExportOnly("PARTITIONED", false);
    // builder.setTableAsExportOnly("PARTITIONED_LARGE", false);
    builder.addExport(
        "org.voltdb.export.processors.RawProcessor",
        true, // enabled
        null); // authGroups (off)

    LocalCluster cluster =
        new LocalCluster("rejoin.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI, true);
    boolean success = cluster.compile(builder);
    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");

    response = client.callProcedure("InsertSinglePartition", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 1);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("InsertReplicated", 0);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    client.close();

    client = ClientFactory.createClient(m_cconfig);
    client.createConnection("localhost", 21213);
    response = client.callProcedure("InsertSinglePartition", 2);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 3);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    client.close();

    TrivialExportClient exportClient = new TrivialExportClient();
    exportClient.work();
    exportClient.work();

    Thread.sleep(4000);

    exportClient.work();

    Thread.sleep(4000);

    exportClient.work();

    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:21213";
    config.m_isRejoinTest = true;
    ServerThread localServer = new ServerThread(config);

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

    Thread.sleep(1000);
    while (VoltDB.instance().recovering()) {
      Thread.sleep(100);
    }

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

    response = client.callProcedure("InsertSinglePartition", 5);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 6);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("InsertReplicated", 7);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    client.close();

    client = ClientFactory.createClient(m_cconfig);
    client.createConnection("localhost", 21213);
    response = client.callProcedure("InsertSinglePartition", 8);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    response = client.callProcedure("Insert", 9);
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    client.close();

    exportClient = new TrivialExportClient();
    exportClient.work();

    Thread.sleep(4000);

    exportClient.work();

    Thread.sleep(4000);

    exportClient.work();

    localServer.shutdown();
    cluster.shutDown();
  }
コード例 #14
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();
      }
    }
  }
コード例 #15
0
  public void testRejoinWithMultipartLoad() throws Exception {
    ExecutionSite.m_recoveryPermit.drainPermits();
    ExecutionSite.m_recoveryPermit.release();
    try {
      System.out.println("testRejoinWithMultipartLoad");
      VoltProjectBuilder builder = getBuilderForTest();
      builder.setSecurityEnabled(true);

      LocalCluster cluster =
          new LocalCluster(
              "rejoin.jar",
              2,
              2,
              1,
              BackendTarget.NATIVE_EE_JNI,
              LocalCluster.FailureState.ALL_RUNNING,
              true,
              true);
      boolean success = cluster.compile(builder);
      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", 21213);

      response = client.callProcedure("InsertSinglePartition", 33);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      response = client.callProcedure("Insert", 1);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      response = client.callProcedure("InsertReplicated", 34);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());

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

      final Client clientForLoadThread = client;
      final java.util.concurrent.atomic.AtomicBoolean shouldContinue =
          new java.util.concurrent.atomic.AtomicBoolean(true);
      Thread loadThread =
          new Thread("Load Thread") {
            @Override
            public void run() {
              try {
                final long startTime = System.currentTimeMillis();
                while (shouldContinue.get()) {
                  try {
                    clientForLoadThread.callProcedure(
                        new org.voltdb.client.ProcedureCallback() {

                          @Override
                          public void clientCallback(ClientResponse clientResponse)
                              throws Exception {
                            if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
                              //
                              // System.err.println(clientResponse.getStatusString());
                            }
                          }
                        },
                        "@Statistics",
                        "MANAGEMENT",
                        1);
                    // clientForLoadThread.callProcedure("@Statistics", );
                    Thread.sleep(1);
                    final long now = System.currentTimeMillis();
                    if (now - startTime > 1000 * 10) {
                      break;
                    }
                  } catch (Exception e) {
                    e.printStackTrace();
                    break;
                  }
                }
              } finally {
                try {
                  clientForLoadThread.close();
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          };
      loadThread.start();

      Thread.sleep(2000);

      ServerThread localServer = null;
      try {
        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 = ClientFactory.createClient(m_cconfig);
        client.createConnection("localhost", 21213);

        //
        // Check that the recovery data transferred
        //
        response = client.callProcedure("SelectBlahSinglePartition", 33);
        assertEquals(ClientResponse.SUCCESS, response.getStatus());
        assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 33);

      } finally {
        shouldContinue.set(false);
      }

      response = client.callProcedure("SelectBlah", 1);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

      response = client.callProcedure("SelectBlahReplicated", 34);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 34);

      //
      //  Try to insert new data
      //
      response = client.callProcedure("InsertSinglePartition", 2);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      response = client.callProcedure("Insert", 3);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      response = client.callProcedure("InsertReplicated", 1);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());

      //
      // See that it was inserted
      //
      response = client.callProcedure("SelectBlahSinglePartition", 2);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 2);
      response = client.callProcedure("SelectBlah", 3);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 3);

      response = client.callProcedure("SelectBlahReplicated", 1);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

      //
      // Kill one of the old ones (not the recovered partition)
      //
      cluster.shutDownSingleHost(1);
      Thread.sleep(1000);

      client.close();

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

      //
      // See that the cluster is available and the data is still there.
      //
      response = client.callProcedure("SelectBlahSinglePartition", 2);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 2);

      response = client.callProcedure("SelectBlah", 3);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 3);

      response = client.callProcedure("SelectBlahReplicated", 1);
      assertEquals(ClientResponse.SUCCESS, response.getStatus());
      assertEquals(response.getResults()[0].fetchRow(0).getLong(0), 1);

      client.close();

      localServer.shutdown();
      cluster.shutDown();
    } finally {
      ExecutionSite.m_recoveryPermit.drainPermits();
      ExecutionSite.m_recoveryPermit.release(Integer.MAX_VALUE);
    }
  }