Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ceresdb-common/src/main/java/com/ceresdb/common/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class Endpoint implements Serializable {
private static final long serialVersionUID = -7329681263115546100L;

@SuppressWarnings("PMD")
private String ip = "0.0.0.0";
private int port;
private String ip = "0.0.0.0";
private int port;

public static Endpoint of(final String ip, final int port) {
return new Endpoint(ip, port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public interface Lifecycle<T> {
*/
void shutdownGracefully();

default void ensureInitialized() {}
default void ensureInitialized() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class SignalHandlersLoader {

private static final Logger LOG = LoggerFactory.getLogger(SignalHandlersLoader.class);
private static final Logger LOG = LoggerFactory.getLogger(SignalHandlersLoader.class);

private static final boolean USE_OS_SIGNAL = SystemPropertyUtil.getBool(OptKeys.USE_OS_SIGNAL, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public final class SignalHelper {

private static final Logger LOG = LoggerFactory.getLogger(SignalHelper.class);
private static final Logger LOG = LoggerFactory.getLogger(SignalHelper.class);

private static final SignalAccessor SIGNAL_ACCESSOR = getSignalAccessor0();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
public class Cpus {

private static final int CPUS = SystemPropertyUtil.getInt(OptKeys.AVAILABLE_CPUS, Runtime.getRuntime()
.availableProcessors());
private static final int CPUS = SystemPropertyUtil.getInt(OptKeys.AVAILABLE_CPUS,
Runtime.getRuntime().availableProcessors());

/**
* The configured number of available processors. The default is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static void fsync(final File file) throws IOException {
return;
}

try (FileChannel fc = FileChannel.open(file.toPath(), isDir ? StandardOpenOption.READ
: StandardOpenOption.WRITE)) {
try (FileChannel fc = FileChannel.open(file.toPath(),
isDir ? StandardOpenOption.READ : StandardOpenOption.WRITE)) {
fc.force(true);
}
}
Expand All @@ -56,8 +56,8 @@ public static void mkdirIfNotExists(final String path) throws IOException {
final File dir = Paths.get(path).toFile().getAbsoluteFile();
if (dir.exists()) {
if (!dir.isDirectory()) {
throw new IOException("File " + dir + " exists and is "
+ "not a directory. Unable to create directory.");
throw new IOException(
"File " + dir + " exists and is " + "not a directory. Unable to create directory.");
}
} else if (!dir.mkdirs() && !dir.isDirectory()) {
// Double-check that some other thread or process hasn't made
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class LogScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor

private static final Logger LOG = LoggerFactory.getLogger(LogScheduledThreadPoolExecutor.class);

private final int corePoolSize;
private final String name;
private final int corePoolSize;
private final String name;

public LogScheduledThreadPoolExecutor(int corePoolSize, String name) {
super(corePoolSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class LogThreadPoolExecutor extends ThreadPoolExecutor {

private static final Logger LOG = LoggerFactory.getLogger(LogThreadPoolExecutor.class);

private final int corePoolSize;
private final int maximumPoolSize;
private final String name;
private final int corePoolSize;
private final int maximumPoolSize;
private final String name;

public LogThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit,
BlockingQueue<Runnable> workQueue, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public static Builder forRegistry(final MetricRegistry registry) {
public void report() {
synchronized (this) {
report(this.registry.getGauges(this.filter), //
this.registry.getCounters(this.filter), //
this.registry.getHistograms(this.filter), //
this.registry.getMeters(this.filter), //
this.registry.getTimers(this.filter));
this.registry.getCounters(this.filter), //
this.registry.getHistograms(this.filter), //
this.registry.getMeters(this.filter), //
this.registry.getTimers(this.filter));
}
}

Expand Down Expand Up @@ -207,19 +207,19 @@ public Builder disabledMetricAttributes(final Set<MetricAttribute> disabledMetri
*/
public MetricReporter build() {
return new MetricReporter(this.registry, //
this.output, //
this.prefix, //
this.locale, //
this.clock, //
this.timeZone, //
this.rateUnit, //
this.durationUnit, //
this.filter, //
this.disabledMetricAttributes);
this.output, //
this.prefix, //
this.locale, //
this.clock, //
this.timeZone, //
this.rateUnit, //
this.durationUnit, //
this.filter, //
this.disabledMetricAttributes);
}
}

private static final int CONSOLE_WIDTH = 80;
private static final int CONSOLE_WIDTH = 80;

private final MetricRegistry registry;
private final Set<MetricAttribute> disabledMetricAttributes;
Expand Down Expand Up @@ -256,8 +256,8 @@ private MetricReporter(MetricRegistry registry, //
this.durationFactor = durationUnit.toNanos(1);
this.durationUnit = durationUnit.toString().toLowerCase(Locale.US);
this.filter = filter;
this.disabledMetricAttributes = disabledMetricAttributes != null ? disabledMetricAttributes : Collections
.emptySet();
this.disabledMetricAttributes = disabledMetricAttributes != null ? disabledMetricAttributes :
Collections.emptySet();
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -320,13 +320,13 @@ public void report(final SortedMap<String, Gauge> gauges, final SortedMap<String
private void printMeter(final Meter meter) {
printIfEnabled(MetricAttribute.COUNT, String.format(this.locale, " count = %d", meter.getCount()));
printIfEnabled(MetricAttribute.MEAN_RATE, String.format(this.locale, " mean rate = %2.2f events/%s",
convertRate(meter.getMeanRate()), this.rateUnit));
convertRate(meter.getMeanRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M1_RATE, String.format(this.locale, " 1-minute rate = %2.2f events/%s",
convertRate(meter.getOneMinuteRate()), this.rateUnit));
convertRate(meter.getOneMinuteRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M5_RATE, String.format(this.locale, " 5-minute rate = %2.2f events/%s",
convertRate(meter.getFiveMinuteRate()), this.rateUnit));
convertRate(meter.getFiveMinuteRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M15_RATE, String.format(this.locale, " 15-minute rate = %2.2f events/%s",
convertRate(meter.getFifteenMinuteRate()), this.rateUnit));
convertRate(meter.getFifteenMinuteRate()), this.rateUnit));
}

private void printCounter(final Map.Entry<String, Counter> entry) {
Expand All @@ -339,60 +339,60 @@ private void printGauge(final Gauge<?> gauge) {

private void printHistogram(final Histogram histogram) {
printIfEnabled(MetricAttribute.COUNT,
String.format(this.locale, " count = %d", histogram.getCount()));
String.format(this.locale, " count = %d", histogram.getCount()));
final Snapshot snapshot = histogram.getSnapshot();
printIfEnabled(MetricAttribute.MIN, String.format(this.locale, " min = %d", snapshot.getMin()));
printIfEnabled(MetricAttribute.MAX, String.format(this.locale, " max = %d", snapshot.getMax()));
printIfEnabled(MetricAttribute.MEAN,
String.format(this.locale, " mean = %2.2f", snapshot.getMean()));
String.format(this.locale, " mean = %2.2f", snapshot.getMean()));
printIfEnabled(MetricAttribute.STDDEV,
String.format(this.locale, " stddev = %2.2f", snapshot.getStdDev()));
String.format(this.locale, " stddev = %2.2f", snapshot.getStdDev()));
printIfEnabled(MetricAttribute.P50,
String.format(this.locale, " median = %2.2f", snapshot.getMedian()));
String.format(this.locale, " median = %2.2f", snapshot.getMedian()));
printIfEnabled(MetricAttribute.P75,
String.format(this.locale, " 75%% <= %2.2f", snapshot.get75thPercentile()));
String.format(this.locale, " 75%% <= %2.2f", snapshot.get75thPercentile()));
printIfEnabled(MetricAttribute.P95,
String.format(this.locale, " 95%% <= %2.2f", snapshot.get95thPercentile()));
String.format(this.locale, " 95%% <= %2.2f", snapshot.get95thPercentile()));
printIfEnabled(MetricAttribute.P98,
String.format(this.locale, " 98%% <= %2.2f", snapshot.get98thPercentile()));
String.format(this.locale, " 98%% <= %2.2f", snapshot.get98thPercentile()));
printIfEnabled(MetricAttribute.P99,
String.format(this.locale, " 99%% <= %2.2f", snapshot.get99thPercentile()));
String.format(this.locale, " 99%% <= %2.2f", snapshot.get99thPercentile()));
printIfEnabled(MetricAttribute.P999,
String.format(this.locale, " 99.9%% <= %2.2f", snapshot.get999thPercentile()));
String.format(this.locale, " 99.9%% <= %2.2f", snapshot.get999thPercentile()));
}

