최초커밋
parent
99c3cc581a
commit
02a996ff1d
@ -0,0 +1,134 @@
|
||||
/* */ import java.io.BufferedInputStream;
|
||||
/* */ import java.io.BufferedOutputStream;
|
||||
/* */ import java.io.BufferedReader;
|
||||
/* */ import java.io.FileInputStream;
|
||||
/* */ import java.io.InputStream;
|
||||
/* */ import java.io.InputStreamReader;
|
||||
/* */ import java.net.HttpURLConnection;
|
||||
/* */ import java.net.URL;
|
||||
/* */ import java.util.Properties;
|
||||
/* */ import org.apache.log4j.Logger;
|
||||
/* */ import org.apache.log4j.PropertyConfigurator;
|
||||
/* */ import org.json.simple.JSONObject;
|
||||
/* */
|
||||
/* */
|
||||
/* */ public class CallServerStatusInfo
|
||||
/* */ {
|
||||
/* 17 */ private String[] g_strFTP = new String[6];
|
||||
/* 18 */ private final Logger logger = Logger.getLogger(CallServerStatusInfo.class);
|
||||
/* */
|
||||
/* */
|
||||
/* */ public CallServerStatusInfo() {
|
||||
/* 22 */ PropertyConfigurator.configure("./log4j.properties");
|
||||
/* */
|
||||
/* */
|
||||
/* */ try {
|
||||
/* 26 */ String propFile = "./config.properties";
|
||||
/* */
|
||||
/* */
|
||||
/* 29 */ Properties props = new Properties();
|
||||
/* */
|
||||
/* */
|
||||
/* 32 */ FileInputStream fis = new FileInputStream(propFile);
|
||||
/* */
|
||||
/* */
|
||||
/* 35 */ props.load(new BufferedInputStream(fis));
|
||||
/* */
|
||||
/* */
|
||||
/* 38 */ this.g_strFTP[0] = props.getProperty("server_type_code");
|
||||
/* 39 */ this.g_strFTP[4] = props.getProperty("api_url_server_stat");
|
||||
/* */
|
||||
/* 41 */ props.clear();
|
||||
/* 42 */ props = null;
|
||||
/* */
|
||||
/* 44 */ JSONObject jsonParam = new JSONObject();
|
||||
/* 45 */ jsonParam.put("sysTyCode", this.g_strFTP[0]);
|
||||
/* 46 */ jsonParam.put("sysSttuscode", "2");
|
||||
/* 47 */ callApi(jsonParam.toJSONString());
|
||||
/* */ }
|
||||
/* 49 */ catch (Exception e) {
|
||||
/* 50 */ this.logger.info("Exception : " + e);
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */
|
||||
/* */
|
||||
/* */ private void callApi(String strJson) {
|
||||
/* 56 */ HttpURLConnection connection = null;
|
||||
/* 57 */ InputStream is = null;
|
||||
/* 58 */ InputStreamReader isr = null;
|
||||
/* 59 */ BufferedReader br = null;
|
||||
/* */
|
||||
/* */ try {
|
||||
/* 62 */ URL url = new URL(this.g_strFTP[4]);
|
||||
/* 63 */ this.logger.info("==== 수집서버 주소 : " + this.g_strFTP[4]);
|
||||
/* */
|
||||
/* 65 */ connection = (HttpURLConnection)url.openConnection();
|
||||
/* */
|
||||
/* 67 */ connection.setDoInput(true);
|
||||
/* 68 */ connection.setDoOutput(true);
|
||||
/* 69 */ connection.setUseCaches(false);
|
||||
/* 70 */ connection.setRequestMethod("POST");
|
||||
/* */
|
||||
/* 72 */ connection.setConnectTimeout(30000);
|
||||
/* */
|
||||
/* 74 */ connection.setReadTimeout(30000);
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* 78 */ connection.setRequestProperty("Accept", "application/json");
|
||||
/* 79 */ connection.setRequestProperty("Content-Type", "application/json");
|
||||
/* */
|
||||
/* */
|
||||
/* 82 */ BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
/* 83 */ bos.write(strJson.getBytes("UTF-8"));
|
||||
/* 84 */ bos.flush();
|
||||
/* 85 */ bos.close();
|
||||
/* */
|
||||
/* 87 */ int resCode = connection.getResponseCode();
|
||||
/* 88 */ StringBuffer sb = new StringBuffer();
|
||||
/* 89 */ String inputLine = null;
|
||||
/* */
|
||||
/* 91 */ this.logger.info("==== : " + resCode);
|
||||
/* 92 */ if (resCode == 200) {
|
||||
/* 93 */ is = connection.getInputStream();
|
||||
/* 94 */ isr = new InputStreamReader(is, "UTF-8");
|
||||
/* 95 */ br = new BufferedReader(isr);
|
||||
/* */
|
||||
/* 97 */ while ((inputLine = br.readLine()) != null) {
|
||||
/* 98 */ sb.append(inputLine);
|
||||
/* */ }
|
||||
/* */
|
||||
/* 101 */ this.logger.info("==== " + sb.toString());
|
||||
/* */ }
|
||||
/* 103 */ else if (connection.getErrorStream() != null) {
|
||||
/* 104 */ br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
/* */
|
||||
/* 106 */ while ((inputLine = br.readLine()) != null) {
|
||||
/* 107 */ sb.append(inputLine);
|
||||
/* */ }
|
||||
/* 109 */ this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
/* */ } else {
|
||||
/* 111 */ this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
/* */ }
|
||||
/* */
|
||||
/* 114 */ } catch (Exception e) {
|
||||
/* 115 */ this.logger.info("Exception : " + e);
|
||||
/* 116 */ this.logger.info("==== Http Error Resopnse : ");
|
||||
/* */ } finally {
|
||||
/* */ try {
|
||||
/* 119 */ if (is != null)
|
||||
/* 120 */ is.close();
|
||||
/* 121 */ if (isr != null)
|
||||
/* 122 */ isr.close();
|
||||
/* 123 */ if (br != null)
|
||||
/* 124 */ br.close();
|
||||
/* 125 */ } catch (Exception exception) {}
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
|
||||
/* Location: C:\Users\XIT_LBJ\Desktop\남산 혼잡통행료\운영환경 실 파일\3호 연계서버\car이미지자르\서버스테이터스센드\ServerStatusSend.jar!\CallServerStatusInfo.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,80 @@
|
||||
/* */ import java.io.BufferedInputStream;
|
||||
/* */ import java.io.FileInputStream;
|
||||
/* */ import java.util.ArrayList;
|
||||
/* */ import java.util.Date;
|
||||
/* */ import java.util.Properties;
|
||||
/* */ import org.apache.log4j.Logger;
|
||||
/* */ import org.apache.log4j.PropertyConfigurator;
|
||||
/* */ import org.quartz.Job;
|
||||
/* */ import org.quartz.JobExecutionContext;
|
||||
/* */ import org.quartz.JobExecutionException;
|
||||
/* */ import org.quartz.JobKey;
|
||||
/* */
|
||||
/* */ public class DumbJob
|
||||
/* */ implements Job
|
||||
/* */ {
|
||||
/* */ private String jobSays;
|
||||
/* */ private float myFloatValue;
|
||||
/* */ private ArrayList<Date> state;
|
||||
/* 19 */ private final Logger logger = Logger.getLogger(DumbJob.class);
|
||||
/* */
|
||||
/* */ public DumbJob() {
|
||||
/* 22 */ PropertyConfigurator.configure("./log4j.properties");
|
||||
/* */
|
||||
/* */
|
||||
/* */ try {
|
||||
/* 26 */ String propFile = "./config.properties";
|
||||
/* */
|
||||
/* */
|
||||
/* 29 */ Properties props = new Properties();
|
||||
/* */
|
||||
/* */
|
||||
/* 32 */ FileInputStream fis = new FileInputStream(propFile);
|
||||
/* */
|
||||
/* */
|
||||
/* 35 */ props.load(new BufferedInputStream(fis));
|
||||
/* */
|
||||
/* 37 */ props.clear();
|
||||
/* 38 */ props = null;
|
||||
/* 39 */ } catch (Exception e) {
|
||||
/* 40 */ this.logger.debug("Exception : " + e);
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */ public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
/* 51 */ JobKey key = context.getJobDetail().getKey();
|
||||
/* 52 */ this.state.add(new Date());
|
||||
/* */
|
||||
/* 54 */ this.logger.info("Instance " + key + " of DmbJob says: " + this.jobSays + ", and val is: " + this.myFloatValue +
|
||||
/* 55 */ ", state size:" + this.state.size() + "," + this.state.get(this.state.size() - 1));
|
||||
/* */
|
||||
/* 57 */ this.logger.info("서버 상태정보 전송 시작");
|
||||
/* 58 */ CallServerStatusInfo obj = new CallServerStatusInfo();
|
||||
/* 59 */ this.logger.info("서버 상태정보 전송 완료");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */
|
||||
/* */ public void setJobSays(String jobSays) {
|
||||
/* 64 */ this.jobSays = jobSays;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void setMyFloatValue(float myFloatValue) {
|
||||
/* 68 */ this.myFloatValue = myFloatValue;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void setState(ArrayList<Date> state) {
|
||||
/* 72 */ this.state = state;
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
|
||||
/* Location: C:\Users\XIT_LBJ\Desktop\남산 혼잡통행료\운영환경 실 파일\3호 연계서버\car이미지자르\서버스테이터스센드\ServerStatusSend.jar!\DumbJob.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,75 @@
|
||||
/* */ import java.util.ArrayList;
|
||||
/* */ import org.quartz.CronScheduleBuilder;
|
||||
/* */ import org.quartz.CronTrigger;
|
||||
/* */ import org.quartz.JobBuilder;
|
||||
/* */ import org.quartz.JobDetail;
|
||||
/* */ import org.quartz.ScheduleBuilder;
|
||||
/* */ import org.quartz.Scheduler;
|
||||
/* */ import org.quartz.SchedulerException;
|
||||
/* */ import org.quartz.Trigger;
|
||||
/* */ import org.quartz.TriggerBuilder;
|
||||
/* */ import org.quartz.impl.StdSchedulerFactory;
|
||||
/* */
|
||||
/* */ public class ServerStatusSend
|
||||
/* */ {
|
||||
/* */ public static void main(String[] args) {
|
||||
/* 16 */ String str = "*/1 * * * * ?";
|
||||
/* 17 */ if (args.length > 0) {
|
||||
/* 18 */ str = String.format("*/%s * * * * ?", new Object[] { args[0] });
|
||||
/* */ }
|
||||
/* */
|
||||
/* 21 */ ServerStatusSend svr = new ServerStatusSend();
|
||||
/* 22 */ svr.runServerStatus(str);
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void runServerStatus(String str) {
|
||||
/* */ try {
|
||||
/* 27 */ ArrayList<String> state = new ArrayList<>();
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* 33 */ JobDetail job = JobBuilder.newJob(DumbJob.class)
|
||||
/* 34 */ .withIdentity("testJob")
|
||||
/* 35 */ .usingJobData("jobSays", "ant.xml")
|
||||
/* 36 */ .usingJobData("myFloatValue", Float.valueOf(3.141F)).build();
|
||||
/* */
|
||||
/* 38 */ job.getJobDataMap().put("state", state);
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* 48 */ CronTrigger cronTrigger =
|
||||
/* 49 */ (CronTrigger)TriggerBuilder.newTrigger()
|
||||
/* 50 */ .withIdentity("crontrigger", "crontriggergroup1")
|
||||
/* 51 */ .withSchedule(
|
||||
/* */
|
||||
/* 53 */ (ScheduleBuilder)CronScheduleBuilder.cronSchedule("0 */4 * * * ?"))
|
||||
/* 54 */ .build();
|
||||
/* */
|
||||
/* */
|
||||
/* 57 */ StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
|
||||
/* 58 */ Scheduler sch = stdSchedulerFactory.getScheduler();
|
||||
/* */
|
||||
/* */
|
||||
/* 61 */ sch.start();
|
||||
/* 62 */ sch.scheduleJob(job, (Trigger)cronTrigger);
|
||||
/* */
|
||||
/* */ }
|
||||
/* 65 */ catch (SchedulerException e) {
|
||||
/* 66 */ e.printStackTrace();
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
|
||||
/* Location: C:\Users\XIT_LBJ\Desktop\남산 혼잡통행료\운영환경 실 파일\3호 연계서버\car이미지자르\서버스테이터스센드\ServerStatusSend.jar!\ServerStatusSend.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
Loading…
Reference in New Issue