Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
Conflicts:
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/ThreadPoolImp.java
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/p206V1_0_0/TkPreGenObjs.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/pom.xml
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/ServerProperties.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/CommandConsole.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwConfigVo.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/Config.xml
20个文件已删除
3 文件已重命名
24个文件已修改
17个文件已添加
| | |
| | | <dependency> |
| | | <groupId>com.fasterxml.jackson.dataformat</groupId> |
| | | <artifactId>jackson-dataformat-yaml</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>*</groupId> |
| | | <artifactId>*</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <!-- apiå¨çº¿ææ¡£ https://springdoc.org/#modules--> |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å¿
é¡»å®ç°WebMvcConfigurerå¦åä¸å¯ä½ç¨ï¼å³Controller转jsonæ¶ä¸ç¨fastjson |
| | | */ |
| | | @Configuration |
| | | public class FastJsonConfig implements WebMvcConfigurer { |
| | | /** |
| | |
| | | JSONWriter.Feature.WriteMapNullValue, |
| | | //è¾åºnullçboolean 为 false |
| | | JSONWriter.Feature.WriteNullBooleanAsFalse, |
| | | //æLongåè¾åºä¸ºString |
| | | //æLongåè¾åºä¸ºStringï¼å¨pojoç屿§ä¸ä¸ªæ§è®¾ç½® |
| | | //JSONWriter.Feature.WriteLongAsString, |
| | | //è¾åºnullçlist 为 [] |
| | | JSONWriter.Feature.WriteNullListAsEmpty, |
| | | //è¾åºnullçnumber 为 0 |
| | | JSONWriter.Feature.WriteNullNumberAsZero, |
| | | //JSONWriter.Feature.WriteNullNumberAsZero, |
| | | //è¾åºnullå符串 为 "" |
| | | JSONWriter.Feature.WriteNullStringAsEmpty, |
| | | //对mapè¿è¡æåº |
| | |
| | | * org.apache.mina.filter.codec.ProtocolDecoderOutput) |
| | | */ |
| | | protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) { |
| | | String meterNo = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | if(meterNo == null){ |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | if(rtuAddr == null){ |
| | | //ä¼è¯æªè¢«ç®¡ç |
| | | //ä¼è¯ç®¡çå¨ä¸ä¸å卿¤ä¼è¯ï¼è¯´æå建ç«ç½ç»è¿æ¥ï¼ |
| | | return this.doDecode_onLineData(session, in, out) ; |
| | | }else{ |
| | | //ä¼è¯å·²è¢«ç®¡ç |
| | | //ä¼è¯ç®¡çå¨ä¸å卿¤ä¼è¯ï¼è¯´æå·²ç»ä¸çº¿äºï¼ |
| | | return this.doDecode_data(session, in, out, meterNo) ; |
| | | return this.doDecode_data(session, in, out, rtuAddr) ; |
| | | } |
| | | } |
| | | |
| | |
| | | * @param session IOä¼è¯ |
| | | * @param in è¾å
¥Buffer |
| | | * @param out åè®®è¾åºç¼ç |
| | | * @param meterNo æ§å¶å¨ç¼å· |
| | | * @param rtuAddr æ§å¶å¨å°å |
| | | * @return æ¯å¦æ£å¥½æç²å
|
| | | */ |
| | | @SuppressWarnings("unused") |
| | | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String meterNo) { |
| | | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String rtuAddr) { |
| | | //éä¸çº¿æ°æ®ï¼å¯è½ä¼åºç°æå
æç²å
ç°è±¡ |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(in) ; |
| | | if(dataStatus == null){ |
| | | //ä¸å¯è½åç |
| | | log.error("严éé误ï¼Rtu (水表å·ä¸º" + meterNo + ")ä¸è¡æ°æ®å®æ´æ§æ£æ¥æ¶ï¼è¿åç对象为空ã") ; |
| | | log.error("严éé误ï¼Rtu (RTU" + rtuAddr + ")ä¸è¡æ°æ®å®æ´æ§æ£æ¥æ¶ï¼è¿åç对象为空ã") ; |
| | | this.nextDeal(in, null, out) ; |
| | | return true; |
| | | }else{ |
| | |
| | | this.nextDeal(in, dataStatus.getDataLen(), out) ; |
| | | if(dataStatus.isAdjoined()){ |
| | | //说æç²å
äºï¼è¿ææ°æ®ï¼éè¦å¯¹è¿äºæ°æ®å次æ§è¡doDecode_æ¹æ³. |
| | | return this.doDecode_data(session, in, out, meterNo) ;//å ä¸éå½ |
| | | return this.doDecode_data(session, in, out, rtuAddr) ;//å ä¸éå½ |
| | | }else if(dataStatus.isCompleted()){ |
| | | //æ°æ®ä¸æä¸ç² |
| | | return true; |
| | |
| | | |
| | | return this ; |
| | | } |
| | | /* |
| | | public static void main(String[] args){ |
| | | String json = "{\"attachment\":null,\"code\":\"03\",\"deviceId\":\"d8c9601f214747d98d47a4736e5\",\"id\":\"999999999\",\"meterNo\":\"23040600377\",\"productId\":16873252,\"param\":\"0002\",\"protocol\":\"HAC_NBhV2_5\",\"rtuAddr\":\"863318060168996\",\"type\":\"outerCommand\"}" ; |
| | | try { |
| | | Command com = jsonToObject(json) ; |
| | | System.out.println(com.param); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | */ |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | Data d = new Data() ; |
| | | d.code = "01" ; |
| | | d.rtuAddr = "123234" ; |
| | | d.meterNo = "1234567890123456" ; |
| | | |
| | | DataV1_0_1 subD = new DataV1_0_1() ; |
| | | subD.rtuAddr = "2342345" ; |
| | | subD.meterNo = "1234567890123456" ; |
| | | |
| | | |
| | | d.subData = subD ; |
| | | |
| | | |
| | |
| | | this.name = name ; |
| | | } |
| | | |
| | | /** |
| | | * å®é
ä¸è½¬jsonï¼è§Pojoç对åºå±æ§ |
| | | * @return json |
| | | */ |
| | | // public String toString(){ |
| | | // return "{\"code\":" + this.code + "," + "\"name\":" + this.name + "}" ; |
| | | // } |
| | | |
| | | @Override |
| | | public Byte getCode() { |
| | | return this.code ; |
| | |
| | | this.name = name ; |
| | | } |
| | | |
| | | /** |
| | | * å®é
ä¸è½¬jsonï¼è§Pojoç对åºå±æ§ |
| | | * @return json |
| | | */ |
| | | //public String toString(){ |
| | | // return "{\"code\":" + this.code + "," + "\"name\":" + this.name + "}" ; |
| | | //} |
| | | |
| | | @Override |
| | | public Byte getCode() { |
| | | return this.code ; |
| | |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger log = LogManager.getLogger(MonitorThread.class.getName()); |
| | | |
| | | /** |
| | | * å¾å°é»è®¤å¯ä¸å®ä¾ |
| | | * @return |
| | | */ |
| | | // public MyThreadPool getDefaultInstance(){ |
| | | // if(myPool == null){ |
| | | // myPool = new MyThreadPool(null, null, null, null, null) ; |
| | | // } |
| | | // return myPool ; |
| | | // } |
| | | /** |
| | | * å¾å°å¯ä¸å®ä¾ |
| | | * @param poolName |
| | | * @param maxNum |
| | | * @param minNum |
| | | * @param freeTimeout |
| | | * @param busyTimeout |
| | | * @return |
| | | */ |
| | | // public MyThreadPool getInstance( |
| | | // String poolName , |
| | | // Integer maxNum , |
| | | // Integer minNum , |
| | | // Long freeTimeout , |
| | | // Long busyTimeout){ |
| | | // if(myPool == null){ |
| | | // myPool = new MyThreadPool(poolName, maxNum, minNum, freeTimeout, busyTimeout) ; |
| | | // } |
| | | // return myPool ; |
| | | // } |
| | | private static final Logger log = LogManager.getLogger(MonitorThread.class) ; |
| | | |
| | | /** |
| | | * çº¿ç¨æ± æé æ¹æ³ |
| | |
| | | } |
| | | this.poolName = poolName ; |
| | | |
| | | if(maxNum == null || maxNum.intValue() <= 0){ |
| | | maxNum = -1 ; |
| | | if(maxNum == null || maxNum.intValue() < 0){ |
| | | maxNum = 65535 ; |
| | | } |
| | | if(minNum == null || minNum.intValue() < 0){ |
| | | minNum = 0 ; |
| | |
| | | }else{ |
| | | this.busyTimeout = busyTimeout ; |
| | | } |
| | | |
| | | this.busiThreads = new ArrayList<MyThread>(); |
| | | this.freeThreads = new ArrayList<MyThread>(); |
| | | |
| | | //æå°åçº¿ç¨æ± |
| | | for (int i = 0; i < this.minNum ; i++) { |
| | | MyThread t = new MyThread(this); |
| | | t.start(); |
| | | this.freeThreads.add(t); |
| | | this.currNum++; |
| | | if(maxNum != 0){ |
| | | this.busiThreads = new ArrayList<>(); |
| | | this.freeThreads = new ArrayList<>(); |
| | | //æå°åçº¿ç¨æ± |
| | | for (int i = 0; i < this.minNum ; i++) { |
| | | MyThread t = new MyThread(this); |
| | | t.start(); |
| | | this.freeThreads.add(t); |
| | | this.currNum++; |
| | | } |
| | | this.monitorThread = new MonitorThread(this) ; |
| | | this.monitorThread.start() ; |
| | | } |
| | | |
| | | this.monitorThread = new MonitorThread(this) ; |
| | | this.monitorThread.start() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void putJob(Job job) throws Exception { |
| | | if(this.busiThreads == null || this.freeThreads == null){ |
| | | throw new Exception("çº¿ç¨æ± æªå¯å¨") ; |
| | | } |
| | | synchronized(this.synObj) { |
| | | //log.debug("å·¥ä½ä»»å¡åé
å°çº¿ç¨æ± ä¸ã") ; |
| | | MyThread t = null ; |
| | |
| | | /** |
| | | * 线ç¨å·¥ä½å®æï¼ä»busiThreadsåå½freeThreads |
| | | */ |
| | | protected void freeThread(MyThread t) { |
| | | protected void freeThread(MyThread t) throws Exception { |
| | | if(this.busiThreads == null || this.freeThreads == null){ |
| | | throw new Exception("çº¿ç¨æ± æªå¯å¨") ; |
| | | } |
| | | synchronized (synObj) { |
| | | busiThreads.remove(t); |
| | | freeThreads.add(t); |
| | |
| | | |
| | | /** |
| | | * |
| | | * @param pool |
| | | * @param pool æ± |
| | | */ |
| | | public MonitorThread(MyThreadPool pool){ |
| | | this.pool = pool ; |
| | |
| | | } |
| | | }//end synchronized (pool.synObj) |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | }finally{ |
| | | continue ; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 设置线ç¨å·¥ä½å¯¹è±¡ |
| | | * @param job |
| | | * @param job å·¥ä½ |
| | | */ |
| | | protected void putJob(Job job) throws Exception { |
| | | if(job == null){ |
| | |
| | | } |
| | | |
| | | public void free(){ |
| | | //使æ¬çº¿ç¨åå½ç©ºé²çº¿ç¨æ± |
| | | pool.freeThread(this); |
| | | //空é²å¼å§è®°æ¶ |
| | | this.time = System.currentTimeMillis() ; |
| | | // 没æå¯åçäº |
| | | this.canJob = false; |
| | | log.debug("çº¿ç¨æ± (" + this.pool.poolName + ")ä¸ç线ç¨åå½ç©ºé²éåã"); |
| | | try{ |
| | | //使æ¬çº¿ç¨åå½ç©ºé²çº¿ç¨æ± |
| | | pool.freeThread(this); |
| | | //空é²å¼å§è®°æ¶ |
| | | this.time = System.currentTimeMillis() ; |
| | | // 没æå¯åçäº |
| | | this.canJob = false; |
| | | log.debug("çº¿ç¨æ± (" + this.pool.poolName + ")ä¸ç线ç¨åå½ç©ºé²éåã"); |
| | | }catch (Exception e){ |
| | | log.error("çº¿ç¨æ± (" + pool.poolName + ")çå·¥ä½çº¿ç¨éæ¾å彿¶åçå¼å¸¸:\n" + e.getMessage(), e); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | target/ |
| | | /pipIrr-global.iml |
| | | /pipIrr-global.iml |
| | |
| | | HELP.md |
| | | target/ |
| | | /pipIrr-mw.iml |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | !**/src/main/**/target/ |
| | | !**/src/test/**/target/ |
| | | |
| | | ### STS ### |
| | | .apt_generated |
| | | .classpath |
| | | .factorypath |
| | | .project |
| | | .settings |
| | | .springBeans |
| | | .sts4-cache |
| | | |
| | | ### IntelliJ IDEA ### |
| | | .idea |
| | | *.iws |
| | | *.iml |
| | | *.ipr |
| | | |
| | | ### NetBeans ### |
| | | /nbproject/private/ |
| | | /nbbuild/ |
| | | /dist/ |
| | | /nbdist/ |
| | | /.nb-gradle/ |
| | | build/ |
| | | !**/src/main/**/build/ |
| | | !**/src/test/**/build/ |
| | | |
| | | ### VS Code ### |
| | | .vscode/ |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal.p206V1_0_0; |
| | | |
| | | import com.dy.aceMw.server.busi.deal.TaskSurpport; |
| | | import com.dy.common.mw.protocol.Data; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | public class TkPreGenObjs extends TaskSurpport { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TkPreGenObjs.class.getName()) ; |
| | | |
| | | //ç±»IDï¼ä¸å®ä¸Tree.xmlé
ç½®æä»¶ä¸é
ç½®ä¸è´ |
| | | public static final String taskId = "TkPreGenObjs" ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void execute(Object data) { |
| | | Data d = (Data)data ; |
| | | String rtuAddr = d.getRtuAddr() ; |
| | | //å¾å°æ¬å°RTU æ°æ®ï¼ä»¥å¤åé¢èç¹åºç¨ |
| | | /* |
| | | BuziInterface baseBusi = BuziGeter.getBaseBusi() ; |
| | | BuziInterface orgBusi = null ; |
| | | SyRtu nbRtu = null ; |
| | | SyRtuTramp rtuTramp = null ; |
| | | if(baseBusi != null){ |
| | | nbRtu = DbSyBuzi.getRtu(baseBusi, imei) ; |
| | | if(nbRtu != null){ |
| | | //æ°æ®åºä¸æ¥è¯¢å°NB产åï¼RTUå®ä½ï¼ |
| | | if(nbRtu.orgTag != null && !nbRtu.orgTag.trim().equals("")){ |
| | | orgBusi = BuziGeter.getBusi(nbRtu.orgTag) ; |
| | | if(orgBusi == null){ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°æ ç¾ä¸º" + nbRtu.orgTag + "ç便°´æºææ°æ®åºä¸å¡Busi"); |
| | | }else{ |
| | | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, rtuAddr) ; |
| | | //å¯è½æªæ¥è¯¢å°meterï¼å³ä»æ¯æµæµªè
RTUï¼ä½ä»è¦åç»å¤çï¼ï¼1ï¼ãä»è½è¯å«åºæµæµªè
RTUï¼ï¼2ï¼ãä»è¦è®°å½å
¶ä¸æ¥æ°æ® |
| | | if(meter != null){ |
| | | String protocol = d.getProtocol() ; |
| | | if(protocol != null){ |
| | | protocol = protocol.trim(); |
| | | if(!protocol.equals("")){ |
| | | if(meter.protocol == null |
| | | || meter.protocol.trim().equals("") |
| | | || !meter.protocol.trim().equals(protocol)){ |
| | | //éè¦æ´æ°åè®®åç§° |
| | | DbOrgBuzi.updateMeter4Protocol(orgBusi, meter.id, protocol); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, null, meter} ; |
| | | this.toNextTasks(data); |
| | | } |
| | | }else{ |
| | | //NB产åï¼RTUå®ä½ï¼æªåé
ç»å
·ä½ç便°´æºæ |
| | | //æµæµªè
RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | | } |
| | | }else{ |
| | | //æ°æ®åºä¸æªæ¥è¯¢å°NB产åï¼RTUå®ä½ï¼ |
| | | //æµæµªè
RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | | } |
| | | }else{ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°BaseBusi对象"); |
| | | } |
| | | */ |
| | | } |
| | | } |
| | |
| | | //æ¯ææ¨¡åï¼ springHibernateå çº¿ç¨æ± |
| | | SupportUnitConfigVo supVo = new SupportUnitConfigVo() ; |
| | | //ç工使¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾ççå·¥ä½ä»»å¡ |
| | | supVo.short_maxThread = conf.getSetAttrPlusInt(doc, "config.support", "short_maxThread", null, 1, 1000, null) ;//æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1 |
| | | supVo.short_minThread = conf.getSetAttrPlusInt(doc, "config.support", "short_minThread", null, 1, 5, null) ;//æ± ä¸æå°çº¿ç¨æ° |
| | | supVo.short_maxThread = conf.getSetAttrPlusInt(doc, "config.support", "short_maxThread", null, -1, 1000, null) ;//æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1 |
| | | if(supVo.short_maxThread < 0){ |
| | | supVo.short_maxThread = -1 ; |
| | | } |
| | | supVo.short_minThread = conf.getSetAttrPlusInt(doc, "config.support", "short_minThread", null, -1, 100, null) ;//æ± ä¸æå°çº¿ç¨æ° |
| | | if(supVo.short_minThread < 0){ |
| | | supVo.short_minThread = -1 ; |
| | | } |
| | | supVo.short_freeTimeout = conf.getSetAttrPlusInt(doc, "config.support", "short_freeTimeout", null, 1, 90, null) * 1000 ;//çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ï¼ä¸ºäºä¸æ¸
é¤ï¼æminThreadä¸maxThread设置ç¸ç |
| | | supVo.short_busyTimeout = conf.getSetAttrPlusInt(doc, "config.support", "short_busyTimeout", null, 1, 10, null) * 1000 ;//线ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è®¤ä¸ºçº¿ç¨å·²ç»äºå´©æºï¼å°å¼ºå¶æ¸
é¤ï¼ç工使¶é¿è®¾ç½®ä¸º5ç§ |
| | | if(supVo.short_maxThread == 0 || supVo.short_minThread == 0){ |
| | | supVo.enableShortThreadPool = false ; |
| | | }else{ |
| | | supVo.enableShortThreadPool = true ; |
| | | } |
| | | |
| | | //é¿å·¥ä½æ¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾é¿çå·¥ä½ä»»å¡ |
| | | supVo.long_maxThread = conf.getSetAttrInt(doc, "config.support", "long_maxThread", null, -1, 1000, null) ;//æ± ä¸æå¤§çº¿ç¨æ°,è¥ä¸º-1ï¼ä¸åéå¶ |
| | | if(supVo.long_maxThread < 0){ |
| | | supVo.long_maxThread = -1 ; |
| | | } |
| | | supVo.long_minThread = conf.getSetAttrPlusInt(doc, "config.support", "long_minThread", null, 0, 5, null) ;//æ± ä¸æå°çº¿ç¨æ° |
| | | supVo.long_minThread = conf.getSetAttrPlusInt(doc, "config.support", "long_minThread", null, -1, 100, null) ;//æ± ä¸æå°çº¿ç¨æ° |
| | | if(supVo.long_minThread < 0){ |
| | | supVo.long_minThread = -1 ; |
| | | } |
| | | supVo.long_freeTimeout = conf.getSetAttrPlusInt(doc, "config.support", "long_freeTimeout", null, 1, 90, null) * 1000 ;//çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ |
| | | supVo.long_busyTimeout = conf.getSetAttrInt(doc, "config.support", "long_busyTimeout", null, -1, 10, null) ;//线ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | if(supVo.long_busyTimeout < 0){ |
| | | supVo.long_busyTimeout = -1 ; |
| | | } |
| | | if(supVo.long_maxThread == 0 || supVo.long_minThread == 0){ |
| | | supVo.enableLongThreadPool = false ; |
| | | }else{ |
| | | supVo.enableLongThreadPool = true ; |
| | | } |
| | | |
| | | supVo.showStartInfo = showStartInfo ; |
| | |
| | | // Tcp Client 模å |
| | | TcpClUnitConfigVo tcpClVo = new TcpClUnitConfigVo(); |
| | | tcpClVo.enable = conf.getSetAttrBoolean(doc, "config.tcpCl", "enable", null, null) ; |
| | | tcpClVo.heartbeatTimes = conf.getSetAttrPlusInt(doc, "config.tcpCl", "heartbeatTimes", null, 1, 10, null) ;//è¿ç»é
置次æ°å¿è·³ååé䏿¬¡æ°æ® |
| | | tcpClVo.sendInterval = conf.getSetAttrPlusInt(doc, "config.tcpCl", "sendInterval", null, 1, 60, null) ;//åéå¿è·³ææ°æ®çæ¶é´é´é |
| | | if(tcpClVo.enable){ |
| | | AdapterImp_TcpClUnit httpClAdap = new AdapterImp_TcpClUnit(); |
| | | httpClAdap.setConfig(tcpClVo); |
| | |
| | | //RTUæªæ¢å°å |
| | | public static Long rtuAddrEnd = 0L ; |
| | | //æå¡ç«¯IP |
| | | public static String serverIp = "" ; |
| | | public static String tcpServerIp = "" ; |
| | | //æå¡ç«¯ä¸ä¸æ |
| | | public static Integer serverPort = 0 ; |
| | | public static Integer tcpServerPort = 0 ; |
| | | //åéæ°æ®æ°æ®é´é |
| | | public static Integer sendInterval = 0 ;//ç§ |
| | | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³æ°æ®çæ¬¡æ° |
| | | public static Integer heartbeatTimes = 3 ; |
| | | //åéæ°æ®æ¬¡æ° |
| | | public static Integer sendTimes = 0 ; |
| | | |
| | |
| | | public static String cd3 = "003" ;//请æ±å¼å§å·¥ä½ |
| | | |
| | | public static String cd4 = "004" ;//åæå¡ç«¯ä¸æ¥ä¿¡æ¯ |
| | | |
| | | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥ æ°æ®ä¸æ¥å·¥ä½å·²ç»å®æ |
| | | |
| | | |
| | | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥ 宿任å¡çæ°é |
| | | |
| | | public static String cd6 = "006" ;//åæå¡ç«¯ä¸æ¥ å
¨é¨ä»»å¡å®æ |
| | | |
| | | } |
| | |
| | | //模æå®¢æ·çIMEIå·æªæ¢å· |
| | | public Long rtuAddrEnd = 0L ; |
| | | //æå¡ç«¯IP |
| | | public String serverIp = "" ; |
| | | public String tcpServerIp = "" ; |
| | | //æå¡ç«¯ä¸ä¸æ |
| | | public Integer serverPort = 0 ; |
| | | public Integer tcpServerPort = 0 ; |
| | | //åéæ°æ®é´é |
| | | public Integer sendInterval = 2 ;//ç§ |
| | | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° |
| | | public Integer heartbeatTimes = 3 ; |
| | | //åéæ°æ®æ¬¡æ° |
| | | public Integer sendTimes = 0 ; |
| | | |
| | | |
| | | /** |
| | | * 对象转æjson |
| | | * @return 对象json |
| | |
| | | this.rtuAddrEnd = rtuAddrEnd; |
| | | } |
| | | |
| | | public String getServerIp() { |
| | | return serverIp; |
| | | public String getTcpServerIp() { |
| | | return tcpServerIp; |
| | | } |
| | | |
| | | public void setServerIp(String serverIp) { |
| | | this.serverIp = serverIp; |
| | | public void setTcpServerIp(String tcpServerIp) { |
| | | this.tcpServerIp = tcpServerIp; |
| | | } |
| | | |
| | | public Integer getServerPort() { |
| | | return serverPort; |
| | | public Integer getTcpServerPort() { |
| | | return tcpServerPort; |
| | | } |
| | | |
| | | public void setServerPort(Integer serverPort) { |
| | | this.serverPort = serverPort; |
| | | public void setTcpServerPort(Integer tcpServerPort) { |
| | | this.tcpServerPort = tcpServerPort; |
| | | } |
| | | |
| | | public Integer getSendInterval() { |
| | | return sendInterval; |
| | | } |
| | | |
| | | public void setSendInterval(Integer sendInterval) { |
| | | this.sendInterval = sendInterval; |
| | | } |
| | | |
| | | public Integer getHeartbeatTimes() { |
| | | return heartbeatTimes; |
| | | } |
| | | |
| | | public void setHeartbeatTimes(Integer heartbeatTimes) { |
| | | this.heartbeatTimes = heartbeatTimes; |
| | | } |
| | | |
| | | public Integer getSendTimes() { |
| | |
| | | } |
| | | |
| | | //ææ°æ®ä¸æ¥å®ææ
åµ ä¸æ¥ç»mwTestServer |
| | | public void reportHadReportOver(Long seconds){ |
| | | public void reportHadReportOver(Integer count){ |
| | | try { |
| | | Thread.sleep(100L); |
| | | RmiRequestVo rqVo = new RmiRequestVo() ; |
| | | rqVo.id = id ; |
| | | rqVo.token = token ; |
| | | rqVo.code = Code.cd5 ; |
| | | rqVo.count = count ; |
| | | String json = rqVo.toJson() ; |
| | | frmWork.syncRequest(json) ; |
| | | } catch (Exception e) { |
| | | log.error("ææ°æ®ä¸æ¥å®ææ
åµ ä¸æ¥ç»mwTestServer失败" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | //ææ°æ®ä¸æ¥å®ææ
åµ ä¸æ¥ç»mwTestServer |
| | | public void allOver(Long seconds){ |
| | | try { |
| | | Thread.sleep(100L); |
| | | RmiRequestVo rqVo = new RmiRequestVo() ; |
| | | rqVo.id = id ; |
| | | rqVo.token = token ; |
| | | rqVo.code = Code.cd6 ; |
| | | rqVo.over = true ; |
| | | rqVo.seconds = seconds ; |
| | | String json = rqVo.toJson() ; |
| | |
| | | if(rVo != null){ |
| | | ServerProperties.rtuAddrStart = rVo.rtuAddrStart; |
| | | ServerProperties.rtuAddrEnd = rVo.rtuAddrEnd; |
| | | ServerProperties.serverIp = rVo.serverIp; |
| | | ServerProperties.serverPort = rVo.serverPort; |
| | | ServerProperties.tcpServerIp = rVo.tcpServerIp; |
| | | ServerProperties.tcpServerPort = rVo.tcpServerPort; |
| | | ServerProperties.sendInterval = rVo.sendInterval ; |
| | | ServerProperties.heartbeatTimes = rVo.heartbeatTimes ; |
| | | ServerProperties.sendTimes = rVo.sendTimes ; |
| | | log.info("å¾å°é
ç½®æå"); |
| | | log.info(" å¼å§RtuAddr=" + ServerProperties.rtuAddrStart); |
| | | log.info(" æªæ¢RtuAddr=" + ServerProperties.rtuAddrEnd); |
| | | log.info(" mwAcceptæå¡IP=" + ServerProperties.serverIp); |
| | | log.info(" mwAcceptæå¡ç«¯å£=" + ServerProperties.serverPort); |
| | | log.info(" æ¯imei䏿¥æ°æ®æ¬¡æ°=" + ServerProperties.sendTimes); |
| | | log.info(" mwAcceptæå¡IP=" + ServerProperties.tcpServerIp); |
| | | log.info(" mwAcceptæå¡ç«¯å£=" + ServerProperties.tcpServerPort); |
| | | log.info(" åéæ°æ®é´é=" + ServerProperties.sendTimes); |
| | | log.info(" æ¯è½®æ¬¡åéå¿è·³æ¬¡æ°=" + ServerProperties.heartbeatTimes); |
| | | log.info(" æ¯RTU䏿¥æ°æ®è½®æ¬¡=" + ServerProperties.sendTimes); |
| | | break ; |
| | | }else{ |
| | | log.error("rmiå¾å°é
置失败ï¼json转ResConfigVo为null"); |
| | |
| | | package com.dy.testClient.rmiClient; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | |
| | | public class RmiResponseVo { |
| | | |
| | |
| | | public String errorInfo ; |
| | | |
| | | public String code ; |
| | | |
| | | |
| | | public Object obj ; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static RmiResponseVo jsonToObject(String json, Class<?> clazz)throws Exception{ |
| | | try{ |
| | | return JSON.parseObject(json, RmiResponseVo.class) ; |
| | | //JSONDeserializer<RmiResponseVo> jsonD = new JSONDeserializer<RmiResponseVo>() ; |
| | | //jsonD.use("obj", clazz) ; |
| | | //RmiResponseVo resp = jsonD.deserialize(json, RmiResponseVo.class) ; |
| | | //return resp ; |
| | | JSONObject jsonObject = JSON.parseObject(json); |
| | | RmiResponseVo vo = jsonObject.to(RmiResponseVo.class) ; |
| | | vo.obj = jsonObject.getObject("obj", clazz); |
| | | return vo ; |
| | | }catch(Exception e){ |
| | | throw new Exception(e.getMessage() , e ) ; |
| | | } |
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpConnect/LocalCodecFactory.java |
| | |
| | | package com.dy.testClient.tcpConnect; |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import org.apache.mina.filter.codec.ProtocolCodecFactory; |
| | | import org.apache.mina.filter.codec.ProtocolEncoder; |
| | | import org.apache.mina.filter.codec.ProtocolDecoder; |
| | | import org.apache.mina.core.session.IoSession; |
| | | import org.apache.mina.filter.codec.ProtocolCodecFactory; |
| | | import org.apache.mina.filter.codec.ProtocolDecoder; |
| | | import org.apache.mina.filter.codec.ProtocolEncoder; |
| | | |
| | | public class LocalCodecFactory implements ProtocolCodecFactory { |
| | | private ProtocolEncoder encoder; |
| New file |
| | |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; |
| | | import org.apache.mina.filter.codec.ProtocolDecoderOutput; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | public class LocalDecoder extends CumulativeProtocolDecoder { |
| | | |
| | | private static final String DECODER_STATE_KEY = LocalDecoder.class.getName() + ".STATE"; |
| | | |
| | | public static final int MAX_SIZE = 2147483647 ; |
| | | |
| | | |
| | | /** |
| | | * 对ç½ç»ä¼ è¾æ¥çæ°æ®è¿è¡è§£ç |
| | | */ |
| | | protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws IOException, Exception{ |
| | | int remain = in.remaining() ; |
| | | if(remain > 0){ |
| | | byte[] preByte = new byte[remain]; |
| | | in.get(preByte) ; |
| | | in.position(0) ; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | import org.apache.mina.filter.codec.ProtocolEncoderAdapter; |
| | | import org.apache.mina.filter.codec.ProtocolEncoderOutput; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | public class LocalEncoder extends ProtocolEncoderAdapter { |
| | | |
| | | /** |
| | | * å¯¹æ°æ®è¿è¡ç¼ç ï¼ä»¥å¤ç½ç»ä¼ è¾ |
| | | */ |
| | | public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws IOException, Exception{ |
| | | byte[] data = (byte[])message; |
| | | //log.info("ä¸è¡æ°æ®ï¼" + ByteUtil.bytes2Hex(data, true)); |
| | | |
| | | out.write(IoBuffer.allocate((data==null?0:data.length), false).put(data).flip()); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; |
| | | import com.dy.common.threadPool.ThreadPool; |
| | | import com.dy.testClient.httpCl.*; |
| | | |
| | | import java.util.Base64; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.testClient.ServerProperties; |
| | | import org.apache.mina.core.future.CloseFuture; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | public class MyThreadJob implements ThreadPool.Job { |
| | | |
| | | public String rtuAddr; |
| | | public String serverIp; |
| | | public Integer serverPort; |
| | | |
| | | public IoSession session ; |
| | | |
| | | public static final int connectTimeout = 3000 ; |
| | | |
| | | public int sendTimes = 0 ;//åéæ°æ®æ¬¡æ° |
| | | public int heartbeatTimes = 0 ;//䏿¥å¿è·³æ¬¡æ° |
| | | |
| | | public boolean isOver = false ; |
| | | |
| | | public MyThreadJob(){ |
| | | } |
| | | public MyThreadJob(String rtuAddr){ |
| | | public MyThreadJob(String rtuAddr, String serverIp, Integer serverPort){ |
| | | this.rtuAddr = rtuAddr ; |
| | | this.serverIp = serverIp ; |
| | | this.serverPort = serverPort ; |
| | | } |
| | | |
| | | @Override |
| | | public void execute() throws Exception { |
| | | testP206V1_0_0() ; |
| | | } |
| | | |
| | | private void testP206V1_0_0(){ |
| | | try{ |
| | | RtuData4MeterV1_0 rd = new RtuData4MeterV1_0() ; |
| | | byte[] bs = rd.create(rtuAddr) ; |
| | | bs = Base64.getEncoder().encode(bs) ; |
| | | |
| | | UpDataPayloadVo payloadVo = new UpDataPayloadVo() ; |
| | | payloadVo.APPdata = new String(bs, "UTF-8") ; |
| | | |
| | | UpDataVo vo = new UpDataVo(rtuAddr, "8086" + rtuAddr) ; |
| | | vo.payload = payloadVo ; |
| | | String json = vo.toJson() ; |
| | | byte[] bytes = json.getBytes() ; |
| | | HttpPost.post(bytes); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | }finally{ |
| | | HttpClUnit.clientOver() ; |
| | | if(session == null){ |
| | | IoSession se = new TcpConnect().createSession(this.rtuAddr, this, this.serverIp, this.serverPort, connectTimeout, new TcpHandler()) ; |
| | | if(se != null){ |
| | | this.session = se ; |
| | | } |
| | | }else{ |
| | | if(sendTimes <= ServerProperties.sendTimes){ |
| | | sendDataOfP206V1_0_0() ; |
| | | }else{ |
| | | this.jobOver() ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void sendDataOfP206V1_0_0(){ |
| | | try{ |
| | | if(heartbeatTimes >= ServerProperties.heartbeatTimes){ |
| | | heartbeatTimes = 0 ; |
| | | this.sendReportData() ; |
| | | sendTimes++ ; |
| | | }else{ |
| | | this.sendHeartbeat() ; |
| | | heartbeatTimes++ ; |
| | | } |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | private void sendHeartbeat(){ |
| | | try{ |
| | | byte[] bs = this.createHeartbeat() ; |
| | | this.session.write(bs) ; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void sendReportData(){ |
| | | TcpClUnit.clientSendData(); |
| | | } |
| | | |
| | | private void jobOver(){ |
| | | CloseFuture closeFuture = session.closeOnFlush() ; |
| | | this.isOver = true ; |
| | | TcpClUnit.clientOver() ; |
| | | } |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] createHeartbeat( ) throws Exception { |
| | | CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; |
| | | byte[] bytes ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; |
| | | |
| | | index++ ; |
| | | GlCreate.createRtuAddr(this.rtuAddr, bsHead, index); |
| | | index += 5 ; |
| | | |
| | | ByteUtil.hex2Bytes("02", bsHead, index) ; |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
| | | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void destroy() { |
| | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class TcpClUnit implements UnitInterface { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TcpClUnit.class) ; |
| | |
| | | public static TcpClUnitConfigVo confVo ; |
| | | |
| | | private static ThreadPool.Pool pool ; |
| | | private static Map<String, MyThreadJob> jobMap = new HashMap<>() ; |
| | | |
| | | private static Integer totalRunedClientCount = 0; |
| | | private static Integer totalSendDataCount = 0; |
| | | private static Integer totalOverClientCount = 0; |
| | | |
| | | private static Long startTime = 0L ; |
| | |
| | | startTime = System.currentTimeMillis() ; |
| | | for(Long addr = ServerProperties.rtuAddrStart; addr <= ServerProperties.rtuAddrEnd; addr++){ |
| | | totalRunedClientCount++ ; |
| | | startClient(addr) ; |
| | | createImitate(addr) ; |
| | | } |
| | | startJob() ; |
| | | while(true){ |
| | | if(totalOverClientCount.longValue() >= totalRunedClientCount.longValue()){ |
| | | Long seconds = (System.currentTimeMillis() - startTime)/1000 ; |
| | | RmiClUnit.getInstance().reportHadReportOver(seconds) ; |
| | | RmiClUnit.getInstance().allOver(seconds) ; |
| | | System.out.println("å
±ç¨æ¶" + seconds + "ç§"); |
| | | break ; |
| | | }else{ |
| | |
| | | }).start(); |
| | | } |
| | | |
| | | private void startClient(Long rtuAddr){ |
| | | try { |
| | | pool.putJob(new MyThreadJob("" + rtuAddr)); |
| | | } catch (Exception e) { |
| | | log.error("TcpClUnit.startClient() ", e); |
| | | } |
| | | /** |
| | | * å建RTU模æMyThreadJob |
| | | * @param rtuAddr rtuå°å |
| | | */ |
| | | private void createImitate(Long rtuAddr){ |
| | | jobMap.put("" + rtuAddr, new MyThreadJob("" + rtuAddr, ServerProperties.tcpServerIp, ServerProperties.tcpServerPort)) ; |
| | | } |
| | | |
| | | private void startJob(){ |
| | | new Thread(new Runnable(){ |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(1000L); |
| | | while(true){ |
| | | Collection<MyThreadJob> collection = jobMap.values() ; |
| | | for(MyThreadJob job : collection){ |
| | | pool.putJob(job); |
| | | } |
| | | Thread.sleep(ServerProperties.sendInterval * 1000); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | public static synchronized void clientSendData(){ |
| | | totalSendDataCount++; |
| | | if(totalSendDataCount % 100 == 0){ |
| | | RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount); |
| | | System.out.println("å·²ç»åé" + totalSendDataCount + "æ¡æ°æ®"); |
| | | } |
| | | } |
| | | |
| | | public static synchronized void clientOver(){ |
| | | totalOverClientCount++; |
| | | if(totalOverClientCount % 100 == 0){ |
| | | RmiClUnit.getInstance().reportHadReportCount(totalOverClientCount); |
| | | System.out.println("å·²ç»åé" + totalOverClientCount + "æ¡æ°æ®"); |
| | | RmiClUnit.getInstance().reportHadReportOver(totalOverClientCount); |
| | | System.out.println("å·²æ" + totalOverClientCount + "宿äºä»»å¡"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public class TcpClUnitConfigVo { |
| | | public boolean enable ; |
| | | public int heartbeatTimes ; |
| | | public int sendInterval ; |
| | | } |
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpConnect/MinaConnect.java |
| | |
| | | package com.dy.testClient.tcpConnect; |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import org.apache.mina.core.future.ConnectFuture; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | import org.apache.mina.filter.codec.ProtocolCodecFilter; |
| | | import org.apache.mina.transport.socket.SocketConnector; |
| | | import org.apache.mina.transport.socket.nio.NioSocketConnector; |
| | | |
| | | import java.net.InetSocketAddress; |
| | | |
| | | public class MinaConnect { |
| | | public class TcpConnect { |
| | | |
| | | public static final String rtuAddrKey = "rtuAddr" ; |
| | | public static final String threadJobKey = "threadJob" ; |
| | | |
| | | /** |
| | | * 夿ä¼è¯æ¯å¦ææ |
| | | * @param se ç½ç»ä¼è¯ |
| | | * @return æ¯å¦è¿æ¥ |
| | | */ |
| | | protected boolean isConnected(IoSession se) { |
| | | public boolean isConnected(IoSession se) { |
| | | return (se != null && se.isConnected()); |
| | | } |
| | | |
| | | /** |
| | | * å建æ°ä¼è¯ |
| | | * @param rtuAddr rtuå°å |
| | | * @param job rtuå·¥ä½ç±» |
| | | * @param host æå¡å¨URI |
| | | * @param port æå¡å¨ç«¯å£ |
| | | * @return ç½ç»ä¼è¯ |
| | | */ |
| | | protected IoSession createSession(String host , int port , int connectTimeout , MinaHandler handler) throws Exception{ |
| | | public IoSession createSession(String rtuAddr, MyThreadJob job, String host , int port , int connectTimeout , TcpHandler handler) throws Exception{ |
| | | SocketConnector connector = new NioSocketConnector(); |
| | | connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new LocalCodecFactory())); |
| | | connector.setHandler(handler); |
| | | ConnectFuture connectFuture = connector.connect(new InetSocketAddress(host, port)); |
| | | connectFuture.awaitUninterruptibly(connectTimeout); |
| | | IoSession se = connectFuture.getSession(); |
| | | se.setAttribute(rtuAddrKey, rtuAddr) ; |
| | | se.setAttribute(threadJobKey, job) ; |
| | | return se ; |
| | | } |
| | | |
| | |
| | | * @param se |
| | | * @param connectTimeout |
| | | */ |
| | | protected void disconnect(IoSession se , int connectTimeout) { |
| | | public void disconnect(IoSession se , int connectTimeout) { |
| | | if (se != null) { |
| | | try{ |
| | | se.closeNow().awaitUninterruptibly(connectTimeout); |
| New file |
| | |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.service.IoHandlerAdapter; |
| | | import org.apache.mina.core.session.IdleStatus; |
| | | import org.apache.mina.core.session.IoSession; |
| | | import org.apache.mina.filter.FilterEvent; |
| | | |
| | | public class TcpHandler extends IoHandlerAdapter { |
| | | |
| | | private static Logger log = LogManager.getLogger(TcpHandler.class.getName()) ; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void sessionCreated(IoSession session) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void sessionOpened(IoSession session) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void sessionClosed(IoSession session) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void sessionIdle(IoSession session, IdleStatus status) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void exceptionCaught(IoSession session, Throwable cause) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void messageReceived(IoSession session, Object message) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void messageSent(IoSession session, Object message) throws Exception { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void inputClosed(IoSession session) throws Exception { |
| | | session.closeNow(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void event(IoSession session, FilterEvent event) throws Exception { |
| | | } |
| | | } |
| | |
| | | --> |
| | | <rmiCl |
| | | rmiSvUrl="127.0.0.1" |
| | | rmiSvContext="mwTestServer" |
| | | rmiSvPort="9898" |
| | | rmiSvContext="mwTestSv" |
| | | rmiSvPort="12345" |
| | | /> |
| | | <!-- |
| | | enable:æ¯å¦å¯å¨ |
| | | heartbeatTimes:è¿ç»é
置次æ°å¿è·³ååé䏿¬¡æ°æ® |
| | | sendInterval:åéå¿è·³ææ°æ®çæ¶é´é´é |
| | | --> |
| | | <tcpCl |
| | | enable="true" |
| | | heartbeatTimes="3" |
| | | sendInterval="3" |
| | | /> |
| | | </config> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <!-- |
| | | fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz" |
| | | fileName="/logs/testJgroups.log" filePattern="/logs/testJgroups-%d{yyyyMMdd}-%i.log.gz" |
| | | fileName="logs/testJgroups.log" filePattern="logs/testJgroups-%d{yyyyMMdd}-%i.log.gz" |
| | | sys:user.homeå½åç¨æ·å¨æä½ç³»ç»ä¸çææ¡£ç®å½ |
| | | /logs/testJgroups.logå½å软件æå¨ç¡¬çæ ¹ç®å½ |
| | | logs/testJgroups.logå½å软件æå¨ç®å½ |
| | | --> |
| | | <RollingFile name="File" fileName="logs/mwTestCl.log" filePattern="logs/aepTest-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/> |
| | | <Policies> |
| | | <TimeBasedTriggeringPolicy interval="7" /> |
| | | <SizeBasedTriggeringPolicy size="10MB"/> |
| | | </Policies> |
| | | <DefaultRolloverStrategy max="50" /> |
| | | </RollingFile> |
| | | </Appenders> |
| | | <Loggers> |
| | | <!-- |
| | | <Logger name="com.zhzc.jgTest" level="debug"> |
| | | <AppenderRef ref="Console"/> |
| | | </Logger> |
| | | <Logger name="org.jgroups" level="info"> |
| | | <AppenderRef ref="File"/> |
| | | </Logger> |
| | | --> |
| | | <!-- Rootä¸å个Loggeråæ¶èµ·ä½ç¨ --> |
| | | <Root level="info"> |
| | | <AppenderRef ref="Console"/> |
| | | <AppenderRef ref="File"/> |
| | | </Root> |
| | | </Loggers> |
| | | </Configuration> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <artifactId>pipIrr-mw</artifactId> |
| | | <groupId>com.dy</groupId> |
| | | <version>1.0.0</version> |
| | | <relativePath>../pom.xml</relativePath> |
| | | </parent> |
| | | |
| | | <packaging>jar</packaging> |
| | | <artifactId>pipIrr-mwTest-server</artifactId> |
| | | <version>1.0.0</version> |
| | | <name>pipIrr-mwTest-server</name> |
| | | <description>为模æRTUæµè¯ç«¯æä¾æå¡</description> |
| | | |
| | | <dependencies> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <resources> |
| | | <resource> |
| | | <directory>src/main/java</directory> |
| | | <includes> |
| | | <include>**/*.xml</include> |
| | | </includes> |
| | | </resource> |
| | | <resource> |
| | | <directory>src/main/resources</directory> |
| | | <includes> |
| | | <include>**/*.xml</include> |
| | | <include>**/*.yml</include> |
| | | </includes> |
| | | </resource> |
| | | </resources> |
| | | <plugins> |
| | | <plugin> |
| | | <!-- 该æä»¶ä¸ä¼å°é¡¹ç®ä¸å¼å
¥çä¾èµæè¿æç»ç Jar æä»¶ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-jar-plugin</artifactId> |
| | | <configuration> |
| | | <archive> |
| | | <!-- çæçjarä¸ï¼ä¸è¦å
å«pom.xmlåpom.propertiesè¿ä¸¤ä¸ªæä»¶ --> |
| | | <addMavenDescriptor>false</addMavenDescriptor> |
| | | <!-- è¿é¨å坿坿 ,å ä¸çè¯åç´æ¥çæå¯è¿è¡jarå
--> |
| | | <manifest> |
| | | <mainClass>com.dy.testServer.Server</mainClass> |
| | | <useUniqueVersions>false</useUniqueVersions> |
| | | <addClasspath>true</addClasspath> |
| | | <classpathPrefix>lib/</classpathPrefix> |
| | | </manifest> |
| | | <!-- manifestEntriesçä½ç¨æ¯æå®æ¬å°ï¼èªå·±ä¸è½½çlibä¸çï¼jarå
æ·»å å°MANIFEST.MFæä»¶ä¸å» |
| | | <manifestEntries> |
| | | <Class-Path>.lib/alipay-sdk.java.jar</Class-Path> |
| | | </manifestEntries> |
| | | --> |
| | | </archive> |
| | | <!-- æé¤æä¸ªæä»¶ |
| | | <excludes> |
| | | <exclude>com/dy/App.class</exclude> |
| | | </excludes> |
| | | --> |
| | | <!-- 坿§è¡jarè¿è¡å½åãè¿æ ·ä¼æå
æä¸¤ä¸ªjarå
ï¼ä¸ä¼å¯¹æ®éjaréæ°å½åã |
| | | <classifier>exec</classifier> |
| | | --> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- å½é¡¹ç®ä¸ä¾èµæ¯è¾å¤æ¶ï¼æä»¬å¯ä»¥åå© maven-dependency-plugin æä»¶èªå¨å¸®æä»¬ä¸è½½ä¾èµç Jar æä»¶ï¼æ¨èå°è¯¥æä»¶ç»å®å°packageçå½å¨æä¸ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-dependency-plugin</artifactId> |
| | | <executions> |
| | | <execution> |
| | | <!-- ç»å®çå½å¨æ --> |
| | | <phase>package</phase> |
| | | <goals> |
| | | <goal>copy-dependencies</goal> |
| | | </goals> |
| | | <!-- 设置ä¾èµçåæ¾è·¯å¾ --> |
| | | <configuration> |
| | | <outputDirectory>${project.build.directory}/lib</outputDirectory> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- 设置javaç¼è¯çæ¬ï¼è¿è¡ç¯å¢çæ¬ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-compiler-plugin</artifactId> |
| | | <!-- sourceï¼ æºä»£ç ç¼è¯çæ¬ï¼targetï¼ ç®æ å¹³å°ç¼è¯çæ¬ï¼encodingï¼ å符éç¼ç ã --> |
| | | <configuration> |
| | | <source>${java.version}</source> |
| | | <target>${java.version}</target> |
| | | <encoding>${encoding}</encoding> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- è§£å³èµæºæä»¶çç¼ç é®é¢ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-resources-plugin</artifactId> |
| | | <configuration> |
| | | <encoding>${encoding}</encoding> |
| | | </configuration> |
| | | </plugin> |
| | | |
| | | <plugin> |
| | | <!-- mavenéæ§è¡æµè¯ç¨ä¾çæä»¶ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <configuration> |
| | | <skipTests>true</skipTests> |
| | | </configuration> |
| | | </plugin> |
| | | |
| | | </plugins> |
| | | </build> |
| | | </project> |
| New file |
| | |
| | | package com.dy.testServer; |
| | | |
| | | import java.io.Console; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.dy.testServer.console.CommandConsole; |
| | | import com.dy.testServer.forRmi.Manager; |
| | | import org.jdom2.Document; |
| | | |
| | | import com.dy.common.mw.UnitInterface; |
| | | import com.dy.common.mw.UnitStartedCallbackInterface; |
| | | import com.dy.common.mw.channel.rmi.RmiConfigVo; |
| | | import com.dy.common.mw.channel.rmi.RmiUnit; |
| | | import com.dy.common.util.ConfigXml; |
| | | import com.dy.common.util.NumUtil; |
| | | |
| | | public class Server{ |
| | | |
| | | private ConfigXml conf = null ; |
| | | private Document doc = null ; |
| | | private boolean showStartInfo = false ; |
| | | |
| | | private String RmiSvUrl ; |
| | | |
| | | private final List<UnitInterface> units = new ArrayList<>() ; |
| | | |
| | | /** |
| | | * @param args åæ° |
| | | */ |
| | | public static void main(String[] args) { |
| | | new Server().startServer(args); |
| | | } |
| | | |
| | | /** |
| | | * å¯å¨æå¡ |
| | | */ |
| | | public void startServer(String[] args){ |
| | | Server sv = new Server(); |
| | | long start = System.currentTimeMillis() ; |
| | | try { |
| | | sv.conf = new ConfigXml() ; |
| | | sv.doc = sv.conf.createDom(sv.getClass(), "config.xml") ; |
| | | //////////////// |
| | | //æå¡ é
ç½® |
| | | sv.showStartInfo = sv.conf.getSetAttrBoolean(sv.doc, "config.server", "showStartInfo", null, null) ; |
| | | |
| | | sv.startUnits() ; |
| | | |
| | | String svName ; |
| | | try{ |
| | | svName = sv.conf.getSetAttrTxt(sv.doc, "config.server", "name", null, false, null) ; |
| | | }catch(Exception e){ |
| | | svName = "" ; |
| | | } |
| | | |
| | | System.out.println("OOOOOOOOOO OOOOOOOO OOOOOOOO") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@#O $@@@@@@@@& @@@@@@@@#") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@# @@@@@@@@# $@@@@@@@@&") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@O") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@@@ &@@@@@@@@@@@@@@") ; |
| | | System.out.println("@@@@@@$ $@@@@@@@@@& O@@@@@@@@@@@#") ; |
| | | System.out.println("@@@@@@$ @@@@@@@@@ @@@@@@@@@& " + svName + "mwTestSv " ) ; |
| | | System.out.println("@@@@@@$ @@@@@@@@@ &@@@@@@@@") ; |
| | | System.out.println("@@@@@@$ O@@@@@@@@@ &@@@@@@@@") ; |
| | | if(sv.RmiSvUrl != null){ |
| | | System.out.println("@@@@@@$ #@@@@@@@@@$ &@@@@@@@@ RmiSv " + sv.RmiSvUrl ) ; |
| | | }else{ |
| | | System.out.println("@@@@@@$ #@@@@@@@@@$ &@@@@@@@@" ) ; |
| | | } |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ Runing in standalone mode" ) ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@& &@@@@@@@@ Startup in " + (System.currentTimeMillis() - start) + " MS" ) ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@# &@@@@@@@@") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ; |
| | | |
| | | |
| | | |
| | | Console console = System.console(); |
| | | if (console == null) { |
| | | throw new IllegalStateException("严ééè¯¯ï¼æªè½å¾å°æ§å¶å°å¯¹è±¡!"); |
| | | } |
| | | CommandConsole mwConsole = new CommandConsole(console) ; |
| | | mwConsole.init(args); |
| | | boolean exit = mwConsole.clientConsole() ; |
| | | if(exit){ |
| | | System.exit(-1); |
| | | } |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void startUnits(){ |
| | | try { |
| | | /////////////// |
| | | //åºæ¬é
ç½® |
| | | String txt = conf.getSetAttrTxt(doc, "config.base", "rtuAddrStart", null, false, null) ; |
| | | if(txt == null || txt.trim().equals("")){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrStartçå¼ä¸ºç©ºå符串!"); |
| | | } |
| | | txt = txt.trim() ; |
| | | if(!NumUtil.isPlusIntNumber(txt)){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrStartçå¼å¿
须为æ°å¼!"); |
| | | } |
| | | if(txt.startsWith("0")){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrStartçæ°å¼ä¸è½ä»¥0å¼å¤´!"); |
| | | } |
| | | if(txt.length() != 10){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrStartçæ°å¼é¿åº¦å¿
须为10ä½!"); |
| | | } |
| | | ServerProperties.rtuAddrStart = Long.valueOf(txt) ; |
| | | |
| | | txt = conf.getSetAttrTxt(doc, "config.base", "rtuAddrEnd", null, false, null) ; |
| | | if(txt == null || txt.trim().equals("")){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrEndçå¼ä¸ºç©ºå符串!"); |
| | | } |
| | | txt = txt.trim() ; |
| | | if(!NumUtil.isPlusIntNumber(txt)){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrEndçå¼å¿
须为æ°å¼!"); |
| | | } |
| | | if(txt.startsWith("0")){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrEndçæ°å¼ä¸è½ä»¥0å¼å¤´!"); |
| | | } |
| | | if(txt.length() != 10){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrEndçæ°å¼é¿åº¦å¿
须为10ä½!"); |
| | | } |
| | | ServerProperties.rtuAddrEnd = Long.valueOf(txt) ; |
| | | if(ServerProperties.rtuAddrEnd <= ServerProperties.rtuAddrStart){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrEndçæ°å¼å¿
须大äºrtuAddrStart!"); |
| | | } |
| | | |
| | | ServerProperties.rtuAddrPerMwTest = conf.getSetAttrPlusInt(doc, "config.base", "rtuAddrPerMwTest", null, 1, null, null) ; |
| | | if(ServerProperties.rtuAddrPerMwTest > ServerProperties.rtuAddrEnd - ServerProperties.rtuAddrStart){ |
| | | throw new Exception("å
ç´ config.baseç屿§rtuAddrPerMwTestçæ°å¼é
ç½®ä¸æ£ç¡®!"); |
| | | } |
| | | ServerProperties.tcpServerIp = conf.getSetAttrTxt(doc, "config.base", "tcpServerIp", null, false, null) ; |
| | | ServerProperties.tcpServerPort = conf.getSetAttrPlusInt(doc, "config.base", "tcpServerPort", null, 1, 65535, null) ; |
| | | ServerProperties.sendInterval = conf.getSetAttrPlusInt(doc, "config.base", "sendInterval", null, 1, null, null) ; |
| | | ServerProperties.heartbeatTimes = conf.getSetAttrPlusInt(doc, "config.base", "heartbeatTimes", null, 1, null, null) ; |
| | | ServerProperties.sendTimes = conf.getSetAttrPlusInt(doc, "config.base", "sendTimes", null, 1, null, null) ; |
| | | |
| | | |
| | | ///////////////// |
| | | //RMI模å |
| | | Manager.init(); |
| | | RmiConfigVo rmiVo = new RmiConfigVo(); |
| | | rmiVo.enable = conf.getSetAttrBoolean(doc, "config.rmi", "enable", null, null) ; |
| | | if(rmiVo.enable){ |
| | | rmiVo.port = conf.getSetAttrPlusInt(doc, "config.rmi", "port", null, 100, 65535, null); |
| | | rmiVo.context = conf.getSetAttrTxt(doc, "config.rmi", "context", null, false, null); |
| | | rmiVo.showStartInfo = showStartInfo ; |
| | | AdapterImp_RmiUnit rmiAdap = new AdapterImp_RmiUnit(); |
| | | rmiAdap.setConfig(rmiVo); |
| | | RmiUnit rmiUnit = RmiUnit.getInstance(); |
| | | rmiUnit.setAdapter(rmiAdap); |
| | | rmiUnit.start(new UnitStartedCallbackInterface(){ |
| | | @Override |
| | | public void call(Object obj) { |
| | | } |
| | | }); |
| | | RmiSvUrl = "[ip]:" + rmiVo.port + "/" + rmiVo.context ; |
| | | units.add(rmiUnit) ; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.testServer; |
| | | |
| | | public class ServerProperties { |
| | | |
| | | //模æå®¢æ·çrtuAddrèµ·å§å· |
| | | public static Long rtuAddrStart = 0L ; |
| | | //模æå®¢æ·çrtuAddræªæ¢å· |
| | | public static Long rtuAddrEnd = 0L ; |
| | | //æ¯ä¸ªmwTeståé
çrtuAddræ° |
| | | public static Integer rtuAddrPerMwTest = 0 ; |
| | | //æå¡ç«¯URL |
| | | public static String tcpServerIp = "" ; |
| | | //æå¡ç«¯ä¸ä¸æ |
| | | public static Integer tcpServerPort = 60000 ; |
| | | //åéæ°æ®é´é ç§ |
| | | public static Integer sendInterval = 0 ; |
| | | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° |
| | | public static Integer heartbeatTimes = 0 ; |
| | | //åéæ°æ®æ¬¡æ° |
| | | public static Integer sendTimes = 0 ; |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.console; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import com.dy.common.mw.channel.rmi.RmiConfigVo; |
| | | import com.dy.common.mw.channel.rmi.RmiUnit; |
| | | import com.dy.testServer.ServerProperties; |
| | | import com.dy.testServer.forRmi.MwTestClientStatus; |
| | | import com.dy.testServer.forRmi.Manager; |
| | | |
| | | public class Command { |
| | | |
| | | private static final String[] commands ; |
| | | static{ |
| | | commands = new String[]{ |
| | | "config æ¥çé
置信æ¯", |
| | | "show æ¾ç¤ºmwTestæ
åµ", |
| | | "start å¯å¨mwTest䏿¥æ°æ®", |
| | | "exit éåº", |
| | | }; |
| | | } |
| | | |
| | | |
| | | public static boolean dealCommand(String command, PrintWriter prtWrt){ |
| | | boolean exit = false ; |
| | | if (command.equals("help")) { |
| | | outCommand(prtWrt); |
| | | } else if (command.equals("config")) { |
| | | config(prtWrt); |
| | | } else if (command.equals("show")) { |
| | | show(prtWrt); |
| | | } else if (command.equals("start")) { |
| | | start(prtWrt); |
| | | } else if(command.equals("exit")){ |
| | | exit = true ; |
| | | } else { |
| | | outError(prtWrt); |
| | | } |
| | | return exit ; |
| | | } |
| | | private static void outCommand(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("å½ä»¤"); |
| | | for(String s : commands){ |
| | | prtWrt.println(" " + s); |
| | | } |
| | | prtWrt.println(""); |
| | | } |
| | | private static void outError(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("å½ä»¤ä¸å¯è¯å«ï¼"); |
| | | prtWrt.println(""); |
| | | } |
| | | |
| | | private static void config(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("ç¸å
³mwTestçé
ç½®"); |
| | | prtWrt.println(" 模æå®¢æ·çRtuAddrèµ·å§å·ï¼" + ServerProperties.rtuAddrStart); |
| | | prtWrt.println(" 模æå®¢æ·çRtuAddræªæ¢å·ï¼" + ServerProperties.rtuAddrEnd); |
| | | prtWrt.println(" æ¯ä¸ªmwTeståé
çRtuAddræ°ï¼" + ServerProperties.rtuAddrPerMwTest); |
| | | prtWrt.println(" éä¿¡ä¸é´ä»¶IPï¼" + ServerProperties.tcpServerIp); |
| | | prtWrt.println(" éä¿¡ä¸é´ä»¶ç«¯å£ï¼" + ServerProperties.tcpServerPort); |
| | | prtWrt.println(" mwTeståéæ°æ®é´éï¼ç§ï¼ï¼" + ServerProperties.sendInterval); |
| | | prtWrt.println(" mwTestæ¯RtuAddrå·åéæ°æ®æ¬¡æ°ï¼" + ServerProperties.sendTimes); |
| | | prtWrt.println(" mwTestæ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ°ï¼" + ServerProperties.heartbeatTimes); |
| | | prtWrt.println("æ¬æå¡RMI Serveré
ç½®"); |
| | | String ip = null ; |
| | | try { |
| | | ip = InetAddress.getLocalHost().getHostAddress(); |
| | | } catch (UnknownHostException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | RmiConfigVo confVo = RmiUnit.getInstance().getAdapter().getConfig() ; |
| | | if(ip != null){ |
| | | prtWrt.println(" RMI Serverï¼" + ip + ":" + confVo.port + "/" + confVo.context); |
| | | }else{ |
| | | prtWrt.println(" RMI Serverï¼[ip]:" + confVo.port + "/" + confVo.context); |
| | | } |
| | | prtWrt.println(""); |
| | | } |
| | | |
| | | private static void show(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("å½å已注åmwTest客æ·ç«¯æ°éï¼" + Manager.id2TokenMap.size()); |
| | | if(Manager.id2TokenMap.size() > 0){ |
| | | prtWrt.println("mwTest客æ·ç«¯åå
¶å·¥ä½ä¿¡æ¯"); |
| | | Set<Map.Entry<String, MwTestClientStatus>> set = Manager.token2ClientMap.entrySet() ; |
| | | Iterator<Map.Entry<String, MwTestClientStatus>> it = set.iterator() ; |
| | | Map.Entry<String, MwTestClientStatus> ent ; |
| | | while(it.hasNext()){ |
| | | ent = it.next() ; |
| | | prtWrt.println(" mwTest客æ·ç«¯(token=" + ent.getKey() + ")"); |
| | | MwTestClientStatus sta = ent.getValue() ; |
| | | if(sta != null){ |
| | | if(sta.confVo != null){ |
| | | prtWrt.println(" rtuAddrèå´ï¼" + sta.confVo.rtuAddrStart + "--" + sta.confVo.rtuAddrEnd); |
| | | } |
| | | if(sta.startVo != null){ |
| | | prtWrt.println(" 䏿¥æ°æ®ï¼" + (sta.startVo.start?"å·²ç»å¼å§":"æªå¼å§")); |
| | | }else{ |
| | | prtWrt.println(" 䏿¥æ°æ®ï¼æªå¼å§") ; |
| | | } |
| | | if(sta.count != null){ |
| | | prtWrt.println(" å·²ç»ä¸æ¥æ°æ®ï¼" + sta.count + "æ¡"); |
| | | } |
| | | if(sta.over != null && sta.over){ |
| | | prtWrt.println(" 䏿¥æ°æ®å·²ç»å®æï¼å
±ç¨æ¶ï¼" + sta.seconds + "ç§"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | prtWrt.println(""); |
| | | } |
| | | |
| | | private static void start(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println(" å·²ç»å
许mwTest䏿¥æ°æ®äº"); |
| | | prtWrt.println(""); |
| | | Manager.enablemwTestStart = true ; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.console; |
| | | |
| | | import java.io.Console; |
| | | import java.io.PrintWriter; |
| | | |
| | | public class CommandConsole { |
| | | |
| | | private Console console ; |
| | | private PrintWriter prtWrt ; |
| | | private static final String myPassword = "123456" ; |
| | | private static final String commandPrefix1 = ">>" ; |
| | | private static final String commandPrefix2 = "$: " ; |
| | | private static String commandPrefix = commandPrefix1 + commandPrefix2 ; |
| | | |
| | | |
| | | public CommandConsole(Console console)throws Exception{ |
| | | this.console = console ; |
| | | if(this.console == null){ |
| | | throw new Exception("严éé误ï¼javaæ§å¶å°å¯¹è±¡ä¸ºç©ºï¼"); |
| | | } |
| | | prtWrt = console.writer() ; |
| | | } |
| | | |
| | | /** |
| | | * åå§ï¼æ£æ¥å¹¶è¾åºä¸äºä¿¡æ¯ |
| | | * @param args åæ° |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public void init(String[] args) throws Exception{ |
| | | PrintWriter prtWrt = console.writer() ; |
| | | if(args != null && args.length > 0){ |
| | | String str = "" ; |
| | | for(String s : args){ |
| | | str += s ; |
| | | } |
| | | prtWrt.println("infoï¼å¯å¨åæ°" + str); |
| | | } |
| | | |
| | | prtWrt.println("----------------------------------------"); |
| | | prtWrt.println("-- --"); |
| | | prtWrt.println("-- 欢è¿ä½¿ç¨mwTest æå¡æ§å¶ç«¯ --"); |
| | | prtWrt.println("-- --"); |
| | | prtWrt.println("----------------------------------------"); |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡æ§å¶å°æ§å¶ |
| | | * @return è¿å |
| | | */ |
| | | public boolean clientConsole(){ |
| | | boolean exit = false ; |
| | | try { |
| | | this.login() ; |
| | | exit = this.doConsole(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return exit ; |
| | | } |
| | | |
| | | private boolean login(){ |
| | | while (true) { |
| | | //String username = console.readLine("Username: "); |
| | | char[] password = console.readPassword(">>Password: "); |
| | | String passwordStr = String.valueOf(password) ; |
| | | if (passwordStr.equals("help")) { |
| | | console.printf("å¯ç æ¯%1$s.\n", "123456"); |
| | | // 使ç¨ååºç«å³å°æ°ç»æ¸
空ï¼ä»¥åå°å
¶å¨å
åä¸å ç¨çæ¶é´ï¼å¢å¼ºå®å
¨æ§ |
| | | password = null; |
| | | } else if(passwordStr.equals(myPassword)){ |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean doConsole(){ |
| | | boolean exit = false ; |
| | | while (!exit) { |
| | | String command = console.readLine(commandPrefix); |
| | | exit = Command.dealCommand(command, prtWrt) ; |
| | | } |
| | | return exit ; |
| | | } |
| | | |
| | | public static void changeCommandPrefix(String prefix){ |
| | | commandPrefix = commandPrefix1 + prefix ; |
| | | } |
| | | public static void recoverCommandPrefix(){ |
| | | commandPrefix = commandPrefix1 + commandPrefix2 ; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.forRmi; |
| | | |
| | | public class Code { |
| | | |
| | | public static String cd1 = "001" ;//注å |
| | | |
| | | public static String cd2 = "002" ;//请æ±mwClientçé
ç½® |
| | | |
| | | public static String cd3 = "003" ;//请æ±å¼å§å·¥ä½ |
| | | |
| | | public static String cd4 = "004" ;//åæå¡ç«¯ä¸æ¥ä¿¡æ¯ |
| | | |
| | | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥ 宿任å¡çæ°é |
| | | |
| | | public static String cd6 = "006" ;//åæå¡ç«¯ä¸æ¥ å
¨é¨ä»»å¡å®æ |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.forRmi; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.dy.testServer.ServerProperties; |
| | | |
| | | public class Manager { |
| | | |
| | | public static boolean enablemwTestStart = false ; |
| | | |
| | | public static int clientId = 1 ; |
| | | |
| | | public static long maxClient = 0 ; |
| | | |
| | | public static Map<String, String> id2TokenMap = new HashMap<>() ; |
| | | |
| | | public static Map<String, MwTestClientStatus> token2ClientMap = new HashMap<>() ; |
| | | |
| | | public static List<Object[]> rtuAddrList = new ArrayList<>() ; |
| | | |
| | | public static void init(){ |
| | | maxClient = (ServerProperties.rtuAddrEnd - ServerProperties.rtuAddrStart)/ServerProperties.rtuAddrPerMwTest ; |
| | | if((ServerProperties.rtuAddrEnd - ServerProperties.rtuAddrStart)%ServerProperties.rtuAddrPerMwTest > 0 ){ |
| | | maxClient = maxClient + 1 ; |
| | | } |
| | | int count = 0 ; |
| | | for(int i = 0; i < maxClient; i++){ |
| | | long start = ServerProperties.rtuAddrStart + (i * ServerProperties.rtuAddrPerMwTest) ; |
| | | long end = ServerProperties.rtuAddrStart + ((i + 1) * ServerProperties.rtuAddrPerMwTest - 1) ; |
| | | if(end > ServerProperties.rtuAddrEnd){ |
| | | end = ServerProperties.rtuAddrEnd ; |
| | | } |
| | | if(end < start){ |
| | | break ; |
| | | }else{ |
| | | rtuAddrList.add(count++, new Object[]{start, end}); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public synchronized static String dealRequest(Object obj) throws Exception{ |
| | | RmiResponseVo resVo ; |
| | | if(obj == null){ |
| | | resVo = new RmiResponseVo() ; |
| | | resVo.success = false ; |
| | | resVo.errorInfo = "æ¶å°çæ°æ®ä¸ºnull" ; |
| | | }else if(!(obj instanceof String)){ |
| | | resVo = new RmiResponseVo() ; |
| | | resVo.success = false ; |
| | | resVo.errorInfo = "æ¶å°çæ°æ®ä¸æ¯å符串类å" ; |
| | | }else{ |
| | | RmiRequestVo rqVo = RmiRequestVo.jsonToObject((String)obj) ; |
| | | resVo = doDeal(rqVo) ; |
| | | } |
| | | return resVo.toJson() ; |
| | | } |
| | | |
| | | private static RmiResponseVo doDeal(RmiRequestVo rqVo){ |
| | | RmiResponseVo resVo = new RmiResponseVo() ; |
| | | resVo.code = rqVo.code ; |
| | | if(rqVo.code.equals(Code.cd1)){ |
| | | if(rqVo.id == null || rqVo.id.trim().equals("")){ |
| | | resVo.success = false ; |
| | | resVo.errorInfo = "注å失败ï¼å¿
é¡»æä¾å®¢æ·ç«¯ID " ; |
| | | }else{ |
| | | ResRegisterVo vo = doDealRegister(rqVo) ; |
| | | if(vo != null){ |
| | | resVo.obj = vo ; |
| | | }else{ |
| | | resVo.success = false ; |
| | | resVo.errorInfo = "rtuAddrå·²ç»åé
å®æï¼æ³¨å失败" ; |
| | | } |
| | | } |
| | | }else if(rqVo.code.equals(Code.cd2)){ |
| | | resVo.obj = doDealGetConfig(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd3)){ |
| | | resVo.obj = doDealGetStart(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd4)){ |
| | | doDealReportCount(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd5)){ |
| | | doDealReportOver(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd6)){ |
| | | doDealAllOver(rqVo) ; |
| | | } |
| | | return resVo ; |
| | | } |
| | | |
| | | private static ResRegisterVo doDealRegister(RmiRequestVo rqVo){ |
| | | ResRegisterVo resVo = null ; |
| | | String token = id2TokenMap.get(rqVo.id) ; |
| | | if(token == null){ |
| | | if(clientId <= rtuAddrList.size()){ |
| | | resVo = new ResRegisterVo() ; |
| | | resVo.token = "" + clientId ; |
| | | id2TokenMap.put(rqVo.id, resVo.token) ; |
| | | clientId++ ; |
| | | } |
| | | }else{ |
| | | resVo = new ResRegisterVo() ; |
| | | resVo.token = token ; |
| | | } |
| | | return resVo ; |
| | | } |
| | | |
| | | private static MwConfigVo doDealGetConfig(RmiRequestVo rqVo){ |
| | | MwConfigVo conVo ; |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | Object[] rtuAddrs = rtuAddrList.get(token-1) ; |
| | | conVo = new MwConfigVo() ; |
| | | conVo.rtuAddrStart = (Long)rtuAddrs[0] ; |
| | | conVo.rtuAddrEnd = (Long)rtuAddrs[1] ; |
| | | conVo.tcpServerIp = ServerProperties.tcpServerIp ; |
| | | conVo.tcpServerPort = ServerProperties.tcpServerPort ; |
| | | conVo.sendInterval = ServerProperties.sendInterval ; |
| | | conVo.heartbeatTimes = ServerProperties.heartbeatTimes ; |
| | | conVo.sendTimes = ServerProperties.sendTimes ; |
| | | sta = new MwTestClientStatus() ; |
| | | sta.confVo = conVo ; |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | conVo = sta.confVo; |
| | | } |
| | | return conVo ; |
| | | } |
| | | private static ResStartVo doDealGetStart(RmiRequestVo rqVo){ |
| | | ResStartVo rvo = new ResStartVo() ; |
| | | rvo.start = enablemwTestStart ; |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | sta.startVo = rvo ; |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | sta.startVo = rvo ; |
| | | } |
| | | return rvo ; |
| | | } |
| | | |
| | | |
| | | private static void doDealReportCount(RmiRequestVo rqVo){ |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | sta.count = rqVo.count ; |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | sta.count = rqVo.count ; |
| | | } |
| | | } |
| | | |
| | | |
| | | private static void doDealReportOver(RmiRequestVo rqVo){ |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | sta.overCount = rqVo.count ; |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | sta.count = rqVo.count ; |
| | | } |
| | | } |
| | | |
| | | |
| | | private static void doDealAllOver(RmiRequestVo rqVo){ |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | if(rqVo.over != null && rqVo.over){ |
| | | sta.over = true ; |
| | | sta.seconds = rqVo.seconds ; |
| | | } |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | if(rqVo.over != null && rqVo.over){ |
| | | sta.over = true ; |
| | | sta.seconds = rqVo.seconds ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.forRmi; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | |
| | | public class MwConfigVo { |
| | | //模æå®¢æ·çRtuAddrèµ·å§å· |
| | | public Long rtuAddrStart = 0L ; |
| | | //模æå®¢æ·çRtuAddræªæ¢å· |
| | | public Long rtuAddrEnd = 0L ; |
| | | //éä¿¡ä¸é´ä»¶IP |
| | | public String tcpServerIp = "" ; |
| | | //éä¿¡ä¸é´ä»¶ç«¯å£ |
| | | public Integer tcpServerPort = 0 ; |
| | | //åéæ°æ®æ°æ®é´é |
| | | public Integer sendInterval = 2 ;//ç§ |
| | | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° |
| | | public Integer heartbeatTimes = 3 ; |
| | | //åéæ°æ®æ¬¡æ° |
| | | public Integer sendTimes = 0 ; |
| | | /** |
| | | * 对象转æjson |
| | | * @return è¿å json |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String toJson()throws Exception{ |
| | | try{ |
| | | return JSON.toJSONString(this) ; |
| | | //return new JSONSerializer().exclude(new String[]{"class", "*.class"}).deepSerialize(this); |
| | | }catch(Exception e){ |
| | | throw new Exception(e.getMessage() , e ) ; |
| | | } |
| | | } |
| | | /** |
| | | * json转æå¯¹è±¡ |
| | | * @param json åæ° |
| | | * @return è¿å对象 |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static MwConfigVo jsonToObject(String json)throws Exception{ |
| | | try{ |
| | | return JSON.parseObject(json, MwConfigVo.class) ; |
| | | //return new JSONDeserializer<ResConfigVo>().deserialize(json, ResConfigVo.class) ; |
| | | }catch(Exception e){ |
| | | throw new Exception(e.getMessage() , e ) ; |
| | | } |
| | | } |
| | | |
| | | public Long getRtuAddrStart() { |
| | | return rtuAddrStart; |
| | | } |
| | | |
| | | public void setRtuAddrStart(Long rtuAddrStart) { |
| | | this.rtuAddrStart = rtuAddrStart; |
| | | } |
| | | |
| | | public Long getRtuAddrEnd() { |
| | | return rtuAddrEnd; |
| | | } |
| | | |
| | | public void setRtuAddrEnd(Long rtuAddrEnd) { |
| | | this.rtuAddrEnd = rtuAddrEnd; |
| | | } |
| | | |
| | | public String getTcpServerIp() { |
| | | return tcpServerIp; |
| | | } |
| | | |
| | | public void setTcpServerIp(String tcpServerIp) { |
| | | this.tcpServerIp = tcpServerIp; |
| | | } |
| | | |
| | | public Integer getTcpServerPort() { |
| | | return tcpServerPort; |
| | | } |
| | | |
| | | public void setTcpServerPort(Integer tcpServerPort) { |
| | | this.tcpServerPort = tcpServerPort; |
| | | } |
| | | |
| | | public Integer getSendInterval() { |
| | | return sendInterval; |
| | | } |
| | | |
| | | public void setSendInterval(Integer sendInterval) { |
| | | this.sendInterval = sendInterval; |
| | | } |
| | | |
| | | public Integer getHeartbeatTimes() { |
| | | return heartbeatTimes; |
| | | } |
| | | |
| | | public void setHeartbeatTimes(Integer heartbeatTimes) { |
| | | this.heartbeatTimes = heartbeatTimes; |
| | | } |
| | | |
| | | public Integer getSendTimes() { |
| | | return sendTimes; |
| | | } |
| | | |
| | | public void setSendTimes(Integer sendTimes) { |
| | | this.sendTimes = sendTimes; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dy.testServer.forRmi; |
| | | |
| | | public class MwTestClientStatus { |
| | | |
| | | public MwConfigVo confVo ; |
| | | |
| | | public ResStartVo startVo ; |
| | | |
| | | public Integer count ;//mwTest䏿¥æ°æ®æ°é |
| | | |
| | | public Integer overCount ;//mwTest宿å
¨é¨ä¸æ¥æ°æ®RTUæ°é |
| | | |
| | | public Boolean over ;//mwTest䏿¥æ°æ®ç»æ |
| | | |
| | | public Long seconds ;//mwTest䏿¥æ°æ®ç¨æ¶(ç§) |
| | | |
| | | public MwConfigVo getConfVo() { |
| | | return confVo; |
| | | } |
| | | |
| | | public void setConfVo(MwConfigVo confVo) { |
| | | this.confVo = confVo; |
| | | } |
| | | |
| | | public ResStartVo getStartVo() { |
| | | return startVo; |
| | | } |
| | | |
| | | public void setStartVo(ResStartVo startVo) { |
| | | this.startVo = startVo; |
| | | } |
| | | |
| | | public Integer getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(Integer count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public Boolean getOver() { |
| | | return over; |
| | | } |
| | | |
| | | public void setOver(Boolean over) { |
| | | this.over = over; |
| | | } |
| | | |
| | | public Long getSeconds() { |
| | | return seconds; |
| | | } |
| | | |
| | | public void setSeconds(Long seconds) { |
| | | this.seconds = seconds; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <config> |
| | | <server name="mwTestæµè¯æ§å¶ç«¯" showStartInfo="true" company="http://www.dyjs.com"/> |
| | | <!-- |
| | | åºæ¬é
ç½® |
| | | rtuAddrStart: 模æå®¢æ·çRtuAddrèµ·å§å· |
| | | rtuAddrEnd: 模æå®¢æ·çRtuAddræªæ¢å· |
| | | rtuAddrsPerMwTest: æ¯ä¸ªmwTeståé
çRtuAddræ° |
| | | tcpServerIp: éä¿¡ä¸é´ä»¶IP |
| | | tcpServerPort: éä¿¡ä¸é´ä»¶ç«¯å£ |
| | | sendIntervalï¼åéæ°æ®é´é ç§ |
| | | heartbeatTimesï¼æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° |
| | | sendTimesï¼åéæ°æ®æ¬¡æ° |
| | | --> |
| | | <base |
| | | rtuAddrStart="5323280000" |
| | | rtuAddrEnd="5323289999" |
| | | rtuAddrPerMwTest="1" |
| | | tcpServerIp="127.0.0.1" |
| | | tcpServerPort="60000" |
| | | sendInterval="2" |
| | | heartbeatTimes="3" |
| | | sendTimes="1" |
| | | /> |
| | | |
| | | <!-- |
| | | portï¼rmiæå¡ç«¯å£å· |
| | | contextï¼rmiæå¡ä¸ä¸æ |
| | | --> |
| | | <rmi enable="true" |
| | | port="12345" |
| | | context="mwTestSv" |
| | | /> |
| | | |
| | | </config> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <!-- |
| | | fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz" |
| | | fileName="/logs/testJgroups.log" filePattern="/logs/testJgroups-%d{yyyyMMdd}-%i.log.gz" |
| | | fileName="logs/testJgroups.log" filePattern="logs/testJgroups-%d{yyyyMMdd}-%i.log.gz" |
| | | sys:user.homeå½åç¨æ·å¨æä½ç³»ç»ä¸çææ¡£ç®å½ |
| | | /logs/testJgroups.logå½å软件æå¨ç¡¬çæ ¹ç®å½ |
| | | logs/testJgroups.logå½å软件æå¨ç®å½ |
| | | --> |
| | | <RollingFile name="File" fileName="logs/mwTestSv.log" filePattern="logs/aepTest-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/> |
| | | <Policies> |
| | | <TimeBasedTriggeringPolicy interval="7" /> |
| | | <SizeBasedTriggeringPolicy size="10MB"/> |
| | | </Policies> |
| | | <DefaultRolloverStrategy max="50" /> |
| | | </RollingFile> |
| | | </Appenders> |
| | | <Loggers> |
| | | <!-- Rootä¸å个Loggeråæ¶èµ·ä½ç¨ --> |
| | | <Root level="info"> |
| | | <AppenderRef ref="Console"/> |
| | | <AppenderRef ref="File"/> |
| | | </Root> |
| | | </Loggers> |
| | | </Configuration> |
| | |
| | | <groupId>com.dy</groupId> |
| | | <artifactId>pipIrr-common</artifactId> |
| | | <version>1.0.0</version> |
| | | <scope>provided</scope> |
| | | <!-- |
| | | scopeä¸è½ç¨providedï¼å¦åServer.javaçè¿è¡ä¸èµ·æ¥ |
| | | scopeä¸è½ç¨runtimeï¼å¦åä¸è½ç¼è¾ |
| | | --> |
| | | <scope>compile</scope> |
| | | <optional>true</optional> |
| | | <exclusions> |
| | | <exclusion> |
| | |
| | | <groupId>com.dy</groupId> |
| | | <artifactId>pipIrr-global</artifactId> |
| | | <version>1.0.0</version> |
| | | <scope>provided</scope> |
| | | <scope>compile</scope> |
| | | <optional>true</optional> |
| | | <exclusions> |
| | | <exclusion> |
| | |
| | | <artifactId>jackson-dataformat-yaml</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <!-- æé¤æä¾èµ --> |
| | | <groupId>com.fasterxml.jackson.core</groupId> |
| | | <artifactId>jackson-databind</artifactId> |
| | | <groupId>*</groupId> |
| | | <artifactId>*</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | |
| | | target/ |
| | | /pipIrr-web.iml |
| | | pipIrr-web.iml |
| | |
| | | HELP.md |
| | | target/ |
| | | /pipIrr-web-sso.iml |
| | | mvnw |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | !**/src/main/**/target/ |
| | | !**/src/test/**/target/ |
| | |
| | | <dependency> |
| | | <groupId>com.fasterxml.jackson.dataformat</groupId> |
| | | <artifactId>jackson-dataformat-yaml</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>*</groupId> |
| | | <artifactId>*</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <!-- ç³»ç»ç管 --> |