Skip to content

Commit f55d6b8

Browse files
committed
spotless
1 parent 7c9c80d commit f55d6b8

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/iot/logdispatcher/IoTConsensusMemoryManagerTest.java

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919

2020
package org.apache.iotdb.consensus.iot.logdispatcher;
2121

22-
import static org.junit.Assert.assertEquals;
23-
import static org.junit.Assert.assertFalse;
24-
import static org.junit.Assert.assertTrue;
25-
26-
import java.nio.ByteBuffer;
27-
import java.util.ArrayList;
28-
import java.util.Collections;
29-
import java.util.List;
3022
import org.apache.iotdb.consensus.common.request.ByteBufferConsensusRequest;
3123
import org.apache.iotdb.consensus.common.request.IndexedConsensusRequest;
3224
import org.apache.iotdb.consensus.config.IoTConsensusConfig;
3325
import org.apache.iotdb.consensus.iot.thrift.TLogEntry;
26+
3427
import org.junit.Test;
3528

29+
import java.nio.ByteBuffer;
30+
import java.util.ArrayList;
31+
import java.util.Collections;
32+
import java.util.List;
33+
34+
import static org.junit.Assert.assertEquals;
35+
import static org.junit.Assert.assertFalse;
36+
import static org.junit.Assert.assertTrue;
37+
3638
public class IoTConsensusMemoryManagerTest {
3739

3840
@Test
@@ -44,8 +46,11 @@ public void testAllocateQueue() {
4446
IndexedConsensusRequest request;
4547
List<IndexedConsensusRequest> requestList = new ArrayList<>();
4648
while (occupiedMemory <= maxMemory) {
47-
request = new IndexedConsensusRequest(0, Collections.singletonList(new ByteBufferConsensusRequest(
48-
ByteBuffer.wrap(new byte[4 * 1024 * 1024]))));
49+
request =
50+
new IndexedConsensusRequest(
51+
0,
52+
Collections.singletonList(
53+
new ByteBufferConsensusRequest(ByteBuffer.wrap(new byte[4 * 1024 * 1024]))));
4954
request.buildSerializedRequests();
5055
long requestSize = request.getMemorySize();
5156
if (occupiedMemory + requestSize < maxMemory) {
@@ -84,9 +89,17 @@ public void testAllocateBatch() {
8489
batch = new Batch(IoTConsensusConfig.newBuilder().build());
8590
for (int i = 0; i < batchSize; i++) {
8691
IndexedConsensusRequest request;
87-
request = new IndexedConsensusRequest(0, Collections.singletonList(new ByteBufferConsensusRequest(
88-
ByteBuffer.wrap(new byte[1024 * 1024]))));
89-
batch.addTLogEntry(new TLogEntry(request.getSerializedRequests(), request.getSearchIndex(), false, request.getMemorySize()));
92+
request =
93+
new IndexedConsensusRequest(
94+
0,
95+
Collections.singletonList(
96+
new ByteBufferConsensusRequest(ByteBuffer.wrap(new byte[1024 * 1024]))));
97+
batch.addTLogEntry(
98+
new TLogEntry(
99+
request.getSerializedRequests(),
100+
request.getSearchIndex(),
101+
false,
102+
request.getMemorySize()));
90103
}
91104

92105
long requestSize = batch.getMemorySize();
@@ -123,8 +136,11 @@ public void testAllocateMixed() {
123136
int i = 0;
124137
while (occupiedMemory <= maxMemory) {
125138
if (i % 2 == 0) {
126-
request = new IndexedConsensusRequest(0, Collections.singletonList(new ByteBufferConsensusRequest(
127-
ByteBuffer.wrap(new byte[4 * 1024 * 1024]))));
139+
request =
140+
new IndexedConsensusRequest(
141+
0,
142+
Collections.singletonList(
143+
new ByteBufferConsensusRequest(ByteBuffer.wrap(new byte[4 * 1024 * 1024]))));
128144
request.buildSerializedRequests();
129145
long requestSize = request.getMemorySize();
130146
if (occupiedMemory + requestSize < maxMemory) {
@@ -141,9 +157,17 @@ public void testAllocateMixed() {
141157
batch = new Batch(IoTConsensusConfig.newBuilder().build());
142158
for (int j = 0; j < batchSize; j++) {
143159
IndexedConsensusRequest batchRequest;
144-
batchRequest = new IndexedConsensusRequest(0, Collections.singletonList(new ByteBufferConsensusRequest(
145-
ByteBuffer.wrap(new byte[1024 * 1024]))));
146-
batch.addTLogEntry(new TLogEntry(batchRequest.getSerializedRequests(), batchRequest.getSearchIndex(), false, batchRequest.getMemorySize()));
160+
batchRequest =
161+
new IndexedConsensusRequest(
162+
0,
163+
Collections.singletonList(
164+
new ByteBufferConsensusRequest(ByteBuffer.wrap(new byte[1024 * 1024]))));
165+
batch.addTLogEntry(
166+
new TLogEntry(
167+
batchRequest.getSerializedRequests(),
168+
batchRequest.getSearchIndex(),
169+
false,
170+
batchRequest.getMemorySize()));
147171
}
148172

149173
long requestSize = batch.getMemorySize();
@@ -156,7 +180,7 @@ public void testAllocateMixed() {
156180
assertFalse(memoryManager.reserve(batch));
157181
}
158182
}
159-
i ++;
183+
i++;
160184
}
161185
assertTrue(memoryManager.getMemorySizeInByte() <= maxMemory);
162186

@@ -166,18 +190,18 @@ public void testAllocateMixed() {
166190
memoryManager.free(request);
167191
occupiedMemory -= request.getMemorySize();
168192
assertEquals(occupiedMemory, memoryManager.getMemorySizeInByte());
169-
i --;
193+
i--;
170194
}
171195
if (!batchList.isEmpty()) {
172196
batch = batchList.remove(0);
173197
memoryManager.free(batch);
174198
occupiedMemory -= batch.getMemorySize();
175199
assertEquals(occupiedMemory, memoryManager.getMemorySizeInByte());
176-
i --;
200+
i--;
177201
}
178202
}
179203
assertEquals(0, i);
180204
assertEquals(0, memoryManager.getMemorySizeInByte());
181205
assertEquals(0, memoryManager.getQueueMemorySizeInByte());
182206
}
183-
}
207+
}

0 commit comments

Comments
 (0)