Package com.sun.grid.jgdi

Examples of com.sun.grid.jgdi.JGDIException


        Object value;
        StringBuilder sb = new StringBuilder();
        List subNames = null, subValues = null;
        PropertyDescriptor pd = getProperty(obj, propScope, propName);
        if (pd == null) {
            throw new JGDIException("JGDI Error: Attribute \"" + propName + "\" does not exits in " + obj.getName());
        }
        subNames = getStretchedElementNames(obj, pd);
        if (subNames.size() > 0) {
            subValues = getStretchedElementValues(obj, pd);
            if (subNames.size() != subValues.size()) {
View Full Code Here


            }
           
            if ((pd = getPropertyDescriptor(obj, attr)) == null || pd.isReadOnly()) {
                String msg = AnnotatedCommand.getDefaultErrorMessage("QConfCommand", "UnknownAttribute", attr);
                int exitCode = AnnotatedCommand.getCustomExitCode("QConfCommand", "UnknownAttribute", "");
                throw new JGDIException(msg, exitCode);
            }
           
            line = parseOnePlainTextLine(obj, pd, line.trim());
            if (line == null || line.length() == 0) {
                throw new IllegalArgumentException("Invalid value format for attribute \"" + attr + "\"");
View Full Code Here

            if (libNotLoaded) {
                try {
                    System.loadLibrary("jgdi");
                    libNotLoaded = false;
                } catch (Throwable e) {
                    JGDIException ex = new JGDIException("Can not load native jgdi lib: " + e.getMessage());
                    // ex.initCause(e);  does not work for whatever reason
                    throw ex;
                }
            }
        }
View Full Code Here

                //If some is recognized as valid option. First extra arg is InvalidArgument
                if (!extraArgsValid || optMap.containsKey(option)) {
                    msg = getErrorMessage("InvalidArgument", extraArgs.get(0).get(0));
                    int exitCode = getCustomExitCode("InvalidArgument", extraArgs.get(0).get(0));
                    extraArgs = null;
                    throw new JGDIException(msg, exitCode);
                }
            }
            //We now store the extraArgs to this command.
            this.extraArgs = extraArgs;
            return null;    //null says now you have the extra args so save them
        }
       
        //We take out first arg list
        tempArg = args.remove(0);
        //And remove the recognized option
        tempArg.remove(0);
        //And we put it back if not empty
        if (tempArg.size()>0) {
            args.add(0, tempArg);
        }
        OptionDescriptor od = optMap.get(option);
        List<List<String>> argList = new ArrayList<List<String>>();
        List<String> tempList = new ArrayList<String>();
        String arg;
             
        if (!od.isWithoutArgs()) {
            int i = 0;
           
            //Try to get all mandatory args
            while (i < od.getMandatoryArgCount() && args.size() > 0) {
                tempArg = args.remove(0);
                tempList.clear();
                while (tempArg.size() > 0 && i < od.getMandatoryArgCount()) {
                    arg = tempArg.remove(0);
                    tempList.add(arg);
                    i++;
                }
                if (tempList.size() > 0) {
                    argList.add(new ArrayList<String>(tempList));
                }
            }
            //We check we completed the subList (comma separated list) otherwise we mark it for continue
            boolean appendToLastList = false;
            if (tempArg.size() > 0) {
                appendToLastList = true;
                args.add(0, tempArg);
            }
           
            //Check we have all mandatory args
            if (i != od.getMandatoryArgCount()) {
                final String msgType = (i == 0) ? "NoArgument" : "LessArguments";
                msg = getErrorMessage(msgType, option, argList);
                int exitCode = getCustomExitCode(msgType, option);
                throw new JGDIException(msg, exitCode);
            }
           
            //Try to get as many optional args as possible
            String argVal;
            boolean exit = false;
            i = 0;
            while (!exit && (i < od.getOptionalArgCount() && args.size() > 0)) {
                tempArg = args.remove(0);
                tempList.clear();
                if (appendToLastList) {
                    appendToLastList = false;
                    tempList = argList.remove(argList.size() - 1);
                }
                for (int j = 0; j<tempArg.size(); j++) {
                    //We have comma separated list with more elems than required - Error
                    if (i >= od.getOptionalArgCount()) {
                        final String msgType = "MoreArguments";
                        msg = getErrorMessage(msgType, option, argList);
                        int exitCode = getCustomExitCode(msgType, option);
                        throw new JGDIException(msg, exitCode);
                    }
                    argVal = tempArg.get(j);
                    //Not enough args?
                    if (optMap.containsKey(argVal)) {
                        if (j == 0) {
                            //Next recognized option must be the first in the sub list
                            exit = true;
                            args.add(0, tempArg);
                            break;
                        } else {
                            //This is an error since option is found in the list
                            //qconf -sq a,b c,d,-sh <= -sh is known option so whole command is wrong
                            //qconf -sq a,g -sh would be accepted
                            msg = getErrorMessage("InvalidArgument", option, argVal);
                            int exitCode = getCustomExitCode("InvalidArgument", option);
                            throw new JGDIException(msg, exitCode);
                        }
                    }
                    tempList.add(argVal);
                    i++;
                }
View Full Code Here

    private static boolean shutdown = false;

    public void init(String url) throws JGDIException {
        synchronized (instances) {
            if (shutdown) {
                throw new JGDIException("shutdown in progress");
            }
            instances.add(this);
        }
        ctxIndex = nativeInit(url);
        if (log.isLoggable(Level.FINE)) {
View Full Code Here

        boolean started = false;
        executorLock.lock();
        try {
            if (eventLoop.getState().equals(State.STOPPED)) {
                if (shutdown) {
                    throw new JGDIException("Can not start event client, shutdown is in progress");
                }
                // the close method is smart enough to do nothing
                // if the event client is already stopped
                // However it can happen that the executor thread is still
                // active => close it
View Full Code Here

        public void commit() throws JGDIException {
            lock.lock();
            try {
                if (!state.equals(State.RUNNING)) {
                    throw new JGDIException("Cannot commit, event client is not started");
                }
                commitFlag = true;
                interruptNative(evcIndex);
                commitCondition.await();
            } catch (InterruptedException ex) {
View Full Code Here

                        case RUNNING:
                            return;
                        case ERROR:
                            throw error;
                        case STOPPING:
                            throw new JGDIException("event client is going down");
                        default:
                            stateChangedCondition.await();
                    }

                }
            } catch (InterruptedException ex) {
                throw new JGDIException(ex, "Startup of event client has been interrupted");
            } finally {
                lock.unlock();
            }
        }
View Full Code Here

                    eventList.clear();
                }
            } catch (JGDIException ex) {
                error(ex);
            } catch (Throwable ex) {
                error(new JGDIException(ex, "Unknown error in event loop"));
            } finally {
                setState(State.STOPPING);
                if (evcIndex >= 0) {
                    try {
                        closeNative(evcIndex);
View Full Code Here

        //This is the only call we want to make
        oi.optionDone();
        if (userList.size() == 0) {
            //We are missing the set list and used usernames as sets
            String msg = getErrorMessage("LessArguments", oi.getOd().getOption(), new ArrayList(setList));
            throw new JGDIException(msg, getCustomExitCode("LessArguments", oi.getOd().getOption()));
        }
        boolean isNew;
        //We add all the users to all the usersets
        for (String set : setList) {
            obj = jgdi.getUserSet(set);
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.JGDIException

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.