Esempio n. 1
0
  public void JSONBench(int clientCount, int iterations) throws Exception {
    ServerThread server = startup();
    Thread.sleep(1000);

    JSONClient[] clients = new JSONClient[clientCount];
    for (int i = 0; i < clientCount; i++) clients[i] = new JSONClient(i, iterations);

    long execTime = 0;

    long start = System.nanoTime();
    for (JSONClient client : clients) {
      client.start();
    }
    for (JSONClient client : clients) {
      client.join();
      execTime += client.totalExecTime;
    }

    long finish = System.nanoTime();

    double seconds = (finish - start) / (1000d * 1000d * 1000d);
    double rate = (iterations * clientCount) / seconds;
    double latency = execTime / (double) (iterations * clientCount);
    latency /= 1000d * 1000d;

    System.out.printf(
        "Simple bench did %.2f iterations / sec at %.2f ms latency per txn.\n", rate, latency);

    server.shutdown();
    server.join();
  }
Esempio n. 2
0
  @AfterClass
  public static void stopDatabase() throws InterruptedException {
    if (client != null) client.close();
    client = null;

    if (localServer != null) {
      localServer.shutdown();
      localServer.join();
    }
    localServer = null;
  }
Esempio n. 3
0
 private static void stopServer() throws SQLException {
   if (conn != null) {
     conn.close();
     conn = null;
   }
   if (server != null) {
     try {
       server.shutdown();
     } catch (InterruptedException e) {
       /*empty*/
     }
     server = null;
   }
 }
Esempio n. 4
0
  @Override
  public synchronized List<String> shutDown() throws InterruptedException {
    // there are couple of ways to shutdown. sysproc @kill could be
    // issued to listener. this would require that the test didn't
    // break the cluster somehow.  Or ... just old fashioned kill?

    try {
      if (m_localServer != null) m_localServer.shutdown();
    } finally {
      m_running = false;
    }
    shutDownExternal();

    return null;
  }
  /**
   * Assuming given tables have schema metadata, fill them with random data and compare a pure-java
   * schema migration with an EE schema migration.
   */
  void migrateSchema(VoltTable t1, VoltTable t2, boolean withData) throws Exception {
    ServerThread server = null;
    Client client = null;
    TableHelper helper = new TableHelper();

    try {
      if (withData) {
        helper.randomFill(t1, 1000, 1024);
      }

      String catPath1 = catalogPathForTable(t1, "t1.jar");
      String catPath2 = catalogPathForTable(t2, "t2.jar");
      byte[] catBytes2 = MiscUtils.fileToBytes(new File(catPath2));

      DeploymentBuilder depBuilder = new DeploymentBuilder(1, 1, 0);
      depBuilder.setVoltRoot("/tmp/foobar");
      // disable logging
      depBuilder.configureLogging("/tmp/foobar", "/tmp/foobar", false, false, 1, 1, 3);
      String deployment = depBuilder.getXML();
      File deploymentFile = VoltProjectBuilder.writeStringToTempFile(deployment);

      VoltDB.Configuration config = new VoltDB.Configuration();
      config.m_pathToDeployment = deploymentFile.getAbsolutePath();
      config.m_pathToCatalog = catPath1;
      config.m_ipcPort = 10000;
      // config.m_backend = BackendTarget.NATIVE_EE_IPC;
      server = new ServerThread(config);
      server.start();
      server.waitForInitialization();

      System.out.printf("PRE:  %s\n", TableHelper.ddlForTable(t1));
      System.out.printf("POST: %s\n", TableHelper.ddlForTable(t2));

      ClientConfig clientConfig = new ClientConfig();
      client = ClientFactory.createClient(clientConfig);
      client.createConnection("localhost");

      TableHelper.loadTable(client, t1);

      ClientResponseImpl response =
          (ClientResponseImpl) client.callProcedure("@UpdateApplicationCatalog", catBytes2, null);
      System.out.println(response.toJSONString());

      VoltTable t3 = client.callProcedure("@AdHoc", "select * from FOO").getResults()[0];
      t3 = TableHelper.sortTable(t3);

      // compute the migrated table entirely in Java for comparison purposes
      TableHelper.migrateTable(t1, t2);
      t2 = TableHelper.sortTable(t2);

      // compare the tables
      StringBuilder sb = new StringBuilder();
      if (!TableHelper.deepEqualsWithErrorMsg(t2, t3, sb)) {
        System.out.println("Table Mismatch");
        // System.out.printf("PRE:  %s\n", t2.toFormattedString());
        // System.out.printf("POST: %s\n", t3.toFormattedString());
        System.out.println(sb.toString());
        fail();
      }
    } finally {
      if (client != null) {
        client.close();
      }
      if (server != null) {
        server.shutdown();
      }
    }
  }