Package org.globus.workspace.service

Examples of org.globus.workspace.service.InstanceResource


        // This simple scheduler implementation only decides what to do at
        // creation and when to shutdown (with lockdown of web services start
        // and shutdown operations).

        InstanceResource resource = null;

        // In the case of a slot obtained in a delayed manner (e.g. using
        // the workspace-pilot and/or coscheduled), we cannot act on
        // STATE_FIRST_LEGAL unless this.slotReserved is called (where
        // stop is !null).
        // In the future, stop time should not be overloaded like this, make
        // a more explicit parameter.

        boolean noActivateSituation = false;
        boolean populateAndSchedule = false;

        if (state == WorkspaceConstants.STATE_FIRST_LEGAL) {

            if (this.slotManager.isBestEffort() && stop == null) {

                noActivateSituation = true;

            } else if (this.slotManager.isBestEffort()) {

                populateAndSchedule = true;

            } else {

                resource = this.fetchResource(id, state);
                if (resource == null) {
                    return;
                }

                if (resource.getEnsembleId() != null) {
                    if (stop == null) {
                        noActivateSituation = true;
                    } else {
                        populateAndSchedule = true;
                    }
                }
            }


        }

        if (state == WorkspaceConstants.STATE_FIRST_LEGAL) {
            this.creationPending.notpending(id);
            if (noActivateSituation) {
                return;
            }
        }

        // Since it is immediate, nothing needs to be decided.
        if (state == WorkspaceConstants.STATE_FIRST_LEGAL) {

            if (resource == null) {
                resource = this.fetchResource(id, state);
                if (resource == null) {
                    return;
                }
            }

            if (populateAndSchedule) {

                // note that in the pilot case running time duration currently
                // equals requested running time, leaving no time for
                // unpropagation (need B scheduler), client will need to call
                // shutdown + ready-for-transport to get unpropagation
                this.db.scheduleTasks(id, stop);
               
                if (hostname == null) {
                    logger.error(Lager.id(id) + "scheduler received " +
                            "slot-reserved notification without a hostname");
                    return;
                } else {
                    resource.newHostname(hostname);
                }

                if (start == null) {
                    logger.error(Lager.id(id) + "scheduler received " +
                            "slot-reserved notification without a start time");
                    return;
                } else {
                    resource.newStartTime(start);
                }

                if (stop == null) {
                    // this is actually impossible to reach, leaving in
                    // for future developers
                    logger.error(Lager.id(id) + "scheduler received " +
                            "slot-reserved notification without a stop time");
                    return;
                } else {
                    resource.newStopTime(stop);
                }
            }

            resource.setOpsEnabled(true);
            try {
                resource.activate();
                this.sweeper.scheduleSweeper();
            } catch (ManageException e) {
                logger.error("", e);
            }
        }


        /* Once transport-readying is hit for any reason, no turning back */
        else if (state == WorkspaceConstants.STATE_READYING_FOR_TRANSPORT) {
            try {
                resource = this.home.find(id);
            } catch (DoesNotExistException e) {
                logger.error("scheduler received state notification (" +
                        this.dataConvert.stateName(state) + ") about " +
                        Lager.id(id) + ", but it seems to be gone now", e);
                return;
            }

            // find will not return null
            resource.setOpsEnabled(false);
            try {
                this.db.markShutdown(id);
            } catch (WorkspaceDatabaseException e) {
                logger.error("", e);
            }
View Full Code Here


    }

    private InstanceResource fetchResource(int id, int state)
                    throws ManageException {

        InstanceResource resource = null;
        try {
            // find will not return null
            resource = this.home.find(id);
            return resource;
           
View Full Code Here

        boolean aProblem = false;
        final StringBuffer returnMsg = new StringBuffer();

        for (int i = 0; i < resources.length; i++) {

            final InstanceResource resource = resources[i];
           
            // in the future, the VMM controller(s) will be able to support
            // getting bulk requests
            resource.setLastInGroup(false);
            resource.setPartOfGroupRequest(false);

            try {

                switch (type) {
                    case t_START:
                        resource.start();
                        break;
                    case t_SHUTDOWN:
                        resource.shutdown(tasks);
                        break;
                    case t_SHUTDOWN_SAVE:
                        resource.shutdownSave(tasks);
                        break;
                    case t_PAUSE:
                        resource.pause(tasks);
                        break;
                    case t_SERIALIZE:
                        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();
View Full Code Here

            logger.error("Problem moving " + Lager.id(id) + " to state '" +
                        this.dataConvert.stateName(notify) + "': " + err.getMessage());
            corrupted = true;
        }

        final InstanceResource resource;
        try {
            resource = this.home.find(id);
        } catch (ManageException e) {
            logger.error("",e);
            return;
        } catch (DoesNotExistException e) {
            // error already logged above
            final String errStr ="received notification concerning resource " +
                    "that does not exist anymore.  " + Lager.id(id) +
                    ", state = " + this.dataConvert.stateName(notify);
            logger.error(errStr);
            return;
        }

        try {

            // the corrupted states can be used to track the target state
            // at the time of corruption (notify() of success and error send
            // the same state, the target state that task was supposed to
            // take the resource to)

            if (corrupted) {
                if (notify == STATE_DESTROYING) {
                    resource.setState(STATE_DESTROY_FAILED, err);
                    resource.setTargetState(STATE_DESTROY_FAILED);
                } else if (notify >= STATE_FIRST_LEGAL && notify < STATE_DESTROYING) {
                    resource.setState(notify + STATE_CORRUPTED, err);
                } else {
                    logger.error("erroneous error notification, target " +
                            "state not legal, val=" + notify);
                    resource.setState(STATE_CORRUPTED_GENERIC, err);
                }

            } else {
                if (notify == STATE_DESTROYING) {
                    resource.setState(STATE_DESTROY_SUCCEEDED, null);
                } else {
                    resource.setState(notify, null);
                }
            }

        } catch (LockAcquisitionFailure e) {
            // notify() is one way only
View Full Code Here

        // get the necessary information from the resource, no reason (yet) to
        // double track it here even if that is in principle more encapsulated

        // assuming resource vm correlation as usual
        final InstanceResource resource;
        try {
            // find will not return null
            resource = this.home.find(vmid);
        } catch (DoesNotExistException e) {
            logger.error("resource pool management received releaseSpace " +
                    "for workspace " + Lager.id(vmid)
                    + ", but WorkspaceHome failed to find it", e);
            return;
        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.error(e.getMessage(), e);
            } else {
                logger.error(e.getMessage());
            }
            throw new ManageException(e);
        }

        logger.debug("found resource = " + resource);

        final VirtualMachine vm = resource.getVM();
        if (vm == null) {
            throw new ProgrammingError("vm is null");
        }

        final String node = vm.getNode();
View Full Code Here

                                        this.sshAccount,
                                        this.sshIdentityFile);

        // todo: temporary hack, RequiredVMM implementation and configurations
        //       will be more encapsulated in the future
        final InstanceResource vw = this.newEmptyResource();
        if (vw instanceof Xen) {
            if (this.backendPath == null) {
                throw new Exception(
                        "workspace control executable path is not configured");
            }
View Full Code Here

        if (idStr == null) {
            throw new IllegalArgumentException("idStr may not be null");
        }

        final InstanceResource resource;

        final Lock lock = this.lockManager.getLock(idStr);
        try {
            lock.lockInterruptibly();
        } catch (InterruptedException e) {
View Full Code Here

        if (id == null) {
            throw new ManageException("id may not be null");
        }

        final InstanceResource resource;

        final Lock lock = this.lockManager.getLock(id);
        try {
            lock.lockInterruptibly();
        } catch (InterruptedException e) {
            throw new ManageException(e.getMessage(), e);
        }

        try {

            final Element el = this.cache.get(id);
            if (el == null) {
                resource = this.newInstance(id);
                resource.load(id); // throws DoesNotExistException if not in db

                final Calendar currTime = Calendar.getInstance();
                final Calendar termTime = resource.getTerminationTime();
                if (termTime != null && termTime.before(currTime)) {
                    boolean destroyed = this.destroy(id);
                    if (destroyed) {
                      throw new DoesNotExistException(Lager.id(id) + " expired");
                    }
View Full Code Here

            destroy_lock.unlock();
            throw new ManageException(e.getMessage(), e);
        }

        try {
            final InstanceResource resource = this.find(id);
            this.scheduler.cleanup(id);
            resource.cleanup();
        } finally {
            lock.unlock();
            destroy_lock.unlock();
        }
    }
View Full Code Here

            destroy_lock.unlock();
            throw new ManageException(e.getMessage(), e);
        }

        try {
            final InstanceResource resource = this.find(id);
            destroyed = resource.remove();
            if (destroyed) {
                this.cache.remove(id);
            }

        } finally {
View Full Code Here

TOP

Related Classes of org.globus.workspace.service.InstanceResource

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.