Package eu.mosaic_cloud.cloudlets.implementation.cloudlet.CloudletFsm

Examples of eu.mosaic_cloud.cloudlets.implementation.cloudlet.CloudletFsm.FsmCallbackCompletionTransaction


    }
   
    @Override
    public final void registeredCallbacks (final Callbacks proxy, final CallbackIsolate isolate)
    {
      final FsmCallbackCompletionTransaction initializeSucceededCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksInitializeSucceededCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> initializedCompletion)
        {
          Preconditions.checkState (Cloudlet.this.initializeFuture != null);
          final Throwable exception = initializedCompletion.getException ();
          StateAndOutput<FsmState, Void> result;
          if (exception == null) {
            Cloudlet.this.initializeFuture.trigger.triggerSucceeded (null);
            Cloudlet.this.initializeFuture = null;
            result = StateAndOutput.create (FsmState.Active, null);
          } else {
            Cloudlet.this.failures.traceDeferredException (exception);
            Cloudlet.this.initializeFuture.trigger.triggerFailed (QueuedExceptions.create (Cloudlet.this.failures));
            Cloudlet.this.initializeFuture = null;
            Cloudlet.this.reactor.destroyProxy (Cloudlet.this.callbacksProxy);
            result = StateAndOutput.create (FsmState.CallbacksUnregisterPending, null);
          }
          return result;
        }
      };
      final FsmCallbackCompletionTransaction initializeFailedCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksInitializeFailedCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> initializedCompletion)
        {
          Preconditions.checkState (Cloudlet.this.initializeFuture != null);
          final Throwable exception = initializedCompletion.getException ();
          if (exception != null) {
            Cloudlet.this.failures.traceDeferredException (exception);
          }
          Cloudlet.this.initializeFuture.trigger.triggerFailed (QueuedExceptions.create (Cloudlet.this.failures));
          Cloudlet.this.initializeFuture = null;
          Cloudlet.this.reactor.destroyProxy (Cloudlet.this.callbacksProxy);
          return StateAndOutput.create (FsmState.CallbacksUnregisterPending, null);
        }
      };
      final FsmCallbackCompletionTransaction initializeCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksInitializeCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> initializeCompletion)
        {
          final Throwable exception = initializeCompletion.getException ();
          StateAndOutput<FsmState, Void> result;
          if (exception == null) {
            final CloudletCallbackCompletionArguments<TContext> arguments = new CloudletCallbackCompletionArguments<TContext> (Cloudlet.this.controllerProxy);
            final CallbackCompletion<Void> initializedCompletion = Cloudlet.this.callbacksProxy.initializeSucceeded (Cloudlet.this.controllerContext, arguments);
            initializeSucceededCompletedTransaction.observe (initializedCompletion);
            result = StateAndOutput.create (FsmState.CallbacksInitializeSucceededPending, null);
          } else {
            Cloudlet.this.failures.traceDeferredException (exception);
            final CloudletCallbackCompletionArguments<TContext> arguments = new CloudletCallbackCompletionArguments<TContext> (Cloudlet.this.controllerProxy, exception);
            final CallbackCompletion<Void> initializedCompletion = Cloudlet.this.callbacksProxy.initializeFailed (Cloudlet.this.controllerContext, arguments);
            initializeFailedCompletedTransaction.observe (initializedCompletion);
            result = StateAndOutput.create (FsmState.CallbacksInitializeFailedPending, null);
          }
          return result;
        }
      };
      Cloudlet.this.fsm.new FsmVoidTransaction (FsmTransition.CallbacksRegisterCompleted) {
        @Override
        public final StateAndOutput<FsmState, Void> execute ()
        {
          final CloudletCallbackArguments<TContext> arguments = new CloudletCallbackArguments<TContext> (Cloudlet.this.controllerProxy);
          final CallbackCompletion<Void> completion = Cloudlet.this.callbacksProxy.initialize (Cloudlet.this.controllerContext, arguments);
          initializeCompletedTransaction.observe (completion);
          return StateAndOutput.create (FsmState.CallbacksInitializePending, null);
        }
      }.trigger ();
    }
View Full Code Here


          future.trigger.triggerSucceeded (null);
          return;
        default:
          break;
      }
      final FsmCallbackCompletionTransaction destroySucceededCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksDestroySucceededCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> destroyedCompletion)
        {
          final Throwable exception = destroyedCompletion.getException ();
          if (exception != null) {
            Cloudlet.this.failures.traceDeferredException (exception);
          }
          Cloudlet.this.reactor.destroyProxy (Cloudlet.this.callbacksProxy);
          return StateAndOutput.create (FsmState.CallbacksUnregisterPending, null);
        }
      };
      final FsmCallbackCompletionTransaction destroyFailedCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksDestroyFailedCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> destroyedCompletion)
        {
          final Throwable exception = destroyedCompletion.getException ();
          if (exception != null) {
            Cloudlet.this.failures.traceDeferredException (exception);
          }
          Cloudlet.this.reactor.destroyProxy (Cloudlet.this.callbacksProxy);
          return StateAndOutput.create (FsmState.CallbacksUnregisterPending, null);
        }
      };
      final FsmCallbackCompletionTransaction destroyCompletedTransaction = Cloudlet.this.fsm.new FsmCallbackCompletionTransaction (FsmTransition.CallbacksDestroyCompleted) {
        @Override
        protected final StateAndOutput<FsmState, Void> execute (final CallbackCompletion<Void> destroyCompletion)
        {
          final Throwable exception = destroyCompletion.getException ();
          StateAndOutput<FsmState, Void> result;
          if (exception == null) {
            final CloudletCallbackCompletionArguments<TContext> arguments = new CloudletCallbackCompletionArguments<TContext> (Cloudlet.this.controllerProxy);
            final CallbackCompletion<Void> destroyedCompletion = Cloudlet.this.callbacksProxy.destroySucceeded (Cloudlet.this.controllerContext, arguments);
            destroySucceededCompletedTransaction.observe (destroyedCompletion);
            result = StateAndOutput.create (FsmState.CallbacksDestroySucceededPending, null);
          } else {
            Cloudlet.this.failures.traceDeferredException (exception);
            final CloudletCallbackCompletionArguments<TContext> arguments = new CloudletCallbackCompletionArguments<TContext> (Cloudlet.this.controllerProxy, exception);
            final CallbackCompletion<Void> destroyedCompletion = Cloudlet.this.callbacksProxy.destroyFailed (Cloudlet.this.controllerContext, arguments);
            destroyFailedCompletedTransaction.observe (destroyedCompletion);
            result = StateAndOutput.create (FsmState.CallbacksDestroyFailedPending, null);
          }
          return result;
        }
      };
      Cloudlet.this.fsm.new FsmVoidTransaction (FsmTransition.ExternalDestroy) {
        @Override
        public final StateAndOutput<FsmState, Void> execute ()
        {
          Preconditions.checkState (Cloudlet.this.destroyFuture == null);
          Cloudlet.this.destroyFuture = future;
          final CloudletCallbackArguments<TContext> arguments = new CloudletCallbackArguments<TContext> (Cloudlet.this.controllerProxy);
          final CallbackCompletion<Void> completion = Cloudlet.this.callbacksProxy.destroy (Cloudlet.this.controllerContext, arguments);
          destroyCompletedTransaction.observe (completion);
          return StateAndOutput.create (FsmState.CallbacksDestroyPending, null);
        }
      }.trigger ();
    }
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.cloudlets.implementation.cloudlet.CloudletFsm.FsmCallbackCompletionTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.