Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
import org.apache.hudi.common.util.ReflectionUtils;
import org.apache.hudi.common.util.ValidationUtils;
import org.apache.hudi.config.metrics.HoodieMetricsConfig;
import org.apache.hudi.config.metrics.HoodieMetricsDatadogConfig;
import org.apache.hudi.config.metrics.HoodieMetricsGraphiteConfig;
import org.apache.hudi.config.metrics.HoodieMetricsJmxConfig;
import org.apache.hudi.config.metrics.HoodieMetricsPrometheusConfig;
import org.apache.hudi.execution.bulkinsert.BulkInsertSortMode;
import org.apache.hudi.index.HoodieIndex;
import org.apache.hudi.keygen.SimpleAvroKeyGenerator;
Expand Down Expand Up @@ -1459,23 +1464,23 @@ public MetricsReporterType getMetricsReporterType() {
}

public String getGraphiteServerHost() {
return getString(HoodieMetricsConfig.GRAPHITE_SERVER_HOST_NAME);
return getString(HoodieMetricsGraphiteConfig.GRAPHITE_SERVER_HOST_NAME);
}

public int getGraphiteServerPort() {
return getInt(HoodieMetricsConfig.GRAPHITE_SERVER_PORT_NUM);
return getInt(HoodieMetricsGraphiteConfig.GRAPHITE_SERVER_PORT_NUM);
}

public String getGraphiteMetricPrefix() {
return getString(HoodieMetricsConfig.GRAPHITE_METRIC_PREFIX_VALUE);
return getString(HoodieMetricsGraphiteConfig.GRAPHITE_METRIC_PREFIX_VALUE);
}

public String getJmxHost() {
return getString(HoodieMetricsConfig.JMX_HOST_NAME);
return getString(HoodieMetricsJmxConfig.JMX_HOST_NAME);
}

public String getJmxPort() {
return getString(HoodieMetricsConfig.JMX_PORT_NUM);
return getString(HoodieMetricsJmxConfig.JMX_PORT_NUM);
}

