Package condor.classad

Examples of condor.classad.Expr


            }
        }
    }

    public ArrayList<OutputDataRecord> getOutputData() throws Exception {
        Expr expr = attributes.get(OUTPUTDATA.toLowerCase());
        if (expr == null) {
            return null;
        }

        ArrayList<OutputDataRecord> outputDataAttribute = new ArrayList<OutputDataRecord>(0);

        if (expr instanceof ListExpr) {
            Iterator iteratorExpr = ((ListExpr) expr).iterator();
            RecordExpr jdlRecExpr = null;
            Expr exprTmp = null;
            OutputDataRecord outputDataRecord = null;

            while (iteratorExpr.hasNext()) {
                outputDataRecord = new OutputDataRecord();
                jdlRecExpr = (RecordExpr) iteratorExpr.next();

                exprTmp = jdlRecExpr.lookup(OUTPUTDATA_OUTPUTFILE);
                if (exprTmp == null) {
                    throw new Exception("OutputFile is mandatory for the OutputData jdl attribute.");
                }
                outputDataRecord.setODOutputFile(exprTmp.stringValue().trim());

                exprTmp = jdlRecExpr.lookup(OUTPUTDATA_LOGICALFILENAME);
                outputDataRecord.setODLogicalFilename((exprTmp != null) ? exprTmp.stringValue().trim() : "");

                exprTmp = jdlRecExpr.lookup(OUTPUTDATA_STORAGEELEMENT);
                outputDataRecord.setODStorageElement((exprTmp != null) ? exprTmp.stringValue().trim() : "");

                outputDataAttribute.add(outputDataRecord);
            }
        } else {
            throw new Exception("Bad format for 'OutputData' jdl attribute.");
View Full Code Here


            } else {
                return null;
            }
        }

        Expr expr = attributes.get(attrName.toLowerCase());
        if (expr instanceof Constant) {
            Constant co = (Constant) expr;

            if (exprType == Expr.INTEGER) {
                try {
                    return new Integer(co.intValue()); // Integer Value
                } catch (Throwable ex) {
                    throw new Exception("wrong type (expected type: integer)");
                }
            } else if (exprType == Expr.BOOLEAN) {
                try {
                    return new Boolean(co.isTrue()); // Boolean Value
                } catch (Throwable ex) {
                    throw new Exception("wrong type (expected type: boolean)");
                }
            } else if (exprType == Expr.REAL) {
                return new Double(co.realValue()); // Real Value
            } else if (exprType == Expr.STRING) {
                String result = co.stringValue();

                if (result != null) {
                    if (result.startsWith("\"") && result.endsWith("\"")) {
                        result = result.substring(1, result.length() - 1);
                    } else if (result.length() == 0) {
                        result = null;
                    }
                }

                return result;
            } else {
                throw new IllegalArgumentException(attrName + ": unexpected type found.");
            }
        }

        if (expr instanceof ListExpr) {
            return getList(expr);
        }

        if (expr != null) {
            String value = expr.toString();
            if (value.length() > 0) {
                if (value.charAt(0) == '"') {
                    value = value.substring(1, value.length() - 1);
                }
            }

            return value;
        }

        throw new Exception("attribute " + attrName + ": " + expr.getClass().getName() + " not supported");
    }
