@@ -551,109 +551,6 @@ public void easyStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> pa
551551 }
552552 }
553553
554- /*
555- protected boolean checkWorkItems(VMInstanceVO vm, State state) throws ConcurrentOperationException {
556- while (true) {
557- VmWorkJobVO vo = _workDao.findByOutstandingWork(vm.getId(), state);
558- if (vo == null) {
559- if (s_logger.isDebugEnabled()) {
560- s_logger.debug("Unable to find work for VM: " + vm + " and state: " + state);
561- }
562- return true;
563- }
564-
565- if (vo.getStep() == Step.Done) {
566- if (s_logger.isDebugEnabled()) {
567- s_logger.debug("Work for " + vm + " is " + vo.getStep());
568- }
569- return true;
570- }
571-
572- if (vo.getSecondsTaskIsInactive() > _cancelWait) {
573- s_logger.warn("The task item for vm " + vm + " has been inactive for " + vo.getSecondsTaskIsInactive());
574- return false;
575- }
576-
577- try {
578- Thread.sleep(_opWaitInterval);
579- } catch (InterruptedException e) {
580- s_logger.info("Waiting for " + vm + " but is interrupted");
581- throw new ConcurrentOperationException("Waiting for " + vm + " but is interrupted");
582- }
583- s_logger.debug("Waiting some more to make sure there's no activity on " + vm);
584- }
585- }
586- */
587-
588- /*
589- @DB
590- protected VirtualMachineernary<T, ReservationContext, VmWorkJobVO> changeToStartState(VirtualMachineGuru<T> vmGuru, String vmUuid, User caller, Account account)
591- throws ConcurrentOperationException {
592- long vmId = vm.getId();
593-
594- VmWorkJobVO work = new VmWorkJobVO(UUID.randomUUID().toString(), _nodeId, State.Starting, vm.getType(), vm.getId());
595- int retry = _lockStateRetry;
596- while (retry-- != 0) {
597- Transaction txn = Transaction.currentTxn();
598- Ternary<T, ReservationContext, VmWorkJobVO> result = null;
599- txn.start();
600- try {
601- Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
602- work = _workDao.persist(work);
603- ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account);
604-
605- if (stateTransitTo(vm, VirtualMachine.Event.StartRequested, null, work.getId())) {
606- if (s_logger.isDebugEnabled()) {
607- s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
608- }
609- result = new Ternary<T, ReservationContext, VmWorkJobVO>(vmGuru.findById(vmId), context, work);
610- txn.commit();
611- return result;
612- }
613- } catch (NoTransitionException e) {
614- if (s_logger.isDebugEnabled()) {
615- s_logger.debug("Unable to transition into Starting state due to " + e.getMessage());
616- }
617- } finally {
618- if (result == null) {
619- txn.rollback();
620- }
621- }
622-
623- VMInstanceVO instance = _vmDao.findById(vmId);
624- if (instance == null) {
625- throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
626- }
627-
628- if (s_logger.isDebugEnabled()) {
629- s_logger.debug("Determining why we're unable to update the state to Starting for " + instance + ". Retry=" + retry);
630- }
631-
632- State state = instance.getState();
633- if (state == State.Running) {
634- if (s_logger.isDebugEnabled()) {
635- s_logger.debug("VM is already started: " + vm);
636- }
637- return null;
638- }
639-
640- if (state.isTransitional()) {
641- if (!checkWorkItems(vm, state)) {
642- throw new ConcurrentOperationException("There are concurrent operations on " + vm);
643- } else {
644- continue;
645- }
646- }
647-
648- if (state != State.Stopped) {
649- s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
650- return null;
651- }
652- }
653-
654- throw new ConcurrentOperationException("Unable to change the state of " + vm);
655- }
656- */
657554
658555 @ DB
659556 protected Ternary <VMInstanceVO , ReservationContext , VmWorkJobVO > changeToStartState (VirtualMachineGuru vmGuru , VMInstanceVO vm , User caller , Account account )
0 commit comments