com.xxl.job.core.util.ScriptUtil Java Examples
The following examples show how to use
com.xxl.job.core.util.ScriptUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptJobHandler.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> execute(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType["+ glueType +"] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat("/") .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); ScriptUtil.markScriptFile(scriptFileName, gluesource); // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:"+ scriptFileName +" -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); ReturnT<String> result = (exitValue==0)?IJobHandler.SUCCESS:new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); return result; }
Example #2
Source File: ScriptJobHandler.java From microservices-platform with Apache License 2.0 | 4 votes |
@Override public ReturnT<String> execute(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType["+ glueType +"] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:"+ scriptFileName +" -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); } }
Example #3
Source File: ScriptJobHandler.java From zuihou-admin-boot with Apache License 2.0 | 4 votes |
@Override public ReturnT<String> execute2(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType[" + glueType + "] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:" + scriptFileName + " -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value(" + exitValue + ") is failed"); } }
Example #4
Source File: ScriptJobHandler.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
@Override public ReturnT<String> execute2(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType[" + glueType + "] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:" + scriptFileName + " -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value(" + exitValue + ") is failed"); } }
Example #5
Source File: ScriptJobHandler.java From xxl-job with GNU General Public License v3.0 | 4 votes |
@Override public ReturnT<String> execute(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType["+ glueType +"] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobContext.getXxlJobContext().getJobLogFileName(); // script params:0=param、1=分片序号、2=分片总数 String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(XxlJobContext.getXxlJobContext().getShardIndex()); scriptParams[2] = String.valueOf(XxlJobContext.getXxlJobContext().getShardTotal()); // invoke XxlJobLogger.log("----------- script file:"+ scriptFileName +" -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); } }