提交 543b2d44 编写于 作者: wu-sheng's avatar wu-sheng

Support empty operation name, and add buffer size of dictionary for avoiding out of memory.

上级 57b69fb8
......@@ -73,6 +73,15 @@ public class Config {
public static int BUFFER_SIZE = 300;
}
public static class Dictionary {
/**
* The buffer size of application codes and peer
*/
public static int APPLICATION_CODE_BUFFER_SIZE = 10 * 10000;
public static int OPERATION_NAME_BUFFER_SIZE = 1000 * 10000;
}
public static class Logging {
/**
* Log file name.
......
......@@ -9,6 +9,8 @@ import org.skywalking.apm.network.proto.ApplicationMapping;
import org.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc;
import org.skywalking.apm.network.proto.KeyWithIntegerValue;
import static org.skywalking.apm.agent.core.conf.Config.Dictionary.APPLICATION_CODE_BUFFER_SIZE;
/**
* Map of application id to application code, which is from the collector side.
*
......@@ -24,7 +26,9 @@ public enum ApplicationDictionary {
if (applicationId != null) {
return new Found(applicationId);
} else {
unRegisterApplications.add(applicationCode);
if (applicationDictionary.size() + unRegisterApplications.size() < APPLICATION_CODE_BUFFER_SIZE) {
unRegisterApplications.add(applicationCode);
}
return new NotFound();
}
}
......
......@@ -10,6 +10,8 @@ import org.skywalking.apm.network.proto.ServiceNameElement;
import org.skywalking.apm.network.proto.ServiceNameMappingCollection;
import org.skywalking.apm.network.proto.ServiceNameMappingElement;
import static org.skywalking.apm.agent.core.conf.Config.Dictionary.OPERATION_NAME_BUFFER_SIZE;
/**
* @author wusheng
*/
......@@ -19,12 +21,17 @@ public enum OperationNameDictionary {
private Set<OperationNameKey> unRegisterOperationNames = new ConcurrentSet<OperationNameKey>();
public PossibleFound find(int applicationId, String operationName) {
if (operationName == null || operationName.length() == 0) {
return new NotFound();
}
OperationNameKey key = new OperationNameKey(applicationId, operationName);
Integer operationId = operationNameDictionary.get(key);
if (operationId != null) {
return new Found(applicationId);
} else {
unRegisterOperationNames.add(key);
if (operationNameDictionary.size() + unRegisterOperationNames.size() < OPERATION_NAME_BUFFER_SIZE) {
unRegisterOperationNames.add(key);
}
return new NotFound();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册