Simpler and more comprehensive method naming in monitor

This commit is contained in:
Trustin Lee 2012-12-26 13:48:29 +09:00
parent 852f546b5b
commit 6b9f7065a2
9 changed files with 99 additions and 51 deletions

View File

@ -37,43 +37,43 @@ public interface CounterMonitor {
}
@Override
public void inc(long delta) {
public void increment(long delta) {
}
@Override
public void inc() {
public void increment() {
}
@Override
public void decr(long delta) {
public void decrement(long delta) {
}
@Override
public void decr() {
public void decrement() {
}
};
/**
* Increment this counter by 1.
*/
void inc();
void increment();
/**
* Increment this counter by the supplied {@code delta}.
* @param delta The delta to apply
*/
void inc(long delta);
void increment(long delta);
/**
* Decrement this counter by 1.
*/
void decr();
void decrement();
/**
* Decrement this counter by the supplied {@code delta}.
* @param delta The delta to apply
*/
void decr(long delta);
void decrement(long delta);
/**
* Reset this counter to its initial state.

View File

@ -46,13 +46,13 @@ public final class MonitorName {
/**
* Create a new {@code MonitorName}, using the supplied
* {@code monitoredClass}'s {@code package name} as its {@link #getGroup()
* {@code monitoredClass}'s {@code package name} as its {@link #group()
* group}, the {@code monitoredClass}'s {@code simple name} as its
* {@link #getType()} and the supplied {@code name} as its
* {@link #getName() name}.
* {@link #type()} and the supplied {@code name} as its
* {@link #name() name}.
* @param monitoredClass The class to be monitored, i.e. a class that
* represents a resource whose statistics we are interested in
* @param name Our new {@code MonitorName}'s {@link #getName() name}
* @param name Our new {@code MonitorName}'s {@link #name() name}
* @throws NullPointerException If either {@code monitoredClass} or
* {@code name} is {@code null}
*/
@ -63,15 +63,15 @@ public final class MonitorName {
/**
* Create a new {@code MonitorName}, using the supplied
* {@code monitoredClass}'s {@code package name} as its {@link #getGroup()
* {@code monitoredClass}'s {@code package name} as its {@link #group()
* group}, the {@code monitoredClass}'s {@code simple name} as its
* {@link #getType()}, the supplied {@code name} as its {@link #getName()
* name} and the supplied {@code instance} as its {@link #getInstance()
* {@link #type()}, the supplied {@code name} as its {@link #name()
* name} and the supplied {@code instance} as its {@link #instance()
* instance}.
* @param monitoredClass The class to be monitored, i.e. a class that
* represents a resource whose statistics we are interested in
* @param name Our new {@code MonitorName}'s {@link #getName() name}
* @param instance Our new {@code MonitorName}'s {@link #getInstance()
* @param name Our new {@code MonitorName}'s {@link #name() name}
* @param instance Our new {@code MonitorName}'s {@link #instance()
* instance}
* @throws NullPointerException If either {@code monitoredClass} or
* {@code name} is {@code null}
@ -83,9 +83,9 @@ public final class MonitorName {
/**
* Create a new {@code MonitorName} out of the supplied {@code group},
* {@code type} and {@code name}.
* @param group Our new {@code MonitorName}'s {@link #getGroup() group}
* @param type Our new {@code MonitorName}'s {@link #getType() type}
* @param name Our new {@code MonitorName}'s {@link #getName() name}
* @param group Our new {@code MonitorName}'s {@link #group() group}
* @param type Our new {@code MonitorName}'s {@link #type() type}
* @param name Our new {@code MonitorName}'s {@link #name() name}
* @throws NullPointerException If one of {@code group}, {@code type} and
* {@code name} is {@code null}
*/
@ -96,10 +96,10 @@ public final class MonitorName {
/**
* Create a new {@code MonitorName} out of the supplied {@code group},
* {@code type}, {@code name} and {@code instance}
* @param group Our new {@code MonitorName}'s {@link #getGroup() group}
* @param type Our new {@code MonitorName}'s {@link #getType() type}
* @param name Our new {@code MonitorName}'s {@link #getName() name}
* @param instance Our new {@code MonitorName}'s {@link #getInstance()
* @param group Our new {@code MonitorName}'s {@link #group() group}
* @param type Our new {@code MonitorName}'s {@link #type() type}
* @param name Our new {@code MonitorName}'s {@link #name() name}
* @param instance Our new {@code MonitorName}'s {@link #instance()
* instance}
* @throws NullPointerException If one of {@code group}, {@code type} and
* {@code name} is {@code null}
@ -122,13 +122,13 @@ public final class MonitorName {
/**
* Returns a copy of this {@code MonitorName} with its
* {@link #getInstance() instance} field replaced by the supplied
* {@link #instance() instance} field replaced by the supplied
* {@code instance}. Serves to support a poor man's templating mechanism for
* {@code MonitorNames}.
* @param instance The instance to be used in the {@code MonitorName}
* returned by this method
* @return A copy of this {@code MonitorName} with its
* {@link #getInstance() instance} field replaced by the supplied
* {@link #instance() instance} field replaced by the supplied
* {@code instance}
* @throws NullPointerException If {@code instance} is {@code null}
*/
@ -148,7 +148,7 @@ public final class MonitorName {
* @return The group, an arbitrary name for a set of logically related
* {@code Monitors}
*/
public String getGroup() {
public String group() {
return group;
}
@ -159,7 +159,7 @@ public final class MonitorName {
* @return The type, an arbitrary string identifying a {@code Monitor}'s
* {@code type}, commonly denoting the resource to be monitored
*/
public String getType() {
public String type() {
return type;
}
@ -169,7 +169,7 @@ public final class MonitorName {
* @return The name, an arbitrary string identifying what is actually
* monitored
*/
public String getName() {
public String name() {
return name;
}
@ -182,7 +182,7 @@ public final class MonitorName {
* exact resource instance to be monitored, in case we aren't
* dealing with a singleton resource
*/
public String getInstance() {
public String instance() {
return instance;
}

View File

@ -30,7 +30,7 @@ public final class MonitorProvider implements Serializable, Comparable<MonitorPr
/**
* Create a new {@code MonitorProvider} instance having the supplied
* {@code name}.
* @param name The new {@code MonitorProvider}'s {@link #getName() name}.
* @param name The new {@code MonitorProvider}'s {@link #name() name}.
* @return A new {@code MonitorProvider} instance having the supplied
* {@code name}
*/
@ -54,7 +54,7 @@ public final class MonitorProvider implements Serializable, Comparable<MonitorPr
* This {@code MonitorProvider}'s unique name.
* @return This {@code MonitorProvider}'s unique name
*/
public String getName() {
public String name() {
return name;
}

View File

@ -1,3 +1,19 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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 io.netty.monitor.support;
import io.netty.monitor.CounterMonitor;
@ -66,19 +82,19 @@ public class AnotherSampleMonitorRegistryFactory implements MonitorRegistryFacto
}
@Override
public void inc(long delta) {
public void increment(long delta) {
}
@Override
public void inc() {
public void increment() {
}
@Override
public void decr(long delta) {
public void decrement(long delta) {
}
@Override
public void decr() {
public void decrement() {
}
};
}

View File

@ -1,3 +1,19 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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 io.netty.monitor.support;
import io.netty.monitor.CounterMonitor;
@ -66,19 +82,19 @@ public class SampleMonitorRegistryFactory implements MonitorRegistryFactory {
}
@Override
public void inc(long delta) {
public void increment(long delta) {
}
@Override
public void inc() {
public void increment() {
}
@Override
public void decr(long delta) {
public void decrement(long delta) {
}
@Override
public void decr() {
public void decrement() {
}
};
}

View File

@ -1,3 +1,19 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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 io.netty.util;
import io.netty.monitor.CounterMonitor;
@ -80,19 +96,19 @@ public class HashedWheelTimerMonitorTest {
}
@Override
public void inc(long delta) {
public void increment(long delta) {
}
@Override
public void inc() {
public void increment() {
}
@Override
public void decr(long delta) {
public void decrement(long delta) {
}
@Override
public void decr() {
public void decrement() {
}
};
}

View File

@ -26,8 +26,8 @@ import io.netty.monitor.MonitorName;
final class Utils {
static MetricName toMetricName(final MonitorName monitorName) {
return new MetricName(monitorName.getGroup(), monitorName.getType(), monitorName.getName(),
monitorName.getInstance());
return new MetricName(monitorName.group(), monitorName.type(), monitorName.name(),
monitorName.instance());
}
private Utils() {

View File

@ -36,22 +36,22 @@ class YammerCounterMonitor implements CounterMonitor {
}
@Override
public void inc() {
public void increment() {
delegate.inc();
}
@Override
public void inc(final long delta) {
public void increment(final long delta) {
delegate.inc(delta);
}
@Override
public void decr() {
public void decrement() {
delegate.dec();
}
@Override
public void decr(final long delta) {
public void decrement(final long delta) {
delegate.dec(delta);
}

View File

@ -79,7 +79,7 @@ public final class YammerMonitorRegistry implements MonitorRegistry {
*/
@Override
public EventRateMonitor newEventRateMonitor(final MonitorName monitorName, final TimeUnit rateUnit) {
final Meter meter = delegate.newMeter(Utils.toMetricName(monitorName), monitorName.getName(), rateUnit);
final Meter meter = delegate.newMeter(Utils.toMetricName(monitorName), monitorName.name(), rateUnit);
return new YammerEventRateMonitor(meter);
}