Package org.nimbustools.api.services.rm

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


        // nothing to back out:
        if (bailed < 1) {
            if (failure instanceof ResourceRequestDeniedException) {
                throw (ResourceRequestDeniedException) failure;
            } else {
                throw new ResourceRequestDeniedException(
                                                failure.getMessage());
            }
        }

        final String clientMsg;
        if (bailed == 1) {
            clientMsg = "Problem reserving enough space (did get enough " +
                        "for one VM)";
        } else {
            clientMsg = "Problem reserving enough space (did get enough " +
                        "for " + bailed + " VMs)";
        }

        // back out
        for (int i = 0; i < bailed; i++) {
            try {
                ResourcepoolUtil.retireMem(nodes[i], memory, this.db,
                                           this.lager.eventLog,
                                           this.lager.traceLog,
                                           vmids[i], preemptable);
            } catch (Throwable t) {
                if (logger.isDebugEnabled()) {
                    logger.error(
                            "Error with one backout: " + t.getMessage(), t);
                } else {
                    logger.error(
                            "Error with one backout: " + t.getMessage());
                }
                // continue trying to backout anyhow
            }
        }

        throw new ResourceRequestDeniedException(clientMsg);
    }
View Full Code Here


                highestDuration = thisDuration;
            }

            final int[] ids = requests[i].getIds();
            if (ids == null) {
                throw new ResourceRequestDeniedException(
                        "Cannot proceed, no ids in NodeRequest parameter (?)");
            }

            for (int j = 0; j < ids.length; j++) {
                idInts.add(new Integer(ids[j]));
View Full Code Here

        if (memory > this.maxMB) {
            String msg = "Memory request (" + memory + " MB) cannot be " +
                    "fulfilled by any VMM node (maximum: " + this.maxMB +
                    " MB).";
            throw new ResourceRequestDeniedException(msg);
        }

        // When there is no core request, the default is -1,
        // we would actually like one core.
        int cores;
        if (requestedCores <= 0) {
            cores = 1;
        }
        else {
            cores = requestedCores;
        }

        if (vmids.length > 1 && uuid == null) {
            logger.error("cannot make group space request without group ID");
            throw new ResourceRequestDeniedException("internal " +
                    "pilot management error");
        }

        final String slotid;
        if (uuid == null) {
            slotid = uuidGen.generateRandomBasedUUID().toString();
        } else {
            slotid = uuid;
            try {
                for (int i = 0; i < vmids.length; i++) {
                    // add to our own group register, encapsulated from
                    // main service group/coscheduling management
                    this.db.newGroupMember(uuid, vmids[i]);
                }
            } catch (WorkspaceDatabaseException e) {
                logger.error(e.getMessage(), e);
                throw new ResourceRequestDeniedException("internal " +
                        "pilot management error");
            }
        }

        this.reserveSpaceImpl(memory, cores, duration, slotid, vmids, creatorDN);
View Full Code Here

                logger.error(msg + ": " + e.getMessage(), e);
            } else {
                logger.error(msg + ": " + e.getMessage());
            }
            // scrubbing what client sees
            throw new ResourceRequestDeniedException(msg);
        }

        // no casing necessary yet for pilot, only 0.2 supported now
        final ArrayList pilotCommon;
        try {
            pilotCommon = this.pilot.constructCommon(false, false, true, null);
        } catch (ManageException e) {
            final String msg = "Problem with pilot argument construction";
            if (logger.isDebugEnabled()) {
                logger.error(msg + ": " + e.getMessage(), e);
            } else {
                logger.error(msg + ": " + e.getMessage());
            }
            // scrubbing what client sees
            throw new ResourceRequestDeniedException(msg);
        }

        // same params sent to each pilot in a group job
        final ArrayList pilotReserveSlot;
        try {

            final String notifyString;
            if (this.httpNotifyString != null
                    && this.sshNotifyString != null) {

                notifyString = this.httpNotifyString + "+++" +
                               this.sshNotifyString;
            } else if (this.httpNotifyString != null) {
                notifyString = this.httpNotifyString;
            } else if (this.sshNotifyString != null) {
                notifyString = this.sshNotifyString;
            } else {
                final String msg = "No pilot-->service notification mechanism";
                throw new ResourceRequestDeniedException(msg);
            }

            pilotReserveSlot = this.pilot.constructReserveSlot(memory,
                                                               dur,
                                                               this.grace,
                                                               uuid,
                                                               notifyString);
        } catch (ManageException e) {
            final String msg = "Problem with pilot argument construction";
            if (logger.isDebugEnabled()) {
                logger.error(msg + ": " + e.getMessage(), e);
            } else {
                logger.error(msg + ": " + e.getMessage());
            }
            // scrubbing what client sees
            throw new ResourceRequestDeniedException(msg);
        }

        final StringBuffer pilotcmdbuf = new StringBuffer(256);

        if (this.multiJobPrefix != null && vmids.length > 1) {
            pilotcmdbuf.append(this.multiJobPrefix);
            pilotcmdbuf.append(" ");
        }

        pilotcmdbuf.append(this.pilotPath);
        Iterator iter = pilotCommon.iterator();
        while (iter.hasNext()) {
            pilotcmdbuf.append(" ");
            pilotcmdbuf.append(iter.next());
        }
        iter = pilotReserveSlot.iterator();
        while (iter.hasNext()) {
            pilotcmdbuf.append(" ");
            pilotcmdbuf.append(iter.next());
        }
        final String pilotcmd = pilotcmdbuf.toString();
        logger.info("pilot command = " + pilotcmd);

        final String[] cmd = (String[]) torquecmd.toArray(
                                            new String[torquecmd.size()]);
        String stdout;
        try {
            stdout = WorkspaceUtil.runCommand(cmd, true, pilotcmd,
                                              this.lager.eventLog,
                                              this.lager.traceLog);
        } catch (WorkspaceException e) {
            final String msg = "Problem calling Torque";
            if (logger.isDebugEnabled()) {
                logger.error(msg + ": " + e.getMessage(), e);
            } else {
                logger.error(msg + ": " + e.getMessage());
            }
            // scrubbing what client sees
            throw new ResourceRequestDeniedException(msg);
        } catch (ReturnException e) {
            final String msg = "Problem calling Torque";

            final StringBuffer buf = new StringBuffer(msg);
            buf.append(": return code = ")
               .append(e.retval);

            if (e.stderr != null) {
                buf.append(", stderr = '")
                   .append(e.stderr)
                   .append("'");
            } else {
                buf.append(", no stderr");
            }

            if (e.stdout != null) {
                buf.append(", stdout = '")
                   .append(e.stdout)
                   .append("'");
            } else {
                buf.append(", no stdout");
            }

            logger.error(msg + ": " + buf.toString());

            // scrubbing what client sees
            throw new ResourceRequestDeniedException(msg);
        }

        if (stdout == null || stdout.length() == 0) {
            final String msg = "Inexplicable problem receiving job ID from" +
                    " Torque (return == 0, but no stdout), aborting.";
            logger.error(msg);
            throw new ResourceRequestDeniedException(msg);
        }

        // TODO: analyze stdout here, should have no newlines or spaces
        logger.debug("torque stdout = " + stdout);

        stdout = stdout.trim();
        if (stdout.indexOf('\n') >= 0) {
            logger.warn("torque stdout has a new line");
            // todo: throw exc? strip it?
        }

        try {
            if (vmids.length == 1) {
                this.db.newSlot(uuid, vmids[0], stdout, dur);
            } else {
                this.db.newSlotGroup(uuid, vmids, stdout, dur);
            }
        } catch (WorkspaceDatabaseException e) {
            String msg = "Problem with service database, aborting pilot job.";

            if (logger.isDebugEnabled()) {
                logger.error(msg + ": " + e.getMessage(), e);
            } else {
                logger.error(msg + ": " + e.getMessage());
            }

            // we know it's torque for now, no casing
            try {
                WorkspaceUtil.runCommand(this.torque.constructQdel(stdout),
                                         this.lager.eventLog,
                                         this.lager.traceLog);

            } catch (WorkspaceException e2) {
                String msg2 = " (and problem with Torque qdel)";
                msg += msg2;

                if (logger.isDebugEnabled()) {
                    logger.error(msg2 + ": " + e2.getMessage(), e2);
                } else {
                    logger.error(msg2 + ": " + e2.getMessage());
                }
            } catch (ReturnException e2) {
                String msg2 = " (and problem calling Torque qdel)";
                msg += msg2;

                StringBuffer buf = new StringBuffer(msg2);
                buf.append(": return code = ")
                   .append(e2.retval);

                if (e2.stderr != null) {
                    buf.append(", stderr = '")
                       .append(e2.stderr)
                       .append("'");
                } else {
                    buf.append(", no stderr");
                }

                if (e2.stdout != null) {
                    buf.append(", stdout = '")
                       .append(e2.stdout)
                       .append("'");
                } else {
                    buf.append(", no stdout");
                }

                logger.error(buf.toString());
            }
            throw new ResourceRequestDeniedException(msg);
        }

        if (this.watcher != null) {
            this.watcher.scheduleNotificationWatcher();
        }
