Skip to content

Commit

Permalink
[#noissue] code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed May 16, 2017
1 parent 12b8b08 commit a707679
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
protected abstract void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable);

protected AsyncTraceId getAsyncTraceId(Object target) {
return target != null && target instanceof AsyncTraceIdAccessor ? ((AsyncTraceIdAccessor) target)._$PINPOINT$_getAsyncTraceId() : null;
if (target instanceof AsyncTraceIdAccessor) {
return ((AsyncTraceIdAccessor) target)._$PINPOINT$_getAsyncTraceId();
}
return null;
}

private Trace createAsyncTrace(AsyncTraceId asyncTraceId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<ActiveTraceBo> agentStatDataPoints) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (agentStatDataPoints == null || agentStatDataPoints.isEmpty()) {
if (CollectionUtils.isEmpty(agentStatDataPoints)) {
return;
}
List<Put> activeTracePuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.ACTIVE_TRACE, agentStatDataPoints, this.activeTraceSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<CpuLoadBo> cpuLoadBos) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (cpuLoadBos == null || cpuLoadBos.isEmpty()) {
if (CollectionUtils.isEmpty(cpuLoadBos)) {
return;
}
List<Put> cpuLoadPuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.CPU_LOAD, cpuLoadBos, this.cpuLoadSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<JvmGcBo> jvmGcBos) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (jvmGcBos == null || jvmGcBos.isEmpty()) {
if (CollectionUtils.isEmpty(jvmGcBos)) {
return;
}
List<Put> jvmGcBoPuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.JVM_GC, jvmGcBos, this.jvmGcSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<JvmGcDetailedBo> jvmGcDetailedBos) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (jvmGcDetailedBos == null || jvmGcDetailedBos.isEmpty()) {
if (CollectionUtils.isEmpty(jvmGcDetailedBos)) {
return;
}
List<Put> jvmGcDetailedPuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.JVM_GC_DETAILED, jvmGcDetailedBos, this.jvmGcDetailedSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<ResponseTimeBo> responseTimeBos) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (responseTimeBos == null || responseTimeBos.isEmpty()) {
if (CollectionUtils.isEmpty(responseTimeBos)) {
return;
}
List<Put> responseTimePuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.RESPONSE_TIME, responseTimeBos, this.responseTimeSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void insert(String agentId, List<TransactionBo> transactionBos) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (transactionBos == null || transactionBos.isEmpty()) {
if (CollectionUtils.isEmpty(transactionBos)) {
return;
}
List<Put> transactionPuts = this.agentStatHbaseOperationFactory.createPuts(agentId, AgentStatType.TRANSACTION, transactionBos, this.transactionSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public RealIpHeaderResolver(String realIpHeaderName, String emptyHeaderValue) {
@Override
public String resolve(T httpServletRequest) {
final String realIp = httpServletRequest.getHeader(this.realIpHeaderName);
if (realIp == null || realIp.isEmpty()) {
if (StringUtils.isEmpty(realIp)) {
if (httpServletRequest.remoteAddress() != null) {
return httpServletRequest.remoteAddress().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.navercorp.pinpoint.rpc.PinpointSocket;
import com.navercorp.pinpoint.rpc.cluster.ClusterOption;
import com.navercorp.pinpoint.web.config.WebConfig;
import org.apache.commons.lang3.StringUtils;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -52,10 +53,12 @@ public void start() throws InterruptedException, IOException, KeeperException {
clusterAcceptor.start();
}

String connectAddress = config.getClusterConnectAddress();
if (connectAddress != null && !connectAddress.trim().isEmpty()) {
clusterConnector = new ClusterConnector(config.getClusterConnectAddress());
final String clusterConnectAddress = config.getClusterConnectAddress();
if (StringUtils.isNotBlank(clusterConnectAddress)) {
clusterConnector = new ClusterConnector(clusterConnectAddress);
clusterConnector.start();
} else {
logger.info("cluster.connect.address is empty");
}

logger.info("start() completed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.navercorp.pinpoint.web.mapper.stat.sampling.sampler;

import com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.web.vo.chart.Point;
import com.navercorp.pinpoint.web.vo.chart.UncollectedPoint;
import com.navercorp.pinpoint.web.vo.stat.SampledDataSource;
Expand All @@ -37,26 +38,28 @@ public class DataSourceSampler implements AgentStatSampler<DataSourceBo, Sampled

@Override
public SampledDataSource sampleDataPoints(int timeWindowIndex, long timestamp, List<DataSourceBo> dataSourceBoList, DataSourceBo previousDataSourceBo) {
if (dataSourceBoList == null || dataSourceBoList.size() == 0) {
if (CollectionUtils.isEmpty(dataSourceBoList)) {
return null;
}

List<Integer> activeConnectionSizes = new ArrayList<>(dataSourceBoList.size());
List<Integer> maxConnectionSizes = new ArrayList<>(dataSourceBoList.size());
final List<Integer> activeConnectionSizes = new ArrayList<>(dataSourceBoList.size());
final List<Integer> maxConnectionSizes = new ArrayList<>(dataSourceBoList.size());

DataSourceBo defaultDataSourceBo = dataSourceBoList.get(0);
int id = defaultDataSourceBo.getId();
short serviceTypeCode = defaultDataSourceBo.getServiceTypeCode();
final DataSourceBo defaultDataSourceBo = dataSourceBoList.get(0);
final int id = defaultDataSourceBo.getId();
final short serviceTypeCode = defaultDataSourceBo.getServiceTypeCode();
String databaseName = defaultDataSourceBo.getDatabaseName();
String jdbcUrl = defaultDataSourceBo.getJdbcUrl();
for (DataSourceBo dataSourceBo : dataSourceBoList) {
int activeConnectionSize = dataSourceBo.getActiveConnectionSize();

final int activeConnectionSize = dataSourceBo.getActiveConnectionSize();
if (activeConnectionSize >= 0) {
activeConnectionSizes.add(dataSourceBo.getActiveConnectionSize());
activeConnectionSizes.add(activeConnectionSize);
}
int maxConnectionSize = dataSourceBo.getMaxConnectionSize();

final int maxConnectionSize = dataSourceBo.getMaxConnectionSize();
if (maxConnectionSize >= 0) {
maxConnectionSizes.add(dataSourceBo.getMaxConnectionSize());
maxConnectionSizes.add(maxConnectionSize);
}

if (dataSourceBo.getId() != id) {
Expand Down

0 comments on commit a707679

Please sign in to comment.