@peng-yongsheng Found you have two `endpoint` concepts in different package. I have rename the one in register, the new is `endpointInventory*`. Because the register and meta data of the cluster should be named inventory.
This commit is contained in:
parent
6fbffcbd5d
commit
43ccfa7eda
|
|
@ -20,9 +20,9 @@ package org.apache.skywalking.oap.server.core.cache;
|
|||
|
||||
import com.google.common.cache.*;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.register.endpoint.Endpoint;
|
||||
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.IEndpointCacheDAO;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.slf4j.*;
|
||||
|
||||
|
|
@ -31,20 +31,20 @@ import static java.util.Objects.*;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class EndpointCacheService implements Service {
|
||||
public class EndpointInventoryCacheService implements Service {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(EndpointCacheService.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCacheService.class);
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private IEndpointCacheDAO cacheDAO;
|
||||
private IEndpointInventoryCacheDAO cacheDAO;
|
||||
|
||||
public EndpointCacheService(ModuleManager moduleManager) {
|
||||
public EndpointInventoryCacheService(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
private final Cache<String, Integer> idCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(1000000).build();
|
||||
|
||||
private final Cache<Integer, Endpoint> sequenceCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(1000000).build();
|
||||
private final Cache<Integer, EndpointInventory> sequenceCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(1000000).build();
|
||||
|
||||
public int get(int serviceId, String serviceName, int srcSpanType) {
|
||||
String id = serviceId + Const.ID_SPLIT + serviceName + Const.ID_SPLIT + srcSpanType;
|
||||
|
|
@ -66,29 +66,29 @@ public class EndpointCacheService implements Service {
|
|||
return endpointId;
|
||||
}
|
||||
|
||||
public Endpoint get(int endpointId) {
|
||||
Endpoint endpoint = null;
|
||||
public EndpointInventory get(int endpointId) {
|
||||
EndpointInventory endpointInventory = null;
|
||||
try {
|
||||
endpoint = sequenceCache.get(endpointId, () -> getCacheDAO().get(endpointId));
|
||||
endpointInventory = sequenceCache.get(endpointId, () -> getCacheDAO().get(endpointId));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (isNull(endpoint)) {
|
||||
endpoint = getCacheDAO().get(endpointId);
|
||||
if (nonNull(endpoint)) {
|
||||
sequenceCache.put(endpointId, endpoint);
|
||||
if (isNull(endpointInventory)) {
|
||||
endpointInventory = getCacheDAO().get(endpointId);
|
||||
if (nonNull(endpointInventory)) {
|
||||
sequenceCache.put(endpointId, endpointInventory);
|
||||
} else {
|
||||
logger.warn("Endpoint id {} is not in cache and persistent storage.", endpointId);
|
||||
logger.warn("EndpointInventory id {} is not in cache and persistent storage.", endpointId);
|
||||
}
|
||||
}
|
||||
|
||||
return endpoint;
|
||||
return endpointInventory;
|
||||
}
|
||||
|
||||
private IEndpointCacheDAO getCacheDAO() {
|
||||
private IEndpointInventoryCacheDAO getCacheDAO() {
|
||||
if (isNull(cacheDAO)) {
|
||||
cacheDAO = moduleManager.find(StorageModule.NAME).getService(IEndpointCacheDAO.class);
|
||||
cacheDAO = moduleManager.find(StorageModule.NAME).getService(IEndpointInventoryCacheDAO.class);
|
||||
}
|
||||
return cacheDAO;
|
||||
}
|
||||
|
|
@ -16,12 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.register.endpoint;
|
||||
package org.apache.skywalking.oap.server.core.register;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.register.RegisterSource;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
|
|
@ -31,8 +30,8 @@ import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
@StreamData
|
||||
@StorageEntity(name = "endpoint", builder = Endpoint.Builder.class)
|
||||
public class Endpoint extends RegisterSource {
|
||||
@StorageEntity(name = "endpoint_inventory", builder = EndpointInventory.Builder.class)
|
||||
public class EndpointInventory extends RegisterSource {
|
||||
|
||||
private static final String SERVICE_ID = "service_id";
|
||||
private static final String NAME = "name";
|
||||
|
|
@ -62,7 +61,7 @@ public class Endpoint extends RegisterSource {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
Endpoint source = (Endpoint)obj;
|
||||
EndpointInventory source = (EndpointInventory)obj;
|
||||
if (serviceId != source.getServiceId())
|
||||
return false;
|
||||
if (name.equals(source.getName()))
|
||||
|
|
@ -97,20 +96,20 @@ public class Endpoint extends RegisterSource {
|
|||
setName(remoteData.getDataStrings(1));
|
||||
}
|
||||
|
||||
public static class Builder implements StorageBuilder<Endpoint> {
|
||||
public static class Builder implements StorageBuilder<EndpointInventory> {
|
||||
|
||||
@Override public Endpoint map2Data(Map<String, Object> dbMap) {
|
||||
Endpoint endpoint = new Endpoint();
|
||||
endpoint.setSequence((Integer)dbMap.get(SEQUENCE));
|
||||
endpoint.setServiceId((Integer)dbMap.get(SERVICE_ID));
|
||||
endpoint.setName((String)dbMap.get(NAME));
|
||||
endpoint.setSrcSpanType((Integer)dbMap.get(SRC_SPAN_TYPE));
|
||||
endpoint.setRegisterTime((Long)dbMap.get(REGISTER_TIME));
|
||||
endpoint.setHeartbeatTime((Long)dbMap.get(HEARTBEAT_TIME));
|
||||
return endpoint;
|
||||
@Override public EndpointInventory map2Data(Map<String, Object> dbMap) {
|
||||
EndpointInventory endpointInventory = new EndpointInventory();
|
||||
endpointInventory.setSequence((Integer)dbMap.get(SEQUENCE));
|
||||
endpointInventory.setServiceId((Integer)dbMap.get(SERVICE_ID));
|
||||
endpointInventory.setName((String)dbMap.get(NAME));
|
||||
endpointInventory.setSrcSpanType((Integer)dbMap.get(SRC_SPAN_TYPE));
|
||||
endpointInventory.setRegisterTime((Long)dbMap.get(REGISTER_TIME));
|
||||
endpointInventory.setHeartbeatTime((Long)dbMap.get(HEARTBEAT_TIME));
|
||||
return endpointInventory;
|
||||
}
|
||||
|
||||
@Override public Map<String, Object> data2Map(Endpoint storageData) {
|
||||
@Override public Map<String, Object> data2Map(EndpointInventory storageData) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(SEQUENCE, storageData.getSequence());
|
||||
map.put(SERVICE_ID, storageData.getServiceId());
|
||||
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.storage.cache;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.register.endpoint.Endpoint;
|
||||
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.DAO;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IEndpointCacheDAO extends DAO {
|
||||
public interface IEndpointInventoryCacheDAO extends DAO {
|
||||
|
||||
int get(String id);
|
||||
|
||||
Endpoint get(int sequence);
|
||||
EndpointInventory get(int sequence);
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.register.RegisterSource;
|
||||
import org.apache.skywalking.oap.server.core.register.endpoint.Endpoint;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IEndpointCacheDAO;
|
||||
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
|
|
@ -28,9 +28,9 @@ import org.elasticsearch.action.get.GetResponse;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class EndpointCacheEsDAO extends EsDAO implements IEndpointCacheDAO {
|
||||
public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInventoryCacheDAO {
|
||||
|
||||
public EndpointCacheEsDAO(ElasticSearchClient client) {
|
||||
public EndpointInventoryCacheEsDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ public class EndpointCacheEsDAO extends EsDAO implements IEndpointCacheDAO {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public Endpoint get(int sequence) {
|
||||
@Override public EndpointInventory get(int sequence) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue