mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
= cold cleanup
* using lambda if possible (we are already building in Java8) * using diamond when new generic instance * remove used improt
This commit is contained in:
@@ -280,10 +280,10 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple
|
||||
}
|
||||
|
||||
if (current >= maxAbleSequence) {
|
||||
return new Events<Event>();
|
||||
return new Events<>();
|
||||
}
|
||||
|
||||
Events<Event> result = new Events<Event>();
|
||||
Events<Event> result = new Events<>();
|
||||
List<Event> entrys = result.getEvents();
|
||||
long memsize = 0;
|
||||
if (batchMode.isItemSize()) {
|
||||
@@ -329,7 +329,7 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple
|
||||
|
||||
}
|
||||
|
||||
PositionRange<LogPosition> range = new PositionRange<LogPosition>();
|
||||
PositionRange<LogPosition> range = new PositionRange<>();
|
||||
result.setPositionRange(range);
|
||||
|
||||
range.setStart(CanalEventUtils.createPosition(entrys.get(0)));
|
||||
@@ -354,7 +354,7 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple
|
||||
profiling(result.getEvents(), OP.GET);
|
||||
return result;
|
||||
} else {
|
||||
return new Events<Event>();
|
||||
return new Events<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,19 +167,16 @@ public class MemoryEventStoreMemBatchTest extends MemoryEventStoreBase {
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
executor.submit(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
boolean result = false;
|
||||
try {
|
||||
eventStore.get(position, batchSize);
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("interrupt occured.");
|
||||
result = true;
|
||||
}
|
||||
Assert.assertTrue(result);
|
||||
executor.submit(() -> {
|
||||
boolean result = false;
|
||||
try {
|
||||
eventStore.get(position, batchSize);
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("interrupt occured.");
|
||||
result = true;
|
||||
}
|
||||
Assert.assertTrue(result);
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -245,7 +242,7 @@ public class MemoryEventStoreMemBatchTest extends MemoryEventStoreBase {
|
||||
|
||||
first = eventStore.getFirstPosition();
|
||||
lastest = eventStore.getLatestPosition();
|
||||
List<Event> entrys = new ArrayList<Event>(entrys2.getEvents());
|
||||
List<Event> entrys = new ArrayList<>(entrys2.getEvents());
|
||||
Assert.assertTrue(entrys.size() == bufferSize);
|
||||
Assert.assertEquals(first, entrys2.getPositionRange().getStart());
|
||||
Assert.assertEquals(lastest, entrys2.getPositionRange().getEnd());
|
||||
@@ -299,7 +296,7 @@ public class MemoryEventStoreMemBatchTest extends MemoryEventStoreBase {
|
||||
|
||||
first = eventStore.getFirstPosition();
|
||||
lastest = eventStore.getLatestPosition();
|
||||
List<Event> entrys = new ArrayList<Event>(entrys2.getEvents());
|
||||
List<Event> entrys = new ArrayList<>(entrys2.getEvents());
|
||||
// Assert.assertEquals(first, entrys2.getPositionRange().getStart());
|
||||
Assert.assertEquals(lastest, entrys2.getPositionRange().getEnd());
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class MemoryEventStoreMultiThreadTest extends MemoryEventStoreBase {
|
||||
private CountDownLatch latch;
|
||||
private int freq;
|
||||
private int batchSize;
|
||||
private List<Long> result = new ArrayList<Long>();
|
||||
private List<Long> result = new ArrayList<>();
|
||||
|
||||
public Cosumer(CountDownLatch latch, int freq, int batchSize){
|
||||
this.latch = latch;
|
||||
|
||||
@@ -145,19 +145,16 @@ public class MemoryEventStorePutAndGetTest extends MemoryEventStoreBase {
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
executor.submit(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
boolean result = false;
|
||||
try {
|
||||
eventStore.get(position, batchSize);
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("interrupt occured.");
|
||||
result = true;
|
||||
}
|
||||
Assert.assertTrue(result);
|
||||
executor.submit(() -> {
|
||||
boolean result = false;
|
||||
try {
|
||||
eventStore.get(position, batchSize);
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("interrupt occured.");
|
||||
result = true;
|
||||
}
|
||||
Assert.assertTrue(result);
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MemoryEventStoreRollbackAndAckTest extends MemoryEventStoreBase {
|
||||
|
||||
first = eventStore.getFirstPosition();
|
||||
lastest = eventStore.getLatestPosition();
|
||||
List<Event> entrys = new ArrayList<Event>(entrys2.getEvents());
|
||||
List<Event> entrys = new ArrayList<>(entrys2.getEvents());
|
||||
Assert.assertTrue(entrys.size() == bufferSize);
|
||||
Assert.assertEquals(first, entrys2.getPositionRange().getStart());
|
||||
Assert.assertEquals(lastest, entrys2.getPositionRange().getEnd());
|
||||
@@ -120,7 +120,7 @@ public class MemoryEventStoreRollbackAndAckTest extends MemoryEventStoreBase {
|
||||
|
||||
first = eventStore.getFirstPosition();
|
||||
lastest = eventStore.getLatestPosition();
|
||||
List<Event> entrys = new ArrayList<Event>(entrys2.getEvents());
|
||||
List<Event> entrys = new ArrayList<>(entrys2.getEvents());
|
||||
// because doGet() contains the logic about whether include first event , so not to compare
|
||||
//Assert.assertEquals(first, entrys2.getPositionRange().getStart());
|
||||
Assert.assertEquals(lastest, entrys2.getPositionRange().getEnd());
|
||||
|
||||
Reference in New Issue
Block a user