Simpler and more comprehensive method naming in monitor
This commit is contained in:
parent
852f546b5b
commit
6b9f7065a2
@ -37,43 +37,43 @@ public interface CounterMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc(long delta) {
|
public void increment(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc() {
|
public void increment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr(long delta) {
|
public void decrement(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr() {
|
public void decrement() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment this counter by 1.
|
* Increment this counter by 1.
|
||||||
*/
|
*/
|
||||||
void inc();
|
void increment();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment this counter by the supplied {@code delta}.
|
* Increment this counter by the supplied {@code delta}.
|
||||||
* @param delta The delta to apply
|
* @param delta The delta to apply
|
||||||
*/
|
*/
|
||||||
void inc(long delta);
|
void increment(long delta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrement this counter by 1.
|
* Decrement this counter by 1.
|
||||||
*/
|
*/
|
||||||
void decr();
|
void decrement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrement this counter by the supplied {@code delta}.
|
* Decrement this counter by the supplied {@code delta}.
|
||||||
* @param delta The delta to apply
|
* @param delta The delta to apply
|
||||||
*/
|
*/
|
||||||
void decr(long delta);
|
void decrement(long delta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset this counter to its initial state.
|
* Reset this counter to its initial state.
|
||||||
|
@ -46,13 +46,13 @@ public final class MonitorName {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code MonitorName}, using the supplied
|
* 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
|
* group}, the {@code monitoredClass}'s {@code simple name} as its
|
||||||
* {@link #getType()} and the supplied {@code name} as its
|
* {@link #type()} and the supplied {@code name} as its
|
||||||
* {@link #getName() name}.
|
* {@link #name() name}.
|
||||||
* @param monitoredClass The class to be monitored, i.e. a class that
|
* @param monitoredClass The class to be monitored, i.e. a class that
|
||||||
* represents a resource whose statistics we are interested in
|
* 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
|
* @throws NullPointerException If either {@code monitoredClass} or
|
||||||
* {@code name} is {@code null}
|
* {@code name} is {@code null}
|
||||||
*/
|
*/
|
||||||
@ -63,15 +63,15 @@ public final class MonitorName {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code MonitorName}, using the supplied
|
* 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
|
* group}, the {@code monitoredClass}'s {@code simple name} as its
|
||||||
* {@link #getType()}, the supplied {@code name} as its {@link #getName()
|
* {@link #type()}, the supplied {@code name} as its {@link #name()
|
||||||
* name} and the supplied {@code instance} as its {@link #getInstance()
|
* name} and the supplied {@code instance} as its {@link #instance()
|
||||||
* instance}.
|
* instance}.
|
||||||
* @param monitoredClass The class to be monitored, i.e. a class that
|
* @param monitoredClass The class to be monitored, i.e. a class that
|
||||||
* represents a resource whose statistics we are interested in
|
* 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}
|
||||||
* @param instance Our new {@code MonitorName}'s {@link #getInstance()
|
* @param instance Our new {@code MonitorName}'s {@link #instance()
|
||||||
* instance}
|
* instance}
|
||||||
* @throws NullPointerException If either {@code monitoredClass} or
|
* @throws NullPointerException If either {@code monitoredClass} or
|
||||||
* {@code name} is {@code null}
|
* {@code name} is {@code null}
|
||||||
@ -83,9 +83,9 @@ public final class MonitorName {
|
|||||||
/**
|
/**
|
||||||
* Create a new {@code MonitorName} out of the supplied {@code group},
|
* Create a new {@code MonitorName} out of the supplied {@code group},
|
||||||
* {@code type} and {@code name}.
|
* {@code type} and {@code name}.
|
||||||
* @param group Our new {@code MonitorName}'s {@link #getGroup() group}
|
* @param group Our new {@code MonitorName}'s {@link #group() group}
|
||||||
* @param type Our new {@code MonitorName}'s {@link #getType() type}
|
* @param type Our new {@code MonitorName}'s {@link #type() type}
|
||||||
* @param name Our new {@code MonitorName}'s {@link #getName() name}
|
* @param name Our new {@code MonitorName}'s {@link #name() name}
|
||||||
* @throws NullPointerException If one of {@code group}, {@code type} and
|
* @throws NullPointerException If one of {@code group}, {@code type} and
|
||||||
* {@code name} is {@code null}
|
* {@code name} is {@code null}
|
||||||
*/
|
*/
|
||||||
@ -96,10 +96,10 @@ public final class MonitorName {
|
|||||||
/**
|
/**
|
||||||
* Create a new {@code MonitorName} out of the supplied {@code group},
|
* Create a new {@code MonitorName} out of the supplied {@code group},
|
||||||
* {@code type}, {@code name} and {@code instance}
|
* {@code type}, {@code name} and {@code instance}
|
||||||
* @param group Our new {@code MonitorName}'s {@link #getGroup() group}
|
* @param group Our new {@code MonitorName}'s {@link #group() group}
|
||||||
* @param type Our new {@code MonitorName}'s {@link #getType() type}
|
* @param type Our new {@code MonitorName}'s {@link #type() type}
|
||||||
* @param name Our new {@code MonitorName}'s {@link #getName() name}
|
* @param name Our new {@code MonitorName}'s {@link #name() name}
|
||||||
* @param instance Our new {@code MonitorName}'s {@link #getInstance()
|
* @param instance Our new {@code MonitorName}'s {@link #instance()
|
||||||
* instance}
|
* instance}
|
||||||
* @throws NullPointerException If one of {@code group}, {@code type} and
|
* @throws NullPointerException If one of {@code group}, {@code type} and
|
||||||
* {@code name} is {@code null}
|
* {@code name} is {@code null}
|
||||||
@ -122,13 +122,13 @@ public final class MonitorName {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of this {@code MonitorName} with its
|
* 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 instance}. Serves to support a poor man's templating mechanism for
|
||||||
* {@code MonitorNames}.
|
* {@code MonitorNames}.
|
||||||
* @param instance The instance to be used in the {@code MonitorName}
|
* @param instance The instance to be used in the {@code MonitorName}
|
||||||
* returned by this method
|
* returned by this method
|
||||||
* @return A copy of this {@code MonitorName} with its
|
* @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}
|
* {@code instance}
|
||||||
* @throws NullPointerException If {@code instance} is {@code null}
|
* @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
|
* @return The group, an arbitrary name for a set of logically related
|
||||||
* {@code Monitors}
|
* {@code Monitors}
|
||||||
*/
|
*/
|
||||||
public String getGroup() {
|
public String group() {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public final class MonitorName {
|
|||||||
* @return The type, an arbitrary string identifying a {@code Monitor}'s
|
* @return The type, an arbitrary string identifying a {@code Monitor}'s
|
||||||
* {@code type}, commonly denoting the resource to be monitored
|
* {@code type}, commonly denoting the resource to be monitored
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String type() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ public final class MonitorName {
|
|||||||
* @return The name, an arbitrary string identifying what is actually
|
* @return The name, an arbitrary string identifying what is actually
|
||||||
* monitored
|
* monitored
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String name() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ public final class MonitorName {
|
|||||||
* exact resource instance to be monitored, in case we aren't
|
* exact resource instance to be monitored, in case we aren't
|
||||||
* dealing with a singleton resource
|
* dealing with a singleton resource
|
||||||
*/
|
*/
|
||||||
public String getInstance() {
|
public String instance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public final class MonitorProvider implements Serializable, Comparable<MonitorPr
|
|||||||
/**
|
/**
|
||||||
* Create a new {@code MonitorProvider} instance having the supplied
|
* Create a new {@code MonitorProvider} instance having the supplied
|
||||||
* {@code name}.
|
* {@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
|
* @return A new {@code MonitorProvider} instance having the supplied
|
||||||
* {@code name}
|
* {@code name}
|
||||||
*/
|
*/
|
||||||
@ -54,7 +54,7 @@ public final class MonitorProvider implements Serializable, Comparable<MonitorPr
|
|||||||
* This {@code MonitorProvider}'s unique name.
|
* This {@code MonitorProvider}'s unique name.
|
||||||
* @return This {@code MonitorProvider}'s unique name
|
* @return This {@code MonitorProvider}'s unique name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String name() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
package io.netty.monitor.support;
|
||||||
|
|
||||||
import io.netty.monitor.CounterMonitor;
|
import io.netty.monitor.CounterMonitor;
|
||||||
@ -66,19 +82,19 @@ public class AnotherSampleMonitorRegistryFactory implements MonitorRegistryFacto
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc(long delta) {
|
public void increment(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc() {
|
public void increment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr(long delta) {
|
public void decrement(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr() {
|
public void decrement() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package io.netty.monitor.support;
|
||||||
|
|
||||||
import io.netty.monitor.CounterMonitor;
|
import io.netty.monitor.CounterMonitor;
|
||||||
@ -66,19 +82,19 @@ public class SampleMonitorRegistryFactory implements MonitorRegistryFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc(long delta) {
|
public void increment(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc() {
|
public void increment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr(long delta) {
|
public void decrement(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr() {
|
public void decrement() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package io.netty.util;
|
||||||
|
|
||||||
import io.netty.monitor.CounterMonitor;
|
import io.netty.monitor.CounterMonitor;
|
||||||
@ -80,19 +96,19 @@ public class HashedWheelTimerMonitorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc(long delta) {
|
public void increment(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc() {
|
public void increment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr(long delta) {
|
public void decrement(long delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr() {
|
public void decrement() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ import io.netty.monitor.MonitorName;
|
|||||||
final class Utils {
|
final class Utils {
|
||||||
|
|
||||||
static MetricName toMetricName(final MonitorName monitorName) {
|
static MetricName toMetricName(final MonitorName monitorName) {
|
||||||
return new MetricName(monitorName.getGroup(), monitorName.getType(), monitorName.getName(),
|
return new MetricName(monitorName.group(), monitorName.type(), monitorName.name(),
|
||||||
monitorName.getInstance());
|
monitorName.instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Utils() {
|
private Utils() {
|
||||||
|
@ -36,22 +36,22 @@ class YammerCounterMonitor implements CounterMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc() {
|
public void increment() {
|
||||||
delegate.inc();
|
delegate.inc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inc(final long delta) {
|
public void increment(final long delta) {
|
||||||
delegate.inc(delta);
|
delegate.inc(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr() {
|
public void decrement() {
|
||||||
delegate.dec();
|
delegate.dec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decr(final long delta) {
|
public void decrement(final long delta) {
|
||||||
delegate.dec(delta);
|
delegate.dec(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public final class YammerMonitorRegistry implements MonitorRegistry {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EventRateMonitor newEventRateMonitor(final MonitorName monitorName, final TimeUnit rateUnit) {
|
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);
|
return new YammerEventRateMonitor(meter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user