forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This closes apache#2374
- Loading branch information
Showing
19 changed files
with
638 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/Meter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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 org.apache.flink.metrics; | ||
|
||
/** | ||
* Metric for measuring throughput. | ||
*/ | ||
public interface Meter extends Metric { | ||
|
||
/** | ||
* Mark occurrence of an event. | ||
*/ | ||
void markEvent(); | ||
|
||
/** | ||
* Mark occurrence of multiple events. | ||
* | ||
* @param n number of events occurred | ||
*/ | ||
void markEvent(long n); | ||
|
||
/** | ||
* Returns the current rate of events per second. | ||
* | ||
* @return current rate of events per second | ||
*/ | ||
double getRate(); | ||
|
||
/** | ||
* Get number of events marked on the meter. | ||
* | ||
* @return number of events marked on the meter | ||
*/ | ||
long getCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/util/TestMeter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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 org.apache.flink.metrics.util; | ||
|
||
import org.apache.flink.metrics.Meter; | ||
|
||
public class TestMeter implements Meter { | ||
|
||
@Override | ||
public void markEvent() { | ||
} | ||
|
||
@Override | ||
public void markEvent(long n) { | ||
} | ||
|
||
@Override | ||
public double getRate() { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public long getCount() { | ||
return 100L; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...-dropwizard/src/main/java/org/apache/flink/dropwizard/metrics/DropwizardMeterWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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 org.apache.flink.dropwizard.metrics; | ||
|
||
import org.apache.flink.metrics.Meter; | ||
|
||
/** | ||
* Wrapper to use a Dropwizard {@link com.codahale.metrics.Meter} as a Flink {@link Meter}. | ||
*/ | ||
public class DropwizardMeterWrapper implements Meter { | ||
|
||
private final com.codahale.metrics.Meter meter; | ||
|
||
public DropwizardMeterWrapper(com.codahale.metrics.Meter meter) { | ||
this.meter = meter; | ||
} | ||
|
||
public com.codahale.metrics.Meter getDropwizardMeter() { | ||
return meter; | ||
} | ||
|
||
@Override | ||
public void markEvent() { | ||
meter.mark(); | ||
} | ||
|
||
@Override | ||
public void markEvent(long n) { | ||
meter.mark(n); | ||
} | ||
|
||
@Override | ||
public double getRate() { | ||
return meter.getOneMinuteRate(); | ||
} | ||
|
||
@Override | ||
public long getCount() { | ||
return meter.getCount(); | ||
} | ||
} |
Oops, something went wrong.