Package com.sun.grid.jgdi.configuration

Examples of com.sun.grid.jgdi.configuration.ComplexEntry


        }
        if (o instanceof Boolean) {
            return String.valueOf(o).toUpperCase();
        }
        if (o instanceof ComplexEntryImpl) {
            ComplexEntry ce = ((ComplexEntryImpl)o);
            return ce.getName()+"="+ce.getStringval();
        }
        if (o instanceof UserSetImpl) {
            UserSet us = ((UserSetImpl)o);
            return us.getName();
        }
View Full Code Here


        int consumableLen = 0;
        int defaultLen = 0;
        int urgencyLen = 0;
        //Sort the list alphabetically
        List<ComplexEntry> complexList = sortListByName(cList);
        ComplexEntry ceDummy = new ComplexEntryImpl(true);
        //Need to first get the maximum column lengths
        for (ComplexEntry complex : complexList) {
            nameLen = Math.max(nameLen, complex.getName().length());
            shortcutLen = Math.max(shortcutLen, complex.getShortcut().length());
            typeLen = Math.max(typeLen, ceDummy.typeToString(complex.getValtype()).length());
            requestableLen = Math.max(requestableLen, (complex.getRequestable() == 1) ? 2 : 3); //length of YES, NO
            consumableLen = Math.max(consumableLen, (complex.getConsumable() != 0) ? 3 : 2); //length of YES/JOB, NO);
            defaultLen = Math.max(defaultLen, complex.getDefault().length());
            urgencyLen = Math.max(urgencyLen, complex.getUrgencyWeight().length());
        }
        //Now format the columns
        String header0 = String.format("%-19.19s %-10.10s %-11.11s %-5.5s %-11.11s %-10.10s %-8.8s %-8s", "#name", "shortcut", "type", "relop", "requestable", "consumable", "default", "urgency");
        StringBuilder header1 = new StringBuilder("#");
        for (int j = 0; j < header0.length() - 1; j++) {
            header1.append("-");
        }
        sb.append(header0 + "\n");
        sb.append(header1 + "\n");
        String val;
        //And finally print the columns
        for (ComplexEntry complex : complexList) {
            val = String.format("%-19.19s %-10.10s %-11.11s %-5.5s %-11.11s %-10.10s %-8.8s %-8s", complex.getName(),
                    complex.getShortcut(), ceDummy.typeToString(complex.getValtype()), ceDummy.opToString(complex.getRelop()),
                    ceDummy.reqToString(complex.getRequestable()), Util.getYesNoJobAsString(complex.getConsumable()), complex.getDefault(),
                    complex.getUrgencyWeight());
            sb.append(val + "\n");
        }
        sb.append("# >#< starts a comment but comments are not saved across edits --------\n");
        return sb.toString();
View Full Code Here

                continue;
            }
            if (singleLine.size() != 8) {
                throw new IllegalArgumentException("Expected 8 elements: name, shortcut, type, relop, requestable, consumable, default, urgency");
            }
            ComplexEntry ce = new ComplexEntryImpl(true);
            ce.setName(elem);
            ce.setShortcut(singleLine.get(1));

            val = ce.typeToInt(singleLine.get(2));
            //TODO LP: deny invalid
            ce.setValtype(val);

            val = ce.opToInt(singleLine.get(3));
            //TODO LP: deny invalid
            ce.setRelop(val);

            val = ce.reqToInt(singleLine.get(4));
            //TODO LP: deny invalid
            ce.setRequestable(val);

            ce.setConsumable(Util.getYesNoJobAsInt(singleLine.get(5)));

            ce.setDefault(singleLine.get(6));

            //val = Integer.parseInt((String) singleLine.get(7));
            ce.setUrgencyWeight(singleLine.get(7));

            newCEMap.put(elem, ce);
        }
        //TODO LP: Better to have jgdi.replaceCEList(List newList) and make the checks on qmaster side
        List<ComplexEntry> toModify = new LinkedList<ComplexEntry>();
        List<ComplexEntry> toDelete = new LinkedList<ComplexEntry>();
        List<ComplexEntry> origList = jgdi.getComplexEntryList();

        String name;
        String shortCut;
        for (ComplexEntry ce : origList) {
            name = ce.getName();
            //Check if existing value is modified
            if (newCEMap.containsKey(name)) {
                if (!ce.equalsCompletely(newCEMap.get(name))) {
                    toModify.add(newCEMap.get(name));
                }
                newCEMap.remove(name);
            } else {
                toDelete.add(ce);
            }
        }
        //Add new complexes
        for (String key : newCEMap.keySet()) {
            ComplexEntry ce = newCEMap.get(key);
            try {
                jgdi.addComplexEntry(ce);
            } catch (JGDIException ex) {
                err.println(ex.getMessage());
                setExitCode(ex.getExitCode());
View Full Code Here

    public void setResourceList(final OptionInfo oi) throws JGDIException {
        ResourceFilter resourceList = ResourceFilter.parse(oi.getArgsAsString());
        @SuppressWarnings(value = "unchecked")
        Set<String> names = resourceList.getResourceNames();
        for (String name : names) {
            ComplexEntry ce = new ComplexEntryImpl(name);
            ce.setStringval(resourceList.getResource(name));
            if (hard) {
                job.addHardResource(ce);
            } else {
                job.addSoftResource(ce);
            }
View Full Code Here

    public void setResourceList(final OptionInfo oi) throws JGDIException {
        ResourceFilter resourceList =  ResourceFilter.parse(oi.getArgsAsString());
        @SuppressWarnings("unchecked")
        Set<String> names = resourceList.getResourceNames();
        for(String name: names){
            ComplexEntry ce = new ComplexEntryImpl(name);
            ce.setStringval(resourceList.getResource(name));
            ar.addResource(ce);
        }
        oi.optionDone();
    }
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.configuration.ComplexEntry

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.