parameterize the cache size. (#3741)
This commit is contained in:
parent
bcaa8be0aa
commit
42d422e852
|
|
@ -58,6 +58,14 @@ public class CoreModuleConfig extends ModuleConfig {
|
|||
*/
|
||||
@Setter private int remoteTimeout = 20;
|
||||
|
||||
/**
|
||||
* Following are cache settings for inventory(s)
|
||||
*/
|
||||
private long maxSizeOfServiceInventory = 10_000L;
|
||||
private long maxSizeOfServiceInstanceInventory = 1_000_000L;
|
||||
private long maxSizeOfEndpointInventory = 1_000_000L;
|
||||
private long maxSizeOfNetworkInventory = 1_000_000L;
|
||||
|
||||
CoreModuleConfig() {
|
||||
this.downsampling = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,16 +141,16 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IModelGetter.class, storageModels);
|
||||
this.registerServiceImplementation(IModelOverride.class, storageModels);
|
||||
|
||||
this.registerServiceImplementation(ServiceInventoryCache.class, new ServiceInventoryCache(getManager()));
|
||||
this.registerServiceImplementation(ServiceInventoryCache.class, new ServiceInventoryCache(getManager(), moduleConfig));
|
||||
this.registerServiceImplementation(IServiceInventoryRegister.class, new ServiceInventoryRegister(getManager()));
|
||||
|
||||
this.registerServiceImplementation(ServiceInstanceInventoryCache.class, new ServiceInstanceInventoryCache(getManager()));
|
||||
this.registerServiceImplementation(ServiceInstanceInventoryCache.class, new ServiceInstanceInventoryCache(getManager(), moduleConfig));
|
||||
this.registerServiceImplementation(IServiceInstanceInventoryRegister.class, new ServiceInstanceInventoryRegister(getManager()));
|
||||
|
||||
this.registerServiceImplementation(EndpointInventoryCache.class, new EndpointInventoryCache(getManager()));
|
||||
this.registerServiceImplementation(EndpointInventoryCache.class, new EndpointInventoryCache(getManager(), moduleConfig));
|
||||
this.registerServiceImplementation(IEndpointInventoryRegister.class, new EndpointInventoryRegister(getManager()));
|
||||
|
||||
this.registerServiceImplementation(NetworkAddressInventoryCache.class, new NetworkAddressInventoryCache(getManager()));
|
||||
this.registerServiceImplementation(NetworkAddressInventoryCache.class, new NetworkAddressInventoryCache(getManager(), moduleConfig));
|
||||
this.registerServiceImplementation(INetworkAddressInventoryRegister.class, new NetworkAddressInventoryRegister(getManager()));
|
||||
|
||||
this.registerServiceImplementation(TopologyQueryService.class, new TopologyQueryService(getManager()));
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.cache;
|
|||
import com.google.common.cache.*;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
|
||||
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO;
|
||||
|
|
@ -38,19 +39,24 @@ public class EndpointInventoryCache implements Service {
|
|||
|
||||
private final ModuleManager moduleManager;
|
||||
private final EndpointInventory userEndpoint;
|
||||
private final Cache<String, Integer> endpointNameCache = CacheBuilder.newBuilder().initialCapacity(5000).maximumSize(100000).build();
|
||||
|
||||
private final Cache<Integer, EndpointInventory> endpointIdCache = CacheBuilder.newBuilder().initialCapacity(5000).maximumSize(100000).build();
|
||||
private final Cache<String, Integer> endpointNameCache;
|
||||
private final Cache<Integer, EndpointInventory> endpointIdCache;
|
||||
|
||||
private IEndpointInventoryCacheDAO cacheDAO;
|
||||
|
||||
public EndpointInventoryCache(ModuleManager moduleManager) {
|
||||
public EndpointInventoryCache(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
|
||||
this.moduleManager = moduleManager;
|
||||
|
||||
this.userEndpoint = new EndpointInventory();
|
||||
this.userEndpoint.setSequence(Const.USER_ENDPOINT_ID);
|
||||
this.userEndpoint.setName(Const.USER_CODE);
|
||||
this.userEndpoint.setServiceId(Const.USER_SERVICE_ID);
|
||||
|
||||
long initialSize = moduleConfig.getMaxSizeOfEndpointInventory() / 10L;
|
||||
int initialCapacitySize = (int)(initialSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : initialSize);
|
||||
|
||||
endpointNameCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfEndpointInventory()).build();
|
||||
endpointIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfEndpointInventory()).build();
|
||||
}
|
||||
|
||||
private IEndpointInventoryCacheDAO getCacheDAO() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.cache;
|
|||
import com.google.common.cache.*;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
|
||||
import org.apache.skywalking.oap.server.core.register.NetworkAddressInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO;
|
||||
|
|
@ -36,14 +37,20 @@ public class NetworkAddressInventoryCache implements Service {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NetworkAddressInventoryCache.class);
|
||||
|
||||
private final Cache<String, Integer> networkAddressCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(5000).build();
|
||||
private final Cache<Integer, NetworkAddressInventory> addressIdCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(5000).build();
|
||||
private final Cache<String, Integer> networkAddressCache;
|
||||
private final Cache<Integer, NetworkAddressInventory> addressIdCache;
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private INetworkAddressInventoryCacheDAO cacheDAO;
|
||||
|
||||
public NetworkAddressInventoryCache(ModuleManager moduleManager) {
|
||||
public NetworkAddressInventoryCache(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
|
||||
this.moduleManager = moduleManager;
|
||||
|
||||
long initialSize = moduleConfig.getMaxSizeOfNetworkInventory() / 10L;
|
||||
int initialCapacitySize = (int)(initialSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : initialSize);
|
||||
|
||||
networkAddressCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfNetworkInventory()).build();
|
||||
addressIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfNetworkInventory()).build();
|
||||
}
|
||||
|
||||
private INetworkAddressInventoryCacheDAO getCacheDAO() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.cache;
|
|||
import com.google.common.cache.*;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO;
|
||||
|
|
@ -38,16 +39,13 @@ public class ServiceInstanceInventoryCache implements Service {
|
|||
private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceInventoryCache.class);
|
||||
|
||||
private final ServiceInstanceInventory userServiceInstance;
|
||||
private final Cache<Integer, ServiceInstanceInventory> serviceInstanceIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final Cache<String, Integer> serviceInstanceNameCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final Cache<String, Integer> addressIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final Cache<Integer, ServiceInstanceInventory> serviceInstanceIdCache;
|
||||
private final Cache<String, Integer> serviceInstanceNameCache;
|
||||
private final Cache<String, Integer> addressIdCache;
|
||||
private final ModuleManager moduleManager;
|
||||
private IServiceInstanceInventoryCacheDAO cacheDAO;
|
||||
|
||||
public ServiceInstanceInventoryCache(ModuleManager moduleManager) {
|
||||
public ServiceInstanceInventoryCache(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
|
||||
this.moduleManager = moduleManager;
|
||||
|
||||
this.userServiceInstance = new ServiceInstanceInventory();
|
||||
|
|
@ -55,6 +53,13 @@ public class ServiceInstanceInventoryCache implements Service {
|
|||
this.userServiceInstance.setName(Const.USER_CODE);
|
||||
this.userServiceInstance.setServiceId(Const.USER_SERVICE_ID);
|
||||
this.userServiceInstance.setIsAddress(BooleanUtils.FALSE);
|
||||
|
||||
long initialSize = moduleConfig.getMaxSizeOfServiceInstanceInventory() / 10L;
|
||||
int initialCapacitySize = (int)(initialSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : initialSize);
|
||||
|
||||
serviceInstanceIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInstanceInventory()).build();
|
||||
serviceInstanceNameCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInstanceInventory()).build();
|
||||
addressIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInstanceInventory()).build();
|
||||
}
|
||||
|
||||
private IServiceInstanceInventoryCacheDAO getCacheDAO() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.cache;
|
|||
import com.google.common.cache.*;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO;
|
||||
|
|
@ -38,20 +39,27 @@ public class ServiceInventoryCache implements Service {
|
|||
private static final Logger logger = LoggerFactory.getLogger(ServiceInventoryCache.class);
|
||||
|
||||
private final ServiceInventory userService;
|
||||
private final Cache<String, Integer> serviceNameCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(1000).build();
|
||||
private final Cache<String, Integer> addressIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(1000).build();
|
||||
private final Cache<Integer, ServiceInventory> serviceIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(1000).build();
|
||||
private final Cache<String, Integer> serviceNameCache;
|
||||
private final Cache<String, Integer> addressIdCache;
|
||||
private final Cache<Integer, ServiceInventory> serviceIdCache;
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private IServiceInventoryCacheDAO cacheDAO;
|
||||
|
||||
public ServiceInventoryCache(ModuleManager moduleManager) {
|
||||
public ServiceInventoryCache(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
|
||||
this.moduleManager = moduleManager;
|
||||
|
||||
this.userService = new ServiceInventory();
|
||||
this.userService.setSequence(Const.USER_SERVICE_ID);
|
||||
this.userService.setName(Const.USER_CODE);
|
||||
this.userService.setIsAddress(BooleanUtils.FALSE);
|
||||
|
||||
long initialSize = moduleConfig.getMaxSizeOfServiceInventory() / 10L;
|
||||
int initialCapacitySize = (int)(initialSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : initialSize);
|
||||
|
||||
serviceNameCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInventory()).build();
|
||||
addressIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInventory()).build();
|
||||
serviceIdCache = CacheBuilder.newBuilder().initialCapacity(initialCapacitySize).maximumSize(moduleConfig.getMaxSizeOfServiceInventory()).build();
|
||||
}
|
||||
|
||||
private IServiceInventoryCacheDAO getCacheDAO() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue