示例#1
0
 private ErdoTransactionTest(String[] args) throws IOException, InterruptedException {
   // Database setup
   FileUtil.deleteDirectory(DB_DIRECTORY);
   db = Database.createDatabase(DB_DIRECTORY, configuration());
   accounts = db.createMap(MAP_NAME, AccountId.class, Account.class);
   int a = 0;
   this.nAccounts = Integer.parseInt(args[a++]);
   this.threads = new ErdoTestThread[Integer.parseInt(args[a++])];
   this.transactionsPerThread = Integer.parseInt(args[a++]);
   LOG.log(Level.INFO, "accounts: {0}", nAccounts);
   LOG.log(Level.INFO, "threads: {0}", threads.length);
   LOG.log(Level.INFO, "transactions per thread: {0}", transactionsPerThread);
 }
示例#2
0
 private void verify() throws IOException, InterruptedException {
   long sum = 0;
   Cursor cursor = accounts.first();
   Account account;
   while ((account = (Account) cursor.next()) != null) {
     LOG.log(Level.INFO, "{0}", account);
     sum += account.balance();
   }
   db.commitTransaction();
   if (sum == 0) {
     LOG.log(Level.INFO, "OK!");
   } else {
     LOG.log(Level.WARNING, "Test failed, sum = {0}", sum);
   }
 }
示例#3
0
 private void shutdown() throws IOException, InterruptedException {
   LOG.log(Level.INFO, "Shutting down");
   db.close();
 }
示例#4
0
 private void waitForCompletion() throws InterruptedException {
   for (ErdoTestThread thread : threads) {
     thread.join();
   }
   LOG.log(Level.INFO, "Test threads have all exited.");
 }