Пример #1
0
 protected boolean writeObjectStoreRecord(OSRecordHolder holder) {
   try {
     return StoreManager.getRecoveryStore().write_committed(holder.uid, holder.type, holder.oos);
   } catch (ObjectStoreException e) {
     return false;
   }
 }
Пример #2
0
  public static final void main(String[] args) {
    LogConsole console = new LogConsole();

    console.doWork();

    StoreManager.getRecoveryStore().stop();
  }
Пример #3
0
  private final boolean supportedLog(String logID) throws ObjectStoreException, IOException {
    Uid id = new Uid(logID);

    if (id.equals(Uid.nullUid())) return false;

    ObjectStoreIterator iter =
        new ObjectStoreIterator(
            StoreManager.getRecoveryStore(),
            TransactionTypeManager.getInstance().getTransactionType(_transactionType));
    Uid u;

    do {
      u = iter.iterate();

      if (u.equals(id)) return true;
    } while (Uid.nullUid().notEquals(u));

    return false;
  }
Пример #4
0
  private final void listLogs(String type) throws IOException {
    InputObjectState buff = new InputObjectState();

    try {
      if (StoreManager.getRecoveryStore()
          .allObjUids(TransactionTypeManager.getInstance().getTransactionType(type), buff)) {
        Uid u = null;

        do {
          u = UidHelper.unpackFrom(buff);

          if (Uid.nullUid().notEquals(u)) {
            System.out.println("Log: " + u);
          }
        } while (Uid.nullUid().notEquals(u));
      }
    } catch (final ObjectStoreException ex) {
      throw new IOException();
    }
  }
Пример #5
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);
  }
Пример #6
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;
  }
Пример #7
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();
    }
  }