⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jobfilereader.java

📁 这是一个基于计算网格的web service。它用java编写。一旦安装完成
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            "",             "",                                 "<! REQUIRED DIRECTIVES !>",            "",            "##################################################################",            "",            "[" + TYPE + "]",            "",            "The job type directive identifies the type of executable / ",            "package being submitted. Only of of these directives can be",            "specified per description. Valid job types are listed at the",            "end of this file.",            "",            "##################################################################",            "",            TYPE + " \"type\"",              "",            "##################################################################",            "",            "[" + EXEC + "]",                                "",                        "The job executable directive identifies the main executable /",            "package to run on the target job host. Only of of these directives",              "can be specified per description. An optional second parameter",            "specifies the relative path the executable should be deployed to",            "on the target job host. If the optional parameter is not",            "specified, the file will be deployed in the deployment path's",            "relative root",            "",            "i.e " + EXEC + " \"/usr/share/myapp/myexec\"" + " \"/bin/\"",             "",            "will cause the file 'myexec' to be deployed to a relative '/bin'",            "path on the platform it is deployed to",              "",            "##################################################################",            "",            EXEC + " \"path to exec\"",              "",            "##################################################################",            "",            "[" + CONSTRAINTS + "]",                     "",            "The constraints directive allows you to specify constraints on",            "target platform the job should be run on. Constraint specification",            "format is described in RFC 2254. The attributes that can be",            "used in constraint specification are listed at the end of the file",            "Only one of these directives can be specified per description",            "",            "i.e. (&(" + GlobalDefs.ATTR_JHOS_NAME + "=Linux)" +                    "(" + GlobalDefs.ATTR_JHOS_VERSION + "=2.6.10-1-386)" +                    "(" + GlobalDefs.ATTR_JHOS_ARCH + "=i386))",            "",            "##################################################################",            "",            CONSTRAINTS + " \"constraints\"",            "",            "##################################################################",            "",            "[" + MAX_DEPLOYMENTS + "]",              "[" + MIN_DEPLOYMENTS + "]",             "",                 "The maximum and minimum deployment directives specify a permittable",            "range of JobHosts this job should be deployed on according to the",            "contraints directive. For example, if the minimum is set to 3 and",            "the maximum to 10, the jobs will only be deployed if at least 3",            "JobHosts can be found which match the constraints. Only one of",            "each of these directives can be specified per description.",            "",            "##################################################################",            "",            MAX_DEPLOYMENTS + " \"1\"",            MIN_DEPLOYMENTS + " \"1\"",                    "",            "##################################################################",                                "",            "<! OPTIONAL DIRECTIVES !>",            "",            "##################################################################",            "",            "[" + INPUT_ARG + "]",              "",            "The input argument directive specifies a parameter that should",            "be passed into the main executable/package on startup. Each",            "individual parameter should be specified by a seperate directive",            "or be specified in the same directive but seperated by double",            "quote characters. ",            "",            "i.e. " + INPUT_ARG + " \"one\"" + " \"two\"",            "and  " + INPUT_ARG + " \"one\"",              "     " + INPUT_ARG + " \"two\"",             "are considered to be the same",            "",            "##################################################################",            "",            INPUT_ARG + " \"input param1\"",            INPUT_ARG + " \"input param2\"",            "",            "##################################################################",            "",            "[" + INPUT_FILE + "]",             "",            "The input file directive specifies an input/data file that is",             "required by the job. An optional second parameter specifies the",            "relative path in which the file should be deployed on the target",            "platform. If the second parameter is not specified, the file",            "will be deployed in the deployment path's relative root. Each",            "input file must be specified in a seperate directive",            "",            "i.e " + INPUT_FILE + " \"/home/myhome/data/data1.dat\" \"/data\"",            "",            "will cause the file data1.dat to be deployed to the relative",            "path /data/ on the target platform.",            "",            "##################################################################",            "",            INPUT_FILE + " \"path to input file 1\"",            INPUT_FILE + " \"path to input file 2\" \"deployment path\"",            "",            "##################################################################",            "",            "[" + ENV_VAR + "]",             "",            "The environment variable directive specifies an environment",            "variable that should be set on the target platform when the ",            "job is run.",            "",            "WARNING: any variable that uses absolute paths should NOT",            "be used since you do not know the layout, permissions or",            "software that is installed on the target platform",            "",            "##################################################################",            "",            ENV_VAR + " \"name1=value1\"",            ENV_VAR + " \"name2=value2\"",            "",            "##################################################################",            "",            "[" + NOTIFY_EMAIL + "]",            "",            "The notify email directive specifies that you wish to receive",            "email notification about job status changes or any errors that",            "occur while attempting to deploy/run the job",            "",            "##################################################################",            "",            NOTIFY_EMAIL + " \"email.address@some.domain.com\"",            "",            "##################################################################",        };                BufferedWriter writer = new BufferedWriter( new FileWriter( file ) );                         try {                        for( int i = 0; i < comments.length; i++ ) {                writer.write( COMMENT + " " + comments[ i ] + "\n" );            }                         writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\n" );            writer.write( COMMENT + " <! JOB TYPES !>\n" );            writer.write( COMMENT + "\n" );                          for( int i = 0; i < GlobalDefs.JOBTYPES.length; i++ ) {                writer.write(                         COMMENT + "\t" + TYPE + " \"" +                          GlobalDefs.JOBTYPES[ i ] + "\"\n" );            }                                     writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\n" );            writer.write( COMMENT + " <! CONSTRAINT ATTRIBUTES !>\n" );             writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHOS_NAME + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHOS_VERSION + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHOS_ARCH + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_VENDOR + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_MODEL + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_COUNT + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_SPEED + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_IDLETIME + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_USERTIME + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHCPU_SYSTIME + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHMEM_TOTAL + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHMEM_FREE + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHDISK_TOTAL + "\n" );            writer.write( COMMENT + "\t" + GlobalDefs.ATTR_JHDISK_FREE + "\n" );                        writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\n" );            writer.write( COMMENT + " <! AUTODETECTED SYSINFO !>\n" );            writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\tOperating System\n" );            writer.write( COMMENT + "\t\tname: " + System.getProperty( "os.name" ) + "\n" );            writer.write( COMMENT + "\t\tver : " + System.getProperty( "os.version" ) + "\n" );            writer.write( COMMENT + "\t\tarch: " + System.getProperty( "os.arch" ) + "\n" );                        writer.write( COMMENT + "\tCPU\n" );            SigarCpuInfo sigarCpuInfo = new SigarCpuInfo();            writer.write( COMMENT + "\t\tcount : " + sigarCpuInfo.getCpuCount() + "\n" );            if ( sigarCpuInfo.getCpuCount() != 0 ) {                net.hyperic.sigar.CpuInfo cpuInfo = sigarCpuInfo.getCpuInfo( 0 );                writer.write( COMMENT + "\t\tvendor: " + cpuInfo.getVendor() + "\n" );                writer.write( COMMENT + "\t\tmodel : " + cpuInfo.getModel() + "\n" );                writer.write( COMMENT + "\t\tspeed : " + cpuInfo.getMhz() + "\n" );            }                        writer.write( COMMENT + "\tMemory\n" );            SigarMemInfo sigarMemInfo = new SigarMemInfo();            writer.write( COMMENT + "\t\ttotal: " + sigarMemInfo.getMem().getRam() + "\n" );                        writer.write( COMMENT + "\n" );            writer.write( COMMENT + "\n" );            writer.write( COMMENT + " <! EXAMPLES !>\n" );            writer.write( COMMENT + "\n" );                         String constraints =                    "(&(" + GlobalDefs.ATTR_JHOS_NAME + "="+ System.getProperty( "os.name" ) +                    ")(" + GlobalDefs.ATTR_JHOS_VERSION + "=" + System.getProperty( "os.version" ) +                    ")(" + GlobalDefs.ATTR_JHOS_ARCH + "=" + System.getProperty( "os.arch" ) + "))";                        writer.write( COMMENT + "\t[\n" );             writer.write( COMMENT + "\t" + TYPE + "\t\t\"java/jar\"\n" );            writer.write( COMMENT + "\t" + EXEC + "\t\t\"/usr/projects/testapps/javaloop/dist/javaloop.jar\"\n" );            writer.write( COMMENT + "\t" + INPUT_ARG + "\t\"6\" \"2\"\n" );            writer.write( COMMENT + "\t" + INPUT_FILE + "\t\"/usr/projects/testapps/javaloop/testdata/data/input1.dat");            writer.write( "\" \"/data/\"\n" );             writer.write( COMMENT + "\t" + INPUT_FILE + "\t\"/usr/projects/testapps/javaloop/testdata/input2.dat");            writer.write( "\" \"/data\"\n" );              writer.write( COMMENT + "\t" + INPUT_FILE + "\t\"/bin/ls\"" + " \"/\"\n" );            writer.write( COMMENT + "\t" + ENV_VAR + "\t\t\"ONE=one\" \"TWO=two\"\n" );             writer.write( COMMENT + "\t" + CONSTRAINTS + "\t\"" + constraints + "\"\n" );            writer.write( COMMENT + "\t" + MAX_DEPLOYMENTS + "\t\"1\"\n" );            writer.write( COMMENT + "\t" + MIN_DEPLOYMENTS + "\t\"1\"\n" );            writer.write( COMMENT + "\t" + NOTIFY_EMAIL + "\t\"email@some.domain.com\"\n" );            writer.write( COMMENT + "\t]\n" );                      } catch ( IOException ioe ) {            throw ioe;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if ( writer != null ) {                    writer.flush();                    writer.close();                    writer = null;                }                            } catch ( Exception e ) {}        }    }        private String[] getLineValues( String src, int lineNum )             throws InvalidJobFileException {        Vector values = new Vector();        String[] result = null;                String[] tokens = src.split( "\"" );        if ( !src.startsWith( "\"" ) ) {            throw new InvalidJobFileException(                    "line " + lineNum + ": values must be enclosed " +                    "in double-quote charaters" );        }                if ( !src.endsWith( "\"" ) ) {            throw new InvalidJobFileException(                    "line " + lineNum + ": values must be enclosed " +                    "in double-quote charaters" );                  }                  if ( tokens.length == 0 ) {            return null;        }                if ( ! (tokens.length % 2 == 0) ) {            throw new InvalidJobFileException(                    "line " + lineNum + ": uneven number of double-quotes" );                     }                         for ( int i = 1; i < tokens.length; i+=2 ) {            values.addElement( tokens[ i ].trim() );        }                result = new String[ values.size() ];                for ( int i = 0; i < values.size(); i++ ) {            result[ i ] = (String) values.elementAt( i );        }                              return result;    }        private void checkDoubleQuotes( String str, int lineNum )             throws InvalidJobFileException {        int count = 0;                for ( int i = 0; i < str.length(); i++ ) {            if ( str.charAt( i ) == '"' ) {                count++;            }        }                if ( (count % 2) != 0 ) {            throw new InvalidJobFileException(                    "line " + lineNum + ": uneven number of double quotes" );        }    }  */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -