-
-
Save dasl-/cb51c4047770f5ac16588a5f2f714cae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 210a9a6bff7b36210a48bd3b3dbc9f2311ef9e84 | |
Author: dleibovic <[email protected]> | |
Date: Thu May 11 18:32:58 2017 -0400 | |
add a slave_of whitelist for creating connectors. this will be helpful for creating connectors for a subset of the comboshards as the gtid rollout progresses on the multishards (the comboshards are slaves of the multishards). | |
diff --git a/create-or-update-connectors.php b/create-or-update-connectors.php | |
index fd8f71f..0736ad1 100755 | |
--- a/create-or-update-connectors.php | |
+++ b/create-or-update-connectors.php | |
@@ -24,11 +24,12 @@ new class { | |
" -o <role> Create connectors for dbs with this mysql_role\n" . | |
" -k <csv> CSV of Kafka broker host:ports\n" . | |
" -s <id> Base server_id (default: " . self::DEFAULT_BASE_SERVER_ID . ")\n" . | |
- " -t Create DDL topic (default: disabled)\n"; | |
+ " -t Create DDL topic (default: disabled)\n" . | |
+ " -F <csv> comma separated host_port whitelist regexes\n"; | |
} | |
private function parseOpts() { | |
- $opt = getopt('c:d:hk:Lo:p:r:s:tu:z:B:W:v'); | |
+ $opt = getopt('c:d:hk:Lo:p:r:s:tu:z:B:W:F:'); | |
$this->connect_url = $opt['c'] ?? self::DEFAULT_KAFKA_CONNECT_URL; | |
$this->db_class = $opt['d'] ?? ''; | |
$this->show_help = isset($opt['h']); | |
@@ -43,6 +44,12 @@ new class { | |
$this->zk_url = $opt['z'] ?? self::DEFAULT_ZK_URL; | |
$this->db_whitelist = isset($opt['W']) ? '@' . preg_quote($opt['W'], '@') . '@' : null; | |
$this->db_blacklist = isset($opt['B']) ? '@' . preg_quote($opt['B'], '@') . '@' : null; | |
+ if (isset($opt['F'])) { | |
+ $this->host_port_whitelist_regexes = explode(",", $opt['F']); | |
+ foreach ($host_port_whitelist_regexes as $key => $host_port_whitelist_regex) { | |
+ $this->host_port_whitelist_regexes[$key] = '@' . preg_quote($host_port_whitelist_regex, '@') . '@'; | |
+ } | |
+ } | |
} | |
public function __construct() { | |
@@ -60,13 +67,27 @@ new class { | |
$host_port = $mysqld['host_port']; | |
$dbs_json = json_encode($mysqld['dbs']); | |
if ($this->db_blacklist && preg_match($this->db_blacklist, $dbs_json)) { | |
- echo "Blacklisted: {$host_port} {$dbs_json}\n"; | |
+ echo "Blacklisted by db blacklist: {$host_port} {$dbs_json}\n"; | |
continue; | |
} | |
if ($this->db_whitelist && !preg_match($this->db_whitelist, $dbs_json)) { | |
- echo "Not whitelisted: {$host_port} {$dbs_json}\n"; | |
+ echo "Not whitelisted by db whitelist: {$host_port} {$dbs_json}\n"; | |
continue; | |
} | |
+ if ($this->host_port_whitelist_regexes) { | |
+ $is_host_port_whitelisted = false; | |
+ foreach ($host_port_whitelist_regexes as $host_port_whitelist_regex) { | |
+ if (preg_match($host_port_whitelist_regex, $host_port)) { | |
+ $is_host_port_whitelisted = true; | |
+ break; | |
+ } | |
+ } | |
+ if (!$is_host_port_whitelisted) { | |
+ echo "Not whitelisted by host_port whitelist: {$host_port}\n"; | |
+ continue; | |
+ } | |
+ } | |
+ | |
$connector_name = $this->getConnectorName($host_port); | |
$ddl_topic = $this->getDdlTopicName($connector_name); | |
$server_uuid = $this->getMasterServerUuid($host_port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment