maven - Performance of Spring boot project when makes it installed -
i made 2 programs. 1 client program sends udp packet udp server , other server program receives udp packet udp client.
udp server made spring boot. problem there difference of performance between run in sts(spring tools suite) , run jar(maven installed). when run program in sts(run as->spring boot app), gets packets client. if client sent 3,000 packets, gets 3,000 packet. when run jar(maven install), gets little of packets 200-300. it's same code.
i don't know why occurs. there way build spring boot app or need option?
whole code large. upload connect, send, bind code.
this client program
public udpclient(string[] args) { connector = new niodatagramconnector(); connector.sethandler(this); connectfuture connfuture = connector.connect(new inetsocketaddress( args[0], 6001)); connfuture.awaituninterruptibly(); if(args[1] != null) { totalcount = integer.parseint(args[1]); } if(args[2] != null) { count = integer.parseint(args[2]); } connfuture.addlistener(new iofuturelistener<connectfuture>() { public void operationcomplete(connectfuture future) { if (future.isconnected()) { session = future.getsession(); try { senddata(totalcount, count); } catch (interruptedexception e) { e.printstacktrace(); } } else { logger.error("not connected...exiting"); } } }); } private void senddata(int totalcount, int count) throws interruptedexception { int tempcount = 0; (int = 0; < totalcount; i++) { try{ file udpdata = new file("udp_data.txt"); bufferedreader br = new bufferedreader(new filereader(udpdata)); string line; int k = 0; arraylist<iobuffer> buflist = new arraylist<iobuffer>(); while((line = br.readline()) != null) { string[] str = line.split(" "); iobuffer buf = iobuffer.allocate(str.length); (int j = 0; j < str.length; j++) { int hexdata = integer.parseint(str[j],16); byte hexbyte = (byte)hexdata; buf.put(hexbyte); } buflist.add(buf); buf.flip(); } long starttime = system.currenttimemillis(); (int j = 0; j < count; j++) { session.write(buflist.get(j)); tempcount++; if(j % 100 == 0) { thread.sleep(1); } } long endtime = system.currenttimemillis(); system.out.println("oper time : " + (endtime - starttime)); } catch(exception e) { e.printstacktrace(); } } system.out.println("total send count : " + tempcount); }
and server program.
@service public class modbusudpmina { private static logger logger = loggerfactory.getlogger(modbusudpmina.class); @autowired private iohandleradapter ioudphandleradapter; @autowired private protocolcodecfactory ambprotocolcodecfactory; @postconstruct public void bind() { niodatagramacceptor acceptor = new niodatagramacceptor(); acceptor.getfilterchain().addlast(\"codec\", new protocolcodecfilter(ambprotocolcodecfactory)); acceptor.sethandler(ioudphandleradapter); acceptor.getsessionconfig().setreuseaddress(true); acceptor.getsessionconfig().setreceivebuffersize(1024*512); acceptor.getsessionconfig().setreadbuffersize(2048); acceptor.getsessionconfig().setidletime(idlestatus.both_idle, 10); try { acceptor.bind(new inetsocketaddress(6001)); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } }
Comments
Post a Comment