public int getDatadogReportPeriodSeconds() {
Expand Down Expand Up @@ -1777,6 +1782,8 @@ public static class Builder {
private boolean isMetadataConfigSet = false;
private boolean isLockConfigSet = false;
private boolean isPreCommitValidationConfigSet = false;
private boolean isMetricsJmxConfigSet = false;
private boolean isMetricsGraphiteConfigSet = false;

public Builder withEngineType(EngineType engineType) {
this.engineType = engineType;
Expand Down Expand Up @@ -1931,6 +1938,18 @@ public Builder withLockConfig(HoodieLockConfig lockConfig) {
return this;
}

public Builder withMetricsJmxConfig(HoodieMetricsJmxConfig metricsJmxConfig) {
writeConfig.getProps().putAll(metricsJmxConfig.getProps());
isMetricsJmxConfigSet = true;
return this;
}

public Builder withMetricsGraphiteConfig(HoodieMetricsGraphiteConfig mericsGraphiteConfig) {
writeConfig.getProps().putAll(mericsGraphiteConfig.getProps());
isMetricsGraphiteConfigSet = true;
return this;
}

public Builder withPreCommitValidatorConfig(HoodiePreCommitValidatorConfig validatorConfig) {
writeConfig.getProps().putAll(validatorConfig.getProps());
isPreCommitValidationConfigSet = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hudi.config;
package org.apache.hudi.config.metrics;

import org.apache.hudi.common.config.ConfigClassProperty;
import org.apache.hudi.common.config.ConfigGroups;
Expand Down Expand Up @@ -55,42 +55,6 @@ public class HoodieMetricsConfig extends HoodieConfig {
.sinceVersion("0.5.0")
.withDocumentation("Type of metrics reporter.");

// Graphite
public static final String GRAPHITE_PREFIX = METRIC_PREFIX + ".graphite";

public static final ConfigProperty<String> GRAPHITE_SERVER_HOST_NAME = ConfigProperty
.key(GRAPHITE_PREFIX + ".host")
.defaultValue("localhost")
.sinceVersion("0.5.0")
.withDocumentation("Graphite host to connect to");

public static final ConfigProperty<Integer> GRAPHITE_SERVER_PORT_NUM = ConfigProperty
.key(GRAPHITE_PREFIX + ".port")
.defaultValue(4756)
.sinceVersion("0.5.0")
.withDocumentation("Graphite port to connect to");

// Jmx
public static final String JMX_PREFIX = METRIC_PREFIX + ".jmx";

public static final ConfigProperty<String> JMX_HOST_NAME = ConfigProperty
.key(JMX_PREFIX + ".host")
.defaultValue("localhost")
.sinceVersion("0.5.1")
.withDocumentation("Jmx host to connect to");

public static final ConfigProperty<Integer> JMX_PORT_NUM = ConfigProperty
.key(JMX_PREFIX + ".port")
.defaultValue(9889)
.sinceVersion("0.5.1")
.withDocumentation("Jmx port to connect to");

public static final ConfigProperty<String> GRAPHITE_METRIC_PREFIX_VALUE = ConfigProperty
.key(GRAPHITE_PREFIX + ".metric.prefix")
.noDefaultValue()
.sinceVersion("0.5.1")
.withDocumentation("Standard prefix applied to all metrics. This helps to add datacenter, environment information for e.g");

// User defined
public static final ConfigProperty<String> METRICS_REPORTER_CLASS_NAME = ConfigProperty
.key(METRIC_PREFIX + ".reporter.class")
Expand Down Expand Up @@ -125,51 +89,6 @@ public class HoodieMetricsConfig extends HoodieConfig {
*/
@Deprecated
public static final MetricsReporterType DEFAULT_METRICS_REPORTER_TYPE = METRICS_REPORTER_TYPE_VALUE.defaultValue();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_SERVER_HOST = GRAPHITE_SERVER_HOST_NAME.key();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String DEFAULT_GRAPHITE_SERVER_HOST = GRAPHITE_SERVER_HOST_NAME.defaultValue();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_PORT_NUM} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_SERVER_PORT = GRAPHITE_SERVER_PORT_NUM.key();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_PORT_NUM} and its methods instead
*/
@Deprecated
public static final int DEFAULT_GRAPHITE_SERVER_PORT = GRAPHITE_SERVER_PORT_NUM.defaultValue();
/**
* @deprecated Use {@link #JMX_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String JMX_HOST = JMX_HOST_NAME.key();
/**
* @deprecated Use {@link #JMX_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String DEFAULT_JMX_HOST = JMX_HOST_NAME.defaultValue();
/**
* @deprecated Use {@link #JMX_PORT_NUM} and its methods instead
*/
@Deprecated
public static final String JMX_PORT = JMX_PORT_NUM.key();
/**
* @deprecated Use {@link #JMX_PORT_NUM} and its methods instead
*/
@Deprecated
public static final int DEFAULT_JMX_PORT = JMX_PORT_NUM.defaultValue();
/**
* @deprecated Use {@link #GRAPHITE_METRIC_PREFIX_VALUE} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_METRIC_PREFIX_VALUE.key();
/**
* @deprecated Use {@link #METRICS_REPORTER_CLASS_NAME} and its methods instead
*/
Expand Down Expand Up @@ -220,31 +139,6 @@ public Builder withReporterType(String reporterType) {
return this;
}

public Builder toGraphiteHost(String host) {
hoodieMetricsConfig.setValue(GRAPHITE_SERVER_HOST_NAME, host);
return this;
}

public Builder onGraphitePort(int port) {
hoodieMetricsConfig.setValue(GRAPHITE_SERVER_PORT_NUM, String.valueOf(port));
return this;
}

public Builder toJmxHost(String host) {
hoodieMetricsConfig.setValue(JMX_HOST_NAME, host);
return this;
}

public Builder onJmxPort(String port) {
hoodieMetricsConfig.setValue(JMX_PORT_NUM, port);
return this;
}

public Builder usePrefix(String prefix) {
hoodieMetricsConfig.setValue(GRAPHITE_METRIC_PREFIX_VALUE, prefix);
return this;
}

public Builder withReporterClass(String className) {
hoodieMetricsConfig.setValue(METRICS_REPORTER_CLASS_NAME, className);
return this;
Expand All @@ -267,6 +161,10 @@ public HoodieMetricsConfig build() {
HoodieMetricsPrometheusConfig.newBuilder().fromProperties(hoodieMetricsConfig.getProps()).build());
hoodieMetricsConfig.setDefaultOnCondition(reporterType == MetricsReporterType.PROMETHEUS,
HoodieMetricsPrometheusConfig.newBuilder().fromProperties(hoodieMetricsConfig.getProps()).build());
hoodieMetricsConfig.setDefaultOnCondition(reporterType == MetricsReporterType.JMX,
HoodieMetricsJmxConfig.newBuilder().fromProperties(hoodieMetricsConfig.getProps()).build());
hoodieMetricsConfig.setDefaultOnCondition(reporterType == MetricsReporterType.GRAPHITE,
HoodieMetricsGraphiteConfig.newBuilder().fromProperties(hoodieMetricsConfig.getProps()).build());
return hoodieMetricsConfig;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.hudi.config;
package org.apache.hudi.config.metrics;

import org.apache.hudi.common.config.ConfigClassProperty;
import org.apache.hudi.common.config.ConfigGroups;
Expand All @@ -27,7 +27,7 @@

import java.util.Properties;

import static org.apache.hudi.config.HoodieMetricsConfig.METRIC_PREFIX;
import static org.apache.hudi.config.metrics.HoodieMetricsConfig.METRIC_PREFIX;

/**
* Configs for Datadog reporter type.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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.hudi.config.metrics;

import org.apache.hudi.common.config.ConfigClassProperty;
import org.apache.hudi.common.config.ConfigGroups;
import org.apache.hudi.common.config.ConfigProperty;
import org.apache.hudi.common.config.HoodieConfig;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import static org.apache.hudi.config.metrics.HoodieMetricsConfig.METRIC_PREFIX;

/**
* Configs for Graphite reporter type.
* <p>
* {@link org.apache.hudi.metrics.MetricsReporterType#GRAPHITE}
*/
@ConfigClassProperty(name = "Metrics Configurations for Graphite",
groupName = ConfigGroups.Names.METRICS,
description = "Enables reporting on Hudi metrics using Graphite. "
+ " Hudi publishes metrics on every commit, clean, rollback etc.")
public class HoodieMetricsGraphiteConfig extends HoodieConfig {

public static final String GRAPHITE_PREFIX = METRIC_PREFIX + ".graphite";

public static final ConfigProperty<String> GRAPHITE_SERVER_HOST_NAME = ConfigProperty
.key(GRAPHITE_PREFIX + ".host")
.defaultValue("localhost")
.sinceVersion("0.5.0")
.withDocumentation("Graphite host to connect to.");

public static final ConfigProperty<Integer> GRAPHITE_SERVER_PORT_NUM = ConfigProperty
.key(GRAPHITE_PREFIX + ".port")
.defaultValue(4756)
.sinceVersion("0.5.0")
.withDocumentation("Graphite port to connect to.");

public static final ConfigProperty<String> GRAPHITE_METRIC_PREFIX_VALUE = ConfigProperty
.key(GRAPHITE_PREFIX + ".metric.prefix")
.noDefaultValue()
.sinceVersion("0.5.1")
.withDocumentation("Standard prefix applied to all metrics. This helps to add datacenter, environment information for e.g");

/**
* @deprecated Use {@link #GRAPHITE_SERVER_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_SERVER_HOST = GRAPHITE_SERVER_HOST_NAME.key();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_HOST_NAME} and its methods instead
*/
@Deprecated
public static final String DEFAULT_GRAPHITE_SERVER_HOST = GRAPHITE_SERVER_HOST_NAME.defaultValue();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_PORT_NUM} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_SERVER_PORT = GRAPHITE_SERVER_PORT_NUM.key();
/**
* @deprecated Use {@link #GRAPHITE_SERVER_PORT_NUM} and its methods instead
*/
@Deprecated
public static final int DEFAULT_GRAPHITE_SERVER_PORT = GRAPHITE_SERVER_PORT_NUM.defaultValue();
/**
* @deprecated Use {@link #GRAPHITE_METRIC_PREFIX_VALUE} and its methods instead
*/
@Deprecated
public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_METRIC_PREFIX_VALUE.key();

private HoodieMetricsGraphiteConfig() {
super();
}

public static HoodieMetricsGraphiteConfig.Builder newBuilder() {
return new HoodieMetricsGraphiteConfig.Builder();
}

public static class Builder {

private final HoodieMetricsGraphiteConfig hoodieMetricsGraphiteConfig = new HoodieMetricsGraphiteConfig();

public HoodieMetricsGraphiteConfig.Builder fromFile(File propertiesFile) throws IOException {
try (FileReader reader = new FileReader(propertiesFile)) {
this.hoodieMetricsGraphiteConfig.getProps().load(reader);
return this;
}
}

public HoodieMetricsGraphiteConfig.Builder fromProperties(Properties props) {
this.hoodieMetricsGraphiteConfig.getProps().putAll(props);
return this;
}

public HoodieMetricsGraphiteConfig.Builder toGraphiteHost(String host) {
hoodieMetricsGraphiteConfig.setValue(GRAPHITE_SERVER_HOST_NAME, host);
return this;
}

public HoodieMetricsGraphiteConfig.Builder onGraphitePort(int port) {
hoodieMetricsGraphiteConfig.setValue(GRAPHITE_SERVER_PORT_NUM, String.valueOf(port));
return this;
}

public HoodieMetricsGraphiteConfig.Builder usePrefix(String prefix) {
hoodieMetricsGraphiteConfig.setValue(GRAPHITE_METRIC_PREFIX_VALUE, prefix);
return this;
}

public HoodieMetricsGraphiteConfig build() {
hoodieMetricsGraphiteConfig.setDefaults(HoodieMetricsGraphiteConfig.class.getName());
return hoodieMetricsGraphiteConfig;
}
}
}
Loading