Skip to content

Commit df76b0a

Browse files
committed
INTERNAL: Remove duplicated pipe max item count vars.
1 parent c542530 commit df76b0a

File tree

10 files changed

+35
-44
lines changed

10 files changed

+35
-44
lines changed

src/main/java/net/spy/memcached/ArcusClient.java

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public class ArcusClient extends FrontCacheMemcachedClient implements ArcusClien
191191
private static final Logger arcusLogger = LoggerFactory.getLogger(ArcusClient.class);
192192
private static final String ARCUS_ADMIN_ADDR = "127.0.0.1:2181";
193193
private static final String DEFAULT_ARCUS_CLIENT_NAME = "ArcusClient";
194+
public static final int MAX_PIPED_ITEM_COUNT = 500;
194195

195196
private final Transcoder<Object> collectionTranscoder;
196197

@@ -844,10 +845,10 @@ public void complete() {
844845
// got status
845846
public void gotStatus(Integer index, OperationStatus status) {
846847
if (status instanceof CollectionOperationStatus) {
847-
rv.addEachResult(index + (idx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT),
848+
rv.addEachResult(index + (idx * MAX_PIPED_ITEM_COUNT),
848849
(CollectionOperationStatus) status);
849850
} else {
850-
rv.addEachResult(index + (idx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT),
851+
rv.addEachResult(index + (idx * MAX_PIPED_ITEM_COUNT),
851852
new CollectionOperationStatus(status));
852853
}
853854
}
@@ -1774,11 +1775,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip
17741775

17751776
List<CollectionPipedInsert<T>> insertList = new ArrayList<>();
17761777

1777-
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) {
1778+
if (elements.size() <= MAX_PIPED_ITEM_COUNT) {
17781779
insertList.add(new BTreePipedInsert<>(key, elements, attributesForCreate, tc));
17791780
} else {
17801781
PartitionedMap<Long, T> list = new PartitionedMap<>(
1781-
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT);
1782+
elements, MAX_PIPED_ITEM_COUNT);
17821783
for (Map<Long, T> elementMap : list) {
17831784
insertList.add(new BTreePipedInsert<>(key, elementMap, attributesForCreate, tc));
17841785
}
@@ -1798,11 +1799,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip
17981799

17991800
List<CollectionPipedInsert<T>> insertList = new ArrayList<>();
18001801

1801-
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) {
1802+
if (elements.size() <= MAX_PIPED_ITEM_COUNT) {
18021803
insertList.add(new ByteArraysBTreePipedInsert<>(key, elements, attributesForCreate, tc));
18031804
} else {
18041805
PartitionedList<Element<T>> list = new PartitionedList<>(
1805-
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT);
1806+
elements, MAX_PIPED_ITEM_COUNT);
18061807
for (List<Element<T>> elementList : list) {
18071808
insertList.add(new ByteArraysBTreePipedInsert<>(key, elementList, attributesForCreate, tc));
18081809
}
@@ -1826,11 +1827,10 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncMopPip
18261827

18271828
List<CollectionPipedInsert<T>> insertList = new ArrayList<>();
18281829

1829-
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) {
1830+
if (elements.size() <= MAX_PIPED_ITEM_COUNT) {
18301831
insertList.add(new MapPipedInsert<>(key, elements, attributesForCreate, tc));
18311832
} else {
1832-
PartitionedMap<String, T> list = new PartitionedMap<>(
1833-
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT);
1833+
PartitionedMap<String, T> list = new PartitionedMap<>(elements, MAX_PIPED_ITEM_COUNT);
18341834
for (Map<String, T> elementMap : list) {
18351835
insertList.add(new MapPipedInsert<>(key, elementMap, attributesForCreate, tc));
18361836
}
@@ -1850,11 +1850,10 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncLopPip
18501850

18511851
List<CollectionPipedInsert<T>> insertList = new ArrayList<>();
18521852

1853-
if (valueList.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) {
1853+
if (valueList.size() <= MAX_PIPED_ITEM_COUNT) {
18541854
insertList.add(new ListPipedInsert<>(key, index, valueList, attributesForCreate, tc));
18551855
} else {
1856-
PartitionedList<T> list = new PartitionedList<>(valueList,
1857-
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT);
1856+
PartitionedList<T> list = new PartitionedList<>(valueList, MAX_PIPED_ITEM_COUNT);
18581857
for (List<T> elementList : list) {
18591858
insertList.add(new ListPipedInsert<>(key, index, elementList, attributesForCreate, tc));
18601859
}
@@ -1874,11 +1873,10 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncSopPip
18741873

18751874
List<CollectionPipedInsert<T>> insertList = new ArrayList<>();
18761875

1877-
if (valueList.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) {
1876+
if (valueList.size() <= MAX_PIPED_ITEM_COUNT) {
18781877
insertList.add(new SetPipedInsert<>(key, valueList, attributesForCreate, tc));
18791878
} else {
1880-
PartitionedList<T> list = new PartitionedList<>(valueList,
1881-
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT);
1879+
PartitionedList<T> list = new PartitionedList<>(valueList, MAX_PIPED_ITEM_COUNT);
18821880
for (List<T> elementList : list) {
18831881
insertList.add(new SetPipedInsert<>(key, elementList, attributesForCreate, tc));
18841882
}
@@ -2310,11 +2308,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip
23102308

23112309
List<CollectionPipedUpdate<T>> updateList = new ArrayList<>();
23122310

2313-
if (elements.size() <= CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT) {
2311+
if (elements.size() <= MAX_PIPED_ITEM_COUNT) {
23142312
updateList.add(new BTreePipedUpdate<>(key, elements, tc));
23152313
} else {
23162314
PartitionedList<Element<T>> list = new PartitionedList<>(
2317-
elements, CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT);
2315+
elements, MAX_PIPED_ITEM_COUNT);
23182316
for (List<Element<T>> elementList : list) {
23192317
updateList.add(new BTreePipedUpdate<>(key, elementList, tc));
23202318
}
@@ -2343,11 +2341,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncMopPip
23432341

23442342
List<CollectionPipedUpdate<T>> updateList = new ArrayList<>();
23452343

2346-
if (elements.size() <= CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT) {
2344+
if (elements.size() <= MAX_PIPED_ITEM_COUNT) {
23472345
updateList.add(new MapPipedUpdate<>(key, elements, tc));
23482346
} else {
23492347
PartitionedMap<String, T> list = new PartitionedMap<>(
2350-
elements, CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT);
2348+
elements, MAX_PIPED_ITEM_COUNT);
23512349

23522350
for (Map<String, T> elementMap : list) {
23532351
updateList.add(new MapPipedUpdate<>(key, elementMap, tc));
@@ -2943,10 +2941,10 @@ <T> CollectionFuture<Map<T, Boolean>> asyncSetPipedExist(
29432941
throw new IllegalArgumentException(
29442942
"The number of piped operations must be larger than 0.");
29452943
}
2946-
if (exist.getItemCount() > SetPipedExist.MAX_PIPED_ITEM_COUNT) {
2944+
if (exist.getItemCount() > MAX_PIPED_ITEM_COUNT) {
29472945
throw new IllegalArgumentException(
29482946
"The number of piped operations must not exceed a maximum of "
2949-
+ SetPipedExist.MAX_PIPED_ITEM_COUNT + ".");
2947+
+ MAX_PIPED_ITEM_COUNT + ".");
29502948
}
29512949

29522950
final CountDownLatch latch = new CountDownLatch(1);
@@ -3107,10 +3105,10 @@ public void complete() {
31073105
// got status
31083106
public void gotStatus(Integer index, OperationStatus status) {
31093107
if (status instanceof CollectionOperationStatus) {
3110-
rv.addEachResult(index + (idx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT),
3108+
rv.addEachResult(index + (idx * MAX_PIPED_ITEM_COUNT),
31113109
(CollectionOperationStatus) status);
31123110
} else {
3113-
rv.addEachResult(index + (idx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT),
3111+
rv.addEachResult(index + (idx * MAX_PIPED_ITEM_COUNT),
31143112
new CollectionOperationStatus(status));
31153113
}
31163114
}

src/main/java/net/spy/memcached/collection/CollectionPipedInsert.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
public abstract class CollectionPipedInsert<T> extends CollectionPipe {
3232

33-
public static final int MAX_PIPED_ITEM_COUNT = 500;
34-
3533
protected final String key;
3634
protected final CollectionAttributes attribute;
3735
protected final Transcoder<T> tc;

src/main/java/net/spy/memcached/collection/CollectionPipedUpdate.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
public abstract class CollectionPipedUpdate<T> extends CollectionPipe {
3131

32-
public static final int MAX_PIPED_ITEM_COUNT = 500;
33-
3432
protected final String key;
3533
protected final Transcoder<T> tc;
3634

src/main/java/net/spy/memcached/collection/SetPipedExist.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
public class SetPipedExist<T> extends CollectionPipe {
3030

31-
public static final int MAX_PIPED_ITEM_COUNT = 500;
32-
3331
private static final String COMMAND = "sop exist";
3432

3533
private final String key;

src/test/java/net/spy/memcached/ArcusTimeoutTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.concurrent.TimeoutException;
2828

2929
import net.spy.memcached.collection.CollectionAttributes;
30-
import net.spy.memcached.collection.CollectionPipedInsert;
3130
import net.spy.memcached.collection.ElementFlagFilter;
3231
import net.spy.memcached.collection.SMGetElement;
3332
import net.spy.memcached.collection.SMGetMode;
@@ -142,7 +141,7 @@ void testBulkDeleteTimeoutUsingSingleThread() {
142141
@Test
143142
void testSopPipedInsertBulkTimeout() {
144143
String key = "testTimeout";
145-
int valueCount = CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
144+
int valueCount = ArcusClient.MAX_PIPED_ITEM_COUNT;
146145
Object[] valueList = new Object[valueCount];
147146
for (int i = 0; i < valueList.length; i++) {
148147
valueList[i] = "MyValue" + i;
@@ -199,7 +198,7 @@ void testBopPipedInsertBulkTimeout() {
199198
String key = "MyBopKey";
200199
String value = "MyValue";
201200

202-
int bkeySize = CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
201+
int bkeySize = ArcusClient.MAX_PIPED_ITEM_COUNT;
203202
Map<Long, Object> bkeys = new TreeMap<>();
204203
for (int i = 0; i < bkeySize; i++) {
205204
bkeys.put((long) i, value);
@@ -297,7 +296,7 @@ void testMopInsertBulkMultipleTimeout() {
297296
String key = "MyMopKey";
298297
String value = "MyValue";
299298

300-
int elementSize = CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
299+
int elementSize = ArcusClient.MAX_PIPED_ITEM_COUNT;
301300
Map<String, Object> elements = new TreeMap<>();
302301
for (int i = 0; i < elementSize; i++) {
303302
elements.put(String.valueOf(i), value);

src/test/manual/net/spy/memcached/bulkoperation/SopInsertBulkMultipleValueTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import java.util.concurrent.TimeUnit;
2424
import java.util.concurrent.TimeoutException;
2525

26+
import net.spy.memcached.ArcusClient;
2627
import net.spy.memcached.collection.BaseIntegrationTest;
2728
import net.spy.memcached.collection.CollectionAttributes;
28-
import net.spy.memcached.collection.CollectionPipedInsert;
2929
import net.spy.memcached.ops.CollectionOperationStatus;
3030

3131
import org.junit.jupiter.api.Test;
@@ -42,7 +42,7 @@ void testInsertAndGet() {
4242
String key = "testInsertAndGet";
4343
String prefix = "MyValue";
4444

45-
int valueCount = CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
45+
int valueCount = ArcusClient.MAX_PIPED_ITEM_COUNT;
4646
Object[] valueList = new Object[valueCount];
4747
for (int i = 0; i < valueList.length; i++) {
4848
valueList[i] = String.format("%s%d", prefix, i);

src/test/manual/net/spy/memcached/collection/list/LopBulkAPITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import java.util.concurrent.Future;
2323
import java.util.concurrent.TimeUnit;
2424

25+
import net.spy.memcached.ArcusClient;
2526
import net.spy.memcached.collection.BaseIntegrationTest;
2627
import net.spy.memcached.collection.CollectionAttributes;
2728
import net.spy.memcached.collection.CollectionOverflowAction;
28-
import net.spy.memcached.collection.CollectionPipedInsert;
2929
import net.spy.memcached.internal.CollectionFuture;
3030
import net.spy.memcached.ops.CollectionOperationStatus;
3131

@@ -43,7 +43,7 @@ class LopBulkAPITest extends BaseIntegrationTest {
4343
private final List<Object> valueList = new ArrayList<>();
4444

4545
private int getValueCount() {
46-
return CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
46+
return ArcusClient.MAX_PIPED_ITEM_COUNT;
4747
}
4848

4949
@BeforeEach

src/test/manual/net/spy/memcached/collection/map/MopBulkAPITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import java.util.concurrent.Future;
2222
import java.util.concurrent.TimeUnit;
2323

24+
import net.spy.memcached.ArcusClient;
2425
import net.spy.memcached.collection.BaseIntegrationTest;
2526
import net.spy.memcached.collection.CollectionAttributes;
2627
import net.spy.memcached.collection.CollectionOverflowAction;
27-
import net.spy.memcached.collection.CollectionPipedInsert;
2828
import net.spy.memcached.internal.CollectionFuture;
2929
import net.spy.memcached.ops.CollectionOperationStatus;
3030

@@ -42,7 +42,7 @@ class MopBulkAPITest extends BaseIntegrationTest {
4242
private final Map<String, Object> updateMap = new HashMap<>();
4343

4444
private int getValueCount() {
45-
return CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
45+
return ArcusClient.MAX_PIPED_ITEM_COUNT;
4646
}
4747

4848
@BeforeEach

src/test/manual/net/spy/memcached/collection/set/SopBulkAPITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import java.util.concurrent.Future;
2525
import java.util.concurrent.TimeUnit;
2626

27+
import net.spy.memcached.ArcusClient;
2728
import net.spy.memcached.collection.BaseIntegrationTest;
2829
import net.spy.memcached.collection.CollectionAttributes;
29-
import net.spy.memcached.collection.CollectionPipedInsert;
3030
import net.spy.memcached.internal.CollectionFuture;
3131
import net.spy.memcached.ops.CollectionOperationStatus;
3232

@@ -43,7 +43,7 @@ class SopBulkAPITest extends BaseIntegrationTest {
4343
private final List<Object> valueList = new ArrayList<>();
4444

4545
private int getValueCount() {
46-
return CollectionPipedInsert.MAX_PIPED_ITEM_COUNT;
46+
return ArcusClient.MAX_PIPED_ITEM_COUNT;
4747
}
4848

4949
@BeforeEach

src/test/manual/net/spy/memcached/collection/set/SopPipedExistTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import net.spy.memcached.ArcusClient;
2324
import net.spy.memcached.collection.BaseIntegrationTest;
2425
import net.spy.memcached.collection.CollectionAttributes;
2526
import net.spy.memcached.collection.CollectionResponse;
2627
import net.spy.memcached.collection.ElementValueType;
27-
import net.spy.memcached.collection.SetPipedExist;
2828
import net.spy.memcached.internal.CollectionFuture;
2929

3030
import org.junit.jupiter.api.AfterEach;
@@ -146,7 +146,7 @@ void testMaxPipedExist() {
146146
List<Object> findValues = new ArrayList<>();
147147

148148
// insert items
149-
for (int i = 0; i < SetPipedExist.MAX_PIPED_ITEM_COUNT; i++) {
149+
for (int i = 0; i < ArcusClient.MAX_PIPED_ITEM_COUNT; i++) {
150150
findValues.add("VALUE" + i);
151151

152152
if (i / 2 == 0) {
@@ -164,7 +164,7 @@ void testMaxPipedExist() {
164164

165165
assertTrue(future.getOperationStatus().isSuccess());
166166

167-
for (int i = 0; i < SetPipedExist.MAX_PIPED_ITEM_COUNT; i++) {
167+
for (int i = 0; i < ArcusClient.MAX_PIPED_ITEM_COUNT; i++) {
168168
if (i / 2 == 0) {
169169
assertFalse(map.get("VALUE" + i));
170170
} else {

0 commit comments

Comments
 (0)