From 40c1a196d019fbaf3dd8f0d8f6d1bdc8225bb7a0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 8 Nov 2016 16:11:53 +0300 Subject: juick-xmpp: statsfile -> status --- .../java/com/juick/components/s2s/CleaningUp.java | 106 ++++++--------------- 1 file changed, 29 insertions(+), 77 deletions(-) (limited to 'juick-xmpp/src/main/java/com/juick/components/s2s') diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/CleaningUp.java b/juick-xmpp/src/main/java/com/juick/components/s2s/CleaningUp.java index 031a7b34..52d2f3a6 100644 --- a/juick-xmpp/src/main/java/com/juick/components/s2s/CleaningUp.java +++ b/juick-xmpp/src/main/java/com/juick/components/s2s/CleaningUp.java @@ -2,9 +2,6 @@ package com.juick.components.s2s; import com.juick.components.XMPPServer; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; import java.util.Iterator; /** @@ -21,89 +18,44 @@ public class CleaningUp implements Runnable { @Override public void run() { while (true) { - try { - PrintWriter statsFile = new PrintWriter(xmpp.STATSFILE, "UTF-8"); - statsFile.write("

Threads: " + Thread.activeCount() + "

"); - statsFile.write("

Out (" + xmpp.getOutConnections().size() + ")

"); - - long now = System.currentTimeMillis(); - - synchronized (xmpp.getOutConnections()) { - for (Iterator i = xmpp.getOutConnections().iterator(); i.hasNext();) { - ConnectionOut c = i.next(); - int inactive = (int) ((double) (now - c.tsLocalData) / 1000.0); - if (inactive > 900) { - c.closeConnection(); - i.remove(); - } else { - statsFile.write(" "); - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" "); - } + long now = System.currentTimeMillis(); + + synchronized (xmpp.getOutConnections()) { + for (Iterator i = xmpp.getOutConnections().iterator(); i.hasNext(); ) { + ConnectionOut c = i.next(); + int inactive = (int) ((double) (now - c.tsLocalData) / 1000.0); + if (inactive > 900) { + c.closeConnection(); + i.remove(); } } + } - statsFile.write("
tosidinactiveout packetsout bytes
" + c.to + "" + c.streamID + "" + inactive + "" + c.packetsLocal + "" + c.bytesLocal + "

In (" + xmpp.getInConnections().size() + ")

"); - - synchronized (xmpp.getInConnections()) { - for (Iterator i = xmpp.getInConnections().iterator(); i.hasNext();) { - ConnectionIn c = i.next(); - int inactive = (int) ((double) (now - c.tsRemoteData) / 1000.0); - if (inactive > 900) { - c.closeConnection(); - i.remove(); - } else { - statsFile.write(" "); - if (c.from.isEmpty()) { - statsFile.write(" \n"); - } else if (c.from.size() == 1) { - statsFile.write(" \n"); - } else { - String out = " \n"); - } - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" \n"); - statsFile.write(" "); - } + synchronized (xmpp.getInConnections()) { + for (Iterator i = xmpp.getInConnections().iterator(); i.hasNext(); ) { + ConnectionIn c = i.next(); + int inactive = (int) ((double) (now - c.tsRemoteData) / 1000.0); + if (inactive > 900) { + c.closeConnection(); + i.remove(); } } + } - statsFile.write("
fromsidinactivein packets
 " + c.from.get(0) + ""; - for (int n = 0; n < c.from.size(); n++) { - if (n > 0) { - out += "
"; - } - out += c.from.get(n); - } - statsFile.write(out + "
" + c.streamID + "" + inactive + "" + c.packetsRemote + "

Cache (" + xmpp.getOutCache().size() + ")

"); - - synchronized (xmpp.getOutCache()) { - for (Iterator i = xmpp.getOutCache().iterator(); i.hasNext();) { - CacheEntry c = i.next(); - int inactive = (int) ((double) (now - c.tsCreated) / 1000.0); - if (inactive > 600) { - i.remove(); - } else { - statsFile.write(""); - } + synchronized (xmpp.getOutCache()) { + for (Iterator i = xmpp.getOutCache().iterator(); i.hasNext(); ) { + CacheEntry c = i.next(); + int inactive = (int) ((double) (now - c.tsCreated) / 1000.0); + if (inactive > 600) { + i.remove(); } } - - statsFile.write("
hostlivesize
" + c.hostname + "" + inactive + "" + c.xml.length() + "
"); - statsFile.close(); - - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - } - } catch (FileNotFoundException e) { - } catch (UnsupportedEncodingException e) { } + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + } + } } } -- cgit v1.2.3