private void printTimer(final Timer timer) {
final Snapshot snapshot = timer.getSnapshot();
printIfEnabled(MetricAttribute.COUNT, String.format(this.locale, " count = %d", timer.getCount()));
printIfEnabled(MetricAttribute.MEAN_RATE, String.format(this.locale, " mean rate = %2.2f calls/%s",
convertRate(timer.getMeanRate()), this.rateUnit));
convertRate(timer.getMeanRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M1_RATE, String.format(this.locale, " 1-minute rate = %2.2f calls/%s",
convertRate(timer.getOneMinuteRate()), this.rateUnit));
convertRate(timer.getOneMinuteRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M5_RATE, String.format(this.locale, " 5-minute rate = %2.2f calls/%s",
convertRate(timer.getFiveMinuteRate()), this.rateUnit));
convertRate(timer.getFiveMinuteRate()), this.rateUnit));
printIfEnabled(MetricAttribute.M15_RATE, String.format(this.locale, " 15-minute rate = %2.2f calls/%s",
convertRate(timer.getFifteenMinuteRate()), this.rateUnit));
convertRate(timer.getFifteenMinuteRate()), this.rateUnit));

printIfEnabled(MetricAttribute.MIN, String.format(this.locale, " min = %2.2f %s",
convertDuration(snapshot.getMin()), this.durationUnit));
convertDuration(snapshot.getMin()), this.durationUnit));
printIfEnabled(MetricAttribute.MAX, String.format(this.locale, " max = %2.2f %s",
convertDuration(snapshot.getMax()), this.durationUnit));
convertDuration(snapshot.getMax()), this.durationUnit));
printIfEnabled(MetricAttribute.MEAN, String.format(this.locale, " mean = %2.2f %s",
convertDuration(snapshot.getMean()), this.durationUnit));
convertDuration(snapshot.getMean()), this.durationUnit));
printIfEnabled(MetricAttribute.STDDEV, String.format(this.locale, " stddev = %2.2f %s",
convertDuration(snapshot.getStdDev()), this.durationUnit));
convertDuration(snapshot.getStdDev()), this.durationUnit));
printIfEnabled(MetricAttribute.P50, String.format(this.locale, " median = %2.2f %s",
convertDuration(snapshot.getMedian()), this.durationUnit));
convertDuration(snapshot.getMedian()), this.durationUnit));
printIfEnabled(MetricAttribute.P75, String.format(this.locale, " 75%% <= %2.2f %s",
convertDuration(snapshot.get75thPercentile()), this.durationUnit));
convertDuration(snapshot.get75thPercentile()), this.durationUnit));
printIfEnabled(MetricAttribute.P95, String.format(this.locale, " 95%% <= %2.2f %s",
convertDuration(snapshot.get95thPercentile()), this.durationUnit));
convertDuration(snapshot.get95thPercentile()), this.durationUnit));
printIfEnabled(MetricAttribute.P98, String.format(this.locale, " 98%% <= %2.2f %s",
convertDuration(snapshot.get98thPercentile()), this.durationUnit));
convertDuration(snapshot.get98thPercentile()), this.durationUnit));
printIfEnabled(MetricAttribute.P99, String.format(this.locale, " 99%% <= %2.2f %s",
convertDuration(snapshot.get99thPercentile()), this.durationUnit));
convertDuration(snapshot.get99thPercentile()), this.durationUnit));
printIfEnabled(MetricAttribute.P999, String.format(this.locale, " 99.9%% <= %2.2f %s",
convertDuration(snapshot.get999thPercentile()), this.durationUnit));
convertDuration(snapshot.get999thPercentile()), this.durationUnit));
}

