Skip to content

Commit

Permalink
Simpler and more comprehensive method naming in monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
trustin committed Dec 26, 2012
1 parent 852f546 commit 6b9f706
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 51 deletions.
16 changes: 8 additions & 8 deletions common/src/main/java/io/netty/monitor/CounterMonitor.java
Expand Up @@ -37,43 +37,43 @@ public void reset() {
} }


@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.
Expand Down
44 changes: 22 additions & 22 deletions common/src/main/java/io/netty/monitor/MonitorName.java
Expand Up @@ -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}
*/ */
Expand All @@ -63,15 +63,15 @@ public MonitorName(final Class<?> monitoredClass, final String name) {


/** /**
* 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}
Expand All @@ -83,9 +83,9 @@ public MonitorName(final Class<?> monitoredClass, final String name, final Strin
/** /**
* 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}
*/ */
Expand All @@ -96,10 +96,10 @@ public MonitorName(final String group, final String type, final String name) {
/** /**
* 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}
Expand All @@ -122,13 +122,13 @@ public MonitorName(final String group, final String type, final String name, fin


/** /**
* 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}
*/ */
Expand All @@ -148,7 +148,7 @@ public MonitorName ofInstance(final String instance) {
* @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;
} }


Expand All @@ -159,7 +159,7 @@ public String getGroup() {
* @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;
} }


Expand All @@ -169,7 +169,7 @@ public String getType() {
* @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;
} }


Expand All @@ -182,7 +182,7 @@ public String getName() {
* 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;
} }


Expand Down
Expand Up @@ -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}
*/ */
Expand All @@ -54,7 +54,7 @@ private MonitorProvider(final String name) {
* 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;
} }


Expand Down
@@ -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;
Expand Down Expand Up @@ -66,19 +82,19 @@ public void reset() {
} }


@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() {
} }
}; };
} }
Expand Down
@@ -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;
Expand Down Expand Up @@ -66,19 +82,19 @@ public void reset() {
} }


@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() {
} }
}; };
} }
Expand Down
@@ -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;
Expand Down Expand Up @@ -80,19 +96,19 @@ public void reset() {
} }


@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() {
} }
}; };
} }
Expand Down
Expand Up @@ -26,8 +26,8 @@
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() {
Expand Down
Expand Up @@ -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);
} }


Expand Down
Expand Up @@ -79,7 +79,7 @@ public ValueDistributionMonitor newValueDistributionMonitor(final MonitorName mo
*/ */
@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);
} }


Expand Down

0 comments on commit 6b9f706

Please sign in to comment.