View Full Code Here

    public Object[] getNextEntry(String name, int vmid)

            throws ResourceRequestDeniedException {

        if (this.persistence == null) {
            throw new ResourceRequestDeniedException(
                    "networking initialization problem");
        }

        synchronized(this.lock) {
            return Util.getNextEntry(name, this.persistence,
View Full Code Here

                      .append(" concurrently running workspaces.");

                final String msg = newbuf.toString();
                buf.append(msg);
                logger.warn(buf.toString());
                throw new ResourceRequestDeniedException(msg);
            }
        }

        long requestDur = 0;
        for (int i = 0; i < bindings.length; i++) {

            final VirtualMachineDeployment dep = bindings[i].getDeployment();
            if (dep == null) {
                final String msg = "ERROR: No deployment information in " +
                        "binding, can't make decision.";
                buf.append(msg);
                logger.error(buf.toString());
                throw new AuthorizationException(msg);
            }

            final long seconds = dep.getMinDuration();
            requestDur += seconds / 60;
        }

        final Double doubleRequestDur = requestDur * chargeRatio;
        requestDur = doubleRequestDur.longValue();

        if (bindings.length > 1) {
            buf.append("Duration total of all requests in group: ");
        } else {
            buf.append("Duration request: ");
        }

        buf.append(requestDur)
           .append("\n");

        // zero or below means no check should be made
        if (rights.getMaxCPUs() > 0) {
            final long maxCPUs = rights.getMaxCPUs();
            for (int i = 0; i < bindings.length; i++) {

                final VirtualMachineDeployment dep = bindings[i].getDeployment();
                if (dep == null) {
                    final String msg = "ERROR: No deployment information in " +
                            "binding, can't make decision.";
                    buf.append(msg);
                    logger.error(buf.toString());
                    throw new AuthorizationException(msg);
                }
                final long currentCPUs = dep.getIndividualCPUCount();
                if (currentCPUs > maxCPUs) {

                    buf.append("\nDenied: Requested CPU count (")
                       .append(currentCPUs)
                       .append(") + is greater or equal to maximum CPU count (")
                       .append(maxCPUs)
                       .append(").\n");

                    logger.warn(buf.toString());

                    throw new ResourceRequestDeniedException(
                                "You requested too many CPUs (" +
                                        currentCPUs + "), the " +
                                        "maximum is " +
                                        maxCPUs + " CPUs.");
                    }
            }
        }

        // zero or below means no check should be made
        if (rights.getMaxReservedMinutes() > 0) {
            final long max = rights.getMaxReservedMinutes();
            final long current = reservedMins.longValue();
            if (requestDur + current > max) {

                buf.append("\nDenied: Request duration (")
                   .append(requestDur)
                   .append(") + current reserved tally (")
                   .append(current)
                   .append(") + is greater or equal to maximum reserved (")
                   .append(max)
                   .append(").\n");

                logger.warn(buf.toString());

                throw new ResourceRequestDeniedException(
                            "Your request is for too much time (" +
                                    requestDur + "), the " +
                                    "maximum reserved at once is " +
                                    max + " minutes.  You currently have " +
                                    current + " other reserved minutes.");
            }
        }

        // zero or below means no check should be made
        if (rights.getMaxElapsedReservedMinutes() > 0) {
            final long max = rights.getMaxElapsedReservedMinutes();
            final long currentElapsed = elapsedMins.longValue();
            final long currentReserved = reservedMins.longValue();
            final long tally = currentElapsed + currentReserved;
            if (requestDur + tally > max) {

                buf.append("\nDenied: Request duration (")
                   .append(requestDur)
                   .append(") + current reserved+elapsed tally (")
                   .append(tally)
                   .append(") + is greater or equal to maximum reserved+elapsed (")
                   .append(max)
                   .append(").\n");

                logger.warn(buf.toString());

                throw new ResourceRequestDeniedException(
                            "Your request is for too much time (" +
                                requestDur + "), this would exceed the " +
                                "maximum you can have both used in the " +
                                "past and have reserved currently. " +
                                "This maximum is " +
View Full Code Here

               .append(imgURI.getPath())
               .append("') does not start with directory in rights ('")
               .append(path)
               .append("').\n");
            logger.warn(buf.toString());
            throw new ResourceRequestDeniedException(
                    "You may only use images under directory '" + path + "'");
        }

        if (altTargetURI != null &&
                !altTargetURI.getPath().startsWith(path)) {

            buf.append("Request denied because alternate target" +
                    " image path in request ('")
               .append(altTargetURI.getHost())
               .append("') does not start with directory in rights ('")
               .append(path)
               .append("').\n");
            logger.warn(buf.toString());
            throw new ResourceRequestDeniedException(
                    "You may only save images to alternate " +
                            "locations starting with base directory '" +
                            path + "'");
        }
    }
View Full Code Here

               .append(imgURI.getHost())
               .append("') does not match image node in rights ('")
               .append(hostname)
               .append("').\n");
            logger.warn(buf.toString());
            throw new ResourceRequestDeniedException(
                    "You may only use images from host '" + hostname + "'");
        }

        if (altTargetURI != null &&
                !imgURI.getHost().equalsIgnoreCase(
                                    altTargetURI.getHost())) {

            buf.append("Request denied because alternate target" +
                    " image node in request ('")
               .append(altTargetURI.getHost())
               .append("') does not match approved image source " +
                       "node in request ('")
               .append(imgURI.getHost())
               .append("').\n");
            logger.warn(buf.toString());
            throw new ResourceRequestDeniedException(
                    "You may only save images to alternate " +
                            "locations on host '" + hostname + "'");
        }
    }