private void printWithBanner(final String s, final char c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ protected void beforeExecute(final Thread t, final Runnable r) {
@Override
protected void afterExecute(final Runnable r, final Throwable t) {
ThreadPoolMetricRegistry.metricRegistry() //
.timer("scheduled_thread_pool." + getName()) //
.update(ThreadPoolMetricRegistry.finish(), TimeUnit.MILLISECONDS);
.timer("scheduled_thread_pool." + getName()) //
.update(ThreadPoolMetricRegistry.finish(), TimeUnit.MILLISECONDS);
super.afterExecute(r, t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ protected void beforeExecute(final Thread t, final Runnable r) {
@Override
protected void afterExecute(final Runnable r, final Throwable t) {
ThreadPoolMetricRegistry.metricRegistry() //
.timer("thread_pool." + getName()) //
.update(ThreadPoolMetricRegistry.finish(), TimeUnit.MILLISECONDS);
.timer("thread_pool." + getName()) //
.update(ThreadPoolMetricRegistry.finish(), TimeUnit.MILLISECONDS);
super.afterExecute(r, t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@
*/
public final class MetricsUtil {

private static final Logger LOG = LoggerFactory.getLogger(MetricsUtil.class);
private static final Logger LOG = LoggerFactory.getLogger(MetricsUtil.class);

private static final MetricRegistry METRIC_REGISTRY = new MetricRegistry();
private static final ScheduledReporter SCHEDULED_REPORTER;

static {
final ScheduledExecutorService scheduledPool = ThreadPoolUtil.newScheduledBuilder() //
.enableMetric(true) //
.coreThreads(1) //
.poolName("metrics.reporter") //
.threadFactory(new NamedThreadFactory("metrics.reporter", true)) //
.build();
.enableMetric(true) //
.coreThreads(1) //
.poolName("metrics.reporter") //
.threadFactory(new NamedThreadFactory("metrics.reporter", true)) //
.build();
SCHEDULED_REPORTER = createReporter(scheduledPool);
}

private static ScheduledReporter createReporter(final ScheduledExecutorService scheduledPool) {
try {
return Slf4jReporter.forRegistry(MetricsUtil.METRIC_REGISTRY) //
.withLoggingLevel(Slf4jReporter.LoggingLevel.INFO) //
.outputTo(LOG) //
.scheduleOn(scheduledPool) //
.shutdownExecutorOnStop(true) //
.build();
.withLoggingLevel(Slf4jReporter.LoggingLevel.INFO) //
.outputTo(LOG) //
.scheduleOn(scheduledPool) //
.shutdownExecutorOnStop(true) //
.build();
} catch (final Throwable ex) {
LOG.warn("Fail to create metrics reporter.", ex);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
*/
public class NamedThreadFactory implements ThreadFactory {

private static final Logger LOG = LoggerFactory.getLogger(NamedThreadFactory.class);
private static final Logger LOG = LoggerFactory.getLogger(NamedThreadFactory.class);

private static final AtomicInteger FACTORY_ID = new AtomicInteger(0);

private final AtomicInteger id = new AtomicInteger(0);
private final String name;
private final boolean daemon;
private final int priority;
private final ThreadGroup group;
private final AtomicInteger id = new AtomicInteger(0);
private final String name;
private final boolean daemon;
private final int priority;
private final ThreadGroup group;

public NamedThreadFactory(String name) {
this(name, false, Thread.NORM_PRIORITY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
*/
public class Platform {

private static final Logger LOG = LoggerFactory.getLogger(Platform.class);
private static final Logger LOG = LoggerFactory.getLogger(Platform.class);

private static final String WIN_KEY = "win";
private static final String MAC_KEY = "mac os x";
private static final String WIN_KEY = "win";
private static final String MAC_KEY = "mac os x";

private static final boolean IS_WINDOWS = isWindows0();
private static final boolean IS_MAC = isMac0();
Expand Down Expand Up @@ -69,7 +69,7 @@ private static boolean isWindows0() {

private static boolean checkOS(final String osKey) {
return SystemPropertyUtil.get(OptKeys.OS_NAME, "") //
.toLowerCase(Locale.US) //
.contains(osKey);
.toLowerCase(Locale.US) //
.contains(osKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public class RcResourceHolder<T> {

private static final Logger LOG = LoggerFactory.getLogger(RcResourceHolder.class);
private static final Logger LOG = LoggerFactory.getLogger(RcResourceHolder.class);

private final Map<ObjectPool.Resource<T>, Instance<T>> instances = new IdentityHashMap<>();

Expand All @@ -47,7 +47,7 @@ public synchronized void release(final ObjectPool.Resource<T> resource, final T
final Instance<T> cached = this.instances.get(resource);
Requires.requireNonNull(cached, "No cached instance found for " + resource);
Requires.requireTrue(returned == cached.payload(), "Releasing the wrong instance, expected=%s, actual=%s",
cached.payload(), returned);
cached.payload(), returned);
Requires.requireTrue(cached.rc() > 0, "RefCount has already reached zero");
if (cached.decAndGet() == 0) {
LOG.info("[RcResourceHolder] close instance: {}.", cached);
Expand Down
Loading