diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java index 842c57be35..7006043632 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java @@ -683,16 +683,8 @@ public class CollaborationDataManager implements IRosterEventSubscriber { @Subscribe public void handleModifiedPresence(IRosterEntry entry) { final IRosterEntry rosterEntry = entry; - System.out.println("CollaborationDataManager.handleModifiedPresence: " - + rosterEntry.getUser().getFQName() + " mode " - + rosterEntry.getPresence().getMode() + "/" - + rosterEntry.getPresence().getType() + ": \"" - + rosterEntry.getPresence().getStatusMessage() + "\" groups " - + rosterEntry.getGroups()); String userId = CollaborationUtils.makeUserId(rosterEntry); DataUser user = usersMap.get(userId); - System.out.println("\tuserId: " + userId + " DataUser: " + user); - System.out.println(usersMap.keySet()); if (user != null) { user.setPresence(rosterEntry.getPresence()); // Assumes only UI updates will be registered. diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java index 67edf8864c..a50879d9e5 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java @@ -232,10 +232,6 @@ public class SessionView extends AbstractSessionView { @Subscribe public void handleModifiedPresence(IRosterEntry rosterEntry) { - System.out.println("session view roster entry for:" - + rosterEntry.getUser().getFQName() + " " - + rosterEntry.getPresence().getMode() + "/" - + rosterEntry.getPresence().getType()); usersTable.refresh(); } @@ -615,7 +611,6 @@ public class SessionView extends AbstractSessionView { @Subscribe public void participantHandler(IVenueParticipantEvent event) throws Exception { - System.out.println("++ ParticipantHander type " + event.getEventType()); final ParticipantEventType type = event.getEventType(); final UserId participant = event.getParticipant(); final IPresence presence = event.getPresence(); @@ -634,9 +629,7 @@ public class SessionView extends AbstractSessionView { participantPresenceUpdated(participant, presence); break; case UPDATED: - System.out.println("---- handle update here: " - + participant.getName() + ", " - + participant.getFQName()); + // TODO ? break; default: System.err.println("Unknown Event type"); @@ -664,8 +657,6 @@ public class SessionView extends AbstractSessionView { @SuppressWarnings("unchecked") private void participantDeparted(UserId participant) { - System.out.println("++++ handle departed here: " - + participant.getName() + ", " + participant.getFQName()); String userId = CollaborationUtils.makeUserId(participant); List users = (List) usersTable .getInput(); @@ -692,7 +683,5 @@ public class SessionView extends AbstractSessionView { .getInput(); String name = participant.getFQName(); String userId = CollaborationUtils.makeUserId(participant); - System.out.println("++++ handle presence's role updated here name: " - + name + ", userId: " + userId); } } diff --git a/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF index 90284d0a66..182139f44a 100644 --- a/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF @@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.runtime, com.raytheon.uf.common.serialization;bundle-version="1.12.1174", com.raytheon.uf.viz.core;bundle-version="1.12.1174", org.jivesoftware.smack;bundle-version="3.1.100", - org.eclipse.swt;bundle-version="3.6.1" + org.eclipse.swt;bundle-version="3.6.1", + com.raytheon.uf.common.comm Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.collaboration, diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java index a766227ec3..62e6427617 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java @@ -22,6 +22,9 @@ package com.raytheon.uf.viz.collaboration; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import com.raytheon.uf.common.comm.NetworkStatistics; +import com.raytheon.uf.viz.core.jobs.StatsJob; + /** * TODO Add Description * @@ -40,9 +43,20 @@ import org.osgi.framework.BundleContext; */ public class Activator implements BundleActivator { - private static BundleContext context; + public static final String PEER_TO_PEER = "PeerToPeerMsg"; - static BundleContext getContext() { + public static final String VENUE = "VenueMsg"; + + private static Activator plugin; + + private BundleContext context; + + private NetworkStatistics networkStats = new NetworkStatistics(); + + private StatsJob statsJob = new StatsJob("XMPP Network Statistics", + networkStats); + + public BundleContext getContext() { return context; } @@ -50,14 +64,26 @@ public class Activator implements BundleActivator { * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext bundleContext) throws Exception { - Activator.context = bundleContext; + this.context = bundleContext; + plugin = this; + statsJob.schedule(); } /** * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext bundleContext) throws Exception { - Activator.context = null; + plugin = null; + context = null; + statsJob.shutdown(); + } + + public NetworkStatistics getNetworkStats() { + return networkStats; + } + + public static Activator getDefault() { + return plugin; } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java index 607514a301..40fbc0df97 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java @@ -62,10 +62,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; public abstract class Tools { - public static final String PROP_DATA_PROVIDER = "DATA_PROVIDER"; - - public static final String PROP_SESSION_LEADER = "SESSION_LEADER"; - public static final String TAG_INVITE = "[[INVITEID#"; public static final String TAG_INVITE_ID = TAG_INVITE + "%s]]%s"; @@ -107,8 +103,10 @@ public abstract class Tools { public static CompressionType COMPRESSION_TYPE = CompressionType.ZLIB; + private static boolean log_compression = false; + private enum CompressionType { - ZLIB, GZIP, SNAPPY; + ZLIB, GZIP; public byte toByte() { return (byte) ordinal(); @@ -430,7 +428,8 @@ public abstract class Tools { break; } case NONE: { - break; + throw new CollaborationException("Serialization of " + + data.getClass().getName() + " not supported"); } case ISNULL: { break; @@ -524,10 +523,12 @@ public abstract class Tools { compressionStrm.flush(); compressionStrm.close(); byte[] result = out.toByteArray(); - System.out.println(cType + " Compression time(milliseconds) " - + (System.currentTimeMillis() - start) / 1000F - + " to compress " + bytes.length + " bytes to " - + result.length + " bytes."); + if (log_compression) { + System.out.println(cType + " Compression time(milliseconds) " + + (System.currentTimeMillis() - start) / 1000F + + " to compress " + bytes.length + " bytes to " + + result.length + " bytes."); + } return result; } catch (IOException e) { throw new CollaborationException("Unable to compress data.", e); @@ -536,13 +537,17 @@ public abstract class Tools { private static OutputStream createCompressionOutputStream(OutputStream out) throws IOException { + OutputStream stream = null; switch (COMPRESSION_TYPE) { case GZIP: - return new GZIPOutputStream(out); + stream = new GZIPOutputStream(out); + break; case ZLIB: default: - return new DeflaterOutputStream(out); + stream = new DeflaterOutputStream(out); + break; } + return stream; } private static byte[] uncompress(byte[] bytes) @@ -574,10 +579,13 @@ public abstract class Tools { } dest.close(); byte[] resultBuffer = out.toByteArray(); - System.out.println(cType + " Uncompression time(milliseconds): " - + ((System.currentTimeMillis() - start) / 1000F) - + " to uncompress " + bytes.length + " bytes to " - + resultBuffer.length + " bytes."); + if (log_compression) { + System.out.println(cType + + " Uncompression time(milliseconds): " + + ((System.currentTimeMillis() - start) / 1000F) + + " to uncompress " + bytes.length + " bytes to " + + resultBuffer.length + " bytes."); + } return resultBuffer; } catch (IOException e) { throw new CollaborationException("Unable to uncompress data.", e); @@ -586,13 +594,17 @@ public abstract class Tools { private static InputStream createCompressionInputStream( CompressionType cType, InputStream in) throws IOException { + InputStream stream = null; switch (cType) { case GZIP: - return new GZIPInputStream(in); + stream = new GZIPInputStream(in); + break; case ZLIB: default: - return new InflaterInputStream(in); + stream = new InflaterInputStream(in); + break; } + return stream; } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java index 376ca55d1c..9d8333ba9b 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java @@ -203,8 +203,8 @@ public class CollaborationConnection implements IEventPublisher { eventBus.register(rosterEventSubscriber); } // Debug -- event viewer ---------------- - rosterEventHandler = new RosterEventHandler(); - eventBus.register(rosterEventHandler); + // rosterEventHandler = new RosterEventHandler(); + // eventBus.register(rosterEventHandler); // Debug -- event viewer ---------------- sessions = new HashMap(); @@ -217,10 +217,9 @@ public class CollaborationConnection implements IEventPublisher { @Override public void handleEvent(IContainerEvent event) { - + // TODO? System.out.println("ContainerEvent.Type = " + event.getClass().getName()); - } }); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java index c97da371c2..c84ecddb85 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java @@ -30,6 +30,7 @@ import org.eclipse.ecf.presence.im.IChatMessage; import org.eclipse.ecf.presence.im.IChatMessageSender; import com.google.common.eventbus.EventBus; +import com.raytheon.uf.viz.collaboration.Activator; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer; @@ -93,6 +94,11 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer { } } try { + Activator + .getDefault() + .getNetworkStats() + .log(Activator.PEER_TO_PEER, + message.getBody().length(), 0); chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT, subject, body, props); } catch (ECFException e) { diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java index 37dece3d13..4b9179d8a7 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java @@ -26,6 +26,10 @@ import org.eclipse.ecf.presence.IIMMessageListener; import org.eclipse.ecf.presence.im.IChatMessage; import org.eclipse.ecf.presence.im.IChatMessageEvent; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.collaboration.Activator; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent; @@ -54,6 +58,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; public class PeerToPeerCommHelper implements IIMMessageListener { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(PeerToPeerCommHelper.class); + private CollaborationConnection manager; /** @@ -61,7 +68,7 @@ public class PeerToPeerCommHelper implements IIMMessageListener { * @param manager * @param presenceAdapter */ - PeerToPeerCommHelper(CollaborationConnection manager) { + protected PeerToPeerCommHelper(CollaborationConnection manager) { this.manager = manager; } @@ -70,18 +77,16 @@ public class PeerToPeerCommHelper implements IIMMessageListener { */ @Override public void handleMessageEvent(IIMMessageEvent messageEvent) { - if (messageEvent instanceof IChatMessageEvent) { IChatMessageEvent event = (IChatMessageEvent) messageEvent; - System.out.println(" message event.body " - + event.getChatMessage().getBody()); IChatMessage msg = event.getChatMessage(); String body = msg.getBody(); + Activator.getDefault().getNetworkStats() + .log(Activator.PEER_TO_PEER, 0, body.length()); if (body != null) { if (body.startsWith(Tools.CMD_PREAMBLE)) { routeData(msg); - } else { // anything else pass to the normal text routeMessage(msg); @@ -99,7 +104,8 @@ public class PeerToPeerCommHelper implements IIMMessageListener { try { object = Tools.unMarshallData(message.getBody()); } catch (CollaborationException e) { - System.out.println("Error unmarshalling PeerToPeer data"); + statusHandler.handle(Priority.PROBLEM, + "Error unmarshalling PeerToPeer data", e); } if (object != null) { String sessionId = (String) message.getProperties().get( @@ -112,8 +118,8 @@ public class PeerToPeerCommHelper implements IIMMessageListener { if (session != null) { session.getEventPublisher().post(object); } else { - System.out.println("ERROR: Unknown sessionid [" + sessionId - + "]"); + statusHandler.handle(Priority.PROBLEM, + "ERROR: Unknown sessionid [" + sessionId + "]"); } } manager.getEventPublisher().post(object); diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java index 36d611039a..3663d84eec 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java @@ -82,10 +82,8 @@ public class SharedDisplaySession extends VenueSession implements if (session != null) { String message = Tools.marshallData(obj); if (message != null) { - TextMessage msg = new TextMessage(participant, message); msg.setProperty(Tools.PROP_SESSION_ID, getSessionId()); - session.sendPeerToPeer(msg); } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index fd2e30823a..1750393404 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -43,6 +43,7 @@ import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID; import com.google.common.eventbus.EventBus; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.collaboration.Activator; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; @@ -284,6 +285,8 @@ public class VenueSession extends BaseSession implements IVenueSession { throws CollaborationException { // Assume success if ((venueContainer != null) && (message != null)) { + Activator.getDefault().getNetworkStats() + .log(Activator.VENUE, message.length(), 0); IChatRoomMessageSender sender = venueContainer .getChatRoomMessageSender(); try { @@ -408,7 +411,11 @@ public class VenueSession extends BaseSession implements IVenueSession { if (messageEvent instanceof IChatRoomMessageEvent) { IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent) .getChatRoomMessage(); - + Activator + .getDefault() + .getNetworkStats() + .log(Activator.VENUE, 0, + m.getMessage().length()); if (accept(m)) { distributeMessage(convertMessage(m)); } diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/StatsJob.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/jobs/StatsJob.java similarity index 87% rename from cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/StatsJob.java rename to cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/jobs/StatsJob.java index 750137298b..83a948f458 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/StatsJob.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/jobs/StatsJob.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.thinclient; +package com.raytheon.uf.viz.core.jobs; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -46,7 +46,7 @@ import com.raytheon.uf.common.comm.NetworkStatistics.NetworkTraffic; public class StatsJob extends Job { - private NetworkStatistics stats = NetworkStatistics.getInstance(); + private NetworkStatistics stats; private long lastSent = 0, lastReceived = 0, lastRequestCount = 0; @@ -57,9 +57,10 @@ public class StatsJob extends Job { /** * @param name */ - public StatsJob() { - super("Network Statistics Job"); + public StatsJob(String name, NetworkStatistics stats) { + super(name); setSystem(true); + this.stats = stats; } /* @@ -81,14 +82,14 @@ public class StatsJob extends Job { - lastRequestCount; System.out.println("Last minute sent " + requestCountInLastMinute - + " http requests for a total of " - + (sentInLastMinute / 1000) + " kB sent and " - + (receivedInLastMinute / 1000) + " kB received"); + + " messages for a total of " + (sentInLastMinute / 1000) + + " kB sent and " + (receivedInLastMinute / 1000) + + " kB received"); lastSent = total.getBytesSent(); lastReceived = total.getBytesReceived(); lastRequestCount = total.getRequestCount(); System.out.println("Total sent " + total.getRequestCount() - + " http requests for a total of " + (lastSent / 1000) + + " messages for a total of " + (lastSent / 1000) + " kB sent and " + (lastReceived / 1000) + " kB received"); NetworkTraffic[] mapped = stats.getMappedTrafficStats(); for (NetworkTraffic nt : mapped) { diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java index c75e8c66d7..ac6d0a7af4 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java @@ -122,7 +122,8 @@ public class ThriftClient { private static INotAuthHandler defaultHandler = UserController .getNotAuthHandler(); - private static NetworkStatistics stats = NetworkStatistics.getInstance(); + private static NetworkStatistics stats = HttpClient.getInstance() + .getStats(); /** * Construct a thrift web service object that sends method calls to the http diff --git a/cave/com.raytheon.uf.viz.thinclient.alertviz/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.thinclient.alertviz/META-INF/MANIFEST.MF index 1545367269..ce881b65c1 100644 --- a/cave/com.raytheon.uf.viz.thinclient.alertviz/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.thinclient.alertviz/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Require-Bundle: com.raytheon.uf.viz.core, com.raytheon.uf.viz.product.alertviz;bundle-version="1.12.1174", com.raytheon.uf.viz.alertviz.ui;bundle-version="1.12.1174", com.raytheon.uf.viz.alertviz;bundle-version="1.12.1174", - com.raytheon.uf.common.message;bundle-version="1.12.1174" + com.raytheon.uf.common.message;bundle-version="1.12.1174", + com.raytheon.uf.common.comm Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy diff --git a/cave/com.raytheon.uf.viz.thinclient.alertviz/src/com/raytheon/uf/viz/thinclient/alertviz/ThinAlertVizComponent.java b/cave/com.raytheon.uf.viz.thinclient.alertviz/src/com/raytheon/uf/viz/thinclient/alertviz/ThinAlertVizComponent.java index 4f9ea86fc8..0a0d78a69d 100644 --- a/cave/com.raytheon.uf.viz.thinclient.alertviz/src/com/raytheon/uf/viz/thinclient/alertviz/ThinAlertVizComponent.java +++ b/cave/com.raytheon.uf.viz.thinclient.alertviz/src/com/raytheon/uf/viz/thinclient/alertviz/ThinAlertVizComponent.java @@ -26,11 +26,12 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MessageBox; +import com.raytheon.uf.common.comm.HttpClient; import com.raytheon.uf.viz.alertviz.ui.dialogs.AlertVisualization; +import com.raytheon.uf.viz.core.jobs.StatsJob; import com.raytheon.uf.viz.product.alertviz.AlertVizApplication; import com.raytheon.uf.viz.thinclient.Activator; import com.raytheon.uf.viz.thinclient.IThinClientComponent; -import com.raytheon.uf.viz.thinclient.StatsJob; import com.raytheon.uf.viz.thinclient.ThinClientNotificationManagerJob; import com.raytheon.uf.viz.thinclient.cache.ThinClientCacheManager; import com.raytheon.uf.viz.thinclient.localization.LocalizationCachePersistence; @@ -63,9 +64,10 @@ public class ThinAlertVizComponent extends AlertVizApplication implements @Override public Object startComponent(String componentName) throws Exception { - Activator.getDefault().setComponent(this); - // Start network statistics - statsJob = new StatsJob(); + Activator.getDefault().setComponent(this); + // Start network statistics + statsJob = new StatsJob("HTTP Network Statistics", HttpClient + .getInstance().getStats()); statsJob.schedule(); return super.startComponent(componentName); } @@ -94,30 +96,30 @@ public class ThinAlertVizComponent extends AlertVizApplication implements } protected AlertVisualization createAlertVisualization( - boolean runningStandalone, final Display display) { - return new AlertVisualization(runningStandalone, display) { - - @Override - protected void createTrayMenuItems() { - super.createTrayMenuItems(); - if (!runningStandalone) { - new MenuItem(trayItemMenu, SWT.SEPARATOR); - } - MenuItem exitMI = new MenuItem(trayItemMenu, SWT.NONE); - exitMI.setText("Exit..."); - exitMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION - | SWT.YES | SWT.NO); - mb.setText("Confirm Exit"); - mb.setMessage("Any unsaved changes will be lost.\n Are you sure you want to exit?"); - if (mb.open() == SWT.YES) { - display.dispose(); - } - } - }); - } - }; + boolean runningStandalone, final Display display) { + return new AlertVisualization(runningStandalone, display) { + + @Override + protected void createTrayMenuItems() { + super.createTrayMenuItems(); + if (!runningStandalone) { + new MenuItem(trayItemMenu, SWT.SEPARATOR); + } + MenuItem exitMI = new MenuItem(trayItemMenu, SWT.NONE); + exitMI.setText("Exit..."); + exitMI.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION + | SWT.YES | SWT.NO); + mb.setText("Confirm Exit"); + mb.setMessage("Any unsaved changes will be lost.\n Are you sure you want to exit?"); + if (mb.open() == SWT.YES) { + display.dispose(); + } + } + }); + } + }; } } diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java index 8847624c0d..7a7b439666 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java @@ -31,16 +31,17 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.application.WorkbenchAdvisor; import org.osgi.framework.Bundle; +import com.raytheon.uf.common.comm.HttpClient; import com.raytheon.uf.common.datastorage.DataStoreFactory; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.jobs.StatsJob; import com.raytheon.uf.viz.core.localization.BundleScanner; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.thinclient.Activator; import com.raytheon.uf.viz.thinclient.IThinClientComponent; -import com.raytheon.uf.viz.thinclient.StatsJob; import com.raytheon.uf.viz.thinclient.ThinClientNotificationManagerJob; import com.raytheon.uf.viz.thinclient.cache.ThinClientCacheManager; import com.raytheon.uf.viz.thinclient.cave.cache.CachingDataStoreFactory; @@ -106,7 +107,8 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { ThinClientPreferenceConstants.P_MENU_TIME_REFRESH_INTERVAL)); // Start network statistics - statsJob = new StatsJob(); + statsJob = new StatsJob("HTTP Network Statistics", HttpClient + .getInstance().getStats()); statsJob.schedule(); // Set ourselves as the activators component diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java index aceae79e4c..2bbffe1952 100644 --- a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java @@ -89,7 +89,7 @@ public class HttpClient { private ThreadSafeClientConnManager connManager = null; - private NetworkStatistics stats = NetworkStatistics.getInstance(); + private NetworkStatistics stats = new NetworkStatistics(); private HttpClient() { connManager = new ThreadSafeClientConnManager(); @@ -633,6 +633,15 @@ public class HttpClient { this.retryCount = retryCount; } + /** + * Gets the network statistics for http traffic. + * + * @return + */ + public NetworkStatistics getStats() { + return stats; + } + /** * Provides a safe interface callback for implementing stream behavior with * http diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/NetworkStatistics.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/NetworkStatistics.java index 890607a37a..03c5220f90 100644 --- a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/NetworkStatistics.java +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/NetworkStatistics.java @@ -109,7 +109,7 @@ public class NetworkStatistics { String sentString = toString(bytesSent), receivedString = toString(bytesReceived); return "Network Traffic Stats for '" + identifier + "' : " - + requestCount + " requests, sent " + sentString + + requestCount + " messages, sent " + sentString + ", received " + receivedString; } @@ -134,17 +134,11 @@ public class NetworkStatistics { } } - private static final NetworkStatistics instance = new NetworkStatistics(); - private NetworkTraffic totalTraffic = new NetworkTraffic(null); private Map mappedTraffic = new LinkedHashMap(); - public static NetworkStatistics getInstance() { - return instance; - } - - private NetworkStatistics() { + public NetworkStatistics() { } @@ -185,6 +179,7 @@ public class NetworkStatistics { traffic.addBytesSent(bytesSent); traffic.addBytesReceived(bytesReceived); traffic.incrementRequestCount(); + this.log(bytesSent, bytesReceived); } /**