Sat Jan 8 20:48:31 PST 2005
- Previous message: [Slony1-general] next release?
- Next message: [Slony1-general] Slony performance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Affected Files: - subscribe_set.pl - merge_sets.pl - drop_set.pl Changes: - Added a --config option to specify the location of slon.env. - Added a --help option to show usage. - Cleaned up output to be consistent with other scripts from this directory. Additional Changes to drop_set.pl - Output file was being opened using ">>" instead of ">", unlike other scripts in this directory. - Use $MASTERNODE instead of assuming node 1 to be the master. -- Steve Simms <steve at deefs.net> http://www.deefs.net -------------- next part -------------- --- /home/smsimms/projects/slony1-engine/tools/altperl/merge_sets.pl 2004-09-09 13:04:07.000000000 -0400 +++ merge_sets.pl 2005-01-08 15:29:25.000000000 -0500 @@ -1,45 +1,65 @@ -#!perl # -*- perl -*- -# $Id: merge_sets.pl,v 1.4 2004/09/09 17:04:07 cbbrowne Exp $ +#!/usr/bin/perl +# $Id: merge_sets.pl,v 1.4.2.1 2004/09/30 17:37:28 cbbrowne Exp $ # Author: Christopher Browne # Copyright 2004 Afilias Canada +use Getopt::Long; + +$SLON_ENV_FILE = 'slon.env'; # Where to find the slon.env file +$SHOW_USAGE = 0; # Show usage, then quit + +# Read command-line options +GetOptions("config=s" => \$SLON_ENV_FILE, + "help" => \$SHOW_USAGE); + +my $USAGE = +"Usage: merge_sets.pl [--config file] node# set# set# + + Merges the contents of the second set into the first one. + +"; + +if ($SHOW_USAGE) { + print $USAGE; + exit 0; +} + require 'slon-tools.pm'; -require 'slon.env'; +require $SLON_ENV_FILE; my ($node, $set1, $set2) = @ARGV; -if ($node =~ /^node(\d+)$/) { +if ($node =~ /^(?:node)?(\d+)$/) { # Set name is in proper form $node = $1; } else { print "Valid node names are node1, node2, ...\n\n"; - die "Usage: ./merge_sets.pl nodeN setOLD setNEW\n"; + die $USAGE; } -if ($set1 =~ /^set(\d+)$/) { +if ($set1 =~ /^(?:set)?(\d+)$/) { $set1 = $1; } else { print "Valid set names are set1, set2, ...\n\n"; - die "Usage: ./merge_sets.pl nodeN setOLD setNEW\n"; + die $USAGE; } -if ($set2 =~ /^set(\d+)$/) { + +if ($set2 =~ /^(?:set)?(\d+)$/) { $set2 = $1; } else { print "Valid set names are set1, set2, ...\n\n"; - die "Usage: ./merge_sets.pl nodeN setOLD setNEW\n"; + die $USAGE; } -open(SLONIK, ">/tmp/slonik.$$"); -print SLONIK genheader(); -my ($dbname, $dbhost)=($DBNAME[1], $HOST[1]); -print SLONIK qq[ -try { - merge set (id = $set1, add id = $set2, origin = $node); -} on error { - echo 'Failure to merge sets $set1 and $set2 with origin $node'; - exit 1; -} -echo 'Replication set $set2 merged in with $set1 on origin $node'; -]; +my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]); +open(SLONIK, ">", "/tmp/slonik.$$"); +print SLONIK genheader(); +print SLONIK " try {\n"; +print SLONIK " merge set (id = $set1, add id = $set2, origin = $node);\n"; +print SLONIK " } on error {\n"; +print SLONIK " echo 'Failure to merge sets $set1 and $set2 with origin $node';\n"; +print SLONIK " exit 1;\n"; +print SLONIK " }\n"; +print SLONIK " echo 'Replication set $set2 merged in with $set1 on origin $node';\n"; close SLONIK; run_slonik_script("/tmp/slonik.$$"); -------------- next part -------------- --- /home/smsimms/projects/slony1-engine/tools/altperl/subscribe_set.pl 2004-09-29 18:09:38.000000000 -0400 +++ subscribe_set.pl 2005-01-08 15:36:29.000000000 -0500 @@ -1,29 +1,51 @@ -#!perl # -*- perl -*- -# $Id: subscribe_set.pl,v 1.4 2004/09/29 22:09:38 cbbrowne Exp $ +#!/usr/bin/perl +# $Id: subscribe_set.pl,v 1.4.2.1 2004/09/30 17:37:28 cbbrowne Exp $ # Author: Christopher Browne # Copyright 2004 Afilias Canada +use Getopt::Long; + +$SLON_ENV_FILE = 'slon.env'; # Where to find the slon.env file +$SHOW_USAGE = 0; # Show usage, then quit + +# Read command-line options +GetOptions("config=s" => \$SLON_ENV_FILE, + "help" => \$SHOW_USAGE); + +my $USAGE = +"Usage: subscribe_set.pl [--config file] set# node# + + Begins replicating a set to the specified node. + +"; + +if ($SHOW_USAGE) { + print $USAGE; + exit 0; +} + require 'slon-tools.pm'; -require 'slon.env'; +require $SLON_ENV_FILE; + my ($set, $node) = @ARGV; -if ($node =~ /^node(\d+)$/) { +if ($node =~ /^(?:node)?(\d+)$/) { $node = $1; } else { print "Need to specify node!\n"; - die "subscribe_set setM nodeN\n"; + die $USAGE; } -if ($set =~ /^set(\d+)$/) { +if ($set =~ /^(?:set)?(\d+)$/) { $set = $1; } else { print "Need to specify set!\n"; - die "subscribe_set setM nodeN\n"; + die $USAGE; } $FILE="/tmp/slonik-subscribe.$$"; open(SLONIK, ">$FILE"); print SLONIK genheader(); -print SLONIK "try {\n"; +print SLONIK " try {\n"; if ($DSN[$node]) { my $parent = 1; @@ -36,18 +58,15 @@ } else { $forward = "yes"; } - print SLONIK " subscribe set (id = $set, provider = $parent, receiver = $node, forward = $forward);\n"; + print SLONIK " subscribe set (id = $set, provider = $parent, receiver = $node, forward = $forward);\n"; } else { die "Node $node not found\n"; } -print SLONIK "}\n"; -print SLONIK qq{ - on error { - exit 1; - } - echo 'Subscribed nodes to set $set'; -}; - +print SLONIK " }\n"; +print SLONIK " on error {\n"; +print SLONIK " exit 1;\n"; +print SLONIK " }\n"; +print SLONIK " echo 'Subscribed nodes to set $set';\n"; close SLONIK; run_slonik_script($FILE); -------------- next part -------------- --- /home/smsimms/projects/slony1-engine/tools/altperl/drop_set.pl 2004-09-09 10:42:52.000000000 -0400 +++ drop_set.pl 2005-01-08 15:44:30.000000000 -0500 @@ -1,29 +1,48 @@ -#!perl # -*- perl -*- -# $Id: drop_set.pl,v 1.4 2004/09/09 14:42:52 cbbrowne Exp $ +#!/usr/bin/perl +# $Id: drop_set.pl,v 1.4.2.1 2004/09/30 17:37:28 cbbrowne Exp $ # Author: Christopher Browne # Copyright 2004 Afilias Canada +use Getopt::Long; + +$SLON_ENV_FILE = 'slon.env'; # Where to find the slon.env file +$SHOW_USAGE = 0; # Show usage, then quit + +# Read command-line options +GetOptions("config=s" => \$SLON_ENV_FILE, + "help" => \$SHOW_USAGE); + +my $USAGE = +"Usage: drop_set.pl [--config file] set# + + Drops a set. + +"; + +if ($SHOW_USAGE) { + print $USAGE; + exit 0; +} + require 'slon-tools.pm'; -require 'slon.env'; +require $SLON_ENV_FILE; + my ($set) = @ARGV; -if ($set =~ /^set(\d+)$/) { +if ($set =~ /^(?:set)?(\d+)$/) { $set = $1; } else { print "Need set identifier\n"; - die "drop_set.pl setN\n"; + die $USAGE; } -$OUTFILE="/tmp/dropset.$$"; -open(SLONIK, ">>$OUTFILE"); +$FILE = "/tmp/dropset.$$"; +open(SLONIK, ">", $FILE); print SLONIK genheader(); - -print SLONIK qq{ -try { - drop set (id = $set, origin=1); -} on error { - exit 1; -} -echo 'Dropped set $set'; -}; +print SLONIK " try {\n"; +print SLONIK " drop set (id = $set, origin = $MASTERNODE);\n"; +print SLONIK " } on error {\n"; +print SLONIK " exit 1;\n"; +print SLONIK " }\n"; +print SLONIK " echo 'Dropped set $set';\n"; close SLONIK; -run_slonik_script($OUTFILE); +run_slonik_script($FILE);
- Previous message: [Slony1-general] next release?
- Next message: [Slony1-general] Slony performance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list