提交 c69b02d2 编写于 作者: Z zhangxin10

1. 解决不重连的问题

上级 7a270e48
......@@ -40,6 +40,13 @@ public class DataSenderFactory {
}
public static DataSender getSender() {
while(availableSenders.size() <= 0){
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return availableSenders.get(ThreadLocalRandom.current().nextInt(0, availableSenders.size()));
}
......@@ -70,7 +77,6 @@ public class DataSenderFactory {
public void run() {
while (true) {
//当可用的Sender的数量和保存的地址的比例不在1:2,则不创建
for (SocketAddress socketAddress : unUsedSocketAddresses) {
if (availableSenders.size() >= avaiableSize) {
break;
......
......@@ -37,7 +37,7 @@ public class SpanBufferTest {
@Parameterized.Parameters
public static Collection<Integer[]> getParams() {
return Arrays.asList(new Integer[][]{
{2000, 10},
{1, 10001},
// {2000, 100000, 5, 27000, 3},
// {2000, 100000, 5, 24000, 3},
// {2000, 100000, 5, 20000, 2},
......@@ -50,33 +50,24 @@ public class SpanBufferTest {
@Test
public void testSave() throws Exception {
System.out.println(threadSize + " " + sizeCount);
CountDownLatch countDownLatch = new CountDownLatch(threadSize);
long start = System.currentTimeMillis();
long sleepTime = 1000;
for (int i = 0; i < threadSize; i++) {
if (i % 100 == 0) {
sleepTime = sleepTime / 2;
if (sleepTime == 0){
sleepTime = 5;
while (true) {
System.out.println(threadSize + " " + sizeCount);
CountDownLatch countDownLatch = new CountDownLatch(threadSize);
long start = System.currentTimeMillis();
long sleepTime = 1000;
for (int i = 0; i < threadSize; i++) {
if (i % 100 == 0) {
sleepTime = sleepTime / 2;
if (sleepTime == 0) {
sleepTime = 5;
}
Thread.sleep(sleepTime);
}
Thread.sleep(sleepTime);
new ContextBufferThread(countDownLatch, sizeCount).start();
}
new ContextBufferThread(countDownLatch, sizeCount).start();
}
countDownLatch.await();
CountDownLatch countDownLatchA = new CountDownLatch(threadSize);
sleepTime = 1000;
for (int i = 0; i < threadSize; i++) {
if (i % 100 == 0) {
sleepTime = sleepTime / 2;
if (sleepTime == 0){
sleepTime = 5;
}
Thread.sleep(sleepTime);
}
new ContextBufferThreadA(countDownLatchA, sizeCount).start();
countDownLatch.await();
Thread.sleep(5000L);
}
countDownLatchA.await();
}
}
\ No newline at end of file
package com.ai.cloud.skywalking.sender;
import com.ai.cloud.skywalking.buffer.ContextBuffer;
import com.ai.cloud.skywalking.conf.Config;
import com.ai.cloud.skywalking.conf.ConfigInitializer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
@RunWith(Parameterized.class)
......@@ -21,12 +27,16 @@ public class SenderTest {
@Parameterized.Parameters
public static Collection<Integer[]> getParams() {
return Arrays.asList(new Integer[][]{
{1, 100},
{1, 10000000},
});
}
@Test
public void testSender() throws InterruptedException {
public void testSender() throws InterruptedException, IllegalAccessException, IOException {
InputStream inputStream = ContextBuffer.class.getResourceAsStream("/sky-walking.auth");
Properties properties = new Properties();
properties.load(inputStream);
ConfigInitializer.initialize(properties, Config.class);
CountDownLatch countDownLatch = new CountDownLatch(threadSize * countSize);
for (int i = 0; i < threadSize; i++) {
Thread.sleep(1L);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册