Replaced ObjectUtils for Objects methods (#1094)

* Replaced ObjectUtils for Objects methods
This commit is contained in:
Nik 2018-04-19 09:02:12 +03:00 committed by 吴晟 Wu Sheng
parent d9e60e34a3
commit b0d6231022
34 changed files with 182 additions and 220 deletions

View File

@ -23,11 +23,12 @@ import org.apache.skywalking.apm.collector.analysis.jvm.define.service.ICpuMetri
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -38,7 +39,7 @@ public class CpuMetricService implements ICpuMetricService {
private Graph<CpuMetric> cpuMetricGraph;
private Graph<CpuMetric> getCpuMetricGraph() {
if (ObjectUtils.isEmpty(cpuMetricGraph)) {
if (isNull(cpuMetricGraph)) {
cpuMetricGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.CPU_METRIC_PERSISTENCE_GRAPH_ID, CpuMetric.class);
}
return cpuMetricGraph;

View File

@ -23,11 +23,12 @@ import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IGCMetric
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -38,7 +39,7 @@ public class GCMetricService implements IGCMetricService {
private Graph<GCMetric> gcMetricGraph;
private Graph<GCMetric> getGcMetricGraph() {
if (ObjectUtils.isEmpty(gcMetricGraph)) {
if (isNull(gcMetricGraph)) {
gcMetricGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.GC_METRIC_PERSISTENCE_GRAPH_ID, GCMetric.class);
}
return gcMetricGraph;

View File

@ -24,11 +24,12 @@ import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -39,7 +40,7 @@ public class MemoryMetricService implements IMemoryMetricService {
private Graph<MemoryMetric> memoryMetricGraph;
private Graph<MemoryMetric> getMemoryMetricGraph() {
if (ObjectUtils.isEmpty(memoryMetricGraph)) {
if (isNull(memoryMetricGraph)) {
this.memoryMetricGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.MEMORY_METRIC_PERSISTENCE_GRAPH_ID, MemoryMetric.class);
}
return memoryMetricGraph;

View File

@ -23,11 +23,12 @@ import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryPo
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -38,7 +39,7 @@ public class MemoryPoolMetricService implements IMemoryPoolMetricService {
private Graph<MemoryPoolMetric> memoryPoolMetricGraph;
private Graph<MemoryPoolMetric> getMemoryPoolMetricGraph() {
if (ObjectUtils.isEmpty(memoryPoolMetricGraph)) {
if (isNull(memoryPoolMetricGraph)) {
this.memoryPoolMetricGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.MEMORY_POOL_METRIC_PERSISTENCE_GRAPH_ID, MemoryPoolMetric.class);
}
return memoryPoolMetricGraph;

View File

@ -22,12 +22,13 @@ import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGr
import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService;
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -38,7 +39,7 @@ public class InstanceHeartBeatService implements IInstanceHeartBeatService {
private Graph<Instance> heartBeatGraph;
private Graph<Instance> getHeartBeatGraph() {
if (ObjectUtils.isEmpty(heartBeatGraph)) {
if (isNull(heartBeatGraph)) {
this.heartBeatGraph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID, Instance.class);
}
return heartBeatGraph;

View File

@ -18,16 +18,10 @@
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric;
import java.util.LinkedList;
import java.util.List;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.ExitSpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.*;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
@ -36,7 +30,6 @@ import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric;
@ -44,6 +37,11 @@ import org.apache.skywalking.apm.network.proto.SpanLayer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -181,7 +179,7 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
});
exitReferenceMetric.forEach(serviceReferenceMetric -> {
if (ObjectUtils.isNotEmpty(entrySpanDecorator)) {
if (nonNull(entrySpanDecorator)) {
serviceReferenceMetric.setFrontServiceId(entrySpanDecorator.getOperationNameId());
} else {
serviceReferenceMetric.setFrontServiceId(Const.NONE_SERVICE_ID);

View File

@ -28,9 +28,10 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.register.Application;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -46,21 +47,21 @@ public class ApplicationIDService implements IApplicationIDService {
}
private Graph<Application> getApplicationRegisterGraph() {
if (ObjectUtils.isEmpty(applicationRegisterGraph)) {
if (isNull(applicationRegisterGraph)) {
this.applicationRegisterGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.APPLICATION_REGISTER_GRAPH_ID, Application.class);
}
return this.applicationRegisterGraph;
}
private ApplicationCacheService getApplicationCacheService() {
if (ObjectUtils.isEmpty(applicationCacheService)) {
if (isNull(applicationCacheService)) {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
}
return applicationCacheService;
}
private NetworkAddressCacheService getNetworkAddressCacheService() {
if (ObjectUtils.isEmpty(networkAddressCacheService)) {
if (isNull(networkAddressCacheService)) {
this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
}
return networkAddressCacheService;

View File

@ -28,11 +28,12 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -50,21 +51,21 @@ public class InstanceIDService implements IInstanceIDService {
}
private InstanceCacheService getInstanceCacheService() {
if (ObjectUtils.isEmpty(instanceCacheService)) {
if (isNull(instanceCacheService)) {
instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
}
return instanceCacheService;
}
private Graph<Instance> getInstanceRegisterGraph() {
if (ObjectUtils.isEmpty(instanceRegisterGraph)) {
if (isNull(instanceRegisterGraph)) {
this.instanceRegisterGraph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_REGISTER_GRAPH_ID, Instance.class);
}
return instanceRegisterGraph;
}
private ApplicationCacheService getApplicationCacheService() {
if (ObjectUtils.isEmpty(applicationCacheService)) {
if (isNull(applicationCacheService)) {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
}
return applicationCacheService;

View File

@ -29,9 +29,10 @@ import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -48,28 +49,28 @@ public class NetworkAddressIDService implements INetworkAddressIDService {
}
private NetworkAddressCacheService getNetworkAddressCacheService() {
if (ObjectUtils.isEmpty(networkAddressCacheService)) {
if (isNull(networkAddressCacheService)) {
this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
}
return this.networkAddressCacheService;
}
private IApplicationIDService getApplicationIDService() {
if (ObjectUtils.isEmpty(applicationIDService)) {
if (isNull(applicationIDService)) {
this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
}
return this.applicationIDService;
}
private IInstanceIDService getInstanceIDService() {
if (ObjectUtils.isEmpty(instanceIDService)) {
if (isNull(instanceIDService)) {
this.instanceIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IInstanceIDService.class);
}
return this.instanceIDService;
}
private Graph<NetworkAddress> getNetworkAddressGraph() {
if (ObjectUtils.isEmpty(networkAddressGraph)) {
if (isNull(networkAddressGraph)) {
this.networkAddressGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.NETWORK_ADDRESS_NAME_REGISTER_GRAPH_ID, NetworkAddress.class);
}
return this.networkAddressGraph;
@ -120,11 +121,10 @@ public class NetworkAddressIDService implements INetworkAddressIDService {
private boolean compare(int addressId, int spanLayer, int serverType) {
NetworkAddress networkAddress = networkAddressCacheService.getAddress(addressId);
if (ObjectUtils.isNotEmpty(networkAddress)) {
if (isNull(networkAddress)) {
return spanLayer == networkAddress.getSrcSpanLayer() && serverType == networkAddress.getServerType();
}
return true;
}
}

View File

@ -25,11 +25,12 @@ import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService;
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -46,14 +47,14 @@ public class ServiceNameService implements IServiceNameService {
}
private ServiceIdCacheService getServiceIdCacheService() {
if (ObjectUtils.isEmpty(serviceIdCacheService)) {
if (isNull(serviceIdCacheService)) {
serviceIdCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceIdCacheService.class);
}
return serviceIdCacheService;
}
private Graph<ServiceName> getServiceNameRegisterGraph() {
if (ObjectUtils.isEmpty(serviceNameRegisterGraph)) {
if (isNull(serviceNameRegisterGraph)) {
this.serviceNameRegisterGraph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_NAME_REGISTER_GRAPH_ID, ServiceName.class);
}
return serviceNameRegisterGraph;

View File

@ -18,10 +18,11 @@
package org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
import org.apache.skywalking.apm.network.proto.UniqueId;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -53,7 +54,7 @@ public class SegmentDecorator implements StandardBuilder {
}
public SpanDecorator getSpans(int index) {
if (ObjectUtils.isEmpty(spanDecorators[index])) {
if (isNull(spanDecorators[index])) {
if (isOrigin) {
spanDecorators[index] = new SpanDecorator(segmentObject.getSpans(index), this);
} else {

View File

@ -18,11 +18,12 @@
package org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.network.proto.SpanLayer;
import org.apache.skywalking.apm.network.proto.SpanObject;
import org.apache.skywalking.apm.network.proto.SpanType;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -226,7 +227,7 @@ public class SpanDecorator implements StandardBuilder {
}
public ReferenceDecorator getRefs(int index) {
if (ObjectUtils.isEmpty(referenceDecorators[index])) {
if (isNull(referenceDecorators[index])) {
if (isOrigin) {
referenceDecorators[index] = new ReferenceDecorator(spanObject.getRefs(index), this);
} else {

View File

@ -18,21 +18,23 @@
package org.apache.skywalking.apm.collector.analysis.worker.model.impl;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.data.DataCache;
import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric;
import org.apache.skywalking.apm.collector.core.data.StreamData;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -104,7 +106,7 @@ public abstract class PersistenceWorker<INPUT_AND_OUTPUT extends StreamData> ext
dataMap.forEach((id, data) -> {
if (needMergeDBData()) {
INPUT_AND_OUTPUT dbData = persistenceDAO().get(id);
if (ObjectUtils.isNotEmpty(dbData)) {
if (nonNull(dbData)) {
dbData.mergeAndFormulaCalculateData(data);
try {
updateBatchCollection.add(persistenceDAO().prepareBatchUpdate(dbData));

View File

@ -20,16 +20,19 @@ package org.apache.skywalking.apm.collector.cache.caffeine.service;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO;
import org.apache.skywalking.apm.collector.storage.table.register.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -47,7 +50,7 @@ public class ApplicationCacheCaffeineService implements ApplicationCacheService
}
private IApplicationCacheDAO getApplicationCacheDAO() {
if (ObjectUtils.isEmpty(applicationCacheDAO)) {
if (isNull(applicationCacheDAO)) {
this.applicationCacheDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationCacheDAO.class);
}
return this.applicationCacheDAO;
@ -81,9 +84,9 @@ public class ApplicationCacheCaffeineService implements ApplicationCacheService
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(application)) {
if (isNull(application)) {
application = getApplicationCacheDAO().getApplication(applicationId);
if (ObjectUtils.isNotEmpty(application)) {
if (nonNull(application)) {
applicationCache.put(applicationId, application);
}
}

View File

@ -20,16 +20,18 @@ package org.apache.skywalking.apm.collector.cache.caffeine.service;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -51,7 +53,7 @@ public class InstanceCacheCaffeineService implements InstanceCacheService {
}
private IInstanceCacheDAO getInstanceCacheDAO() {
if (ObjectUtils.isEmpty(instanceCacheDAO)) {
if (isNull(instanceCacheDAO)) {
this.instanceCacheDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceCacheDAO.class);
}
return this.instanceCacheDAO;

View File

@ -20,10 +20,8 @@ package org.apache.skywalking.apm.collector.cache.caffeine.service;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO;
@ -31,6 +29,10 @@ import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -48,7 +50,7 @@ public class NetworkAddressCacheCaffeineService implements NetworkAddressCacheSe
}
private INetworkAddressCacheDAO getNetworkAddressCacheDAO() {
if (ObjectUtils.isEmpty(networkAddressCacheDAO)) {
if (isNull(networkAddressCacheDAO)) {
this.networkAddressCacheDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressCacheDAO.class);
}
return this.networkAddressCacheDAO;
@ -83,7 +85,7 @@ public class NetworkAddressCacheCaffeineService implements NetworkAddressCacheSe
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(networkAddress)) {
if (isNull(networkAddress)) {
networkAddress = getNetworkAddressCacheDAO().getAddressById(addressId);
if (StringUtils.isNotEmpty(networkAddress)) {
idCache.put(addressId, networkAddress);

View File

@ -20,16 +20,18 @@ package org.apache.skywalking.apm.collector.cache.caffeine.service;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -47,7 +49,7 @@ public class ServiceIdCacheCaffeineService implements ServiceIdCacheService {
}
private IServiceNameCacheDAO getServiceNameCacheDAO() {
if (ObjectUtils.isEmpty(serviceNameCacheDAO)) {
if (isNull(serviceNameCacheDAO)) {
this.serviceNameCacheDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameCacheDAO.class);
}
return this.serviceNameCacheDAO;

View File

@ -20,16 +20,19 @@ package org.apache.skywalking.apm.collector.cache.caffeine.service;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -47,7 +50,7 @@ public class ServiceNameCacheCaffeineService implements ServiceNameCacheService
}
private IServiceNameCacheDAO getServiceNameCacheDAO() {
if (ObjectUtils.isEmpty(serviceNameCacheDAO)) {
if (isNull(serviceNameCacheDAO)) {
this.serviceNameCacheDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameCacheDAO.class);
}
return this.serviceNameCacheDAO;
@ -61,9 +64,9 @@ public class ServiceNameCacheCaffeineService implements ServiceNameCacheService
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(serviceName)) {
if (isNull(serviceName)) {
serviceName = getServiceNameCacheDAO().get(serviceId);
if (ObjectUtils.isNotEmpty(serviceName)) {
if (nonNull(serviceName)) {
serviceCache.put(serviceId, serviceName);
}
}

View File

@ -22,13 +22,15 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO;
import org.apache.skywalking.apm.collector.storage.table.register.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -46,7 +48,7 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
}
private IApplicationCacheDAO getApplicationCacheDAO() {
if (ObjectUtils.isEmpty(applicationCacheDAO)) {
if (isNull(applicationCacheDAO)) {
this.applicationCacheDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationCacheDAO.class);
}
return this.applicationCacheDAO;
@ -79,9 +81,9 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(application)) {
if (isNull(application)) {
application = getApplicationCacheDAO().getApplication(applicationId);
if (ObjectUtils.isNotEmpty(application)) {
if (nonNull(application)) {
applicationCache.put(applicationId, application);
}
}

View File

@ -23,12 +23,13 @@ import com.google.common.cache.CacheBuilder;
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -50,7 +51,7 @@ public class InstanceCacheGuavaService implements InstanceCacheService {
}
private IInstanceCacheDAO getInstanceCacheDAO() {
if (ObjectUtils.isEmpty(instanceCacheDAO)) {
if (isNull(instanceCacheDAO)) {
this.instanceCacheDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceCacheDAO.class);
}
return this.instanceCacheDAO;

View File

@ -22,7 +22,6 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO;
@ -30,6 +29,8 @@ import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -47,7 +48,7 @@ public class NetworkAddressCacheGuavaService implements NetworkAddressCacheServi
}
private INetworkAddressCacheDAO getNetworkAddressCacheDAO() {
if (ObjectUtils.isEmpty(networkAddressCacheDAO)) {
if (isNull(networkAddressCacheDAO)) {
this.networkAddressCacheDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressCacheDAO.class);
}
return this.networkAddressCacheDAO;
@ -81,7 +82,7 @@ public class NetworkAddressCacheGuavaService implements NetworkAddressCacheServi
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(networkAddress)) {
if (isNull(networkAddress)) {
networkAddress = getNetworkAddressCacheDAO().getAddressById(addressId);
if (StringUtils.isNotEmpty(networkAddress)) {
idCache.put(addressId, networkAddress);

View File

@ -23,12 +23,13 @@ import com.google.common.cache.CacheBuilder;
import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -46,7 +47,7 @@ public class ServiceIdCacheGuavaService implements ServiceIdCacheService {
}
private IServiceNameCacheDAO getServiceNameCacheDAO() {
if (ObjectUtils.isEmpty(serviceNameCacheDAO)) {
if (isNull(serviceNameCacheDAO)) {
this.serviceNameCacheDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameCacheDAO.class);
}
return this.serviceNameCacheDAO;

View File

@ -22,13 +22,15 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -46,7 +48,7 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService {
}
private IServiceNameCacheDAO getServiceNameCacheDAO() {
if (ObjectUtils.isEmpty(serviceNameCacheDAO)) {
if (isNull(serviceNameCacheDAO)) {
this.serviceNameCacheDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameCacheDAO.class);
}
return this.serviceNameCacheDAO;
@ -60,9 +62,9 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService {
logger.error(e.getMessage(), e);
}
if (ObjectUtils.isEmpty(serviceName)) {
if (isNull(serviceName)) {
serviceName = getServiceNameCacheDAO().get(serviceId);
if (ObjectUtils.isNotEmpty(serviceName)) {
if (nonNull(serviceName)) {
serviceCache.put(serviceId, serviceName);
}
}

View File

@ -19,22 +19,20 @@
package org.apache.skywalking.apm.collector.server.jetty;
import com.google.gson.JsonElement;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.server.ServerHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -166,7 +164,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler
response.setStatus(HttpServletResponse.SC_OK);
PrintWriter out = response.getWriter();
if (ObjectUtils.isNotEmpty(resJson)) {
if (nonNull(resJson)) {
out.print(resJson);
}
out.flush();

View File

@ -18,7 +18,7 @@
package org.apache.skywalking.apm.collector.core.data;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
@ -158,25 +158,25 @@ public abstract class AbstractData {
@SuppressWarnings("unchecked")
private void calculateFormula() {
for (int i = 0; i < stringColumns.length; i++) {
if (ObjectUtils.isNotEmpty(stringColumns[i].getFormulaOperation())) {
if (nonNull(stringColumns[i].getFormulaOperation())) {
String stringData = (String)stringColumns[i].getFormulaOperation().operate(this);
this.dataStrings[i] = stringData;
}
}
for (int i = 0; i < longColumns.length; i++) {
if (ObjectUtils.isNotEmpty(longColumns[i].getFormulaOperation())) {
if (nonNull(longColumns[i].getFormulaOperation())) {
Long longData = (Long)longColumns[i].getFormulaOperation().operate(this);
this.dataLongs[i] = longData;
}
}
for (int i = 0; i < doubleColumns.length; i++) {
if (ObjectUtils.isNotEmpty(doubleColumns[i].getFormulaOperation())) {
if (nonNull(doubleColumns[i].getFormulaOperation())) {
Double doubleData = (Double)doubleColumns[i].getFormulaOperation().operate(this);
this.dataDoubles[i] = doubleData;
}
}
for (int i = 0; i < integerColumns.length; i++) {
if (ObjectUtils.isNotEmpty(integerColumns[i].getFormulaOperation())) {
if (nonNull(integerColumns[i].getFormulaOperation())) {
Integer integerData = (Integer)integerColumns[i].getFormulaOperation().operate(this);
this.dataIntegers[i] = integerData;
}

View File

@ -1,33 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.core.util;
/**
* @author peng-yongsheng
*/
public class ObjectUtils {
public static boolean isEmpty(Object obj) {
return obj == null;
}
public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}
}

View File

@ -1,34 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.core.util;
import org.junit.Assert;
import org.junit.Test;
/**
* @author wu-sheng
*/
public class ObjectUtilsTest {
@Test
public void testNullObject() {
Object o = new Object();
Assert.assertTrue(ObjectUtils.isNotEmpty(o));
}
}

View File

@ -18,9 +18,7 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
@ -30,6 +28,10 @@ import org.apache.skywalking.apm.collector.ui.service.AlarmService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import org.apache.skywalking.apm.collector.ui.utils.PaginationUtils;
import java.text.ParseException;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -43,7 +45,7 @@ public class AlarmQuery implements Query {
}
private AlarmService getAlarmService() {
if (ObjectUtils.isEmpty(alarmService)) {
if (isNull(alarmService)) {
this.alarmService = new AlarmService(moduleManager);
}
return alarmService;

View File

@ -18,10 +18,7 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import java.util.List;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
@ -33,6 +30,11 @@ import org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService
import org.apache.skywalking.apm.collector.ui.service.ServerService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import java.text.ParseException;
import java.util.List;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -48,21 +50,21 @@ public class ApplicationQuery implements Query {
}
private ApplicationService getApplicationService() {
if (ObjectUtils.isEmpty(applicationService)) {
if (isNull(applicationService)) {
this.applicationService = new ApplicationService(moduleManager);
}
return applicationService;
}
private ApplicationTopologyService getApplicationTopologyService() {
if (ObjectUtils.isEmpty(applicationTopologyService)) {
if (isNull(applicationTopologyService)) {
this.applicationTopologyService = new ApplicationTopologyService(moduleManager);
}
return applicationTopologyService;
}
private ServerService getServerService() {
if (ObjectUtils.isEmpty(serverService)) {
if (isNull(serverService)) {
this.serverService = new ServerService(moduleManager);
}
return serverService;

View File

@ -18,10 +18,7 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import java.util.List;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
@ -30,13 +27,14 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ClusterBrief;
import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
import org.apache.skywalking.apm.collector.ui.graphql.Query;
import org.apache.skywalking.apm.collector.ui.service.AlarmService;
import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService;
import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService;
import org.apache.skywalking.apm.collector.ui.service.ServiceNameService;
import org.apache.skywalking.apm.collector.ui.service.*;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import java.text.ParseException;
import java.util.List;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -54,35 +52,35 @@ public class OverViewLayerQuery implements Query {
}
private ClusterTopologyService getClusterTopologyService() {
if (ObjectUtils.isEmpty(clusterTopologyService)) {
if (isNull(clusterTopologyService)) {
this.clusterTopologyService = new ClusterTopologyService(moduleManager);
}
return clusterTopologyService;
}
private ApplicationService getApplicationService() {
if (ObjectUtils.isEmpty(applicationService)) {
if (isNull(applicationService)) {
this.applicationService = new ApplicationService(moduleManager);
}
return applicationService;
}
private NetworkAddressService getNetworkAddressService() {
if (ObjectUtils.isEmpty(networkAddressService)) {
if (isNull(networkAddressService)) {
this.networkAddressService = new NetworkAddressService(moduleManager);
}
return networkAddressService;
}
private ServiceNameService getServiceNameService() {
if (ObjectUtils.isEmpty(serviceNameService)) {
if (isNull(serviceNameService)) {
this.serviceNameService = new ServiceNameService(moduleManager);
}
return serviceNameService;
}
private AlarmService getAlarmService() {
if (ObjectUtils.isEmpty(alarmService)) {
if (isNull(alarmService)) {
this.alarmService = new AlarmService(moduleManager);
}
return alarmService;

View File

@ -18,10 +18,7 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import java.util.List;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend;
import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend;
@ -33,6 +30,11 @@ import org.apache.skywalking.apm.collector.ui.graphql.Query;
import org.apache.skywalking.apm.collector.ui.service.ServerService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import java.text.ParseException;
import java.util.List;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -46,7 +48,7 @@ public class ServerQuery implements Query {
}
private ServerService getServerService() {
if (ObjectUtils.isEmpty(serverService)) {
if (isNull(serverService)) {
this.serverService = new ServerService(moduleManager);
}
return serverService;

View File

@ -18,21 +18,19 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import java.util.List;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend;
import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend;
import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.common.*;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo;
import org.apache.skywalking.apm.collector.ui.graphql.Query;
import org.apache.skywalking.apm.collector.ui.service.ServiceNameService;
import org.apache.skywalking.apm.collector.ui.service.ServiceTopologyService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import java.text.ParseException;
import java.util.List;
import static java.util.Objects.isNull;
/**
* @author peng-yongsheng
*/
@ -47,14 +45,14 @@ public class ServiceQuery implements Query {
}
private ServiceNameService getServiceNameService() {
if (ObjectUtils.isEmpty(serviceNameService)) {
if (isNull(serviceNameService)) {
this.serviceNameService = new ServiceNameService(moduleManager);
}
return serviceNameService;
}
private ServiceTopologyService getServiceTopologyService() {
if (ObjectUtils.isEmpty(serviceTopologyService)) {
if (isNull(serviceTopologyService)) {
this.serviceTopologyService = new ServiceTopologyService(moduleManager);
}
return serviceTopologyService;

View File

@ -18,11 +18,9 @@
package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException;
import org.apache.skywalking.apm.collector.core.UnexpectedException;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.apache.skywalking.apm.collector.storage.ui.trace.Trace;
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
@ -33,6 +31,11 @@ import org.apache.skywalking.apm.collector.ui.service.TraceStackService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import org.apache.skywalking.apm.collector.ui.utils.PaginationUtils;
import java.text.ParseException;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -47,14 +50,14 @@ public class TraceQuery implements Query {
}
private SegmentTopService getSegmentTopService() {
if (ObjectUtils.isEmpty(segmentTopService)) {
if (isNull(segmentTopService)) {
this.segmentTopService = new SegmentTopService(moduleManager);
}
return segmentTopService;
}
private TraceStackService getTraceStackService() {
if (ObjectUtils.isEmpty(traceStackService)) {
if (isNull(traceStackService)) {
this.traceStackService = new TraceStackService(moduleManager);
}
return traceStackService;
@ -67,7 +70,7 @@ public class TraceQuery implements Query {
if (StringUtils.isNotEmpty(condition.getTraceId())) {
traceId = condition.getTraceId();
} else if (ObjectUtils.isNotEmpty(condition.getQueryDuration())) {
} else if (nonNull(condition.getQueryDuration())) {
startSecondTimeBucket = DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart());
endSecondTimeBucket = DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getEnd());
} else {

View File

@ -18,9 +18,6 @@
package org.apache.skywalking.apm.collector.ui.service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
@ -30,21 +27,21 @@ import org.apache.skywalking.apm.collector.configuration.service.IComponentLibra
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.CollectionUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.apache.skywalking.apm.collector.storage.ui.trace.KeyValue;
import org.apache.skywalking.apm.collector.storage.ui.trace.LogEntity;
import org.apache.skywalking.apm.collector.storage.ui.trace.Ref;
import org.apache.skywalking.apm.collector.storage.ui.trace.RefType;
import org.apache.skywalking.apm.collector.storage.ui.trace.Span;
import org.apache.skywalking.apm.collector.storage.ui.trace.Trace;
import org.apache.skywalking.apm.collector.storage.ui.trace.*;
import org.apache.skywalking.apm.network.proto.SpanObject;
import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
import org.apache.skywalking.apm.network.proto.UniqueId;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static java.util.Objects.nonNull;
/**
* @author peng-yongsheng
*/
@ -72,7 +69,7 @@ public class TraceStackService {
if (CollectionUtils.isNotEmpty(segmentIds)) {
for (String segmentId : segmentIds) {
TraceSegmentObject segment = segmentDAO.load(segmentId);
if (ObjectUtils.isNotEmpty(segment)) {
if (nonNull(segment)) {
trace.getSpans().addAll(buildSpanList(traceId, segmentId, segment.getApplicationId(), segment.getSpansList()));
}
}
@ -127,7 +124,7 @@ public class TraceStackService {
String operationName = spanObject.getOperationName();
if (spanObject.getOperationNameId() != 0) {
ServiceName serviceName = serviceNameCacheService.get(spanObject.getOperationNameId());
if (ObjectUtils.isNotEmpty(serviceName)) {
if (nonNull(serviceName)) {
operationName = serviceName.getServiceName();
} else {
operationName = Const.EMPTY_STRING;