[1/5] beam git commit: [BEAM-2244] Move details of Metrics to Runners Core
Repository: beam Updated Branches: refs/heads/master 03a7f92e3 -> a39960b13 http://git-wip-us.apache.org/repos/asf/beam/blob/8cd98bd9/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java -- diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java deleted file mode 100644 index a0dd119..000 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java +++ /dev/null @@ -1,242 +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.beam.sdk.metrics; - -import java.util.Objects; -import org.apache.beam.sdk.metrics.MetricUpdates.MetricUpdate; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; - -/** - * Matchers for metrics. - */ -public class MetricMatchers { - - /** - * Matches a {@link MetricUpdate} with the given name and contents. - * - * Visible since it may be used in runner-specific tests. - */ - public static MatchermetricUpdate(final String name, final T update) { -return new TypeSafeMatcher () { - @Override - protected boolean matchesSafely(MetricUpdate item) { -return Objects.equals(name, item.getKey().metricName().name()) -&& Objects.equals(update, item.getUpdate()); - } - - @Override - public void describeTo(Description description) { -description -.appendText("MetricUpdate{name=").appendValue(name) -.appendText(", update=").appendValue(update) -.appendText("}"); - } -}; - } - - /** - * Matches a {@link MetricUpdate} with the given namespace, name, step and contents. - * - * Visible since it may be used in runner-specific tests. - */ - public static Matcher metricUpdate( - final String namespace, final String name, final String step, final T update) { -return new TypeSafeMatcher () { - @Override - protected boolean matchesSafely(MetricUpdate item) { -return Objects.equals(namespace, item.getKey().metricName().namespace()) -&& Objects.equals(name, item.getKey().metricName().name()) -&& Objects.equals(step, item.getKey().stepName()) -&& Objects.equals(update, item.getUpdate()); - } - - @Override - public void describeTo(Description description) { -description -.appendText("MetricUpdate{inNamespace=").appendValue(namespace) -.appendText(", name=").appendValue(name) -.appendText(", step=").appendValue(step) -.appendText(", update=").appendValue(update) -.appendText("}"); - } -}; - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for attempted metrics. - */ - public static Matcher attemptedMetricsResult( - final String namespace, final String name, final String step, final T value) { -return metricsResult(namespace, name, step, value, false); - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for committed metrics. - */ - public static Matcher committedMetricsResult( - final String namespace, final String name, final String step, final T value) { -return metricsResult(namespace, name, step, value, true); - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for either committed or attempted (based on {@code isCommitted}) metrics. - */ - public static Matcher metricsResult( - final String namespace, final String name, final String step, final T value, - final boolean isCommitted) { -final String metricState = isCommitted ? "committed" : "attempted"; -return new TypeSafeMatcher () { - @Override - protected boolean matchesSafely(MetricResult
[1/5] beam git commit: [BEAM-2244] Move details of Metrics to Runners Core
Repository: beam Updated Branches: refs/heads/release-2.0.0 e08cac055 -> 7485583a3 http://git-wip-us.apache.org/repos/asf/beam/blob/0ce5591c/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java -- diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java deleted file mode 100644 index a0dd119..000 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricMatchers.java +++ /dev/null @@ -1,242 +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.beam.sdk.metrics; - -import java.util.Objects; -import org.apache.beam.sdk.metrics.MetricUpdates.MetricUpdate; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; - -/** - * Matchers for metrics. - */ -public class MetricMatchers { - - /** - * Matches a {@link MetricUpdate} with the given name and contents. - * - * Visible since it may be used in runner-specific tests. - */ - public static MatchermetricUpdate(final String name, final T update) { -return new TypeSafeMatcher () { - @Override - protected boolean matchesSafely(MetricUpdate item) { -return Objects.equals(name, item.getKey().metricName().name()) -&& Objects.equals(update, item.getUpdate()); - } - - @Override - public void describeTo(Description description) { -description -.appendText("MetricUpdate{name=").appendValue(name) -.appendText(", update=").appendValue(update) -.appendText("}"); - } -}; - } - - /** - * Matches a {@link MetricUpdate} with the given namespace, name, step and contents. - * - * Visible since it may be used in runner-specific tests. - */ - public static Matcher metricUpdate( - final String namespace, final String name, final String step, final T update) { -return new TypeSafeMatcher () { - @Override - protected boolean matchesSafely(MetricUpdate item) { -return Objects.equals(namespace, item.getKey().metricName().namespace()) -&& Objects.equals(name, item.getKey().metricName().name()) -&& Objects.equals(step, item.getKey().stepName()) -&& Objects.equals(update, item.getUpdate()); - } - - @Override - public void describeTo(Description description) { -description -.appendText("MetricUpdate{inNamespace=").appendValue(namespace) -.appendText(", name=").appendValue(name) -.appendText(", step=").appendValue(step) -.appendText(", update=").appendValue(update) -.appendText("}"); - } -}; - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for attempted metrics. - */ - public static Matcher attemptedMetricsResult( - final String namespace, final String name, final String step, final T value) { -return metricsResult(namespace, name, step, value, false); - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for committed metrics. - */ - public static Matcher committedMetricsResult( - final String namespace, final String name, final String step, final T value) { -return metricsResult(namespace, name, step, value, true); - } - - /** - * Matches a {@link MetricResult} with the given namespace, name and step, and whose value equals - * the given value for either committed or attempted (based on {@code isCommitted}) metrics. - */ - public static Matcher metricsResult( - final String namespace, final String name, final String step, final T value, - final boolean isCommitted) { -final String metricState = isCommitted ? "committed" : "attempted"; -return new TypeSafeMatcher () { - @Override - protected boolean