View Full Code Here

            if (msg != null) {
                if (buf != null) {
                    buf.append(msg);
                    logger.error(buf.toString());
                }
                throw new ResourceRequestDeniedException(msg);
            }
        }

        final StringBuffer newbuf = new StringBuffer(input.length());
View Full Code Here

                    if (elapsed < 0 || reserved < 0) {

                        logger.error("Accounting reader returned negative " +
                                     "value? Aborting.");

                        throw new ResourceRequestDeniedException(
                                             "Request denied, internal issue");
                    }

                    elapsedMins = new Long(elapRes.getElapsed());
                    reservedMins = new Long(elapRes.getReserved());
                }

                final int numWorkspaces =
                        this.currentVMs.countIDsByCaller(callerID);

                final boolean permitted =
                        Callout.isPermitted(this.authzCallout,
                                            callerID,
                                            peerSubject,
                                            bindings,
                                            elapsedMins,
                                            reservedMins,
                                            numWorkspaces,
                                            chargeRatio);

                // if a reason to client is desired, throw
                // WorkspaceResourceRequestDeniedException in callout
                if (!permitted) {
                    throw new ResourceRequestDeniedException(
                            "Your request was denied and no reason " +
                                          "was supplied for you to see.");
                }

            } catch (ResourceRequestDeniedException e) {
                throw e;
            } catch (Exception e) {
                logger.error("Problem in authorization callout", e);
                // do not reveal anything specific to the client
                throw new ResourceRequestDeniedException(
                                             "Request denied, internal issue");
            }
        }

        // enforce (global) factory policies
View Full Code Here

TOP

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

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.