Esempio n. 1
0
  @Test
  public void test() {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    OutputObjectState fluff = new OutputObjectState();
    Uid kungfuTx = new Uid();
    boolean passed = false;
    final String tn = new AtomicAction().type();

    try {
      UidHelper.packInto(kungfuTx, fluff);

      System.err.println("Creating dummy log");

      recoveryStore.write_committed(kungfuTx, tn, fluff);

      if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED) {
        System.err.println("Wrote dummy transaction " + kungfuTx);

        // quicker to deal with scanner directly

        ExpiredTransactionScanner scanner =
            new ExpiredTransactionScanner(tn, "/StateManager/ExpiredEntries");

        scanner.scan();

        scanner.scan();

        if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED)
          System.err.println("Transaction log not moved!");
        else {
          System.err.println("Transaction log moved!");

          passed = true;
        }
      } else System.err.println("State is not committed!");
    } catch (final Exception ex) {
      ex.printStackTrace();
    }

    assertTrue(passed);
  }
Esempio n. 2
0
  protected static OSRecordHolder readObjectStoreRecord(String type) {
    try {
      RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
      InputObjectState states = new InputObjectState();

      if (recoveryStore.allObjUids(type, states) && states.notempty()) {

        Uid uid = UidHelper.unpackFrom(states);

        if (uid.notEquals(Uid.nullUid())) {
          InputObjectState ios = recoveryStore.read_committed(uid, type);

          return new OSRecordHolder(uid, type, ios);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
Esempio n. 3
0
  private static void clearObjectStore(String type) {
    try {
      RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
      InputObjectState states = new InputObjectState();

      if (recoveryStore.allObjUids(type, states) && states.notempty()) {
        boolean finished = false;

        do {
          Uid uid = UidHelper.unpackFrom(states);

          if (uid.notEquals(Uid.nullUid())) {
            recoveryStore.remove_committed(uid, type);
          } else {
            finished = true;
          }
        } while (!finished);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }