Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 23787 Details for
Bug 94452
Timeout exceptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch to measure thru put
jdwp-thuput.patch (text/plain), 12.02 KB, created by
Darin Wright
on 2005-06-22 17:44:42 EDT
(
hide
)
Description:
patch to measure thru put
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2005-06-22 17:44:42 EDT
Size:
12.02 KB
patch
obsolete
>Index: jdi/org/eclipse/jdi/internal/connect/PacketReceiveManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/connect/PacketReceiveManager.java,v >retrieving revision 1.18 >diff -u -r1.18 PacketReceiveManager.java >--- jdi/org/eclipse/jdi/internal/connect/PacketReceiveManager.java 16 May 2005 21:02:40 -0000 1.18 >+++ jdi/org/eclipse/jdi/internal/connect/PacketReceiveManager.java 22 Jun 2005 13:49:40 -0000 >@@ -14,6 +14,7 @@ > import java.io.InterruptedIOException; > import java.text.MessageFormat; > import java.util.ArrayList; >+import java.util.Iterator; > import java.util.LinkedList; > import java.util.ListIterator; > >@@ -22,6 +23,7 @@ > import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket; > import org.eclipse.jdi.internal.jdwp.JdwpPacket; > import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket; >+import org.eclipse.jdi.internal.spy.TrafficManager; > > import com.sun.jdi.VMDisconnectedException; > import com.sun.jdi.connect.spi.Connection; >@@ -50,6 +52,10 @@ > private ArrayList fTimedOutPackets; > > private VirtualMachineImpl fVM; >+ >+ private int fRequestCount = 0; >+ private long fTotalTime = 0L; >+ private LinkedList fRequestsProcessed = new LinkedList(); > > /** > * Create a new thread that receives packets from the Virtual Machine. >@@ -133,8 +139,9 @@ > /** > * @return Returns a specified Reply Packet from the Virtual Machine. > */ >- public JdwpReplyPacket getReply(int id, long timeToWait) { >+ public JdwpReplyPacket getReply(JdwpCommandPacket request, long timeToWait) { > JdwpReplyPacket packet = null; >+ int id = request.getId(); > > long remainingTime = timeToWait; > synchronized (fReplyPackets) { >@@ -159,6 +166,9 @@ > if (packet == null) { > synchronized (fReplyPackets) { > packet = removeReplyPacket(id); >+ if (packet == null) { >+ handleTimeout(request); >+ } > } > } > >@@ -169,11 +179,15 @@ > // Check for a timeout. > if (packet == null) { > synchronized (fTimedOutPackets) { >- fTimedOutPackets.add(new Integer(id)); >+ fTimedOutPackets.add(request); > } > throw new TimeoutException(MessageFormat.format(ConnectMessages.PacketReceiveManager_0, new String[] {id+""})); //$NON-NLS-1$ >+ > } > >+ request.setReply(packet); >+ fRequestCount++; >+ fTotalTime += packet.getTimestamp() - request.getTimestamp(); > return packet; > } > >@@ -181,7 +195,10 @@ > * @return Returns a specified Reply Packet from the Virtual Machine. > */ > public JdwpReplyPacket getReply(JdwpCommandPacket commandPacket) { >- return getReply(commandPacket.getId(), fVM.getRequestTimeout()); >+// synchronized (fRequestsProcessed) { >+// fRequestsProcessed.add(commandPacket); >+// } >+ return getReply(commandPacket, fVM.getRequestTimeout()); > } > > /** >@@ -231,9 +248,6 @@ > * Add a command packet to the command packet list. > */ > private void addCommandPacket(JdwpCommandPacket packet) { >- if (isTimedOut(packet)) { >- return; // already timed out. No need to keep this one >- } > synchronized (fCommandPackets) { > fCommandPackets.add(packet); > fCommandPackets.notifyAll(); >@@ -246,14 +260,62 @@ > * @param packet response packet > * @return whether the request for the given packet has already timed out > */ >- private boolean isTimedOut(JdwpPacket packet) { >+ private boolean isTimedOut(JdwpReplyPacket packet) { > synchronized (fTimedOutPackets) { > if (fTimedOutPackets.isEmpty()) { > return false; > } >- Integer id = new Integer(packet.getId()); >- return fTimedOutPackets.remove(id); >- } >+ Iterator iterator = fTimedOutPackets.listIterator(); >+ while (iterator.hasNext()) { >+ JdwpCommandPacket request = (JdwpCommandPacket) iterator.next(); >+ if (request.getId() == packet.getId()) { >+ iterator.remove(); >+ request.setReply(packet); >+ // >+ timeoutResponseReceived(request); >+ // >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * A request has timed out >+ * >+ * @param request >+ */ >+ private void handleTimeout(JdwpCommandPacket request) { >+// System.out.println("Timeout: " + request.toString()); >+// int index = fRequestsProcessed.indexOf(request); >+// int start = index; >+// for (int i = 0; i < 100; i++) { >+// index--; >+// if (i >= 0) { >+// JdwpCommandPacket prevRequest = (JdwpCommandPacket) fRequestsProcessed.get(index); >+// System.out.println("\t -" + (i + 1) + ": " + prevRequest.toString()); >+// } >+// } >+// long timeout = request.getTimestamp(); >+// long slice = timeout - 500; >+// int requestCount = 0; >+// JdwpPacket packet = request; >+// while (packet.getTimestamp() > slice) { >+// start--; >+// requestCount++; >+// packet = (JdwpPacket) fRequestsProcessed.get(start); >+// } >+// System.out.println("Requests in previous 500ms: " + requestCount); >+ >+ } >+ >+ /** >+ * A request has timed out and a response was later received >+ * @param request >+ */ >+ private void timeoutResponseReceived(JdwpCommandPacket request) { >+ > } > > /** >@@ -277,6 +339,8 @@ > // Read a packet from the Input Stream. > byte[] bytes = getConnection().readPacket(); > JdwpPacket packet = JdwpPacket.build(bytes); >+ packet.timestamp(); >+ TrafficManager.getDefault().replyTick(); > // Add packet to command or reply queue. > if (packet instanceof JdwpCommandPacket) > addCommandPacket((JdwpCommandPacket) packet); >Index: jdi/org/eclipse/jdi/internal/connect/PacketSendManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/connect/PacketSendManager.java,v >retrieving revision 1.13 >diff -u -r1.13 PacketSendManager.java >--- jdi/org/eclipse/jdi/internal/connect/PacketSendManager.java 6 Apr 2005 21:10:48 -0000 1.13 >+++ jdi/org/eclipse/jdi/internal/connect/PacketSendManager.java 22 Jun 2005 13:49:40 -0000 >@@ -16,6 +16,7 @@ > import java.util.LinkedList; > > import org.eclipse.jdi.internal.jdwp.JdwpPacket; >+import org.eclipse.jdi.internal.spy.TrafficManager; > > import com.sun.jdi.VMDisconnectedException; > import com.sun.jdi.connect.spi.Connection; >@@ -103,7 +104,9 @@ > // Put available packets on Output Stream. > while (packetsToSend.size() > 0) { > // Note that only JdwpPackets are added to the list, so a ClassCastException can't occur. >- JdwpPacket packet = (JdwpPacket)packetsToSend.removeFirst(); >+ JdwpPacket packet = (JdwpPacket)packetsToSend.removeFirst(); >+ packet.timestamp(); >+ TrafficManager.getDefault().requestTick(); > byte[] bytes = packet.getPacketAsBytes(); > getConnection().writePacket(bytes); > } >Index: jdi/org/eclipse/jdi/internal/jdwp/JdwpCommandPacket.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/jdwp/JdwpCommandPacket.java,v >retrieving revision 1.20 >diff -u -r1.20 JdwpCommandPacket.java >--- jdi/org/eclipse/jdi/internal/jdwp/JdwpCommandPacket.java 16 May 2005 13:47:41 -0000 1.20 >+++ jdi/org/eclipse/jdi/internal/jdwp/JdwpCommandPacket.java 22 Jun 2005 13:49:40 -0000 >@@ -169,6 +169,8 @@ > private static int fgNextId = 1; > /** Command, note that this field is 256 * JDWP CommandSet (unsigned) + JDWP Command. */ > private int fCommand; >+ >+ private JdwpReplyPacket fReply; > > /** > * Creates new JdwpCommandPacket. >@@ -603,6 +605,30 @@ > buffer.append(getCommand()); > break; > } >+ JdwpReplyPacket reply = getReply(); >+ if (reply != null) { >+ buffer.append("["); >+ buffer.append(reply.getTimestamp() - getTimestamp()); >+ buffer.append("ms]"); >+ } > return buffer.toString(); > } >+ >+ /** >+ * Sets the reply for this request. >+ * >+ * @param reply reply packet >+ */ >+ public void setReply(JdwpReplyPacket reply) { >+ fReply = reply; >+ } >+ >+ /** >+ * Returns the reply for this request, or <code>null</code> if none. >+ * >+ * @return the reply for this request, or <code>null</code> >+ */ >+ public JdwpReplyPacket getReply() { >+ return fReply; >+ } > } >Index: jdi/org/eclipse/jdi/internal/jdwp/JdwpPacket.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/jdwp/JdwpPacket.java,v >retrieving revision 1.11 >diff -u -r1.11 JdwpPacket.java >--- jdi/org/eclipse/jdi/internal/jdwp/JdwpPacket.java 24 Feb 2005 14:50:57 -0000 1.11 >+++ jdi/org/eclipse/jdi/internal/jdwp/JdwpPacket.java 22 Jun 2005 13:49:40 -0000 >@@ -35,6 +35,8 @@ > protected byte fFlags = 0; > protected byte[] fDataBuf = null; > >+ private long fTimestamp; >+ > /** > * Set Id. > */ >@@ -236,4 +238,21 @@ > getConstantMaps(); > return fgFlagStrings; > } >+ >+ /** >+ * Sets the timestamp of this packet to the current time. >+ */ >+ public void timestamp() { >+ fTimestamp = System.currentTimeMillis(); >+ } >+ >+ /** >+ * Returns the current timestamp of this packet. The timestamp >+ * represents the time this packet was sent or received. >+ * >+ * @return the current timestamp of this packet >+ */ >+ public long getTimestamp() { >+ return fTimestamp; >+ } > } >Index: jdi/org/eclipse/jdi/internal/spy/TrafficManager.java >=================================================================== >RCS file: jdi/org/eclipse/jdi/internal/spy/TrafficManager.java >diff -N jdi/org/eclipse/jdi/internal/spy/TrafficManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ jdi/org/eclipse/jdi/internal/spy/TrafficManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdi.internal.spy; >+ >+import java.util.Timer; >+import java.util.TimerTask; >+ >+/** >+ * @since 3.1 >+ */ >+public class TrafficManager { >+ >+ private static TrafficManager fgManager = null; >+ >+ public static TrafficManager getDefault() { >+ if (fgManager == null) { >+ fgManager = new TrafficManager(); >+ } >+ return fgManager; >+ } >+ >+ private int fRequestTicks = 0; >+ private int fReplyTicks = 0; >+ private Timer fTimer = new Timer(true); >+ private TimerTask fIdleTask = new IdleTask(); >+ >+ class IdleTask extends TimerTask { >+ >+ public void run() { >+ fgManager.checkIdle(); >+ } >+ >+ } >+ >+ private static final long IDLE_TIME = 1000; >+ >+ private TrafficManager() { >+ fTimer.scheduleAtFixedRate(fIdleTask, IDLE_TIME, IDLE_TIME); >+ } >+ >+ /** >+ * Notification that another request has been sent to the target VM >+ */ >+ public synchronized void requestTick() { >+ fRequestTicks++; >+ } >+ >+ /** >+ * Notification that another reply\event has been received from the target VM >+ */ >+ public synchronized void replyTick() { >+ fReplyTicks++; >+ } >+ >+ private synchronized void checkIdle() { >+ if (fRequestTicks > 0) { >+ System.out.println("Requests/Replies: " + fRequestTicks + " / " + fReplyTicks); >+ } >+ fRequestTicks = 0; >+ fReplyTicks = 0; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 94452
:
23670
| 23787 |
23788
|
23789
|
23853
|
23855
|
23975
|
25416
|
257464