Skip to content

Commit f873872

Browse files
author
Alexandru Scvortov
committed
rename ackSet to unconfirmedSet
1 parent 6d0bc60 commit f873872

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

test/src/com/rabbitmq/client/test/functional/Confirm.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public class Confirm extends BrokerTestCase
3535
{
3636
final static int NUM_MESSAGES = 1000;
3737
private static final String TTL_ARG = "x-message-ttl";
38-
private SortedSet<Long> ackSet;
38+
private SortedSet<Long> unconfirmedSet;
3939

4040
@Override
4141
protected void setUp() throws IOException {
4242
super.setUp();
43-
ackSet = Collections.synchronizedSortedSet(new TreeSet<Long>());
43+
unconfirmedSet =
44+
Collections.synchronizedSortedSet(new TreeSet<Long>());
4445
channel.setConfirmListener(new ConfirmListener() {
4546
public void handleAck(long seqNo, boolean multiple) {
4647
Confirm.this.handleAck(seqNo, multiple);
@@ -239,7 +240,7 @@ private void publishN(String exchangeName, String queueName,
239240
throws IOException
240241
{
241242
for (long i = 0; i < NUM_MESSAGES; i++) {
242-
ackSet.add(channel.getNextPublishSeqNo());
243+
unconfirmedSet.add(channel.getNextPublishSeqNo());
243244
publish(exchangeName, queueName, persistent, mandatory, immediate);
244245
}
245246
}
@@ -257,13 +258,13 @@ private void publish(String exchangeName, String queueName,
257258
}
258259

259260
private void handleAck(long msgSeqNo, boolean multiple) {
260-
if (!ackSet.contains(msgSeqNo)) {
261+
if (!unconfirmedSet.contains(msgSeqNo)) {
261262
fail("got duplicate ack: " + msgSeqNo);
262263
}
263264
if (multiple) {
264-
ackSet.headSet(msgSeqNo + 1).clear();
265+
unconfirmedSet.headSet(msgSeqNo + 1).clear();
265266
} else {
266-
ackSet.remove(msgSeqNo);
267+
unconfirmedSet.remove(msgSeqNo);
267268
}
268269
}
269270

@@ -281,7 +282,7 @@ private void basicRejectCommon(boolean requeue)
281282
}
282283

283284
private void waitAcks() throws InterruptedException {
284-
while (ackSet.size() > 0)
285+
while (unconfirmedSet.size() > 0)
285286
Thread.sleep(10);
286287
}
287288
}

test/src/com/rabbitmq/examples/ConfirmDontLoseMessages.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void main(String[] args)
4848
}
4949

5050
static class Publisher implements Runnable {
51-
private volatile SortedSet<Long> ackSet =
51+
private volatile SortedSet<Long> unconfirmedSet =
5252
Collections.synchronizedSortedSet(new TreeSet<Long>());
5353

5454
public void run() {
@@ -63,22 +63,22 @@ public void run() {
6363
ch.setConfirmListener(new ConfirmListener() {
6464
public void handleAck(long seqNo, boolean multiple) {
6565
if (multiple) {
66-
ackSet.headSet(seqNo+1).clear();
66+
unconfirmedSet.headSet(seqNo+1).clear();
6767
} else {
68-
ackSet.remove(seqNo);
68+
unconfirmedSet.remove(seqNo);
6969
}
7070
}
7171

7272
public void handleNack(long seqNo, boolean multiple) {
7373
int lost = 0;
7474
if (multiple) {
7575
SortedSet<Long> nackd =
76-
ackSet.headSet(seqNo+1);
76+
unconfirmedSet.headSet(seqNo+1);
7777
lost = nackd.size();
7878
nackd.clear();
7979
} else {
8080
lost = 1;
81-
ackSet.remove(seqNo);
81+
unconfirmedSet.remove(seqNo);
8282
}
8383
System.out.printf("Probably lost %d messages.\n",
8484
lost);
@@ -87,14 +87,14 @@ public void handleNack(long seqNo, boolean multiple) {
8787

8888
// Publish
8989
for (long i = 0; i < MSG_COUNT; ++i) {
90-
ackSet.add(ch.getNextPublishSeqNo());
90+
unconfirmedSet.add(ch.getNextPublishSeqNo());
9191
ch.basicPublish("", QUEUE_NAME,
9292
MessageProperties.PERSISTENT_BASIC,
9393
"nop".getBytes());
9494
}
9595

9696
// Wait
97-
while (ackSet.size() > 0)
97+
while (unconfirmedSet.size() > 0)
9898
Thread.sleep(10);
9999

100100
// Cleanup

test/src/com/rabbitmq/examples/MulticastMain.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static class Producer implements Runnable, ReturnListener,
239239
private long confirmCount;
240240
private long nackCount;
241241
private Semaphore confirmPool;
242-
private volatile SortedSet<Long> ackSet =
242+
private volatile SortedSet<Long> unconfirmedSet =
243243
Collections.synchronizedSortedSet(new TreeSet<Long>());
244244

245245
public Producer(Channel channel, String exchangeName, String id,
@@ -287,11 +287,11 @@ private void handleAckNack(long seqNo, boolean multiple,
287287
boolean nack) {
288288
int numConfirms = 0;
289289
if (multiple) {
290-
SortedSet<Long> confirmed = ackSet.headSet(seqNo + 1);
290+
SortedSet<Long> confirmed = unconfirmedSet.headSet(seqNo + 1);
291291
numConfirms += confirmed.size();
292292
confirmed.clear();
293293
} else {
294-
ackSet.remove(seqNo);
294+
unconfirmedSet.remove(seqNo);
295295
numConfirms = 1;
296296
}
297297
synchronized (this) {
@@ -349,7 +349,7 @@ public void run() {
349349
private void publish(byte[] msg)
350350
throws IOException {
351351

352-
ackSet.add(channel.getNextPublishSeqNo());
352+
unconfirmedSet.add(channel.getNextPublishSeqNo());
353353
channel.basicPublish(exchangeName, id,
354354
mandatory, immediate,
355355
persistent ? MessageProperties.MINIMAL_PERSISTENT_BASIC : MessageProperties.MINIMAL_BASIC,

0 commit comments

Comments
 (0)