Merge lp:~diego-fmpwizard/mysql-sandbox/repl-topo-aggr-support into lp:~sandbox-developers/mysql-sandbox/replication-topo

Proposed by fmpwizard
Status: Merged
Merged at revision: not available
Proposed branch: lp:~diego-fmpwizard/mysql-sandbox/repl-topo-aggr-support
Merge into: lp:~sandbox-developers/mysql-sandbox/replication-topo
Diff against target: 128 lines (+40/-13)
1 file modified
bin/make_sandbox_topology (+40/-13)
To merge this branch: bzr merge lp:~diego-fmpwizard/mysql-sandbox/repl-topo-aggr-support
Reviewer Review Type Date Requested Status
Oldag Approve
Review via email: mp+17463@code.launchpad.net
To post a comment you must log in.
Revision history for this message
fmpwizard (diego-fmpwizard) wrote :

  * Added support for the Aggregator plugin
  * Added suport for the new mysql-monitor-agent init.d script
  * Added support for specifying agent uuid on dot file

Revision history for this message
Oldag (oldag) wrote :

looks good. merge it and push.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/make_sandbox_topology'
2--- bin/make_sandbox_topology 2009-05-08 14:22:36 +0000
3+++ bin/make_sandbox_topology 2010-01-15 15:39:12 +0000
4@@ -90,6 +90,8 @@
5 my $MYSQL = 'mysql';
6 my $PROXY = 'proxy';
7 my $PROXY_ADDR = 'proxy-address';
8+my $AGENT_UUID = 'agent-uuid';
9+my $AGGREGATOR_ADDR = 'aggr-address';
10 my $HOST = 'hostname';
11 my $PLUGINS = 'plugins';
12 my $BACKENDS = 'proxy-backend-addresses';
13@@ -100,7 +102,7 @@
14 my $attrs = $node->{$ATTRS};
15 my $opts = $node->{$OPTS};
16 my $class = $node->{$CLASS};
17- while ((my $key,my $value) = each %$attrs) {
18+ while ((my $key,my $value) = each %$attrs) {
19 if ($key =~ /^$class\./) {
20 $key =~ s/^$class\.(.*)$/$1/;
21 # allow a node-local value to win
22@@ -110,7 +112,7 @@
23 } else {
24 $opts->{$key} = $value;
25 }
26- }
27+ }
28 }
29
30 sub init_mysql_node {
31@@ -132,6 +134,7 @@
32 my ($node) = @_;
33 my $host;
34 my $port;
35+ my $aggr_port;
36 if (not exists $node->{$ATTRS}->{$PROXY_ADDR}) {
37 $port = $next_port++;
38 $node->{$OPTS}->{$PROXY_ADDR} = ":" . $port;
39@@ -140,18 +143,38 @@
40 my $pa = $node->{$ATTRS}->{$PROXY_ADDR};
41 ($host, $port) = split(/:/, $pa);
42 $node->{$OPTS}->{$PROXY_ADDR} = $pa;
43- }
44+ }
45 attributes_to_options($node);
46 my $plugins = $node->{$OPTS}->{$PLUGINS} || 'proxy';
47- $node->{$OPTS}->{$PLUGINS} = $plugins;
48+ $node->{$OPTS}->{$PLUGINS} = $plugins;
49 $node->{$PORT} = $port;
50 $node->{$HOST} = $host;
51 $node->{'is_proxy'} = $plugins =~ /proxy/;
52 $node->{'is_agent'} = $plugins =~ /agent/;
53- if ($node->{'is_agent'}) {
54- my $uuid = `uuidgen` or die "unable to generate uuid\n";
55- $node->{$OPTS}->{'agent-uuid'} = lc $uuid;
56+ $node->{'is_aggregator'} = $plugins =~ /aggr/;
57+
58+ if ($node->{'is_agent'}) {
59+ my $uuid;
60+ if ( exists $node->{$ATTRS}->{$AGENT_UUID}) {
61+ $uuid = $node->{$ATTRS}->{$AGENT_UUID};
62+ } else {
63+ $uuid = `uuidgen` or die "unable to generate uuid\n";
64+ }
65+ $node->{$OPTS}->{'agent-uuid'} = lc $uuid;
66 }
67+
68+ if ($node->{'is_aggregator'}) {
69+
70+ if (not exists $node->{$ATTRS}->{$AGGREGATOR_ADDR}) {
71+ $aggr_port = $next_port++;
72+ $node->{$OPTS}->{$AGGREGATOR_ADDR} = ":" . $aggr_port;
73+ $host = hostname;
74+ } else {
75+ my $pa = $node->{$ATTRS}->{$AGGREGATOR_ADDR};
76+ ($host, $port) = split(/:/, $pa);
77+ $node->{$OPTS}->{$AGGREGATOR_ADDR} = $pa;
78+ }
79+ }
80 push @proxies, $node;
81 }
82
83@@ -237,10 +260,12 @@
84 my $proxy;
85 if (@proxies) {
86 $proxy_home = $ENV{PROXY_HOME} || die "Proxies defined, with no PROXY_HOME specified";
87- if (-x "$proxy_home/bin/mysql-proxy") {
88- $proxy = "$proxy_home/bin/mysql-proxy";
89- } elsif (-x "$proxy_home/sbin/mysql-proxy") {
90- $proxy = "$proxy_home/sbin/mysql-proxy";
91+ if (-x "$proxy_home/bin/mysql-monitor-agent") {
92+ $proxy = "$proxy_home/bin/mysql-monitor-agent";
93+ } elsif (-x "$proxy_home/bin/mysql-proxy") {
94+ $proxy = "$proxy_home/bin/mysql-proxy";
95+ } elsif (-x "$proxy_home/sbin/mysql-proxy") {
96+ $proxy = "$proxy_home/sbin/mysql-proxy";
97 } else {
98 die "mysql-proxy not found in \$PROXY_HOME/bin or \$PROXY_HOME/sbin";
99 }
100@@ -362,18 +387,19 @@
101 for my $node (@proxies) {
102 my $name = $node->{$NAME};
103
104- my $ini = "$name/chassis.ini";
105+ my $ini = "$name/chassis.ini";
106 mkdir "$name";
107
108 $msb->write_to($ini, '>', '[mysql-proxy]');
109 while ((my $key,my $value) = each %{$node->{$OPTS}}) {
110 $msb->write_to($ini, '>>', "$key=$value");
111 }
112+ chmod 0600, $ini;
113
114 if ($node->{'is_agent'} == 1) {
115 my $instances = $node->{$OPTS}->{$INSTANCES};
116 mkdir $instances;
117- my @successors = $g->successors($node->{$NAME});
118+ my @successors = $g->successors($node->{$NAME});
119 for my $backend_name (@successors) {
120 my $dir = "$instances/$backend_name";
121 mkdir $dir;
122@@ -389,6 +415,7 @@
123 $msb->write_to($ini, '>>', "user=msandbox");
124 $msb->write_to($ini, '>>', "password=msandbox");
125 # TODO: socket support
126+ chmod 0600, $ini;
127 }
128 }
129

Subscribers

People subscribed via source and target branches