From c56aab58d63aa7b05868b72199c35ae90e6c0b36 Mon Sep 17 00:00:00 2001 From: Marco Martinez Date: Fri, 16 Apr 2021 16:34:56 -0700 Subject: [PATCH] Use replication JDBC options in bootstrap utility --- .../MaxwellBootstrapUtilityConfig.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java b/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java index 7517afcb9..bee0a0d0c 100644 --- a/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java +++ b/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java @@ -36,16 +36,8 @@ public MaxwellBootstrapUtilityConfig(String argv[]) { public String getConnectionURI() { - URIBuilder uriBuilder = new URIBuilder(); - uriBuilder.setScheme("jdbc:mysql"); - uriBuilder.setHost(mysql.host); - uriBuilder.setPort(mysql.port); - uriBuilder.setPath("/" + schemaDatabaseName); - for (Map.Entry jdbcOption : mysql.jdbcOptions.entrySet()) { - uriBuilder.addParameter(jdbcOption.getKey(), jdbcOption.getValue()); - } try { - return uriBuilder.build().toString(); + return getConfigConnectionURI(mysql); } catch (URISyntaxException e) { LOGGER.error(e.getMessage(), e); throw new RuntimeException("Unable to generate bootstrap's jdbc connection URI", e); @@ -53,7 +45,24 @@ public String getConnectionURI() { } public String getReplicationConnectionURI( ) { - return "jdbc:mysql://" + replicationMysql.host + ":" + replicationMysql.port; + try { + return getConfigConnectionURI(replicationMysql); + } catch (URISyntaxException e) { + LOGGER.error(e.getMessage(), e); + throw new RuntimeException("Unable to generate bootstrap's replication jdbc connection URI", e); + } + } + + private String getConfigConnectionURI(MaxwellMysqlConfig config) throws URISyntaxException { + URIBuilder uriBuilder = new URIBuilder(); + uriBuilder.setScheme("jdbc:mysql"); + uriBuilder.setHost(config.host); + uriBuilder.setPort(config.port); + uriBuilder.setPath("/" + schemaDatabaseName); + for (Map.Entry jdbcOption : config.jdbcOptions.entrySet()) { + uriBuilder.addParameter(jdbcOption.getKey(), jdbcOption.getValue()); + } + return uriBuilder.build().toString(); } protected OptionParser buildOptionParser() {