Package com.vmware.vim.binding.vim

Examples of com.vmware.vim.binding.vim.Task


    */
   public static void dumpRecentTasks() throws Exception {
      TaskManager taskManager = VcContext.getService().getTaskManager();
      ManagedObjectReference taskMoRefs[] = taskManager.getRecentTask();
      for (ManagedObjectReference moRef : taskMoRefs) {
         Task task = MoUtil.getManagedObject(moRef);
         dumpTask(task);
      }
   }
View Full Code Here


      completionTimeNanos = timeNanos;
   }

   @Override
   protected void update(ManagedObject mo) {
      Task task = (Task)mo;
      TaskInfo info = task.getInfo();
      state = info.getState();
      eventChainId = info.getEventChainId();
   }
View Full Code Here

    */
   private void logTaskError(Task task) throws Exception {
      logger.warn("task " + type + " got error");
      if (task.getInfo().getError() instanceof TaskInProgress) {
         TaskInProgress e = (TaskInProgress)task.getInfo().getError();
         Task inProgressTask = MoUtil.getManagedObject(e.getTask());
         logger.warn("Task already in progress: ");
         VcEventUtil.dumpTask(inProgressTask);
      } else {
         logger.warn(task.getInfo().getError());
      }
View Full Code Here

      }
      throw catchedException;
   }

   private VcObject waitForCompletionIntenal() throws Exception {
      Task task = getManagedObject();
      StatsType oldSrc = Profiler.pushInc(StatsType.VC_TASK_WAIT, getType());
      long lastWaitStartedNanos ;
      long waitFinishedNanos = System.nanoTime();

      state = task.getInfo().getState();
      while (state != State.success) {
         boolean normalWaitCompletion = false; // wait() not interrupted.

         switch (state) {
         case success:
            break;
         case error:
            completionTimeNanos = waitFinishedNanos;
            logTaskError(task);
            assistBadTaskCompletion();
            throw task.getInfo().getError();
         case queued:
         case running:
            lastWaitStartedNanos = System.nanoTime();
            try {
               /* Wait for a completion notification from VcEventListener. */
               isWaiting = true;
               wait(TimeUnit.NANOSECONDS.toMillis(getWaitIntervalNanos()));
               normalWaitCompletion = true;
            } catch (InterruptedException e) {
               /* Continue after checks. */
            } finally {
               isWaiting = false;
               waitFinishedNanos = System.nanoTime();
               lastWaitTimeNanos = waitFinishedNanos - lastWaitStartedNanos;
               totalWaitTimeNanos += lastWaitTimeNanos;
            }
            break;
         default:
            AuAssert.check(false);
         }
         /*
          * TODO: taskInfo reload might not be always necessary. If the task has
          * no result, callers likely care only about success/error state which
          * could be obtained from Event Listener without talking to VC.
          */
         state = task.getInfo().getState();
         verifyWaitCompletion(normalWaitCompletion);
      }

      AuAssert.check(taskCompleted());
      logger.debug("task " + type + "completed");
      completionTimeNanos = waitFinishedNanos;
      assistBadTaskCompletion();

      if (!(type.getTargetClass() == Void.class)) {
         taskResult = task.getInfo().getResult();
         if (taskResult instanceof ManagedObjectReference) {
            if (type == TaskType.Snapshot) {
               VcVirtualMachineImpl vm = (VcVirtualMachineImpl)parent;
               vm.update();
               result = vm.getSnapshot((ManagedObjectReference)taskResult);
View Full Code Here

TOP

Related Classes of com.vmware.vim.binding.vim.Task

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.