View Full Code Here

        if (!jdl.startsWith("[")) {
            jdl = "[ " + jdl + "]";
        }

        ClassAdParser cp = new ClassAdParser(jdl);
        Expr expr = cp.parse();

        if (expr == null) {
            throw new Exception("Unable to parse: doesn't seem to be a valid Expression");
        } else if (expr.type != Expr.RECORD) {
            throw new Exception("Unable to parse: the parsed expression is not a ClassAd");
        }

        RecordExpr jdlExpr = (RecordExpr) expr;

        String type = null;
        expr = jdlExpr.lookup(TYPE);

        if (expr == null) {
            type = "Job";
        } else if (!expr.isConstant()) {
            throw new Exception(TYPE + " \"" + expr.stringValue() + "\" not allowed");
        } else {
            type = expr.stringValue();
        }

        if (type.equalsIgnoreCase("Job")) {
            String jobType = null;

            expr = jdlExpr.lookup(JOBTYPE);

            if (expr == null) {
                jobType = "Normal";
            } else {
                jobType = expr.stringValue();
            }

            if (!jobType.equalsIgnoreCase("Normal")) {
                throw new Exception(JOBTYPE + " \"" + jobType + "\" not allowed");
            }
View Full Code Here

    private static final Logger logger = Logger.getLogger(NormalJob.class.getName());

    private static String getAttributeValue(JobAd jab, String attribute) {
        String value = null;
        Expr result = jab.lookup(attribute);

        if (result != null) {
            value = result.toString();
            if (value.length() > 0) {
                if (value.charAt(0) == '"') {
                    value = value.substring(1, value.length() - 1);
                }
            }
View Full Code Here

            throw new IllegalArgumentException("JobAd not defined!");
        }

        ArrayList<String> uriArray = new ArrayList<String>(0);

        Expr expression = jab.lookup(sb);
        if (expression == null) {
            return null;
        }

        if (expression instanceof ListExpr) {
View Full Code Here

            throw new IllegalArgumentException("JobAd not defined!");
        }

        ArrayList<String> fileArray = new ArrayList<String>(0);

        Expr expression = jab.lookup(sb);
        if (expression == null) {
            return null;
        }

        if (expression instanceof ListExpr) {
View Full Code Here

        }

        if(jab == null) {
            throw new IllegalArgumentException("JobAd not defined!");
        }
        Expr expression = jab.lookup(sb);

        if (expression == null) {
            return null;
        }

        ArrayList<OutputDataRecord> outputDataAttribute = new ArrayList<OutputDataRecord>(0);

        if (expression instanceof ListExpr) {
            Iterator iteratorExpr = ((ListExpr) expression).iterator();
            RecordExpr jdlRecExpr    = null;
            Expr exprTmp             = null;
            OutputDataRecord outputDataRecord = null;

            while (iteratorExpr.hasNext()) {
                outputDataRecord = new OutputDataRecord();
                jdlRecExpr = (RecordExpr)iteratorExpr.next();
                exprTmp = jdlRecExpr.lookup(Jdl.OD_OUTPUT_FILE);
                if (exprTmp == null) {
                   throw new IllegalArgumentException("OutputFile is mandatory for the OutputData jdl attribute.");
                }
                outputDataRecord.setODOutputFile(exprTmp.stringValue());
                exprTmp = jdlRecExpr.lookup(Jdl.OD_LOGICAL_FILENAME);
                outputDataRecord.setODLogicalFilename((exprTmp != null) ? exprTmp.stringValue() : "");
                exprTmp = jdlRecExpr.lookup(Jdl.OD_STORAGE_ELEMENT);
                outputDataRecord.setODStorageElement((exprTmp != null) ? exprTmp.stringValue() : "");

                outputDataAttribute.add(outputDataRecord);
            }
        } else {
            throw new IllegalArgumentException("Bad format for 'OutputData' jdl attribute.");
View Full Code Here

        if (job.getType() == null) {
            job.setType("normal");
        }

        Expr expression = jobAd.lookup(Jdl.ENVIRONMENT);

        if (expression != null && expression instanceof ListExpr) {
            Iterator item = ((ListExpr) expression).iterator();

            while (item.hasNext()) {
                String tmps = ((Constant) item.next()).stringValue();
                String[] tokens = tmps.split("=", 2);
                job.addEnvironmentAttribute(tokens[0].trim(), tokens[1].trim());
            }
        }

        job.setNodeNumber(1);

        expression = jobAd.lookup(Jdl.CPUNUMB);
        if (expression != null) {
            if (expression.type != Expr.INTEGER || expression.intValue() <= 0) {
                 throw new Exception("wrong value for " + Jdl.CPUNUMB + ": it must be >=1");
            }

            job.setNodeNumber(expression.intValue());
        } else {
            expression = jobAd.lookup(Jdl.NODENUMB);
           
            if (expression != null) {
                if (expression.type != Expr.INTEGER || expression.intValue() <= 0) {
                    throw new Exception("wrong value for " + Jdl.NODENUMB + ": it must be >=1");
                }

                job.setNodeNumber(expression.intValue());
            }
        }

        boolean wholeNodes = false;
        expression = jobAd.lookup(Jdl.WHOLE_NODES);
        if (expression != null && expression.type == Expr.BOOLEAN && expression.isTrue()) {
            wholeNodes = true;
        }

        job.addExtraAttribute(Jdl.WHOLE_NODES, Boolean.toString(wholeNodes));

        expression = jobAd.lookup(Jdl.SMP_GRANULARITY);
        if (expression != null) {
            if (expression.type != Expr.INTEGER || expression.intValue() <= 0) {
                 throw new Exception("wrong value for " + Jdl.SMP_GRANULARITY + ": it must be >=1");
            }

            job.addExtraAttribute(Jdl.SMP_GRANULARITY, "" + expression.intValue());
        }

        expression = jobAd.lookup(Jdl.HOST_NUMBER);
        if (expression != null) {
            if (expression.type != Expr.INTEGER || expression.intValue() <= 0) {
                 throw new Exception("wrong value for " + Jdl.HOST_NUMBER + ": it must be >=1");
            }

            job.addExtraAttribute(Jdl.HOST_NUMBER, "" + expression.intValue());
        }

        if (!wholeNodes && job.containsExtraAttribute(Jdl.SMP_GRANULARITY) && job.containsExtraAttribute(Jdl.HOST_NUMBER)) {
            throw new Exception("the SMPGranularity and HostNumber attributes cannot be specified together when WholeNodes=false");
        }

        expression = jobAd.lookup("PerusalFileEnable");
        if (expression != null && expression.type == Expr.BOOLEAN && expression.isTrue()) {
            expression = jobAd.lookup("PerusalTimeInterval");
            if (expression != null && expression instanceof Constant) {
                job.setPerusalTimeInterval(expression.intValue());
            } else {
                job.setPerusalTimeInterval(5);
            }
            job.setPerusalFilesDestURI(getAttributeValue(jobAd, "PerusalFilesDestURI"));
            job.setPerusalListFileURI(getAttributeValue(jobAd, "PerusalListFileURI"));
View Full Code Here

TOP

Related Classes of condor.classad.Expr

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.