Skip to content
This repository
Browse code

Merge branch 'master' of github.com:CSEMike/OneSwarm

  • Loading branch information...
commit 21402985341529bc2a400362bd59626591490ef1 2 parents 0518ab4 + 6b17acb
Tomas Isdal isdal authored
4 javatests/edu/washington/cs/oneswarm/test/integration/oop/LocalOneSwarmCoordinatee.java
... ... @@ -1,6 +1,7 @@
1 1 package edu.washington.cs.oneswarm.test.integration.oop;
2 2
3 3 import java.io.ByteArrayOutputStream;
  4 +import java.io.FileNotFoundException;
4 5 import java.io.InputStream;
5 6 import java.io.OutputStreamWriter;
6 7 import java.net.HttpURLConnection;
@@ -107,6 +108,9 @@ public void run() {
107 108
108 109 String response = commands.toString();
109 110 ExperimentalHarnessManager.get().enqueue(response.split("\n"));
  111 + } catch (FileNotFoundException e) {
  112 + // Server isn't up.
  113 + logger.fine("Server isn't up, will try again in a minute.");
110 114 } catch (Exception e) {
111 115 e.printStackTrace();
112 116 }
2  oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/datagram/DatagramConnection.java
@@ -298,7 +298,7 @@ boolean messageReceived(DatagramPacket packet) {
298 298 // The message length is 1 (for the type field) + the actual
299 299 // message length.
300 300 int messageLength = decryptBuffer.getInt();
301   - if (messageLength > MAX_DATAGRAM_SIZE) {
  301 + if (messageLength > MAX_DATAGRAM_SIZE || messageLength < 0) {
302 302 logger.warning("got oversized length field!");
303 303 return false;
304 304 }
2  oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/messaging/OSF2FChannelMsg.java
@@ -59,7 +59,7 @@ public boolean isDatagram() {
59 59 }
60 60
61 61 public void setDatagram(boolean datagram) {
62   - this.datagram = true;
  62 + this.datagram = datagram;
63 63 }
64 64
65 65 }
25 oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/MessageStreamMultiplexer.java
@@ -9,8 +9,6 @@
9 9
10 10 import org.gudy.azureus2.core3.util.DirectByteBuffer;
11 11
12   -import com.google.common.collect.HashMultimap;
13   -
14 12 /**
15 13 * Multiplexes a stream of data, and tracks what is in
16 14 * transit across channels.
@@ -25,22 +23,23 @@
25 23 private final HashMap<Integer, ServiceChannelEndpoint> channels;
26 24
27 25 private final HashMap<Integer, SequenceNumber> outstandingMessages;
28   - private final HashMultimap<Integer, SequenceNumber> channelOutstanding;
  26 + private final HashMap<Integer, Set<SequenceNumber>> channelOutstanding;
29 27 private final static byte ss = 44;
30 28
31 29 public MessageStreamMultiplexer(short flow) {
32 30 this.channels = new HashMap<Integer, ServiceChannelEndpoint>();
33 31 this.outstandingMessages = new HashMap<Integer, SequenceNumber>();
34   - this.channelOutstanding = HashMultimap.create();
  32 + this.channelOutstanding = new HashMap<Integer, Set<SequenceNumber>>();
35 33 this.flow = flow;
36 34 next = 0;
37 35 }
38 36
39 37 public void addChannel(ServiceChannelEndpoint s) {
40 38 this.channels.put(s.getChannelId(), s);
  39 + this.channelOutstanding.put(s.getChannelId(), new HashSet<SequenceNumber>());
41 40 }
42 41
43   - public void onAck(OSF2FServiceDataMsg message) {
  42 + public int onAck(OSF2FServiceDataMsg message) {
44 43 // Parse acknowledged messages
45 44 DirectByteBuffer payload = message.getPayload();
46 45 HashSet<SequenceNumber> numbers = new HashSet<SequenceNumber>();
@@ -65,7 +64,7 @@ public void onAck(OSF2FServiceDataMsg message) {
65 64 seq.ack();
66 65 for (Integer channelId : seq.getChannels()) {
67 66 if (this.channels.get(channelId).forgetMessage(seq)) {
68   - channelOutstanding.remove(channelId, seq);
  67 + channelOutstanding.get(channelId).remove(seq);
69 68 seq.removeChannel(channelId);
70 69 }
71 70 }
@@ -76,6 +75,7 @@ public void onAck(OSF2FServiceDataMsg message) {
76 75 for (Integer num : retransmissions) {
77 76 logger.info("Non outstanding packet acked: " + num);
78 77 }
  78 + return numbers.size();
79 79 }
80 80
81 81 public SequenceNumber nextMsg() {
@@ -88,7 +88,7 @@ public SequenceNumber nextMsg() {
88 88 public void sendMsg(SequenceNumber msg, ServiceChannelEndpoint channel) {
89 89 int channelId = channel.getChannelId();
90 90 msg.addChannel(channelId);
91   - channelOutstanding.put(channelId, msg);
  91 + channelOutstanding.get(channelId).add(msg);
92 92 }
93 93
94 94 public boolean hasOutstanding(ServiceChannelEndpoint channel) {
@@ -100,7 +100,7 @@ public boolean hasOutstanding(ServiceChannelEndpoint channel) {
100 100 HashMap<SequenceNumber, DirectByteBuffer> mapping = new HashMap<SequenceNumber, DirectByteBuffer>();
101 101 for (SequenceNumber s : outstanding) {
102 102 DirectByteBuffer msg = channel.getMessage(s);
103   - if (msg != null) {
  103 + if (msg != null && !s.isAcked()) {
104 104 mapping.put(s, msg);
105 105 }
106 106 }
@@ -110,9 +110,12 @@ public boolean hasOutstanding(ServiceChannelEndpoint channel) {
110 110 public void removeChannel(ServiceChannelEndpoint channel) {
111 111 int channelId = channel.getChannelId();
112 112 channels.remove(channelId);
113   - for (SequenceNumber s : channelOutstanding.get(channelId)) {
114   - s.removeChannel(channelId);
  113 + Set<SequenceNumber> inFlight = channelOutstanding.get(channelId);
  114 + if (inFlight != null) {
  115 + for (SequenceNumber s : inFlight) {
  116 + s.removeChannel(channelId);
  117 + }
  118 + channelOutstanding.remove(channelId);
115 119 }
116   - channelOutstanding.removeAll(channelId);
117 120 }
118 121 }
3  oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/OSF2FServiceDataMsg.java
@@ -46,7 +46,7 @@ private OSF2FServiceDataMsg(byte _version, int channelID, int sequenceNumber, sh
46 46 }
47 47
48 48 static OSF2FServiceDataMsg acknowledge(byte _version, int channelID, short subchannel,
49   - int[] acknowledgements) {
  49 + int[] acknowledgements, boolean datagram) {
50 50 int payloadSize = acknowledgements.length - 1;
51 51 DirectByteBuffer data = null;
52 52 if (payloadSize > 0) {
@@ -58,6 +58,7 @@ static OSF2FServiceDataMsg acknowledge(byte _version, int channelID, short subch
58 58 }
59 59 OSF2FServiceDataMsg msg = new OSF2FServiceDataMsg(_version, channelID, acknowledgements[0],
60 60 subchannel, new int[0], data, (byte) 8);
  61 + msg.setDatagram(datagram);
61 62 return msg;
62 63 }
63 64
2  oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/SequenceNumber.java
@@ -57,6 +57,6 @@ public short getFlow() {
57 57
58 58 @Override
59 59 public String toString() {
60   - return "[message " + this.number + "." + this.flow + "]";
  60 + return "[flow " + this.flow + " message " + this.number + "]";
61 61 }
62 62 }
152 oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/ServiceChannelEndpoint.java
@@ -35,8 +35,11 @@
35 35 public class ServiceChannelEndpoint extends OverlayEndpoint {
36 36 public final static Logger logger = Logger.getLogger(ServiceChannelEndpoint.class.getName());
37 37 private static final byte ss = 0;
  38 + // Moving average sampling weight for latency estimation.
38 39 private static final double EWMA = 0.25;
39   - private static final double RETRANSMISSION_PERIOD = 2;
  40 + // How long (in # RTT) before packet retransmission.
  41 + private static final double RETRANSMISSION_MIN = 2;
  42 + private static final double RETRANSMISSION_MAX = 3;
40 43
41 44 public static final int MAX_SERVICE_MESSAGE_SIZE = 1024;
42 45
@@ -78,6 +81,9 @@ public void addDelegate(ServiceChannelEndpointDelegate d, short flow) {
78 81 this.delegateOrder.add(flow);
79 82 }
80 83 this.delegates.put(flow, d);
  84 + if (friendConnection.isReadyForWrite(null)) {
  85 + d.channelIsReady(this);
  86 + }
81 87 }
82 88
83 89 public void removeDelegate(ServiceChannelEndpointDelegate d) {
@@ -159,14 +165,16 @@ protected void handleDelayedOverlayMessage(OSF2FChannelDataMsg msg) {
159 165 start();
160 166 }
161 167 if (!(msg instanceof OSF2FServiceDataMsg)) {
  168 + logger.warning("Msg wasn't SDM: " + msg.getDescription());
162 169 return;
163 170 }
164 171 OSF2FServiceDataMsg newMessage = (OSF2FServiceDataMsg) msg;
165 172 // logger.fine("Received msg with sequence number " +
166 173 if (!newMessage.isAck()) {
167   - logger.finest("ack enqueued for " + newMessage.getSequenceNumber());
  174 + logger.finest("ack enqueued for " + newMessage.getDescription());
168 175 super.writeMessage(OSF2FServiceDataMsg.acknowledge(OSF2FMessage.CURRENT_VERSION,
169   - channelId, (short) 0, new int[] { newMessage.getSequenceNumber() }));
  176 + channelId, newMessage.getSubchannel(),
  177 + new int[] { newMessage.getSequenceNumber() }, newMessage.isDatagram()));
170 178 }
171 179
172 180 for (ServiceChannelEndpointDelegate d : this.delegates.values()) {
@@ -181,49 +189,67 @@ public long getServiceKey() {
181 189 }
182 190
183 191 public void writeMessage(final SequenceNumber num, DirectByteBuffer buffer, boolean datagram) {
  192 + // Move the requester to the bottom of the priority list.
184 193 try {
185 194 this.delegateOrder.remove(num.getFlow());
186 195 } catch (IndexOutOfBoundsException e) {
187 196 return;
188 197 }
189 198 this.delegateOrder.add(num.getFlow());
190   - writeMessage(num, buffer, 0, datagram);
191   - }
192 199
193   - private void writeMessage(final SequenceNumber num, DirectByteBuffer buffer, int attempt,
194   - boolean datagram) {
195 200 boolean rst = buffer == null;
196 201 if (buffer == null) {
197 202 buffer = new DirectByteBuffer(ByteBuffer.allocate(0));
198 203 }
  204 +
199 205 int length = buffer.remaining(ss);
200   - ReferenceCountedDirectByteBuffer copy = buffer.getReferenceCountedBuffer();
201   - sentMessage sent = new sentMessage(num, copy, length, attempt, datagram);
202   - this.sentMessages.put(num, sent);
203   - this.outstandingBytes += length;
204   - OSF2FServiceDataMsg msg = new OSF2FServiceDataMsg(OSF2FMessage.CURRENT_VERSION, channelId,
205   - num.getNum(), num.getFlow(), new int[0], copy);
206   - if (num.getNum() == 0 && !rst) {
  206 + ReferenceCountedDirectByteBuffer cpy = buffer.getReferenceCountedBuffer();
  207 + sentMessage msg = new sentMessage(num, cpy, length, 0, datagram, rst);
  208 +
  209 + writeMessage(msg);
  210 + }
  211 +
  212 + private void writeMessage(sentMessage msg) {
  213 + SequenceNumber num = msg.num;
  214 + synchronized (sentMessages) {
  215 + this.sentMessages.put(num, msg);
  216 + }
  217 + this.outstandingBytes += msg.length;
  218 +
  219 + double retransmit = RETRANSMISSION_MIN + (RETRANSMISSION_MAX - RETRANSMISSION_MIN)
  220 + * Math.random();
  221 + // Remember the message may need to be retransmitted.
  222 + delayedExecutor.queue((long) (retransmit * this.latency * (1 << msg.attempt)), msg);
  223 +
  224 + if (msg.attempt > 0 && msg.creation + latency > System.currentTimeMillis()) {
  225 + logger.warning("Skipping over-aggresive retransmission.");
  226 + return;
  227 + }
  228 + msg.creation = System.currentTimeMillis();
  229 +
  230 + // Outgoing msg will be freed by super.writeMessage.
  231 + msg.msg.incrementReferenceCount();
  232 + OSF2FServiceDataMsg outgoing = new OSF2FServiceDataMsg(OSF2FMessage.CURRENT_VERSION,
  233 + channelId, num.getNum(), num.getFlow(), new int[0], msg.msg);
  234 +
  235 + if (num.getNum() == 0 && !msg.rst) {
207 236 // Mark SYN messages.
208   - msg.setControlFlag(4);
  237 + outgoing.setControlFlag(4);
209 238 }
210   - if (rst) {
211   - msg.setControlFlag(2);
  239 + if (msg.rst) {
  240 + outgoing.setControlFlag(2);
212 241 }
213   - if (datagram) {
  242 + if (msg.datagram) {
214 243 // Set datagram flag to allow the packet to be sent over UDP.
215   - msg.setDatagram(true);
  244 + outgoing.setDatagram(true);
216 245 }
217 246
218   - long totalWritten = buffer.remaining(DirectByteBuffer.SS_MSG);
  247 + long totalWritten = msg.length;
219 248 if (logger.isLoggable(Level.FINEST)) {
220   - logger.finest(String.format("Wrote %s to network. bytes: %d", num, length));
  249 + logger.finest(String.format("Wrote %s to network. bytes: %d", num, msg.length));
221 250 }
222   - super.writeMessage(msg);
  251 + super.writeMessage(outgoing);
223 252 bytesOut += totalWritten;
224   -
225   - // Remember the message may need to be retransmitted.
226   - delayedExecutor.queue((long) (RETRANSMISSION_PERIOD * this.latency * (1 << attempt)), sent);
227 253 }
228 254
229 255 public int getOutstanding() {
@@ -243,11 +269,13 @@ public long getLatency() {
243 269 }
244 270
245 271 public DirectByteBuffer getMessage(SequenceNumber num) {
246   - sentMessage m = this.sentMessages.get(num);
247   - if (m != null) {
248   - return m.msg;
  272 + synchronized (sentMessages) {
  273 + sentMessage m = this.sentMessages.get(num);
  274 + if (m != null) {
  275 + return m.msg;
  276 + }
  277 + return null;
249 278 }
250   - return null;
251 279 }
252 280
253 281 /**
@@ -258,26 +286,28 @@ public DirectByteBuffer getMessage(SequenceNumber num) {
258 286 * @return True if the message was successfully stopped from retransmitting.
259 287 */
260 288 public boolean forgetMessage(SequenceNumber num) {
261   - sentMessage msg = this.sentMessages.remove(num);
262   - if (msg == null) {
263   - return false;
264   - }
265   - msg.cancel();
266   - this.outstandingBytes -= msg.length;
267   - long now = System.currentTimeMillis();
268   - long sample = now - msg.creation;
269   - // If not the first attempt, we don't know which attempt was acked.
270   - if (msg.attempt == 0) {
271   - this.latency = (long) (this.latency * (1 - EWMA) + sample * EWMA);
272   - if (sample < minLatency) {
273   - minLatency = sample;
  289 + synchronized (sentMessages) {
  290 + sentMessage msg = this.sentMessages.remove(num);
  291 + if (msg == null) {
  292 + return false;
274 293 }
  294 + msg.cancel();
  295 + this.outstandingBytes -= msg.length;
  296 + long now = System.currentTimeMillis();
  297 + long sample = now - msg.creation;
  298 + // If not the first attempt, we don't know which attempt was acked.
  299 + if (msg.attempt == 0) {
  300 + this.latency = (long) (this.latency * (1 - EWMA) + sample * EWMA);
  301 + if (sample < minLatency) {
  302 + minLatency = sample;
  303 + }
275 304
276   - // Pending messages sent before this one were probably lost
277   - sentMessage[] messages = this.sentMessages.values().toArray(new sentMessage[0]);
278   - for (sentMessage m : messages) {
279   - if (m.creation < msg.creation) {
280   - m.run();
  305 + // Pending messages sent before this one were potentially lost
  306 + sentMessage[] messages = this.sentMessages.values().toArray(new sentMessage[0]);
  307 + for (sentMessage m : messages) {
  308 + if (m.creation < msg.creation) {
  309 + m.run();
  310 + }
281 311 }
282 312 }
283 313 }
@@ -296,11 +326,12 @@ protected boolean isService() {
296 326 private final int position;
297 327 public long creation;
298 328 private final SequenceNumber num;
299   - private final int attempt;
  329 + private int attempt;
300 330 private final boolean datagram;
  331 + public final boolean rst;
301 332
302 333 public sentMessage(SequenceNumber num, ReferenceCountedDirectByteBuffer msg, int length,
303   - int attempt, boolean datagram) {
  334 + int attempt, boolean datagram, boolean rst) {
304 335 this.creation = System.currentTimeMillis();
305 336 this.msg = msg;
306 337 this.position = msg.position(ss);
@@ -309,20 +340,27 @@ public sentMessage(SequenceNumber num, ReferenceCountedDirectByteBuffer msg, int
309 340 this.num = num;
310 341 this.attempt = attempt;
311 342 this.datagram = datagram;
  343 + this.rst = rst;
312 344 }
313 345
314 346 @Override
315 347 public void run() {
316   - sentMessage self = sentMessages.remove(num);
317   - if (self != null && !closed) {
318   - if (self.attempt == attempt) {
319   - logger.fine(num + " was retransmitted.");
320   - outstandingBytes -= length;
321   - msg.position(ss, position);
322   - writeMessage(num, msg, attempt + 1, datagram);
323   - } else {
  348 + synchronized (sentMessages) {
  349 + sentMessage self = sentMessages.remove(num);
  350 + if (self == null || closed) {
  351 + return;
  352 + }
  353 + if (self.attempt != attempt) {
  354 + logger.warning("Message queue concurency issues");
324 355 sentMessages.put(num, self);
  356 + return;
325 357 }
  358 +
  359 + this.attempt += 1;
  360 + logger.fine("retransmitting " + num + ", try " + attempt);
  361 + outstandingBytes -= length;
  362 + msg.position(ss, position);
  363 + writeMessage(this);
326 364 }
327 365 }
328 366
3  oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/ServiceConnection.java
@@ -287,8 +287,7 @@ public boolean channelGotMessage(ServiceChannelEndpoint sender, OSF2FServiceData
287 287
288 288 if (msg.isAck()) {
289 289 logger.fine("Acked msg " + msg.getSequenceNumber());
290   - mmt.onAck(msg);
291   - windowSize += 1;
  290 + windowSize += mmt.onAck(msg);
292 291 return true;
293 292 }
294 293
7 oneswarm_f2f/src/edu/washington/cs/oneswarm/f2f/servicesharing/ServiceConnectionManager.java
@@ -33,6 +33,8 @@ public static ServiceConnectionManager getInstance() {
33 33 return instance;
34 34 }
35 35
  36 + // Both are lists are keyed on service key. 1 endpoint per overlay path, 1
  37 + // serviceconnection per local connection.
36 38 private final HashMap<Long, List<ServiceChannelEndpoint>> connections = new HashMap<Long, List<ServiceChannelEndpoint>>();
37 39 private final HashMap<Long, List<ServiceConnection>> services = new HashMap<Long, List<ServiceConnection>>();
38 40
@@ -51,7 +53,7 @@ public ServiceChannelEndpoint createChannel(FriendConnection nextHop, OSF2FHashS
51 53 return channel;
52 54 }
53 55
54   - public void addChannel(ServiceChannelEndpoint channel) {
  56 + private void addChannel(ServiceChannelEndpoint channel) {
55 57 logger.fine("Network Channel registered with Connection Manager");
56 58 Long key = channel.getServiceKey();
57 59 if (!this.connections.containsKey(key)) {
@@ -125,7 +127,8 @@ public boolean channelGotMessage(ServiceChannelEndpoint sender, OSF2FServiceData
125 127 } else {
126 128 for (ServiceConnection c : existing) {
127 129 if (c.subchannelId == msg.getSubchannel()) {
128   - // Ignore duplicate syn messages.
  130 + // Ignore duplicate syn messages - the connection will
  131 + // handle it directly.
129 132 return false;
130 133 }
131 134 }
19 oneswarm_f2f/test/edu/washington/cs/oneswarm/f2f/servicesharing/ClientServiceConnectionTest.java
@@ -27,21 +27,17 @@
27 27 import edu.washington.cs.oneswarm.f2f.network.FriendConnection;
28 28 import edu.washington.cs.oneswarm.f2f.network.QueueManager;
29 29 import edu.washington.cs.oneswarm.f2f.network.SearchManager;
30   -import edu.washington.cs.oneswarm.f2f.servicesharing.ClientServiceConnection;
31   -import edu.washington.cs.oneswarm.f2f.servicesharing.ServiceChannelEndpoint;
32   -import edu.washington.cs.oneswarm.f2f.servicesharing.ServiceSharingLoopback;
33   -import edu.washington.cs.oneswarm.f2f.servicesharing.ServiceSharingManager;
34 30 import edu.washington.cs.oneswarm.test.integration.ServiceSharingClientTest;
35 31 import edu.washington.cs.oneswarm.test.util.MessageStreamDecoderTestImpl;
36 32 import edu.washington.cs.oneswarm.test.util.OneSwarmTestBase;
37 33 import edu.washington.cs.oneswarm.test.util.TestUtils;
38 34
39 35 /**
40   - * Tests ClientServiceConnection, verifying that data put into its NetworkConnection
41   - * makes its way to one of its FriendConnections.
  36 + * Tests ServiceConnections, verifying that data put into its NetworkConnection
  37 + * makes its way to at least one of the connection endpoints.
42 38 *
43 39 * @author Krysta
44   - *
  40 + *
45 41 */
46 42 public class ClientServiceConnectionTest extends OneSwarmTestBase {
47 43
@@ -52,7 +48,7 @@
52 48 private final static int NUM_FRIENDS = 2;
53 49
54 50 /* The various layers of data-handling */
55   - private static ClientServiceConnection clientConn;
  51 + private static ServiceConnection clientConn;
56 52 private static NetworkConnection netConn;
57 53 private static List<FriendConnection> friends;
58 54 private static MessageStreamDecoderTestImpl decoder;
@@ -108,7 +104,7 @@ private static void setupConnections() {
108 104 tcpEndpoint.getConnectionEndpoint(), new OSF2FMessageEncoder(), decoder,
109 105 false, false, null);
110 106
111   - clientConn = ClientServiceConnection.getConnectionForTest(netConn);
  107 + clientConn = new ServiceConnection(true, (short) 0, netConn);
112 108 friends = new ArrayList<FriendConnection>();
113 109 QueueManager qMgr = new QueueManager();
114 110
@@ -116,8 +112,9 @@ private static void setupConnections() {
116 112 Friend remoteFriend = new Friend("", "Remote " + i, null, false);
117 113 FriendConnection friend = FriendConnection.createStubForTests(qMgr, netConn, remoteFriend);
118 114 friends.add(friend);
119   - clientConn.addChannel(friend, new OSF2FHashSearch((byte) 0, 0, 0),
120   - new OSF2FHashSearchResp((byte) 0, 0, 0, 0));
  115 + ServiceChannelEndpoint ep = new ServiceChannelEndpoint(friend, new OSF2FHashSearch(
  116 + (byte) 0, 0, 0), new OSF2FHashSearchResp((byte) 0, 0, 0, 0), true);
  117 + clientConn.addChannel(ep);
121 118 }
122 119 }
123 120
21 oneswarm_f2f/test/edu/washington/cs/oneswarm/f2ftest/OsSSLTester.java
@@ -25,7 +25,6 @@
25 25 import java.io.IOException;
26 26 import java.net.InetSocketAddress;
27 27 import java.nio.ByteBuffer;
28   -import java.nio.channels.ServerSocketChannel;
29 28 import java.nio.channels.SocketChannel;
30 29
31 30 import org.gudy.azureus2.core3.config.COConfigurationManager;
@@ -33,8 +32,6 @@
33 32 import org.gudy.azureus2.core3.util.Debug;
34 33
35 34 import com.aelitis.azureus.core.networkmanager.VirtualChannelSelector;
36   -import com.aelitis.azureus.core.networkmanager.VirtualServerChannelSelector;
37   -import com.aelitis.azureus.core.networkmanager.VirtualServerChannelSelectorFactory;
38 35 import com.aelitis.azureus.core.networkmanager.VirtualChannelSelector.VirtualSelectorListener;
39 36 import com.aelitis.azureus.core.networkmanager.impl.ProtocolDecoder;
40 37 import com.aelitis.azureus.core.networkmanager.impl.ProtocolDecoderAdapter;
@@ -49,7 +46,7 @@
49 46 private final VirtualChannelSelector connect_selector = new VirtualChannelSelector("PHETester",
50 47 VirtualChannelSelector.OP_CONNECT, true);
51 48
52   - private byte[] TEST_HEADER = "TestHeader".getBytes();
  49 + private final byte[] TEST_HEADER = "TestHeader".getBytes();
53 50
54 51 private static boolean OUTGOING_PLAIN = false;
55 52
@@ -92,6 +89,7 @@ protected void incoming(SocketChannel channel) {
92 89
93 90 final ProtocolDecoderInitial decoder = new ProtocolDecoderInitial(helper, null, false,
94 91 null, new ProtocolDecoderAdapter() {
  92 + @Override
95 93 public void decodeComplete(ProtocolDecoder decoder,
96 94 ByteBuffer remaining_initial_data) {
97 95 System.out.println("incoming decode complete: "
@@ -102,18 +100,22 @@ public void decodeComplete(ProtocolDecoder decoder,
102 100 writeStream("ten fat monkies", decoder.getFilter());
103 101 }
104 102
  103 + @Override
105 104 public void decodeFailed(ProtocolDecoder decoder, Throwable cause) {
106 105 System.out.println("incoming decode failed: "
107 106 + Debug.getNestedExceptionMessage(cause));
108 107 }
109 108
  109 + @Override
110 110 public void gotSecret(byte[] session_secret) {
111 111 }
112 112
  113 + @Override
113 114 public int getMaximumPlainHeaderLength() {
114 115 return (TEST_HEADER.length);
115 116 }
116 117
  118 + @Override
117 119 public int matchPlainHeader(ByteBuffer buffer) {
118 120 int pos = buffer.position();
119 121 int lim = buffer.limit();
@@ -164,6 +166,7 @@ protected void outgoing() {
164 166 } else {
165 167
166 168 connect_selector.register(channel, new VirtualSelectorListener() {
  169 + @Override
167 170 public boolean selectSuccess(VirtualChannelSelector selector, SocketChannel sc,
168 171 Object attachment) {
169 172 try {
@@ -184,6 +187,7 @@ public boolean selectSuccess(VirtualChannelSelector selector, SocketChannel sc,
184 187 }
185 188 }
186 189
  190 + @Override
187 191 public void selectFailure(VirtualChannelSelector selector, SocketChannel sc,
188 192 Object attachment, Throwable msg) {
189 193 msg.printStackTrace();
@@ -211,6 +215,7 @@ protected void outgoing(SocketChannel channel) {
211 215
212 216 final ProtocolDecoderInitial decoder = new ProtocolDecoderInitial(helper,
213 217 new byte[][] { shared_secret }, true, null, new ProtocolDecoderAdapter() {
  218 + @Override
214 219 public void decodeComplete(ProtocolDecoder decoder,
215 220 ByteBuffer remaining_initial_data) {
216 221 System.out.println("outgoing decode complete: "
@@ -223,19 +228,23 @@ public void decodeComplete(ProtocolDecoder decoder,
223 228 writeStream("two jolly porkers", decoder.getFilter());
224 229 }
225 230
  231 + @Override
226 232 public void decodeFailed(ProtocolDecoder decoder, Throwable cause) {
227 233 System.out.println("outgoing decode failed: "
228 234 + Debug.getNestedExceptionMessage(cause));
229 235
230 236 }
231 237
  238 + @Override
232 239 public void gotSecret(byte[] session_secret) {
233 240 }
234 241
  242 + @Override
235 243 public int getMaximumPlainHeaderLength() {
236 244 throw (new RuntimeException());
237 245 }
238 246
  247 + @Override
239 248 public int matchPlainHeader(ByteBuffer buffer) {
240 249 throw (new RuntimeException());
241 250 }
@@ -254,6 +263,7 @@ protected void readStream(final String str, final TransportHelperFilter filter)
254 263 .getReadSelector()
255 264 .register(((TCPTransportHelper) filter.getHelper()).getSocketChannel(),
256 265 new VirtualSelectorListener() {
  266 + @Override
257 267 public boolean selectSuccess(VirtualChannelSelector selector,
258 268 SocketChannel sc, Object attachment) {
259 269 ByteBuffer buffer = ByteBuffer.allocate(1024);
@@ -279,6 +289,7 @@ public boolean selectSuccess(VirtualChannelSelector selector,
279 289 }
280 290 }
281 291
  292 + @Override
282 293 public void selectFailure(VirtualChannelSelector selector,
283 294 SocketChannel sc, Object attachment, Throwable msg) {
284 295 msg.printStackTrace();
@@ -317,7 +328,7 @@ protected void writeStream(byte[] data, SocketChannel channel) {
317 328
318 329 public static void main(String[] args) {
319 330 // String[] encrProto = { "Plain", "XOR", "RC4", "AES", "SSL" };
320   - AEDiagnostics.startup();
  331 + AEDiagnostics.startup(true);
321 332
322 333 // OUTGOING_PLAIN = true;
323 334
14 oneswarm_gwt_ui/src/edu/washington/cs/oneswarm/ui/gwt/client/ReportableErrorDialogBox.java
... ... @@ -1,13 +1,13 @@
1 1 package edu.washington.cs.oneswarm.ui.gwt.client;
2 2
  3 +import com.google.gwt.event.dom.client.ClickEvent;
  4 +import com.google.gwt.event.dom.client.ClickHandler;
3 5 import com.google.gwt.user.client.ui.Button;
4   -import com.google.gwt.user.client.ui.ClickListener;
5 6 import com.google.gwt.user.client.ui.HTML;
6 7 import com.google.gwt.user.client.ui.HorizontalPanel;
7 8 import com.google.gwt.user.client.ui.Label;
8 9 import com.google.gwt.user.client.ui.TextArea;
9 10 import com.google.gwt.user.client.ui.VerticalPanel;
10   -import com.google.gwt.user.client.ui.Widget;
11 11
12 12 import edu.washington.cs.oneswarm.ui.gwt.client.i18n.OSMessages;
13 13 import edu.washington.cs.oneswarm.ui.gwt.rpc.OneSwarmException;
@@ -78,8 +78,9 @@ public ReportableErrorDialogBox(final String inErrorString, boolean fatal,
78 78 status_and_button.setCellHorizontalAlignment(statusLabel, HorizontalPanel.ALIGN_LEFT);
79 79
80 80 mainPanel.add(status_and_button);
81   - dismissButton.addClickListener(new ClickListener() {
82   - public void onClick(Widget sender) {
  81 + dismissButton.addClickHandler(new ClickHandler() {
  82 + @Override
  83 + public void onClick(ClickEvent event) {
83 84 // statusLabel.setText("Sending report...");
84 85 // ((Button)sender).setEnabled(false);
85 86 //
@@ -98,9 +99,8 @@ public void onClick(Widget sender) {
98 99 // onFailure(null);
99 100 // }
100 101 hide();
101   - // }); // reportError RPC
102   - } // report button onClick()
103   - }); // add click listener
  102 + }
  103 + });
104 104
105 105 setWidget(mainPanel);
106 106

0 comments on commit 2140298

Please sign in to comment.
Something went wrong with that request. Please try again.