STORM-2153: remove unnecessary Metrics2Utils class
Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/6cb81fd7 Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/6cb81fd7 Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/6cb81fd7 Branch: refs/heads/1.x-branch Commit: 6cb81fd7a911ddcb986d332ec7e793acd009f0a9 Parents: eafc003 Author: P. Taylor Goetz <[email protected]> Authored: Thu Jan 11 15:59:55 2018 -0500 Committer: P. Taylor Goetz <[email protected]> Committed: Thu Jan 11 15:59:55 2018 -0500 ---------------------------------------------------------------------- .../apache/storm/metrics2/Metrics2Utils.java | 28 -------------------- .../reporters/ScheduledStormReporter.java | 9 ++----- 2 files changed, 2 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/6cb81fd7/storm-core/src/jvm/org/apache/storm/metrics2/Metrics2Utils.java ---------------------------------------------------------------------- diff --git a/storm-core/src/jvm/org/apache/storm/metrics2/Metrics2Utils.java b/storm-core/src/jvm/org/apache/storm/metrics2/Metrics2Utils.java deleted file mode 100644 index 716b8b7..0000000 --- a/storm-core/src/jvm/org/apache/storm/metrics2/Metrics2Utils.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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://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.storm.metrics2; - -public class Metrics2Utils { - private Metrics2Utils(){} - - public static Object instantiate(String klass) throws ClassNotFoundException, IllegalAccessException, InstantiationException { - Class<?> c = Class.forName(klass); - return c.newInstance(); - } - -} http://git-wip-us.apache.org/repos/asf/storm/blob/6cb81fd7/storm-core/src/jvm/org/apache/storm/metrics2/reporters/ScheduledStormReporter.java ---------------------------------------------------------------------- diff --git a/storm-core/src/jvm/org/apache/storm/metrics2/reporters/ScheduledStormReporter.java b/storm-core/src/jvm/org/apache/storm/metrics2/reporters/ScheduledStormReporter.java index b7ffa61..dccba06 100644 --- a/storm-core/src/jvm/org/apache/storm/metrics2/reporters/ScheduledStormReporter.java +++ b/storm-core/src/jvm/org/apache/storm/metrics2/reporters/ScheduledStormReporter.java @@ -18,7 +18,6 @@ package org.apache.storm.metrics2.reporters; import com.codahale.metrics.ScheduledReporter; -import org.apache.storm.metrics2.Metrics2Utils; import org.apache.storm.metrics2.filters.StormMetricsFilter; import org.apache.storm.utils.Utils; import org.slf4j.Logger; @@ -77,12 +76,8 @@ public abstract class ScheduledStormReporter implements StormReporter{ if(filterConf != null) { String clazz = (String) filterConf.get("class"); if (clazz != null) { - try { - filter = (StormMetricsFilter) Metrics2Utils.instantiate(clazz); - filter.prepare(filterConf); - } catch (Exception e) { - throw new RuntimeException("Unable to instantiate StormMetricsFilter class: " + clazz); - } + filter = Utils.newInstance(clazz); + filter.prepare(filterConf); } } return filter;
