コード例 #1
0
ファイル: Client21b.java プロジェクト: petenorth/narayana
  public static void main(String[] args) {
    try {
      ORBInterface.initORB(args, null);
      OAInterface.initOA();

      String serviceIOR1 = ServerIORStore.loadIOR(args[args.length - 2]);
      BeforeCrashService service1 =
          BeforeCrashServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR1));

      String serviceIOR2 = ServerIORStore.loadIOR(args[args.length - 1]);
      BeforeCrashService service2 =
          BeforeCrashServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR2));

      ResourceBehavior[] resourceBehaviors1 = new ResourceBehavior[1];
      resourceBehaviors1[0] = new ResourceBehavior();
      resourceBehaviors1[0].crash_behavior = CrashBehavior.CrashBehaviorNoCrash;

      ResourceBehavior[] resourceBehaviors2 = new ResourceBehavior[1];
      resourceBehaviors2[0] = new ResourceBehavior();
      resourceBehaviors2[0].crash_behavior = CrashBehavior.CrashBehaviorCrashInRollback;

      boolean correct = true;

      OTS.current().begin();

      service1.setup_oper(OTS.current().get_control(), resourceBehaviors1);
      service2.setup_oper(OTS.current().get_control(), resourceBehaviors2);

      correct = correct && service1.is_correct();
      correct = correct && service2.is_correct();

      OTS.current().rollback_only();

      try {
        OTS.current().commit(true);
        correct = false;
      } catch (TRANSACTION_ROLLEDBACK transactionRolledback) {
      }

      if (correct) {
        System.out.println("Passed");
      } else {
        System.out.println("Failed");
      }
    } catch (Exception exception) {
      System.out.println("Failed");
      System.err.println("Client21b.main: " + exception);
      exception.printStackTrace(System.err);
    }

    try {
      OAInterface.shutdownOA();
      ORBInterface.shutdownORB();
    } catch (Exception exception) {
      System.err.println("Client21b.main: " + exception);
      exception.printStackTrace(System.err);
    }
  }
コード例 #2
0
ファイル: Server06.java プロジェクト: petenorth/narayana
  public static void main(String args[]) {
    try {
      ORBInterface.initORB(args, null);
      OAInterface.initOA();

      AfterCrashServiceImpl02 afterCrashServiceImpl =
          new AfterCrashServiceImpl02(args[args.length - 2].hashCode(), 0);
      AfterCrashServicePOATie servant = new AfterCrashServicePOATie(afterCrashServiceImpl);

      OAInterface.objectIsReady(servant);
      AfterCrashService afterCrashService =
          AfterCrashServiceHelper.narrow(OAInterface.corbaReference(servant));

      ServerIORStore.storeIOR(
          args[args.length - 1], ORBInterface.orb().object_to_string(afterCrashService));

      System.out.println("Ready");

      ORBInterface.run();
    } catch (Exception exception) {
      System.err.println("Server06.main: " + exception);
      exception.printStackTrace(System.err);
    }
  }
コード例 #3
0
ファイル: Client05a.java プロジェクト: barreiro/narayana
  public static void main(String[] args) {
    try {
      init(args, null);

      String serviceIOR1 = ServerIORStore.loadIOR(args[args.length - 2]);
      AfterCrashService service1 =
          AfterCrashServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR1));

      String serviceIOR2 = ServerIORStore.loadIOR(args[args.length - 1]);
      AfterCrashService service2 =
          AfterCrashServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR2));

      CheckBehavior[] checkBehaviors1 = new CheckBehavior[1];
      checkBehaviors1[0] = new CheckBehavior();
      checkBehaviors1[0].allow_done = false;
      checkBehaviors1[0].allow_returned_prepared = true;
      checkBehaviors1[0].allow_returned_committing = true;
      checkBehaviors1[0].allow_returned_committed = true;
      checkBehaviors1[0].allow_returned_rolledback = false;
      checkBehaviors1[0].allow_raised_not_prepared = false;

      CheckBehavior[] checkBehaviors2 = new CheckBehavior[1];
      checkBehaviors2[0] = new CheckBehavior();
      checkBehaviors2[0].allow_done = true;
      checkBehaviors2[0].allow_returned_prepared = true;
      checkBehaviors2[0].allow_returned_committing = true;
      checkBehaviors2[0].allow_returned_committed = true;
      checkBehaviors2[0].allow_returned_rolledback = false;
      checkBehaviors2[0].allow_raised_not_prepared = false;

      boolean correct = true;

      service1.setup_oper(1);
      service2.setup_oper(1);

      correct = correct && service1.check_oper(checkBehaviors1);
      correct = correct && service2.check_oper(checkBehaviors2);
      correct = correct && service1.is_correct();
      correct = correct && service2.is_correct();

      CrashRecoveryDelays.awaitReplayCompletionCR05();

      ResourceTrace resourceTrace1 = service1.get_resource_trace(0);
      ResourceTrace resourceTrace2 = service2.get_resource_trace(0);

      correct = correct && (resourceTrace1 == ResourceTrace.ResourceTraceCommit);
      correct =
          correct
              && ((resourceTrace2 == ResourceTrace.ResourceTraceNone)
                  || (resourceTrace2 == ResourceTrace.ResourceTraceCommit));

      if (correct) {
        System.out.println("Passed");
      } else {
        System.out.println("Failed");
      }
    } catch (Exception exception) {
      System.out.println("Failed");
      System.err.println("Client05a.main: " + exception);
      exception.printStackTrace(System.err);
    }

    try {
      fini();
    } catch (Exception exception) {
      System.err.println("Client05a.main: " + exception);
      exception.printStackTrace(System.err);
    }
  }