remove useless dependency in pom.xml (#2831)

This commit is contained in:
Collapsar
2021-08-24 16:24:04 +08:00
committed by GitHub
parent b2cb424405
commit 179e59dbc4
10 changed files with 0 additions and 865 deletions
-6
View File
@@ -143,12 +143,6 @@
<version>4.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jsr166-mirror</groupId>
<artifactId>jsr166y</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
@@ -1,91 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.model;
import jsr166y.LinkedTransferQueue;
import java.util.concurrent.BlockingQueue;
/**
* @author mycat
*/
public class M1 {
private long count;
private final BlockingQueue<TransferObject> x;
private final BlockingQueue<TransferObject> y;
public M1() {
this.x = new LinkedTransferQueue<TransferObject>();
this.y = new LinkedTransferQueue<TransferObject>();
}
public long getCount() {
return count;
}
public BlockingQueue<TransferObject> getX() {
return x;
}
public BlockingQueue<TransferObject> getY() {
return y;
}
public void start() {
new Thread(new A(), "A").start();
new Thread(new B(), "B").start();
new Thread(new C(), "C").start();
}
private final class A implements Runnable {
@Override
public void run() {
for (; ; ) {
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
}
for (int i = 0; i < 1000000; i++) {
x.offer(new TransferObject());
}
}
}
}
private final class B implements Runnable {
@Override
public void run() {
TransferObject t = null;
for (; ; ) {
try {
t = x.take();
} catch (InterruptedException e) {
continue;
}
t.handle();
y.offer(t);
}
}
}
private final class C implements Runnable {
@Override
public void run() {
TransferObject t = null;
for (; ; ) {
try {
t = y.take();
} catch (InterruptedException e) {
continue;
}
t.compelete();
count++;
}
}
}
}
@@ -1,36 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.model;
/**
* @author mycat
*/
public class M1Main {
public static void main(String[] args) {
final M1 m1 = new M1();
m1.start();
new Thread() {
@Override
public void run() {
for (; ; ) {
long c = m1.getCount();
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
continue;
}
System.out.println("tps:" + (m1.getCount() - c) / 2);
System.out.println(" x:" + m1.getX().size());
System.out.println(" y:" + m1.getY().size());
System.out.println("==============");
}
}
}.start();
}
}
@@ -1,82 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.model;
import com.actiontech.dble.util.ExecutorUtil;
import jsr166y.LinkedTransferQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author mycat
*/
public class M2 {
private long count;
private final ThreadPoolExecutor x;
private final BlockingQueue<TransferObject> y;
public M2() {
this.x = ExecutorUtil.createFixed("B", 1);
this.y = new LinkedTransferQueue<TransferObject>();
}
public long getCount() {
return count;
}
public ThreadPoolExecutor getX() {
return x;
}
public BlockingQueue<TransferObject> getY() {
return y;
}
public void start() {
new Thread(new A(), "A").start();
new Thread(new C(), "C").start();
}
private final class A implements Runnable {
@Override
public void run() {
for (; ; ) {
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
}
for (int i = 0; i < 1000000; i++) {
final TransferObject t = new TransferObject();
x.execute(new Runnable() {
@Override
public void run() {
t.handle();
y.offer(t);
}
});
}
}
}
}
private final class C implements Runnable {
@Override
public void run() {
TransferObject t = null;
for (; ; ) {
try {
t = y.take();
} catch (InterruptedException e) {
continue;
}
t.compelete();
count++;
}
}
}
}
@@ -1,36 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.model;
/**
* @author mycat
*/
public class M2Main {
public static void main(String[] args) {
final M2 m2 = new M2();
m2.start();
new Thread() {
@Override
public void run() {
for (; ; ) {
long c = m2.getCount();
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
continue;
}
System.out.println("tps:" + (m2.getCount() - c) / 2);
System.out.println(" x:" + m2.getX().getQueue().size());
System.out.println(" y:" + m2.getY().size());
System.out.println("==============");
}
}
}.start();
}
}
@@ -1,23 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.model;
/**
* @author mycat
*/
public class TransferObject {
long handleCount;
long compeleteCount;
public void handle() {
handleCount++;
}
public void compelete() {
compeleteCount++;
}
}
@@ -1,112 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.queue;
import java.util.concurrent.locks.ReentrantLock;
/**
* FixedQueue
*
* @author mycat
*/
public final class FixedQueue<E> {
private final E[] items;
private int putIndex;
private int takeIndex;
private int count;
private final ReentrantLock lock;
@SuppressWarnings("unchecked")
public FixedQueue(int capacity) {
if (capacity <= 0) {
throw new IllegalArgumentException();
}
this.items = (E[]) new Object[capacity];
this.lock = new ReentrantLock();
}
public int size() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
return count;
} finally {
lock.unlock();
}
}
public boolean offer(E e) {
if (e == null) {
throw new NullPointerException();
}
final ReentrantLock lock = this.lock;
lock.lock();
try {
if (count >= items.length) {
return false;
} else {
insert(e);
return true;
}
} finally {
lock.unlock();
}
}
public E poll() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
if (count == 0) {
return null;
}
return extract();
} finally {
lock.unlock();
}
}
public void clear() {
final E[] items = this.items;
final ReentrantLock lock = this.lock;
lock.lock();
try {
int i = takeIndex;
int j = count;
while (j-- > 0) {
items[i] = null;
i = inc(i);
}
count = 0;
putIndex = 0;
takeIndex = 0;
} finally {
lock.unlock();
}
}
private void insert(E x) {
items[putIndex] = x;
putIndex = inc(putIndex);
++count;
}
private E extract() {
E[] items = this.items;
int i = takeIndex;
E x = items[i];
items[i] = null;
takeIndex = inc(i);
--count;
return x;
}
private int inc(int i) {
return (++i == items.length) ? 0 : i;
}
}
@@ -1,191 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.queue;
/**
* @author mycat
*/
public final class Queue<T> {
private static final int MIN_SHRINK_SIZE = 1024;
private T[] items;
private int count = 0;
private int start = 0, end = 0;
private int suggestedSize, size = 0;
public Queue(int suggestedSize) {
this.size = this.suggestedSize = suggestedSize;
items = newArray(this.size);
}
public Queue() {
this(4);
}
public synchronized void clear() {
count = start = end = 0;
size = suggestedSize;
items = newArray(size);
}
public synchronized boolean hasElements() {
return (count != 0);
}
public synchronized int size() {
return count;
}
public synchronized void prepend(T item) {
if (count == size) {
makeMoreRoom();
}
if (start == 0) {
start = size - 1;
} else {
start--;
}
this.items[start] = item;
count++;
if (count == 1) {
notify();
}
}
public synchronized void append(T item) {
append0(item, count == 0);
}
public synchronized void appendSilent(T item) {
append0(item, false);
}
public synchronized void appendLoud(T item) {
append0(item, true);
}
public synchronized T getNonBlocking() {
if (count == 0) {
return null;
}
// pull the object off, and clear our reference to it
T retval = items[start];
items[start] = null;
start = (start + 1) % size;
count--;
return retval;
}
public synchronized void waitForItem() {
while (count == 0) {
try {
wait();
} catch (InterruptedException e) {
}
}
}
public synchronized T get(long maxwait) {
if (count == 0) {
try {
wait(maxwait);
} catch (InterruptedException e) {
}
if (count == 0) {
return null;
}
}
return get();
}
public synchronized T get() {
while (count == 0) {
try {
wait();
} catch (InterruptedException e) {
}
}
// pull the object off, and clear our reference to it
T retval = items[start];
items[start] = null;
start = (start + 1) % size;
count--;
// if we are only filling 1/8th of the space, shrink by half
if ((size > MIN_SHRINK_SIZE) && (size > suggestedSize) && (count < (size >> 3))) {
shrink();
}
return retval;
}
private void append0(T item, boolean notify) {
if (count == size) {
makeMoreRoom();
}
this.items[end] = item;
end = (end + 1) % size;
count++;
if (notify) {
notify();
}
}
private void makeMoreRoom() {
T[] items = newArray(size * 2);
System.arraycopy(this.items, start, items, 0, size - start);
System.arraycopy(this.items, 0, items, size - start, end);
start = 0;
end = size;
size *= 2;
this.items = items;
}
// shrink by half
private void shrink() {
T[] items = newArray(size / 2);
if (start > end) {
// the data wraps around
System.arraycopy(this.items, start, items, 0, size - start);
System.arraycopy(this.items, 0, items, size - start, end + 1);
} else {
// the data does not wrap around
System.arraycopy(this.items, start, items, 0, end - start + 1);
}
size = size / 2;
start = 0;
end = count;
this.items = items;
}
@SuppressWarnings("unchecked")
private T[] newArray(int size) {
return (T[]) new Object[size];
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("[count=").append(count);
buf.append(", size=").append(size);
buf.append(", start=").append(start);
buf.append(", end=").append(end);
buf.append(", elements={");
for (int i = 0; i < count; i++) {
int pos = (i + start) % size;
if (i > 0) {
buf.append(", ");
}
buf.append(items[pos]);
}
buf.append("}]");
return buf.toString();
}
}
@@ -1,212 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.queue;
import jsr166y.LinkedTransferQueue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
/**
* Queue performance test
*
* @author mycat
*/
public class QueuePerfMain {
private static byte[] testData = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
private static BlockingQueue<byte[]> arrayQueue = new ArrayBlockingQueue<byte[]>(5000000);
private static FixedQueue<byte[]> fixedQueue = new FixedQueue<byte[]>(5000000);
private static Queue<byte[]> testQueue = new Queue<byte[]>();
private static BlockingQueue<byte[]> linkedQueue = new LinkedBlockingQueue<byte[]>();
private static LinkedTransferQueue<byte[]> transferQueue = new LinkedTransferQueue<byte[]>();
public static void tArrayQueue() {
new Thread() {
@Override
public void run() {
while (true) {
arrayQueue.offer(testData);
}
}
}.start();
new Thread() {
@Override
public void run() {
int count = 0;
long num = 0;
while (true) {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
}
count++;
num += arrayQueue.size();
arrayQueue.clear();
if (count == 50) {
System.out.println(num / 50);
count = 0;
num = 0;
}
}
}
}.start();
}
public static void tFixedQueue() {
new Thread() {
@Override
public void run() {
while (true) {
fixedQueue.offer(testData);
}
}
}.start();
new Thread() {
@Override
public void run() {
int count = 0;
long num = 0;
while (true) {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
}
count++;
num += fixedQueue.size();
fixedQueue.clear();
if (count == 50) {
System.out.println(num / 50);
count = 0;
num = 0;
}
}
}
}.start();
}
public static void tQueue() {
new Thread() {
@Override
public void run() {
while (true) {
testQueue.append(testData);
}
}
}.start();
new Thread() {
@Override
public void run() {
int count = 0;
long num = 0;
while (true) {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
}
count++;
num += testQueue.size();
testQueue.clear();
if (count == 50) {
System.out.println(num / 50);
count = 0;
num = 0;
}
}
}
}.start();
}
public static void tLinkedQueue() {
new Thread() {
@Override
public void run() {
while (true) {
linkedQueue.offer(testData);
}
}
}.start();
new Thread() {
@Override
public void run() {
int count = 0;
long num = 0;
while (true) {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
}
count++;
num += linkedQueue.size();
linkedQueue.clear();
if (count == 50) {
System.out.println(num / 50);
count = 0;
num = 0;
}
}
}
}.start();
}
public static void tTransferQueue() {
new Thread() {
@Override
public void run() {
while (true) {
transferQueue.offer(testData);
}
}
}.start();
new Thread() {
@Override
public void run() {
int count = 0;
long num = 0;
while (true) {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
}
count++;
num += transferQueue.size();
transferQueue.clear();
if (count == 50) {
System.out.println(num / 50);
count = 0;
num = 0;
}
}
}
}.start();
}
public static void main(String[] args) {
// testArrayQueue();
// testFixedQueue();
// testQueue();
// testLinkedQueue();
// testTransferQueue();
}
}
@@ -1,76 +0,0 @@
/*
* Copyright (C) 2016-2019 ActionTech.
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
*/
package com.actiontech.dble.queue;
import jsr166y.LinkedTransferQueue;
/**
* @author mycat
*/
public class QueueSimpleMain {
static long putCount = 0;
static long takeCount = 0;
public static void main(String[] args) {
// final SynchronousQueue<String> queue = new
// SynchronousQueue<String>();
// final ArrayBlockingQueue<String> queue = new
// ArrayBlockingQueue<String>(10000000);
final LinkedTransferQueue<String> queue = new LinkedTransferQueue<String>();
// final LinkedBlockingQueue<String> queue = new
// LinkedBlockingQueue<String>();
new Thread() {
@Override
public void run() {
for (; ; ) {
long put = putCount;
long take = takeCount;
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("put:" + (putCount - put) / 5 + " take:" + (takeCount - take) / 5);
}
}
}.start();
new Thread() {
@Override
public void run() {
for (; ; ) {
if (queue.offer("A")) {
putCount++;
}
}
}
}.start();
new Thread() {
@Override
public void run() {
for (; ; ) {
// try {
if (queue.poll() != null) {
takeCount++;
}
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// try {
// Thread.sleep(10L);
// } catch (InterruptedException e) {
//
// e.printStackTrace();
// }
}
}
}.start();
}
}