1.修改配置

This commit is contained in:
zhangxin10 2015-11-12 15:33:47 +08:00
parent 20d8a5db54
commit 473023e817
13 changed files with 9 additions and 238 deletions

View File

@ -21,12 +21,6 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ai.cloud</groupId>
<artifactId>skywalking-auth</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>

View File

@ -33,7 +33,7 @@ public class LocalBuriedPointSender implements IBuriedPointSender {
getParentLevel() + "\tLevelId:" + spanData.getLevelId());
}
// 存放到本地发送进程中
if (!Config.Sender.OFF) {
if (!Config.Sender.IS_OFF) {
ContextBuffer.save(spanData);
}
}

View File

@ -33,7 +33,7 @@ public class RPCBuriedPointSender implements IBuriedPointSender {
getParentLevel() + "\tLevelId:" + spanData.getLevelId());
}
// 存放到本地发送进程中
if (!Config.Sender.OFF) {
if (!Config.Sender.IS_OFF) {
ContextBuffer.save(spanData);
}
}

View File

@ -53,7 +53,7 @@ public class ThreadBuriedPointSender implements IBuriedPointSender {
getParentLevel() + "\tLevelId:" + span.getLevelId());
}
// 存放到本地发送进程中
if (!Config.Sender.OFF) {
if (!Config.Sender.IS_OFF) {
ContextBuffer.save(span);
}
}

View File

@ -33,7 +33,7 @@ public class ThreadFactoryBuriedPointSender implements IBuriedPointSender {
getParentLevel() + "\tLevelId:" + spanData.getLevelId());
}
// 存放到本地发送进程中
if (!Config.Sender.OFF) {
if (!Config.Sender.IS_OFF) {
ContextBuffer.save(spanData);
}
}

View File

@ -3,7 +3,7 @@ package com.ai.cloud.skywalking.conf;
public class Config {
public static class BuriedPoint{
public static boolean PRINTF = true;
public static boolean PRINTF = false;
}
public static class Consumer {
@ -32,6 +32,6 @@ public class Config {
public static String SENDER_SERVERS;
// 是否开启发送
public static boolean OFF = false;
public static boolean IS_OFF = false;
}
}

View File

@ -19,6 +19,8 @@ public class Context {
}
public Span removeLastSpan() {
if (nodes.get() == null)
return null;
return nodes.get().pop();
}

View File

@ -52,6 +52,7 @@ public class DataSender {
socketChannel.write(ByteBuffer.wrap(ProtocolBuilder.builder(data)));
return true;
} catch (IOException e) {
e.printStackTrace();
// 发送失败 认为不可连接
DataSenderFactory.unRegister(this);
return false;

View File

@ -1,37 +0,0 @@
package com.ai.cloud.skywalking.buffer;
import com.ai.cloud.skywalking.context.Span;
import java.util.concurrent.CountDownLatch;
/**
* Created by astraea on 2015/10/13.
*/
public class ContextBufferThread extends Thread {
private int maxSize = 500000;
private CountDownLatch countDownLatch;
public ContextBufferThread(CountDownLatch countDownLatch) {
this.countDownLatch = countDownLatch;
}
public ContextBufferThread(CountDownLatch countDownLatch, int maxSize) {
this.countDownLatch = countDownLatch;
this.maxSize = maxSize;
}
@Override
public void run() {
for (int i = 0; i < maxSize; i++) {
Span span = new Span();
span.setLevelId(i);
try {
Thread.sleep(1L);
} catch (InterruptedException e) {
e.printStackTrace();
}
ContextBuffer.save(span);
}
countDownLatch.countDown();
}
}

View File

@ -1,38 +0,0 @@
package com.ai.cloud.skywalking.buffer;
import com.ai.cloud.skywalking.context.Span;
import java.util.concurrent.CountDownLatch;
/**
* Created by astraea on 2015/10/13.
*/
public class ContextBufferThreadA extends Thread {
private CountDownLatch countDownLatch;
private int maxSize = 500000;
public ContextBufferThreadA(CountDownLatch countDownLatch) {
this.countDownLatch = countDownLatch;
}
public ContextBufferThreadA(CountDownLatch countDownLatch, int maxSize) {
this.countDownLatch = countDownLatch;
this.maxSize = maxSize;
}
@Override
public void run() {
for (int i = 0; i < maxSize; i++) {
Span span = new Span();
span.setLevelId(i);
try {
Thread.sleep(1L);
} catch (InterruptedException e) {
e.printStackTrace();
}
// ContextBuffer.save(context);
}
countDownLatch.countDown();
}
}

View File

@ -1,73 +0,0 @@
package com.ai.cloud.skywalking.buffer;
import com.ai.cloud.skywalking.buffer.config.BufferConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SpanBufferTest {
public static CountDownLatch countDownLatch;
private int threadSize = 0;
private int sizeCount = 0;
private String fileName = "d:\\test-data.txt";
public SpanBufferTest(int threadSize, int sizeCount) {
this.threadSize = threadSize;
this.sizeCount = sizeCount;
}
public int getThreadSize() {
return threadSize;
}
public int getSizeCount() {
return sizeCount;
}
@Parameterized.Parameters
public static Collection<Integer[]> getParams() {
return Arrays.asList(new Integer[][]{
{1, 10001},
// {2000, 100000, 5, 27000, 3},
// {2000, 100000, 5, 24000, 3},
// {2000, 100000, 5, 20000, 2},
// {1, 20, 5, 16000, 2},
// {2000, 100000, 5, 14000, 2},
// {2000, 100000, 5, 21000, 3},
});
}
@Test
public void testSave() throws Exception {
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);
}
new ContextBufferThread(countDownLatch, sizeCount).start();
}
countDownLatch.await();
Thread.sleep(5000L);
}
}
}

View File

@ -1,49 +0,0 @@
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)
public class SenderTest {
private int countSize;
private int threadSize;
public SenderTest(int threadSize, int countSize) {
this.threadSize = threadSize;
this.countSize = countSize;
}
@Parameterized.Parameters
public static Collection<Integer[]> getParams() {
return Arrays.asList(new Integer[][]{
{1, 10000000},
});
}
@Test
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);
new SenderThread(countSize, threadSize + "TTTTTTTTTTTTTTt", countDownLatch).start();
}
System.out.println(countDownLatch.getCount());
countDownLatch.await();
System.out.println("发送成功");
}
}

View File

@ -1,29 +0,0 @@
package com.ai.cloud.skywalking.sender;
import java.util.concurrent.CountDownLatch;
public class SenderThread extends Thread {
private int countSize;
private String msg;
private static CountDownLatch countDownLatch;
public SenderThread(int countSize, String msg) {
this.countSize = countSize;
this.msg = msg;
}
public SenderThread(int countSize, String msg, CountDownLatch countDownLatch) {
this.countSize = countSize;
this.msg = msg;
this.countDownLatch = countDownLatch;
}
@Override
public void run() {
for (int i = 0; i < countSize; i++) {
DataSenderFactory.getSender().send(msg + countSize + " ");
countDownLatch.countDown();
}
}
}