Package org.nimbustools.api.services.rm

Examples of org.nimbustools.api.services.rm.ManageException


                             Calendar start,
                             Calendar stop,
                             String hostname) throws ManageException {

        if (!this.valid) {
            throw new ManageException("scheduler was instantiated " +
                    "incorrectly"); // note for future IoC muckers
        }
       
        this.stateNotification(vmid,
                               WorkspaceConstants.STATE_FIRST_LEGAL,
View Full Code Here


     * @throws ManageException
     */
    public void stateNotification(int id, int state)
                                    throws ManageException {
        if (!this.valid) {
            throw new ManageException("scheduler was instantiated " +
                    "incorrectly"); // note for future IoC muckers
        }
        this.stateNotification(id, state, null, null, null);
    }
View Full Code Here

            }

            try {
                destroy_lock.lockInterruptibly();
            } catch (InterruptedException e) {
                throw new ManageException(e.getMessage(), e);
            }

            lock.unlock();

            // TODO: add a timeout
            try {
                req.execute(); // could block
            } catch (Throwable t) {
                // candidate for admin log/trigger of severe issues
                logger.error("",t);
            } finally {
              try {
                  lock.lockInterruptibly();
                  destroy_lock.unlock();
              } catch (InterruptedException e) {
                  throw new ManageException(e.getMessage(), e);
              }
            }

            if (this.trace) {
                logger.trace("\n\n   ***** ST--remove: " + idStr
View Full Code Here

                next = STATE_PROPAGATING_TO_PAUSE;
            }

            final String errMsg = "propagate functionality " +
                            "needed but it has been disabled";
            final ManageException wexc = new ManageException(errMsg);

            final int stateToSet;
            if (next == STATE_INVALID) {
                stateToSet = STATE_CORRUPTED_GENERIC;
            } else {
                stateToSet = STATE_CORRUPTED + next;
            }
            resource.setStateUnderLock(stateToSet, wexc);
            throw wexc;
        }

        WorkspaceRequest req;
        boolean fallback = false;
        final boolean propstartOK = resource.isPropagateStartOK();

        if (target == STATE_STARTED) {

            if (propstartOK) {
                req = this.reqFactory.propagateAndStart();

                if (req == null) {
                    if (this.trace) {
                        logger.trace("\n\n   ***** ST--propagate " + idStr +
                                ": could use propagateToStart, " +
                                            "but not implemented\n");
                    }
                    fallback = true;
                }

            } else {

                req = reqFactory.propagate();

                if (req == null) {

                    final String errMsg = "propagate functionality " +
                            "needed but it is not implemented";
                    final ManageException wexc =
                            new ManageException(errMsg);

                    resource.setStateUnderLock(
                                STATE_CORRUPTED + STATE_PROPAGATING, wexc);
                   
                    throw wexc;
                }

                // just change local var, not real resource target
                target = STATE_PROPAGATED;

                if (this.trace) {
                    logger.trace("\n\n   ***** ST--propagate " + idStr +
                    ": propagateToStart not OK for this resource, doing" +
                        " propagate-only\n");
                }

            }

        } else if (target == STATE_PAUSED) {

            if (propstartOK) {

                req = this.reqFactory.propagateAndPause();

                if (req == null) {
                    if (this.trace) {
                        logger.trace("\n\n   ***** ST--propagate " + idStr +
                       ": could use propagateToPause, but not implemented\n");
                    }
                    fallback = true;
                }

            } else {

                req = reqFactory.propagate();

                if (req == null) {

                    final String errMsg = "propagate functionality " +
                            "needed but it is not implemented";
                    final ManageException wexc =
                            new ManageException(errMsg);

                    resource.setStateUnderLock(
                                STATE_CORRUPTED + STATE_PROPAGATING, wexc);
                   
                    throw wexc;
                }

                // just change local var, not real resource target
                // todo: comment why
                target = STATE_PROPAGATED;

                if (this.trace) {

                    logger.trace("\n\n   ***** ST--propagate " + idStr +
                    ": propagateToPause not OK for this resource, doing" +
                        " propagate-only\n");
                }
            }

        } else if (target == STATE_PROPAGATED) {

            req = this.reqFactory.propagate();

            if (req == null) {

                final String errMsg = "propagate functionality " +
                            "needed but it is not implemented";
                final ManageException wexc =
                        new ManageException(errMsg);

                resource.setStateUnderLock(
                                STATE_CORRUPTED + STATE_PROPAGATING, wexc);

                throw wexc;
            }

        } else {

            // handlers before propagate handler should not
            // let this happen

            throw new ManageException("Current state is " +
                    this.dataConvert.stateName(current) + ", " +
                    "propagate is needed but not" +
                    " achieved, but target state is not " +
                    this.dataConvert.stateName(STATE_STARTED) + ", " +
                    this.dataConvert.stateName(STATE_PAUSED) + ", or" +
                    this.dataConvert.stateName(STATE_PROPAGATED) + ", it is " +
                    this.dataConvert.stateName(target));
        }

        if (fallback) {

            if (this.trace) {
                logger.trace("\n\n   ***** ST--propagate " + idStr +
                                        ": falling back to propagate-only\n");
            }

            req = reqFactory.propagate();

            if (req == null) {

                final String errMsg = "propagate functionality " +
                            "needed but it is not implemented";
                final ManageException wexc =
                        new ManageException(errMsg);

                resource.setStateUnderLock(
                                STATE_CORRUPTED + STATE_PROPAGATING, wexc);
               
                throw wexc;
View Full Code Here

            return false; //shutdown will get this
        }

        if (current >= STATE_READYING_FOR_TRANSPORT) {
            // restriction could go away in the future
            throw new ManageException("illegal to move to " +
                    this.dataConvert.stateName(STATE_STARTED) + " from " +
                    this.dataConvert.stateName(current));
        }

        if (this.trace) {
View Full Code Here

            logger.error("should be unreachable, Binding should have " +
                    "rejected this creation request");

            final String errMsg = "unpropagate functionality " +
                            "needed but it has been disabled";
            final ManageException wexc =
                    new ManageException(errMsg);

            final int stateToSet;
            if (corrupTag == STATE_INVALID) {
                stateToSet = STATE_CORRUPTED_GENERIC;
            } else {
                stateToSet = STATE_CORRUPTED + corrupTag;
            }
            resrc.setStateUnderLock(stateToSet, wexc);
            throw wexc;
        }

        final WorkspaceRequest req = this.reqFactory.readyForTransport();
        if (req == null) {

            final String errMsg = "ready-for-transport " +
                    "functionality needed and enabled but no implementation " +
                        "class is configured";
            final ManageException wexc =
                    new ManageException(errMsg);

            final int stateToSet;
            if (corrupTag == STATE_INVALID) {
                stateToSet = STATE_CORRUPTED_GENERIC;
            } else {
View Full Code Here

     * @throws DoesNotExistException
     */
    public void remove() throws ManageException, DoesNotExistException {

        if (this.groupid == null) {
            throw new ManageException(
                    "illegal class usage, no group ID was stored at creation");
        }

        try {
            _remove();
        } catch (Throwable t) {
            logger.fatal("Could not remove-all? Via group '" +
                    this.groupid + "': " + t.getMessage(), t);
            throw new ManageException("Internal service error, perhaps " +
                    "you'd like to inform the administrator of the time of " +
                    "the error and this key: '" + this.groupid + "'");
        }
    }
View Full Code Here

                    Lager.groupid(this.groupid) + " destroy begins");
        }

        final String errors = do_remove();
        if (errors != null) {
            throw new ManageException(errors);
        }

        if (lager.eventLog) {
            logger.info(Lager.groupev(this.groupid) + "destroyed");
        } else if (lager.traceLog) {
View Full Code Here

                        resource.serialize(tasks);
                        break;
                    case t_REBOOT:
                        resource.reboot(tasks);
                        break;
                    default: throw new ManageException("Unknown request");
                }

            } catch (Throwable t) {
                returnMsg.append(badprefix)
                         .append("Problem ")
                         .append(gerund)
                         .append(" workspace #")
                         .append(resource.getID())
                         .append(": ")
                         .append(t.getMessage())
                         .append(suffix);
                aProblem = true;
                continue;
            }

            // we say "sent to" because the task is asynchronous
            returnMsg.append(prefix)
                     .append(cVerb)
                     .append(" sent to workspace #")
                     .append(resource.getID())
                     .append(suffix);
        }

        final String ret = returnMsg.toString();

        // in future return information about what happened to client
        if (this.lager.eventLog) {
            logger.info(Lager.groupev(this.groupid) + "\n" + ret);
        } else if (this.lager.traceLog) {
            logger.trace(Lager.groupid(this.groupid) + "\n" + ret);
        }

        if (aProblem) {
            throw new ManageException(ret);
        }
    }
View Full Code Here

    public void releaseSpace(final int vmid) throws ManageException {
        try {
            // Read the long locking comment above before using/changing
            this._acquireDestructionLock();
        } catch (ResourceRequestDeniedException e) {
            throw new ManageException("", e);
        }
        try {
            this._releaseSpace(vmid);
        } finally {
            this._releaseDestructionLock();
View Full Code Here

TOP

Related Classes of org.nimbustools.api.services.rm.ManageException

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.