Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][broker] Log warning on missing URL configuration for cluster creation/update #20541

Merged
merged 5 commits into from
Jun 21, 2023
Merged
Changes from 3 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 @@ -25,6 +25,8 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.api.ProxyProtocol;
import org.apache.pulsar.common.util.URIPreconditions;

Expand All @@ -38,6 +40,7 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public final class ClusterDataImpl implements ClusterData, Cloneable {
@ApiModelProperty(
name = "serviceUrl",
Expand Down Expand Up @@ -71,14 +74,14 @@ public final class ClusterDataImpl implements ClusterData, Cloneable {
)
private String proxyServiceUrl;
@ApiModelProperty(
name = "authenticationPlugin",
value = "Authentication plugin when client would like to connect to cluster.",
example = "org.apache.pulsar.client.impl.auth.AuthenticationToken"
name = "authenticationPlugin",
value = "Authentication plugin when client would like to connect to cluster.",
example = "org.apache.pulsar.client.impl.auth.AuthenticationToken"
)
private String authenticationPlugin;
@ApiModelProperty(
name = "authenticationParameters",
value = "Authentication parameters when client would like to connect to cluster."
name = "authenticationParameters",
value = "Authentication parameters when client would like to connect to cluster."
)
private String authenticationParameters;
@ApiModelProperty(
Expand All @@ -97,40 +100,40 @@ public final class ClusterDataImpl implements ClusterData, Cloneable {
private LinkedHashSet<String> peerClusterNames;

@ApiModelProperty(
name = "brokerClientTlsEnabled",
value = "Enable TLS when talking with other brokers in the same cluster (admin operation)"
+ " or different clusters (replication)"
name = "brokerClientTlsEnabled",
value = "Enable TLS when talking with other brokers in the same cluster (admin operation)"
+ " or different clusters (replication)"
)
private boolean brokerClientTlsEnabled;
@ApiModelProperty(
name = "tlsAllowInsecureConnection",
value = "Allow TLS connections to servers whose certificate cannot be"
+ " be verified to have been signed by a trusted certificate"
+ " authority."
name = "tlsAllowInsecureConnection",
value = "Allow TLS connections to servers whose certificate cannot be"
+ " be verified to have been signed by a trusted certificate"
+ " authority."
)
private boolean tlsAllowInsecureConnection;
@ApiModelProperty(
name = "brokerClientTlsEnabledWithKeyStore",
value = "Whether internal client use KeyStore type to authenticate with other Pulsar brokers"
name = "brokerClientTlsEnabledWithKeyStore",
value = "Whether internal client use KeyStore type to authenticate with other Pulsar brokers"
)
private boolean brokerClientTlsEnabledWithKeyStore;
@ApiModelProperty(
name = "brokerClientTlsTrustStoreType",
value = "TLS TrustStore type configuration for internal client: JKS, PKCS12"
+ " used by the internal client to authenticate with Pulsar brokers",
example = "JKS"
name = "brokerClientTlsTrustStoreType",
value = "TLS TrustStore type configuration for internal client: JKS, PKCS12"
+ " used by the internal client to authenticate with Pulsar brokers",
example = "JKS"
)
private String brokerClientTlsTrustStoreType;
@ApiModelProperty(
name = "brokerClientTlsTrustStore",
value = "TLS TrustStore path for internal client"
+ " used by the internal client to authenticate with Pulsar brokers"
name = "brokerClientTlsTrustStore",
value = "TLS TrustStore path for internal client"
+ " used by the internal client to authenticate with Pulsar brokers"
)
private String brokerClientTlsTrustStore;
@ApiModelProperty(
name = "brokerClientTlsTrustStorePassword",
value = "TLS TrustStore password for internal client"
+ " used by the internal client to authenticate with Pulsar brokers"
name = "brokerClientTlsTrustStorePassword",
value = "TLS TrustStore password for internal client"
+ " used by the internal client to authenticate with Pulsar brokers"
)
private String brokerClientTlsTrustStorePassword;
@ApiModelProperty(
Expand Down Expand Up @@ -427,5 +430,20 @@ public void checkPropertiesIfPresent() throws IllegalArgumentException {
|| Objects.equals(uri.getScheme(), "pulsar+ssl"),
"Illegal proxy service url, example: pulsar+ssl://ats-proxy.example.com:4443 "
+ "or pulsar://ats-proxy.example.com:4080");

warnIfUrlIsNotPresent();
}

private void warnIfUrlIsNotPresent() {
if (StringUtils.isEmpty(getServiceUrl()) && StringUtils.isEmpty(getServiceUrlTls())) {
log.warn("Service url not found, "
+ "please provide either service url, example: http://pulsar.example.com:8080 "
+ "or service tls url, example: https://pulsar.example.com:8443");
}
if (StringUtils.isEmpty(getBrokerServiceUrl()) && StringUtils.isEmpty(getBrokerServiceUrlTls())) {
log.warn("Broker service url not found, "
+ "please provide either broker service url, example: pulsar://pulsar.example.com:6650 "
+ "or broker service tls url, example: pulsar+ssl://pulsar.example.com:6651.");
}
}
}