Support empty operation name, and add buffer size of dictionary for avoiding out of memory.
This commit is contained in:
parent
57b69fb88c
commit
543b2d4461
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue