移动BufferPool代码位置,增加可读性。

This commit is contained in:
wusheng 2016-07-21 11:35:11 +08:00
parent 81a8aabc02
commit f9fe2d4d18
3 changed files with 28 additions and 18 deletions

View File

@ -0,0 +1,26 @@
package com.ai.cloud.skywalking.buffer;
import com.ai.cloud.skywalking.protocol.common.ISerializable;
import java.util.concurrent.ThreadLocalRandom;
import static com.ai.cloud.skywalking.conf.Config.Buffer.POOL_SIZE;
/**
* Created by wusheng on 16/7/21.
*/
class BufferPool {
// 注意 这个变量名如果改变需要改变test-api工程中的Config变量
private static BufferGroup[] bufferGroups = new BufferGroup[POOL_SIZE];
static {
for (int i = 0; i < POOL_SIZE; i++) {
bufferGroups[i] = new BufferGroup("buffer_group-" + i);
}
}
public void save(ISerializable data) {
bufferGroups[ThreadLocalRandom.current().nextInt(0, POOL_SIZE)].save(data);
}
}

View File

@ -25,22 +25,6 @@ public class ContextBuffer {
logger.error("save span error.", t);
}
}
static class BufferPool {
// 注意 这个变量名如果改变需要改变test-api工程中的Config变量
private static BufferGroup[] bufferGroups = new BufferGroup[POOL_SIZE];
static {
for (int i = 0; i < POOL_SIZE; i++) {
bufferGroups[i] = new BufferGroup("buffer_group-" + i);
}
}
public void save(ISerializable data) {
bufferGroups[ThreadLocalRandom.current().nextInt(0, POOL_SIZE)].save(data);
}
}
}

View File

@ -19,9 +19,9 @@ public class AtomicRangeInteger extends Number implements java.io.Serializable {
/**
* Creates a new AtomicInteger with the given initial value and max value
*
* @param initialValue
* @param startValue
* the initial value
* @param endValue
* @param maxValue
*
* AtomicRangeInteger在startValue和maxValue循环取值 startValue <= value < maxValue
*/