Bug 326 Run perl tidy on the altperl tools
authorSteve Singer <ssinger@ca.afilias.info>
Wed, 25 Dec 2013 21:04:06 +0000 (16:04 -0500)
committerSteve Singer <ssinger@ca.afilias.info>
Thu, 2 Jan 2014 21:49:58 +0000 (16:49 -0500)
Formatting changes (perltidy) on the altperl tools

Patch by David Fetter

25 files changed:
tools/altperl/slon_kill.pl
tools/altperl/slon_start.pl
tools/altperl/slon_status.pl
tools/altperl/slon_watchdog.pl
tools/altperl/slon_watchdog2.pl
tools/altperl/slonik_add_node.pl
tools/altperl/slonik_build_env.pl
tools/altperl/slonik_create_set.pl
tools/altperl/slonik_drop_node.pl
tools/altperl/slonik_drop_sequence.pl
tools/altperl/slonik_drop_set.pl
tools/altperl/slonik_drop_table.pl
tools/altperl/slonik_execute_script.pl
tools/altperl/slonik_failover.pl
tools/altperl/slonik_init_cluster.pl
tools/altperl/slonik_merge_sets.pl
tools/altperl/slonik_move_set.pl
tools/altperl/slonik_print_preamble.pl
tools/altperl/slonik_restart_node.pl
tools/altperl/slonik_store_node.pl
tools/altperl/slonik_subscribe_set.pl
tools/altperl/slonik_uninstall_nodes.pl
tools/altperl/slonik_unsubscribe_set.pl
tools/altperl/slonik_update_nodes.pl
tools/altperl/slony_show_configuration.pl

index 4a81decb2769712ed02b03ef02752d620aaa41b5..bcc4ceaac0199c98755b4a9d508b944507e417dc 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Kill all slon instances for the current cluster
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
@@ -7,19 +7,20 @@
 use Getopt::Long;
 
 # Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE  = 0;
+$CONFIG_FILE   = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE    = 0;
 $WATCHDOG_ONLY = 0;
-$ONLY_NODE = 0;
+$ONLY_NODE     = 0;
 
 # Read command-line options
-GetOptions("config=s"   => \$CONFIG_FILE,
-          "help"       => \$SHOW_USAGE,
-          "w|watchdog" => \$WATCHDOG_ONLY,
-          "only-node=i" => \$ONLY_NODE);
+GetOptions(
+    "config=s"    => \$CONFIG_FILE,
+    "help"        => \$SHOW_USAGE,
+    "w|watchdog"  => \$WATCHDOG_ONLY,
+    "only-node=i" => \$ONLY_NODE
+);
 
-my $USAGE =
-"Usage: slon_kill [--config file] [-w|--watchdog] 
+my $USAGE = "Usage: slon_kill [--config file] [-w|--watchdog] 
 
     --config file  Location of the slon_tools.conf file
 
@@ -33,27 +34,29 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-print "slon_kill.pl...   Killing all slon and slon_watchdog instances for the cluster $CLUSTER_NAME\n";
+print
+"slon_kill.pl...   Killing all slon and slon_watchdog instances for the cluster $CLUSTER_NAME\n";
 print "1.  Kill slon watchdogs\n";
 
-$found="n";
+$found = "n";
 
 # kill the watchdogs
-if($ONLY_NODE) {
-  kill_watchdog($ONLY_NODE);
-} else {
-  for my $nodenum (@NODES) {
-    kill_watchdog($nodenum);
-  }
+if ($ONLY_NODE) {
+    kill_watchdog($ONLY_NODE);
 }
-if ($found eq 'n') {
+else {
+    for my $nodenum (@NODES) {
+        kill_watchdog($nodenum);
+    }
+}
+if ( $found eq 'n' ) {
     print "No watchdogs found\n";
 }
 
@@ -61,55 +64,63 @@ unless ($WATCHDOG_ONLY) {
     print "\n2. Kill slon processes\n";
 
     # kill the slon daemons
-    $found="n";
-
-    if($ONLY_NODE) {
-      kill_slon_node( $ONLY_NODE );
-    } else {
-      for my $nodenum (@NODES) {
-        kill_slon_node( $nodenum );
-      }
+    $found = "n";
+
+    if ($ONLY_NODE) {
+        kill_slon_node($ONLY_NODE);
+    }
+    else {
+        for my $nodenum (@NODES) {
+            kill_slon_node($nodenum);
+        }
     }
 
-    if ($found eq 'n') {
-      print "No slon processes found\n";
+    if ( $found eq 'n' ) {
+        print "No slon processes found\n";
     }
 }
 
 sub kill_watchdog($) {
-  my ($nodenum) = @_;
-
-  my $config_regexp = quotemeta( $CONFIG_FILE );
-
-  my $command =  ps_args() . "| egrep \"[s]lon_watchdog[2]? .*=$config_regexp node$nodenum \" | awk '{print \$2}' | sort -n";
-
-  #print "Command:\n$command\n";
-  open(PSOUT, "$command|");
-
-  while ($pid = <PSOUT>) {
-      chomp $pid;
-      if (!($pid)) {
-          print "No slon_watchdog is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
-      } else {
-          $found="y";
-          kill 9, $pid;
-          print "slon_watchdog for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
-      }
-  }
-  close(PSOUT);
+    my ($nodenum) = @_;
+
+    my $config_regexp = quotemeta($CONFIG_FILE);
+
+    my $command = ps_args()
+      . "| egrep \"[s]lon_watchdog[2]? .*=$config_regexp node$nodenum \" | awk '{print \$2}' | sort -n";
+
+    #print "Command:\n$command\n";
+    open( PSOUT, "$command|" );
+
+    while ( $pid = <PSOUT> ) {
+        chomp $pid;
+        if ( !($pid) ) {
+            print
+"No slon_watchdog is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
+        }
+        else {
+            $found = "y";
+            kill 9, $pid;
+            print
+"slon_watchdog for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
+        }
+    }
+    close(PSOUT);
 }
 
 sub kill_slon_node($) {
-  my ($nodenum) = @_;
-
-  my $pid = get_pid($nodenum);
-
-  #print "Command:\n$command\n";
-  if (!($pid)) {
-    print "No slon is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
-  } else {
-    $found="y";
-    kill 15, $pid;
-    print "slon for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
-  }
+    my ($nodenum) = @_;
+
+    my $pid = get_pid($nodenum);
+
+    #print "Command:\n$command\n";
+    if ( !($pid) ) {
+        print
+          "No slon is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
+    }
+    else {
+        $found = "y";
+        kill 15, $pid;
+        print
+          "slon for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
+    }
 }
index 0282d4241800302aa87f485b416d29ff6c1c2def..256756fd75522166bca45230d3041a0605f014da 100644 (file)
@@ -1,25 +1,26 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
 use Getopt::Long;
 
 # Defaults
-$START_WATCHDOG = 1;
-$SLEEP_TIME     = 30;
-$CONFIG_FILE    = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE     = 0;
+$START_WATCHDOG   = 1;
+$SLEEP_TIME       = 30;
+$CONFIG_FILE      = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE       = 0;
 $WATCHDOG_VERSION = 1;
 
 # Read command-line options
-GetOptions("config=s"  => \$CONFIG_FILE,
-          "watchdog!" => \$START_WATCHDOG,
-          "sleep=i"   => \$SLEEP_TIME,
-          "help"      => \$SHOW_USAGE);
-
-my $USAGE =
-"Usage: slon_start [--config file] [--watchdog|--nowatchdog]
+GetOptions(
+    "config=s"  => \$CONFIG_FILE,
+    "watchdog!" => \$START_WATCHDOG,
+    "sleep=i"   => \$SLEEP_TIME,
+    "help"      => \$SHOW_USAGE
+);
+
+my $USAGE = "Usage: slon_start [--config file] [--watchdog|--nowatchdog]
        [--sleep seconds] node#
 
     --config file    Location of the slon_tools.conf file
@@ -34,8 +35,8 @@ my $USAGE =
 
 ";
 
-if ($SHOW_USAGE or scalar(@ARGV) != 1) {
-  die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 1 ) {
+    die $USAGE;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -44,16 +45,17 @@ require $CONFIG_FILE;
 $node = $ARGV[0];
 
 # Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = "node$1";
-  $nodenum = $1;
-} else {
-  die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node    = "node$1";
+    $nodenum = $1;
+}
+else {
+    die $USAGE;
 }
 
 $pid = get_pid($node);
 if ($pid) {
-  die "Slon is already running for the '$CLUSTER_NAME' cluster.\n";
+    die "Slon is already running for the '$CLUSTER_NAME' cluster.\n";
 }
 
 my $dsn    = $DSN[$nodenum];
@@ -62,16 +64,20 @@ start_slon($nodenum);
 $pid = get_pid($node);
 
 unless ($pid) {
-  print "Slon failed to start for cluster $CLUSTER_NAME, node $node\n";
-} else {
-  print "Slon successfully started for cluster $CLUSTER_NAME, node $node\n";
-  print "PID [$pid]\n";
-  if ($START_WATCHDOG) {
-    print "Start the watchdog process as well...\n";
-    if( $WATCHDOG_VERSION eq 2 ) {
-      system "@@TOOLSBIN@@/slon_watchdog2 --config=$CONFIG_FILE $node $SLEEP_TIME &";
-    } else {
-      system "@@TOOLSBIN@@/slon_watchdog --config=$CONFIG_FILE $node $SLEEP_TIME &";
+    print "Slon failed to start for cluster $CLUSTER_NAME, node $node\n";
+}
+else {
+    print "Slon successfully started for cluster $CLUSTER_NAME, node $node\n";
+    print "PID [$pid]\n";
+    if ($START_WATCHDOG) {
+        print "Start the watchdog process as well...\n";
+        if ( $WATCHDOG_VERSION eq 2 ) {
+            system
+"@@TOOLSBIN@@/slon_watchdog2 --config=$CONFIG_FILE $node $SLEEP_TIME &";
+        }
+        else {
+            system
+"@@TOOLSBIN@@/slon_watchdog --config=$CONFIG_FILE $node $SLEEP_TIME &";
+        }
     }
-  }
 }
index 1c8b9888b18c38e0f56dd02ca266de2d84c8e15c..7a5ff0fea75205c5aa1aa2258ac31ca928f17695 100644 (file)
@@ -5,22 +5,23 @@
 use Getopt::Long;
 
 # Defaults
-$CONFIG_FILE    = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE     = 0;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s"  => \$CONFIG_FILE,
-          "help"      => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slon_status [--config file] node#
+my $USAGE = "Usage: slon_status [--config file] node#
 
     --config file    Location of the slon_tools.conf file
 
 ";
 
-if ($SHOW_USAGE or scalar(@ARGV) != 1) {
-  die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 1 ) {
+    die $USAGE;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -29,23 +30,24 @@ require $CONFIG_FILE;
 $node = $ARGV[0];
 
 # Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = "node$1";
-  $nodenum = $1;
-} else {
-  die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node    = "node$1";
+    $nodenum = $1;
+}
+else {
+    die $USAGE;
 }
 
-if ( ! $DBNAME[$nodenum] ) {
-  die "There is no such node.\n";
+if ( !$DBNAME[$nodenum] ) {
+    die "There is no such node.\n";
 }
 
 $pid = get_pid($node);
 
 if ($pid) {
-  die "Slon is running for the '$CLUSTER_NAME' cluster on $node.\n";
-} else {
-  die "slon is not running for $node_name cluster.\n";
+    die "Slon is running for the '$CLUSTER_NAME' cluster on $node.\n";
+}
+else {
+    die "slon is not running for $node_name cluster.\n";
 }
-
 
index 72d2b53abd0e53fd00bbc11d7cdadf98d89ec3cf..4ce50ad125f2b0f93284a8e8c69ff123eb65d9a2 100644 (file)
@@ -1,21 +1,22 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
 use Getopt::Long;
 
 # Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE  = 0;
+$CONFIG_FILE      = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE       = 0;
 $WATCHDOG_VERBOSE = 1;
 
 # Read command-line options
-GetOptions("config=s"  => \$CONFIG_FILE,
-          "help"      => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slon_watchdog [--config file] node# sleep_seconds
+my $USAGE = "Usage: slon_watchdog [--config file] node# sleep_seconds
 
     --config file  Location of the slon_tools.conf file
 
@@ -24,69 +25,86 @@ my $USAGE =
 
 ";
 
-if ($SHOW_USAGE or scalar(@ARGV) != 2) {
-  die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 2 ) {
+    die $USAGE;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-$node = $ARGV[0];
+$node  = $ARGV[0];
 $sleep = $ARGV[1];
 
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = "node$1";
-  $nodenum = $1;
-} else {
-  die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node    = "node$1";
+    $nodenum = $1;
+}
+else {
+    die $USAGE;
 }
 
-my $logfile = "$LOGDIR/slon-watchdog.log";
+my $logfile     = "$LOGDIR/slon-watchdog.log";
 my $logfile_err = "$LOGDIR/slon-$CLUSTER_NAME-$node.err";
 
-log_to_file( $logfile , "Invoking watchdog for $CLUSTER_NAME node $nodenum , sleep time = $sleep +/- " . int($sleep/2) . " seconds");
+log_to_file( $logfile,
+"Invoking watchdog for $CLUSTER_NAME node $nodenum , sleep time = $sleep +/- "
+      . int( $sleep / 2 )
+      . " seconds" );
 
 while (1) {
-  $pid = get_pid($node);
-  if (!($pid)) {
-    my ($dsn, $dbname) = ($DSN[$nodenum], $DBNAME[$nodenum]);
-    my $message = qq{WATCHDOG: No Slon is running for $CLUSTER_NAME node $nodenum!
+    $pid = get_pid($node);
+    if ( !($pid) ) {
+        my ( $dsn, $dbname ) = ( $DSN[$nodenum], $DBNAME[$nodenum] );
+        my $message =
+          qq{WATCHDOG: No Slon is running for $CLUSTER_NAME node $nodenum!
 You ought to check the postmaster and slon for evidence of a crash!
 I'm going to restart slon for $node...
 };
 
-    # log to error log as original routine
-    log_to_file( $logfile_err , $message );
-
-    # log to watchdog log
-    log_to_file( $logfile , "No Slon running for $CLUSTER_NAME node $nodenum, restarting slon");
-
-    # First, restart the node using slonik
-    if ($CONFIG_FILE ne "") {
-      system "(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
-    } else {
-      system "(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+        # log to error log as original routine
+        log_to_file( $logfile_err, $message );
+
+        # log to watchdog log
+        log_to_file( $logfile,
+            "No Slon running for $CLUSTER_NAME node $nodenum, restarting slon"
+        );
+
+        # First, restart the node using slonik
+        if ( $CONFIG_FILE ne "" ) {
+            system
+"(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+        }
+        else {
+            system
+"(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+        }
+
+        # Next, restart the slon process to service the node
+        start_slon($nodenum);
+        $pid = get_pid($node);
+        log_to_file( $logfile_err,
+"WATCHDOG: Restarted slon for the $CLUSTER_NAME cluster $node, new PID $pid"
+        );
     }
-    # Next, restart the slon process to service the node
-    start_slon($nodenum);
-    $pid = get_pid($node);
-    log_to_file( $logfile_err , "WATCHDOG: Restarted slon for the $CLUSTER_NAME cluster $node, new PID $pid" );
-  } else {
-    if ( $WATCHDOG_VERBOSE ) {
-      log_to_file( $logfile , "Found slon daemon for $CLUSTER_NAME $node, PID $pid, Sleeping for $sleep +/- " . int($sleep/2) . " seconds" );
+    else {
+        if ($WATCHDOG_VERBOSE) {
+            log_to_file( $logfile,
+"Found slon daemon for $CLUSTER_NAME $node, PID $pid, Sleeping for $sleep +/- "
+                  . int( $sleep / 2 )
+                  . " seconds" );
+        }
     }
-  }
-  sleep $sleep + (rand($sleep) - $sleep/2);
+    sleep $sleep + ( rand($sleep) - $sleep / 2 );
 }
 
 sub log_to_file {
-  my ($logfile,$message) = @_;
-  chomp $message;
-  my $date = `date`;
-  chomp $date;
-
-  open (SLONLOG, ">>$logfile");
-  print SLONLOG $date, " | ", $message, "\n";
-  close SLONLOG;
+    my ( $logfile, $message ) = @_;
+    chomp $message;
+    my $date = `date`;
+    chomp $date;
+
+    open( SLONLOG, ">>$logfile" );
+    print SLONLOG $date, " | ", $message, "\n";
+    close SLONLOG;
 }
 
index 5f40c806da6cf378330dc8836e3a6cde95187a4d..e7cb7abb679225e0d1ff00725224eced1e50681a 100644 (file)
@@ -1,21 +1,22 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
 use Getopt::Long;
 
 # Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE  = 0;
+$CONFIG_FILE      = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE       = 0;
 $WATCHDOG_VERBOSE = 1;
 
 # Read command-line options
-GetOptions("config=s"  => \$CONFIG_FILE,
-           "help"      => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slon_watchdog2 [--config file] node# sleep_seconds
+my $USAGE = "Usage: slon_watchdog2 [--config file] node# sleep_seconds
 
     --config file  Location of the slon_tools.conf file
 
@@ -24,8 +25,8 @@ my $USAGE =
 
 ";
 
-if ($SHOW_USAGE or scalar(@ARGV) != 2) {
-  die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 2 ) {
+    die $USAGE;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -34,16 +35,20 @@ require $CONFIG_FILE;
 $node  = $ARGV[0];
 $sleep = $ARGV[1];
 
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = "node$1";
-  $nodenum = $1;
-} else {
-  die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node    = "node$1";
+    $nodenum = $1;
+}
+else {
+    die $USAGE;
 }
 
 my $logfile = "$LOGDIR/slon-watchdog.log";
 
-log_to_file( $logfile , "Invoking watchdog for $CLUSTER_NAME node $nodenum, sleep time = $sleep +/- " . int($sleep/2) . " seconds");
+log_to_file( $logfile,
+"Invoking watchdog for $CLUSTER_NAME node $nodenum, sleep time = $sleep +/- "
+      . int( $sleep / 2 )
+      . " seconds" );
 
 # When slon daemon is just started, may not have time to start syncronization
 # and the watchdog will kill the process with no mercy.
@@ -51,36 +56,46 @@ log_to_file( $logfile , "Invoking watchdog for $CLUSTER_NAME node $nodenum, slee
 sleep $sleep;
 
 while (1) {
-  my $res = query_slony_status($nodenum);    # See where the node stands
-  my $eventsOK;
-  if ($res =~ /^\s*t\s*\|/) {
-    $eventsOK = "YES";
-    if ( $WATCHDOG_VERBOSE ) {
-      log_to_file( $logfile , "Query_slony_status returns true for $CLUSTER_NAME node $nodenum" );
-    }
-  } else {
-    $res = node_is_subscribing($nodenum);
-    if ($res =~ /SUBSCRIBE_SET/) {
-      $eventsOK = "YES";
-    } else {
-      $eventsOK = "NO";
+    my $res = query_slony_status($nodenum);    # See where the node stands
+    my $eventsOK;
+    if ( $res =~ /^\s*t\s*\|/ ) {
+        $eventsOK = "YES";
+        if ($WATCHDOG_VERBOSE) {
+            log_to_file( $logfile,
+"Query_slony_status returns true for $CLUSTER_NAME node $nodenum"
+            );
+        }
     }
-    if ( $WATCHDOG_VERBOSE ) {
-      log_to_file( $logfile , "Query_slony_status returns false for $CLUSTER_NAME node $nodenum, node_is_subscribing : $eventsOK" );
+    else {
+        $res = node_is_subscribing($nodenum);
+        if ( $res =~ /SUBSCRIBE_SET/ ) {
+            $eventsOK = "YES";
+        }
+        else {
+            $eventsOK = "NO";
+        }
+        if ($WATCHDOG_VERBOSE) {
+            log_to_file( $logfile,
+"Query_slony_status returns false for $CLUSTER_NAME node $nodenum, node_is_subscribing : $eventsOK"
+            );
+        }
     }
-  }
-  my $pid = get_pid($node);  # See if the slon process is alive
-  my ($restart, $kick);
-  $kick = "NO";   # Initially, assume we don't need to submit a "restart node" command
-  if ($pid) {  # PID is alive...
-    if ($eventsOK eq "YES") {
-      # All is well - do nothing!
-      $restart = "NO";
-    } else {
-      $restart = "YES";
+    my $pid = get_pid($node);    # See if the slon process is alive
+    my ( $restart, $kick );
+    $kick =
+      "NO"; # Initially, assume we don't need to submit a "restart node" command
+    if ($pid) {    # PID is alive...
+        if ( $eventsOK eq "YES" ) {
+
+            # All is well - do nothing!
+            $restart = "NO";
+        }
+        else {
+            $restart = "YES";
+        }
     }
-  } else {
-    $restart = "YES";
+    else {
+        $restart = "YES";
 
 #  The message searched isn't generated as bellow anymore...
 #  and may be exist another better way to know if the restart of node is necessary
@@ -93,42 +108,50 @@ while (1) {
 #      $kick = "YES";   # Yup, need to tell slonik to reset this node
 #    }
 
-    # Kicking allways as slon_watchdog.pl do
-    $kick = "YES";
-  }
-
-  # If the node needs a swift kick in the "RESTART", then submit that to slonik
-  if ($kick eq "YES") {
-    log_to_file($logfile,"submit slonik to restart $CLUSTER_NAME node $nodenum");
-    if ($CONFIG_FILE ne "") {
-      system "(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
-    } else {
-      system "(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+        # Kicking allways as slon_watchdog.pl do
+        $kick = "YES";
+    }
+
+   # If the node needs a swift kick in the "RESTART", then submit that to slonik
+    if ( $kick eq "YES" ) {
+        log_to_file( $logfile,
+            "submit slonik to restart $CLUSTER_NAME node $nodenum" );
+        if ( $CONFIG_FILE ne "" ) {
+            system
+"(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+        }
+        else {
+            system
+"(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+        }
     }
-  }
-  if ($restart eq "YES") {
-    if ($pid) {
-      log_to_file($logfile,"terminate slon daemon for $CLUSTER_NAME node $nodenum, PID $pid");
-      # Kill slon until dead...
-      kill 2, $pid;
-      sleep 3;
-      kill 15, $pid;
-      sleep 3;
-      # if killed with 9 the pid file isnยดt deleted and the service donยดt restart
-      # kill 9, $pid;
+    if ( $restart eq "YES" ) {
+        if ($pid) {
+            log_to_file( $logfile,
+"terminate slon daemon for $CLUSTER_NAME node $nodenum, PID $pid"
+            );
+
+            # Kill slon until dead...
+            kill 2, $pid;
+            sleep 3;
+            kill 15, $pid;
+            sleep 3;
+
+   # if killed with 9 the pid file isnยดt deleted and the service donยดt restart
+   # kill 9, $pid;
+        }
+        log_to_file( $logfile, "restart slon for $CLUSTER_NAME node $nodenum" );
+        start_slon($nodenum);
     }
-    log_to_file($logfile,"restart slon for $CLUSTER_NAME node $nodenum");
-    start_slon($nodenum);
-  }
-  sleep $sleep + (rand($sleep) - $sleep/2);
+    sleep $sleep + ( rand($sleep) - $sleep / 2 );
 }
 
 sub log_to_file {
-  my ($logfile,$message) = @_;
-  chomp $message;
-  my $date = `date`;
-  chomp $date;
-  open (SLONLOG, ">>$logfile");
-  print SLONLOG $date, "|", $message, "\n";
-  close SLONLOG;
+    my ( $logfile, $message ) = @_;
+    chomp $message;
+    my $date = `date`;
+    chomp $date;
+    open( SLONLOG, ">>$logfile" );
+    print SLONLOG $date, "|", $message, "\n";
+    close SLONLOG;
 }
index b663bc972d7623a32ed5ea3f250f721928913c21..54e943eac79a31868be9e874d8b65224abaded0f 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Gurjeet Singh
 
 use Getopt::Long;
@@ -9,11 +9,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-         "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: add_node [--config file] node# event_node#
+my $USAGE = "Usage: add_node [--config file] node# event_node#
 
     adds a node to the cluster.
 
@@ -21,53 +22,59 @@ event_node is the node number of the currnet origin node.
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($addnode, $current_origin) = @ARGV;
-if ($addnode =~ /^(?:node)?(\d+)$/) {
-  $addnode = $1;
-} else {
-  die $USAGE;
+my ( $addnode, $current_origin ) = @ARGV;
+if ( $addnode =~ /^(?:node)?(\d+)$/ ) {
+    $addnode = $1;
+}
+else {
+    die $USAGE;
 }
 
-if ($current_origin =~ /^(?:node)?(\d+)$/) {
-  $current_origin = $1;
-} else {
-  die $USAGE;
+if ( $current_origin =~ /^(?:node)?(\d+)$/ ) {
+    $current_origin = $1;
+}
+else {
+    die $USAGE;
 }
 
-my ($dbname, $dbhost) = ($DBNAME[$addnode], $HOST[$addnode]);
+my ( $dbname, $dbhost ) = ( $DBNAME[$addnode], $HOST[$addnode] );
 
 my $slonik = '';
 
-$slonik .=  "\n# ADD NODE\n";
+$slonik .= "\n# ADD NODE\n";
 $slonik .= genheader();
 $slonik .= "  try {\n";
-$slonik .= "     store node (id = $addnode, event node = $current_origin, comment = 'Node $addnode - $dbname\@$dbhost');\n";
+$slonik .=
+"     store node (id = $addnode, event node = $current_origin, comment = 'Node $addnode - $dbname\@$dbhost');\n";
 $slonik .= "  } on error {\n";
 $slonik .= "      echo 'Failed to add node $node to cluster';\n";
 $slonik .= "      exit 1;\n";
 $slonik .= "  }\n";
 
 # STORE PATH
-$slonik .=  "\n# STORE PATHS\n";
+$slonik .= "\n# STORE PATHS\n";
 foreach my $node (@NODES) {
-  my $adddsn = $DSN[$addnode];
-  if ($node != $addnode) {       # skip the master node; it's already initialized!
-    my ($dbname, $dbhost, $nodedsn) = ($DBNAME[$node], $HOST[$node], $DSN[$node]);
-    $slonik .= "  store path (server = $addnode, client = $node, conninfo = '$adddsn');\n";
-    $slonik .= "  store path (server = $node, client = $addnode, conninfo = '$nodedsn');\n";
-  }
+    my $adddsn = $DSN[$addnode];
+    if ( $node != $addnode ) { # skip the master node; it's already initialized!
+        my ( $dbname, $dbhost, $nodedsn ) =
+          ( $DBNAME[$node], $HOST[$node], $DSN[$node] );
+        $slonik .=
+"  store path (server = $addnode, client = $node, conninfo = '$adddsn');\n";
+        $slonik .=
+"  store path (server = $node, client = $addnode, conninfo = '$nodedsn');\n";
+    }
 }
 
 $slonik .= "  echo 'added node $addnode to cluster';\n";
-$slonik .= "  echo 'Please start a slon replication daemon for node $addnode';\n";
-
-run_slonik_script($slonik, 'ADD NODE');
+$slonik .=
+  "  echo 'Please start a slon replication daemon for node $addnode';\n";
 
+run_slonik_script( $slonik, 'ADD NODE' );
 
index 015082f72e9fd2c74867ff2d49dbc78a9888aece..91c86d016b8de23e8f54c4bea7d1a6c79d9d3f0a 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Contributed by:
 # Joe Kalash
 # kalash@savicom.net
@@ -20,97 +20,103 @@ my $dataBasePassword;
 my $dataBasePort;
 my @nodes;
 my $schema = 'public';
-my $usage = "$0 -node host:database:user[:password:port] [-node ...] [-schema myschema]
+my $usage =
+  "$0 -node host:database:user[:password:port] [-node ...] [-schema myschema]
 First node is assumed to be the master.
 Default schema is \"public\"\n";
 
-&usage if(!GetOptions('node=s@'=>\@nodes, 'schema=s' => \$schema));
+&usage if ( !GetOptions( 'node=s@' => \@nodes, 'schema=s' => \$schema ) );
 
 die "At least one node is required" if ( scalar(@nodes) < 1 );
 
-
-
 my $nodeNumber = 1;
 my $parentString;
-foreach my $node (@nodes)
-{
-  my($tmpHost,$tmpDataBase,$tmpDataBaseUser,$tmpDataBasePassword,$tmpPort) =
-    split(/:/,$node);
-  die "Host is required" if ( !$tmpHost );
-  die "database is required" if ( !$tmpDataBase );
-  die "user is required" if ( !$tmpDataBaseUser );
-  $tmpPort = 5432 if ( !$tmpPort );
-  $host = $tmpHost if ( !$host );
-  $dataBase = $tmpDataBase if ( !$dataBase );
-  if ( !$dataBaseUser ) {
-    $dataBaseUser = $tmpDataBaseUser;
-    $dataBasePassword = $tmpDataBasePassword if ( $tmpDataBasePassword );
-    $dataBasePort = $tmpPort if ( $tmpPort );
-  }
-  print "&add_node(host => '$tmpHost', dbname => '$tmpDataBase', port =>$tmpPort,
+foreach my $node (@nodes) {
+    my ( $tmpHost, $tmpDataBase, $tmpDataBaseUser, $tmpDataBasePassword,
+        $tmpPort )
+      = split( /:/, $node );
+    die "Host is required"     if ( !$tmpHost );
+    die "database is required" if ( !$tmpDataBase );
+    die "user is required"     if ( !$tmpDataBaseUser );
+    $tmpPort  = 5432         if ( !$tmpPort );
+    $host     = $tmpHost     if ( !$host );
+    $dataBase = $tmpDataBase if ( !$dataBase );
+    if ( !$dataBaseUser ) {
+        $dataBaseUser     = $tmpDataBaseUser;
+        $dataBasePassword = $tmpDataBasePassword if ($tmpDataBasePassword);
+        $dataBasePort     = $tmpPort if ($tmpPort);
+    }
+    print
+      "&add_node(host => '$tmpHost', dbname => '$tmpDataBase', port =>$tmpPort,
         user=>'$tmpDataBaseUser', password=>'$tmpDataBasePassword', node=>$nodeNumber $parentString);\n";
-  $parentString = ', parent=>1';
-  $nodeNumber++;
+    $parentString = ', parent=>1';
+    $nodeNumber++;
 
 }
 my $connectString = "dbi:Pg:dbname=$dataBase;host=$host;port=$dataBasePort";
-my $dbh = DBI->connect($connectString,$dataBaseUser,$dataBasePassword,
-                      {RaiseError => 0, PrintError => 0, AutoCommit => 1});
+my $dbh = DBI->connect( $connectString, $dataBaseUser, $dataBasePassword,
+    { RaiseError => 0, PrintError => 0, AutoCommit => 1 } );
 die "connect: $DBI::errstr" if ( !defined($dbh) || $DBI::err );
+
 # Read in all the user 'normal' tables in $schema (public by default).
-my $tableQuery = $dbh->prepare("
+my $tableQuery = $dbh->prepare( "
 SELECT pg_namespace.nspname || '.' || pg_class.relname,pg_class.relkind,pg_class.relhaspkey 
 FROM pg_namespace,pg_class
 WHERE pg_class.reltype > 0
 AND pg_class.relnamespace = pg_catalog.pg_namespace.oid
 AND (pg_class.relkind = 'r' OR pg_class.relkind = 'S')
-AND pg_namespace.nspname = '$schema' AND pg_namespace.oid = pg_class.relnamespace");
+AND pg_namespace.nspname = '$schema' AND pg_namespace.oid = pg_class.relnamespace"
+);
 
-die "prepare(tableQuery): $DBI::errstr" if ( !defined($tableQuery) || $DBI::err );
+die "prepare(tableQuery): $DBI::errstr"
+  if ( !defined($tableQuery) || $DBI::err );
 die "execute(tableQuery): $DBI::errstr" if ( !$tableQuery->execute() );
-die "No objects to replicate found in schema \"$schema\"\n" if ($tableQuery->rows <= 0);
+die "No objects to replicate found in schema \"$schema\"\n"
+  if ( $tableQuery->rows <= 0 );
 
 my @tablesWithIndexes;
 my @tablesWithoutIndexes;
 my @sequences;
 while ( my $row = $tableQuery->fetchrow_arrayref() ) {
-  my $relname = @$row[0];
-  my $relkind = @$row[1];
-  my $relhaspkey = @$row[2];
-  push(@sequences,$relname) if ( $relkind eq 'S' );
-  push(@tablesWithIndexes,$relname) if ( $relkind eq 'r' && $relhaspkey == 1 );
-  push(@tablesWithoutIndexes,$relname) if ( $relkind eq 'r' && $relhaspkey == 0 );
+    my $relname    = @$row[0];
+    my $relkind    = @$row[1];
+    my $relhaspkey = @$row[2];
+    push( @sequences, $relname ) if ( $relkind eq 'S' );
+    push( @tablesWithIndexes, $relname )
+      if ( $relkind eq 'r' && $relhaspkey == 1 );
+    push( @tablesWithoutIndexes, $relname )
+      if ( $relkind eq 'r' && $relhaspkey == 0 );
 }
 $tableQuery->finish();
 $dbh->disconnect();
 
 if ( scalar(@tablesWithIndexes) >= 1 ) {
-  print '@PKEYEDTABLES=(' . "\n";
-  foreach my $table (sort @tablesWithIndexes) {
-    print "\t\"$table\",\n";
-  }
-  print ");\n";
+    print '@PKEYEDTABLES=(' . "\n";
+    foreach my $table ( sort @tablesWithIndexes ) {
+        print "\t\"$table\",\n";
+    }
+    print ");\n";
 }
 if ( scalar(@tablesWithoutIndexes) >= 1 ) {
-  my $tables = ''; 
-  foreach my $table (sort @tablesWithoutIndexes) {
-         if($tables ne '') {
-                 $tables.=',';
-         }
-         $tables.="\"$table\"";
-  }
-  die "The following tables had no unique index:" . $tables."\n";
+    my $tables = '';
+    foreach my $table ( sort @tablesWithoutIndexes ) {
+        if ( $tables ne '' ) {
+            $tables .= ',';
+        }
+        $tables .= "\"$table\"";
+    }
+    die "The following tables had no unique index:" . $tables . "\n";
 }
 if ( scalar(@sequences) >= 1 ) {
-  print '@SEQUENCES=(' . "\n";
-  foreach my $table (sort @sequences) {
-    print "\t\"$table\",\n";
-  }
-  print ");\n";
+    print '@SEQUENCES=(' . "\n";
+    foreach my $table ( sort @sequences ) {
+        print "\t\"$table\",\n";
+    }
+    print ");\n";
 }
 exit 0;
 
 sub usage {
-  print "$usage";
-  exit 0;
+    print "$usage";
+    exit 0;
 }
index 70204dde0afef027d8878f0f899594a5c75d3133..3d91ec1b68ecb1d726da09ee3fdb159ad1d6f624 100644 (file)
@@ -1,6 +1,6 @@
 #!@@PERL@@
 
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,17 +10,18 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: create_set [--config file] set
+my $USAGE = "Usage: create_set [--config file] set
 
     set  The name or ID of the set to be created
 
 ";
 
-my $slonik = ''; 
+my $slonik = '';
 
 if ($SHOW_USAGE) {
     print $USAGE;
@@ -36,9 +37,10 @@ die $USAGE unless $set;
 $SET_ID = get_set($set);
 unless ($SET_ID) {
     my $possible_sets = join "\n\t", keys %$SLONY_SETS;
-    print "No set was found with the name provided.  Possible valid names include:\n\t"
-          . $possible_sets . "\n\n"
-          . "New sets may be defined in your slon_tools.conf file\n\n";
+    print
+"No set was found with the name provided.  Possible valid names include:\n\t"
+      . $possible_sets . "\n\n"
+      . "New sets may be defined in your slon_tools.conf file\n\n";
     die $USAGE;
 }
 
@@ -51,7 +53,8 @@ $slonik .= "# TABLE ADD KEY\n";
 # CREATE SET
 $slonik .= "\n";
 $slonik .= "# CREATE SET\n";
-$slonik .= "    create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID ($SET_NAME) for $CLUSTER_NAME');\n";
+$slonik .=
+"    create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID ($SET_NAME) for $CLUSTER_NAME');\n";
 
 # SET ADD TABLE
 $slonik .= "\n";
@@ -64,20 +67,23 @@ $TABLE_ID = 1 if $TABLE_ID < 1;
 foreach my $table (@PKEYEDTABLES) {
     $table = ensure_namespace($table);
     $table = lc($table) if $FOLD_CASE;
-    $slonik .= "  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+    $slonik .=
+"  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
     $slonik .= "                 full qualified name = '$table',\n";
     $slonik .= "                 comment = 'Table $table with primary key');\n";
     $slonik .= "  echo 'Add primary keyed table $table';\n";
     $TABLE_ID++;
 }
 
-foreach my $table (keys %KEYEDTABLES) {
+foreach my $table ( keys %KEYEDTABLES ) {
     my $key = $KEYEDTABLES{$table};
     $table = ensure_namespace($table);
     $table = lc($table) if $FOLD_CASE;
-    $slonik .= "  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+    $slonik .=
+"  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
     $slonik .= "                 full qualified name = '$table', key='$key',\n";
-    $slonik .= "                 comment = 'Table $table with candidate primary key $key');\n";
+    $slonik .=
+"                 comment = 'Table $table with candidate primary key $key');\n";
     $slonik .= "  echo 'Add candidate primary keyed table $table';\n";
     $TABLE_ID++;
 }
@@ -91,7 +97,8 @@ $SEQUENCE_ID = 1 if $SEQUENCE_ID < 1;
 foreach my $seq (@SEQUENCES) {
     $seq = ensure_namespace($seq);
     $seq = lc($seq) if $FOLD_CASE;
-    $slonik .= "  set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
+    $slonik .=
+"  set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
     $slonik .= "                    full qualified name = '$seq',\n";
     $slonik .= "                    comment = 'Sequence $seq');\n";
     $slonik .= "  echo 'Add sequence $seq';\n";
@@ -99,15 +106,17 @@ foreach my $seq (@SEQUENCES) {
 }
 $slonik .= "  echo 'All tables added';\n";
 
-run_slonik_script($slonik, 'CREATE SET');
+run_slonik_script( $slonik, 'CREATE SET' );
 
 ### If object hasn't a namespace specified, assume it's in "public", and make it so...
 sub ensure_namespace {
     my ($object) = @_;
-    if ($object =~ /^(.*\..*)$/) {
-       # Table has a namespace specified
-    } else {
-       $object = "public.$object";
+    if ( $object =~ /^(.*\..*)$/ ) {
+
+        # Table has a namespace specified
+    }
+    else {
+        $object = "public.$object";
     }
     return $object;
 }
index cf12e9f1813701703829dd25ce8740f150fcc469..04ce588033b7668f1b24570ab8c486a01eb44e86 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,11 +10,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: drop_node [--config file] node# event_node#
+my $USAGE = "Usage: drop_node [--config file] node# event_node#
 
     Drops a node.
 
@@ -39,25 +40,27 @@ you from errors.
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($node, $event_node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = $1;
-} else {
-  die $USAGE;
+my ( $node, $event_node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node = $1;
+}
+else {
+    die $USAGE;
 }
 
-if ($event_node =~ /^(?:node)?(\d+)$/) {
-  $event_node = $1;
-} else {
-  print "Need to specify event node!\n";
-  die $USAGE;
+if ( $event_node =~ /^(?:node)?(\d+)$/ ) {
+    $event_node = $1;
+}
+else {
+    print "Need to specify event node!\n";
+    die $USAGE;
 }
 
 my $slonik = '';
@@ -66,4 +69,4 @@ $slonik .= genheader();
 $slonik .= "  drop node (id = $node, event node = $event_node);\n";
 $slonik .= "  echo 'dropped node $node cluster';\n";
 
-run_slonik_script($slonik, 'DROP NODE');
+run_slonik_script( $slonik, 'DROP NODE' );
index 1a12c2dfb3b333d8c0b67c6ca9d54742ce62735d..1698a68d73bb79d0d7e4fee44969082fe42bcd59 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Mark Stosberg
 # Based on work by: Christopher Browne
 # Parts Copyright 2008 Summerault, LLC
@@ -11,11 +11,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slonik_drop_sequence [--config file] sequence_id set
+my $USAGE = "Usage: slonik_drop_sequence [--config file] sequence_id set
 
     sequence_id  The ID of the sequence to be dropped from replication
     set  The name or ID of the set to drop the sequence from
@@ -36,9 +37,9 @@ if ($SHOW_USAGE) {
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($SEQ_ID,$set) = @ARGV;
+my ( $SEQ_ID, $set ) = @ARGV;
 $SET_ID = get_set($set);
-unless ($SEQ_ID && $SET_ID) {
+unless ( $SEQ_ID && $SET_ID ) {
     die $USAGE;
 }
 
@@ -56,5 +57,5 @@ $slonik .= "    echo 'Could not drop sequence $SEQ_ID for $CLUSTER_NAME!';\n";
 $slonik .= "    exit 1;\n";
 $slonik .= "  }\n";
 
-run_slonik_script($slonik, 'DROP SEQUENCE');
+run_slonik_script( $slonik, 'DROP SEQUENCE' );
 
index c97a7d788c65dc02186cfe2b66fbfe3c3b0444a6..6e2019e801a438a8a2c7b6db46c98170a0ac8173 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,8 +10,10 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
 my $USAGE = <<EOF
 "Usage: drop_set [--config file] set#
@@ -30,11 +32,11 @@ isn't anything to prevent potentially career-limiting "unfortunate results."
 Handle with care... 
 
 EOF
-;
+  ;
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -54,4 +56,4 @@ $slonik .= "        exit 1;\n";
 $slonik .= "  }\n";
 $slonik .= "  echo 'Dropped set $set';\n";
 
-run_slonik_script($slonik, 'DROP SET');
+run_slonik_script( $slonik, 'DROP SET' );
index 4c5083e43aad8e521cbe25a75c1c38addc164ad7..80f773a4529a2098b0beea275f364c81982235e0 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Mark Stosberg
 # Based on work by: Christopher Browne
 # Parts Copyright 2006 Summerault, LLC
@@ -11,11 +11,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slonik_drop_table [--config file] table_id set
+my $USAGE = "Usage: slonik_drop_table [--config file] table_id set
 
     table_id  The ID of the table to be dropped from replication
     set  The name or ID of the set to drop the table from
@@ -34,9 +35,9 @@ if ($SHOW_USAGE) {
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($TABLE_ID,$set) = @ARGV;
+my ( $TABLE_ID, $set ) = @ARGV;
 $SET_ID = get_set($set);
-unless ($TABLE_ID && $SET_ID) {
+unless ( $TABLE_ID && $SET_ID ) {
     die $USAGE;
 }
 
@@ -54,4 +55,4 @@ $slonik .= "    echo 'Could not drop table $TABLE_ID for $CLUSTER_NAME!';\n";
 $slonik .= "    exit 1;\n";
 $slonik .= "  }\n";
 
-run_slonik_script($slonik, 'DROP TABLE');
+run_slonik_script( $slonik, 'DROP TABLE' );
index c1912b8701a52c0270b19091f889a2b49d6c8d31..672695100fa639d614db2576db733a60c0f51961 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -20,13 +20,14 @@ my $filename = '';
 my $fh       = undef;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE,
-          "c=s"      => \$SCRIPT_ARG,
-           "n|node=s" => \$node);
-
-my $USAGE =
-"Usage:
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE,
+    "c=s"      => \$SCRIPT_ARG,
+    "n|node=s" => \$node
+);
+
+my $USAGE = "Usage:
     execute_script [options] set# full_path_to_sql_script_file
     execute_script [options] -c SCRIPT set#
 
@@ -46,14 +47,14 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($set, $file) = @ARGV;
+my ( $set, $file ) = @ARGV;
 die $USAGE unless $set;
 $set = get_set($set) or die "Non-existent set specified.\n";
 $node = $SET_ORIGIN unless $node;
@@ -61,20 +62,23 @@ $node = $SET_ORIGIN unless $node;
 # We can either have -c SCRIPT or a filename as an argument.  The
 # latter takes precedence.
 if ($file) {
-    unless ($file =~ /^\// and -f $file) {
-       print STDERR "SQL script path needs to be a full path, e.g. /tmp/my_script.sql\n\n";
-       die $USAGE;
+    unless ( $file =~ /^\// and -f $file ) {
+        print STDERR
+"SQL script path needs to be a full path, e.g. /tmp/my_script.sql\n\n";
+        die $USAGE;
     }
-    $filename = $file
+    $filename = $file;
 }
 elsif ($SCRIPT_ARG) {
+
     # Put the script into a file
-    ($fh, $filename) = tempfile();
+    ( $fh, $filename ) = tempfile();
     print $fh $SCRIPT_ARG;
     close $fh;
 }
 else {
-    print STDERR "You must include either a filename or a SQL statement on the command line to be run.\n\n";
+    print STDERR
+"You must include either a filename or a SQL statement on the command line to be run.\n\n";
     die $USAGE;
 }
 
@@ -87,4 +91,4 @@ $slonik .= "    filename = '$filename',\n";
 $slonik .= "    event node = $node\n";
 $slonik .= "  );\n";
 
-run_slonik_script($slonik, 'EXECUTE SCRIPT');
+run_slonik_script( $slonik, 'EXECUTE SCRIPT' );
index 2c5f9845109d771980ee57be0a7069a4d7cb4c73..43b4bb1ab7113083f10503ad2139a2cb33308ad1 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,11 +10,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slonik_failover [--config file] dead_node backup_node
+my $USAGE = "Usage: slonik_failover [--config file] dead_node backup_node
 
     Abandons dead_node, making backup_node the origin for all sets on
     dead_node.
@@ -25,24 +26,26 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($node1, $node2) = @ARGV;
-if ($node1 =~ /^(?:node)?(\d+)$/) {
-  $node1 = $1;
-} else {
-  die $USAGE;
+my ( $node1, $node2 ) = @ARGV;
+if ( $node1 =~ /^(?:node)?(\d+)$/ ) {
+    $node1 = $1;
+}
+else {
+    die $USAGE;
 }
 
-if ($node2 =~ /^(?:node)?(\d+)$/) {
-  $node2 = $1;
-} else {
-  die $USAGE;
+if ( $node2 =~ /^(?:node)?(\d+)$/ ) {
+    $node2 = $1;
+}
+else {
+    die $USAGE;
 }
 
 my $slonik = '';
@@ -53,6 +56,7 @@ $slonik .= "  } on error {\n";
 $slonik .= "      echo 'Failure to fail node $node1 over to $node2';\n";
 $slonik .= "      exit 1;\n";
 $slonik .= "  }\n";
-$slonik .= "  echo 'Replication sets originating on $node1 failed over to $node2';\n";
+$slonik .=
+  "  echo 'Replication sets originating on $node1 failed over to $node2';\n";
 
-run_slonik_script($slonik, 'FAILOVER');
+run_slonik_script( $slonik, 'FAILOVER' );
index d31e60c39184da5a40b37efc6ac6db811aaf044e..a37abeb7bf049bbe89122797c3c2d7068d571c0a 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,11 +10,12 @@ my $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 my $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: init_cluster [--config file]
+my $USAGE = "Usage: init_cluster [--config file]
 
     Generates the slonik commands necessary to create a cluster and
     prepare the nodes for use.  Also displays a report showing the
@@ -23,50 +24,55 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
 # INIT CLUSTER
-$slonik .=  "\n# INIT CLUSTER\n";
-$slonik .=  genheader();
-my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]);
-$slonik .=  "  init cluster (id = $MASTERNODE, comment = 'Node $MASTERNODE - $dbname\@$dbhost');\n";
+$slonik .= "\n# INIT CLUSTER\n";
+$slonik .= genheader();
+my ( $dbname, $dbhost ) = ( $DBNAME[$MASTERNODE], $HOST[$MASTERNODE] );
+$slonik .=
+"  init cluster (id = $MASTERNODE, comment = 'Node $MASTERNODE - $dbname\@$dbhost');\n";
 
 # STORE NODE
-$slonik .=  "\n# STORE NODE\n";
+$slonik .= "\n# STORE NODE\n";
 foreach my $node (@NODES) {
-  if ($node != $MASTERNODE) {          # skip the master node; it's already initialized!
-    my ($dbname, $dbhost) = ($DBNAME[$node], $HOST[$node]);
-    $slonik .=  "  store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
-  }
+    if ( $node != $MASTERNODE )
+    {    # skip the master node; it's already initialized!
+        my ( $dbname, $dbhost ) = ( $DBNAME[$node], $HOST[$node] );
+        $slonik .=
+"  store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
+    }
 }
-$slonik .=  "  echo 'Set up replication nodes';\n";
+$slonik .= "  echo 'Set up replication nodes';\n";
 
 # STORE PATH
-$slonik .=  "\n# STORE PATH\n";
+$slonik .= "\n# STORE PATH\n";
 
-$slonik .=  "  echo 'Next: configure paths for each node/origin';\n";
+$slonik .= "  echo 'Next: configure paths for each node/origin';\n";
 foreach my $nodea (@NODES) {
-  my $dsna = $DSN[$nodea];
-  foreach my $nodeb (@NODES) {
-    if ($nodea != $nodeb) {
-      my $dsnb = $DSN[$nodeb];
-      if (!$printed[$nodea][$nodeb]) {
-       $slonik .= "  store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
-       $printed[$nodea][$nodeb] = "done";
-      }
-      if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
-       $slonik .= "  store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
-       $printed[$nodeb][$nodea] = "done";
-      }
+    my $dsna = $DSN[$nodea];
+    foreach my $nodeb (@NODES) {
+        if ( $nodea != $nodeb ) {
+            my $dsnb = $DSN[$nodeb];
+            if ( !$printed[$nodea][$nodeb] ) {
+                $slonik .=
+"  store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+                $printed[$nodea][$nodeb] = "done";
+            }
+            if ( !$printed[$nodeb][$nodea] and $providerba == $nodea ) {
+                $slonik .=
+"  store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+                $printed[$nodeb][$nodea] = "done";
+            }
+        }
     }
-  }
 }
 
-$slonik .=  "  echo 'Replication nodes prepared';\n";
-$slonik .=  "  echo 'Please start a slon replication daemon for each node';\n";
-run_slonik_script($slonik, 'INIT CLUSTER');
+$slonik .= "  echo 'Replication nodes prepared';\n";
+$slonik .= "  echo 'Please start a slon replication daemon for each node';\n";
+run_slonik_script( $slonik, 'INIT CLUSTER' );
index 1b3eb7e91cb8737f3cf9aa56a838c38d1cff5aa1..1101141bf9308973efce494dcba231c845c72b5e 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,11 +10,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: merge_sets [--config file] node# targetset# srcset#
+my $USAGE = "Usage: merge_sets [--config file] node# targetset# srcset#
 
     Merges the contents of the second set into the first one.
     When completed, the second set no longer exists.
@@ -22,20 +23,22 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($node, $set1, $set2) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
-  # Set name is in proper form
-  $node = $1;
-} else {
-  print "Valid node names are node1, node2, ...\n\n";
-  die $USAGE;
+my ( $node, $set1, $set2 ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+
+    # Set name is in proper form
+    $node = $1;
+}
+else {
+    print "Valid node names are node1, node2, ...\n\n";
+    die $USAGE;
 }
 
 die $USAGE unless $set1;
@@ -43,12 +46,13 @@ $set1 = get_set($set1) or die "Non-existent set specified.\n";
 die $USAGE unless $set2;
 $set2 = get_set($set2) or die "Non-existent set specified.\n";
 
-my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]);
+my ( $dbname, $dbhost ) = ( $DBNAME[$MASTERNODE], $HOST[$MASTERNODE] );
 
 my $slonik = '';
 
 $slonik .= genheader();
 $slonik .= "    merge set (id = $set1, add id = $set2, origin = $node);\n";
-$slonik .= "  echo 'Replication set $set2 merged into $set1 on origin $node. Set $set2 no longer exists.';\n";
+$slonik .=
+"  echo 'Replication set $set2 merged into $set1 on origin $node. Set $set2 no longer exists.';\n";
 
-run_slonik_script($slonik, 'MERGE SET');
+run_slonik_script( $slonik, 'MERGE SET' );
index 0d0e558d5c318c031bc53b93a74a0459ed301d93..c01887a7c7f591c68985c737c456b2816524a8f2 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,41 +10,44 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: move_set [--config file] set# from_node# to_node#
+my $USAGE = "Usage: move_set [--config file] set# from_node# to_node#
 
     Change a set's origin.
 
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($set, $node1, $node2) = @ARGV;
+my ( $set, $node1, $node2 ) = @ARGV;
 
 die $USAGE unless $set;
 $set = get_set($set) or die "Non-existent set specified.\n";
 
-if ($node1 =~ /^(?:node)?(\d+)$/) {
-  $node1 = $1;
-} else {
-  print "Valid node names are node1, node2, ...\n\n";
-  die $USAGE;
+if ( $node1 =~ /^(?:node)?(\d+)$/ ) {
+    $node1 = $1;
+}
+else {
+    print "Valid node names are node1, node2, ...\n\n";
+    die $USAGE;
 }
 
-if ($node2 =~ /^(?:node)?(\d+)$/) {
-  $node2 = $1;
-} else {
-  print "Valid node names are node1, node2, ...\n\n";
-  die $USAGE;
+if ( $node2 =~ /^(?:node)?(\d+)$/ ) {
+    $node2 = $1;
+}
+else {
+    print "Valid node names are node1, node2, ...\n\n";
+    die $USAGE;
 }
 
 my $slonik = '';
@@ -53,11 +56,15 @@ $slonik .= genheader();
 $slonik .= "  echo 'Locking down set $set on node $node1';\n";
 $slonik .= "  lock set (id = $set, origin = $node1);\n";
 $slonik .= "  sync (id = $node1);\n";
-$slonik .= "  wait for event (origin = $node1, confirmed = $node2, wait on = $node2);\n";
+$slonik .=
+  "  wait for event (origin = $node1, confirmed = $node2, wait on = $node2);\n";
 $slonik .= "  echo 'Locked down - moving it';\n";
-$slonik .= "  move set (id = $set, old origin = $node1, new origin = $node2);\n";
-$slonik .= "  echo 'Replication set $set moved from node $node1 to $node2.  Remember to';\n";
-$slonik .= "  echo 'update your configuration file, if necessary, to note the new location';\n";
+$slonik .=
+  "  move set (id = $set, old origin = $node1, new origin = $node2);\n";
+$slonik .=
+"  echo 'Replication set $set moved from node $node1 to $node2.  Remember to';\n";
+$slonik .=
+"  echo 'update your configuration file, if necessary, to note the new location';\n";
 $slonik .= "  echo 'for the set.';\n";
 
-run_slonik_script($slonik, 'MOVE SET');
+run_slonik_script( $slonik, 'MOVE SET' );
index fddab4cec84568530643c27c3f3f7000c04e365e..5707f6d51a1b7312d9050c270604098ad78c217d 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Mark Stosberg
 # Based on work by: Christopher Browne
 # Parts Copyright 2006 Summerault, LLC
@@ -11,11 +11,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: slonik_print_preamble [--config file]
+my $USAGE = "Usage: slonik_print_preamble [--config file]
 
     print the preamble required by all slonik scripts, using the
     details from the config file
@@ -35,4 +36,4 @@ require $CONFIG_FILE;
 my $slonik = '';
 $slonik .= genheader();
 
-run_slonik_script($slonik, 'PRINT PREAMBLE');
+run_slonik_script( $slonik, 'PRINT PREAMBLE' );
index bed555d089686219db9a40569965a01aff8a23ea..e58bc3dd5cd188c5d35d5ac971c3ec1985c67fe6 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -11,20 +11,21 @@ $SHOW_USAGE  = 0;
 $ALL_NODES   = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE,
-          "all"      => \$ALL_NODES);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE,
+    "all"      => \$ALL_NODES
+);
 
-my $USAGE =
-"Usage: restart_node [--config file] [--all] [node# ...]
+my $USAGE = "Usage: restart_node [--config file] [--all] [node# ...]
 
     Restart one or more nodes
 
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -36,12 +37,12 @@ if ($ALL_NODES) {
 }
 else {
     foreach my $node (@ARGV) {
-       if ($node =~ /^(?:node)?(\d+)$/) {
-           push @nodes, ($1);
-       }
-       else {
-           die $USAGE;
-       }
+        if ( $node =~ /^(?:node)?(\d+)$/ ) {
+            push @nodes, ($1);
+        }
+        else {
+            die $USAGE;
+        }
     }
 }
 
@@ -53,4 +54,4 @@ foreach my $node (@nodes) {
     $slonik .= "  restart node $node;\n";
 }
 
-run_slonik_script($slonik, 'RESTART NODE');
+run_slonik_script( $slonik, 'RESTART NODE' );
index 0eb4cbf90c5c0739cc173bc75ad2684366ac2b67..550c0ae25f033f7a82efee7e70160a9af9069e0b 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Steve Simms
 # Copyright 2005-2009 PostgreSQL Global Development Group
 
@@ -10,11 +10,12 @@ my $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 my $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: store_node [--config file] node#
+my $USAGE = "Usage: store_node [--config file] node#
 
     Generates the slonik commands necessary to add a node to a
     cluster.  Also displays a report showing the relationships between
@@ -23,8 +24,8 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -33,10 +34,11 @@ require $CONFIG_FILE;
 $node = $ARGV[0];
 
 # Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = $1;
-} else {
-  die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node = $1;
+}
+else {
+    die $USAGE;
 }
 
 my $slonik = '';
@@ -45,8 +47,9 @@ $slonik .= genheader();
 
 # STORE NODE
 $slonik .= "\n# STORE NODE\n";
-my ($dbname, $dbhost) = ($DBNAME[$node], $HOST[$node]);
-$slonik .= "  store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
+my ( $dbname, $dbhost ) = ( $DBNAME[$node], $HOST[$node] );
+$slonik .=
+"  store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
 $slonik .= "  echo 'Set up replication nodes';\n";
 
 # STORE PATH
@@ -56,22 +59,24 @@ $slonik .= "  echo 'Next: configure paths for each node/origin';\n";
 foreach my $nodea (@NODES) {
     my $dsna = $DSN[$nodea];
     foreach my $nodeb (@NODES) {
-       if ($nodea != $nodeb) {
-           next unless ($node == $nodea or $node == $nodeb);
-           my $dsnb = $DSN[$nodeb];
-           if (!$printed[$nodea][$nodeb]) {
-               $slonik .= "  store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
-               $printed[$nodea][$nodeb] = "done";
-           }
-           if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
-               $slonik .= "  store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
-               $printed[$nodeb][$nodea] = "done";
-           }
-       }
+        if ( $nodea != $nodeb ) {
+            next unless ( $node == $nodea or $node == $nodeb );
+            my $dsnb = $DSN[$nodeb];
+            if ( !$printed[$nodea][$nodeb] ) {
+                $slonik .=
+"  store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+                $printed[$nodea][$nodeb] = "done";
+            }
+            if ( !$printed[$nodeb][$nodea] and $providerba == $nodea ) {
+                $slonik .=
+"  store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+                $printed[$nodeb][$nodea] = "done";
+            }
+        }
     }
 }
 
 $slonik .= "  echo 'Replication nodes prepared';\n";
 $slonik .= "  echo 'Please start a slon replication daemon for each node';\n";
 
-run_slonik_script($slonik, 'STORE NODE');
+run_slonik_script( $slonik, 'STORE NODE' );
index 8f7b38b9a5003d82ad9ae96768a5b3d7e11d7267..d682206f6be02e73746bfaa845d6b3ef0c77574b 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,30 +10,32 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s"  => \$CONFIG_FILE,
-          "help"      => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: subscribe_set [--config file] set# node#
+my $USAGE = "Usage: subscribe_set [--config file] set# node#
 
     Begins replicating a set to the specified node.
 
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($set, $node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = $1;
-} else {
-  print "Need to specify node!\n";
-  die $USAGE;
+my ( $set, $node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node = $1;
+}
+else {
+    print "Need to specify node!\n";
+    die $USAGE;
 }
 
 die $USAGE unless $set;
@@ -44,20 +46,23 @@ my $slonik = '';
 $slonik .= genheader();
 $slonik .= " \n";
 
-if ($DSN[$node]) {
-  my $provider = $SET_ORIGIN;
-  my $forward;
-  if ($PARENT[$node]) {
-    $provider = $PARENT[$node];
-  }
-  if ($NOFORWARD[$node] eq "yes") {
-    $forward = "no";
-  } else {
-    $forward = "yes";
-  }
-  $slonik .= "    subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
-} else {
-  die "Node $node not found\n";
+if ( $DSN[$node] ) {
+    my $provider = $SET_ORIGIN;
+    my $forward;
+    if ( $PARENT[$node] ) {
+        $provider = $PARENT[$node];
+    }
+    if ( $NOFORWARD[$node] eq "yes" ) {
+        $forward = "no";
+    }
+    else {
+        $forward = "yes";
+    }
+    $slonik .=
+"    subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
+}
+else {
+    die "Node $node not found\n";
 }
 
 $slonik .= "  echo 'Subscribed nodes to set $set';\n";
index 1c9cb27f73ed617ca00e8063e5ed8e63e0ddb190..2b58bb8b41d43702b65d9ffdbaae25d80e0bd968 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,11 +10,12 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: uninstall_nodes [--config file]
+my $USAGE = "Usage: uninstall_nodes [--config file]
 
     Removes Slony configuration from all nodes in a cluster.
 
@@ -30,8 +31,8 @@ drop the node's configuration from replication.
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -40,9 +41,9 @@ require $CONFIG_FILE;
 my $slonik = '';
 $slonik .= genheader();
 foreach my $node (@NODES) {
-    next if $node == $MASTERNODE; # Do this one last
+    next if $node == $MASTERNODE;    # Do this one last
     $slonik .= "  uninstall node (id=$node);\n";
 }
 $slonik .= "  uninstall node (id=$MASTERNODE);\n";
 
-run_slonik_script($slonik, 'UNINSTALL NODE');
+run_slonik_script( $slonik, 'UNINSTALL NODE' );
index 6573393f4c43c58df3d9ce36513b59e2526de242..81d9edb35881ad43fe5461813deac9eceb11478e 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,30 +10,32 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: unsubscribe_set [--config file] set# node#
+my $USAGE = "Usage: unsubscribe_set [--config file] set# node#
 
     Stops replicating a set on the specified node.
 
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
 require $CONFIG_FILE;
 
-my ($set, $node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
-  $node = $1;
-} else {
-  print "Need to specify node!\n\n";
-  die $USAGE;
+my ( $set, $node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+    $node = $1;
+}
+else {
+    print "Need to specify node!\n\n";
+    die $USAGE;
 }
 
 die $USAGE unless $set;
@@ -50,4 +52,4 @@ $slonik .= "      exit 1;\n";
 $slonik .= "  }\n";
 $slonik .= "  echo 'unsubscribed node $node from set $set';\n";
 
-run_slonik_script($slonik, 'UNSUBSCRIBE SET');
+run_slonik_script( $slonik, 'UNSUBSCRIBE SET' );
index bf66b6721d2fa642e1a352be8477262b94637cf8..798b6f537f9f465e07285a64c960ef6060536c58 100644 (file)
@@ -1,5 +1,5 @@
 #!@@PERL@@
-# 
+#
 # Author: Christopher Browne
 # Copyright 2004-2009 Afilias Canada
 
@@ -10,19 +10,20 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-          "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
-my $USAGE =
-"Usage: update_nodes [--config file]
+my $USAGE = "Usage: update_nodes [--config file]
 
     Updates the functions on all nodes.
 
 ";
 
 if ($SHOW_USAGE) {
-  print $USAGE;
-  exit 0;
+    print $USAGE;
+    exit 0;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -31,7 +32,7 @@ require $CONFIG_FILE;
 my $slonik = '';
 $slonik .= genheader();
 foreach my $node (@NODES) {
-  $slonik .= "  update functions (id = $node);\n";
-};
+    $slonik .= "  update functions (id = $node);\n";
+}
 
-run_slonik_script($slonik, 'UPDATE FUNCTIONS');
+run_slonik_script( $slonik, 'UPDATE FUNCTIONS' );
index b4b6ce55b3b9709445aa0cc78b1c3ab1473722f4..d3a62c47b2b8813524c8493f194d75c45bfa2a65 100644 (file)
@@ -14,11 +14,13 @@ $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
 $SHOW_USAGE  = 0;
 
 # Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
-           "help"     => \$SHOW_USAGE);
+GetOptions(
+    "config=s" => \$CONFIG_FILE,
+    "help"     => \$SHOW_USAGE
+);
 
 my $USAGE =
-"Usage: slony_show_configuration [--config file] [node# nodeproperty]
+  "Usage: slony_show_configuration [--config file] [node# nodeproperty]
 
   nodeproperty valid values:
         host : return host
@@ -37,7 +39,7 @@ my $USAGE =
 ";
 
 if ($SHOW_USAGE) {
-  die $USAGE;
+    die $USAGE;
 }
 
 require '@@PERLSHAREDIR@@/slon-tools.pm';
@@ -45,67 +47,76 @@ require $CONFIG_FILE;
 
 if ( scalar(@ARGV) == 0 ) {
 
-  print_configurations();
+    print_configurations();
 
-} elsif ( scalar(@ARGV) == 2 ) {
-    $nodenum = $ARGV[0];
+}
+elsif ( scalar(@ARGV) == 2 ) {
+    $nodenum      = $ARGV[0];
     $nodeproperty = $ARGV[1];
 
-    if ($nodenum =~ /^(?:node)?(\d+)$/) {
-      $nodenum = $1;
+    if ( $nodenum =~ /^(?:node)?(\d+)$/ ) {
+        $nodenum = $1;
     }
     print_property_value();
 
-} else {
-  die $USAGE;
+}
+else {
+    die $USAGE;
 }
 
 sub print_configurations {
-  print "Slony Configuration\n-------------------------------------\n";
-  if ($ENV{"SLONYNODES"}) {
-    print "With node configuration from ", $ENV{"SLONYNODES"}, "\n";
-  }
-  if ($ENV{"SLONYSET"}) {
-    print "With set configuration from ", $ENV{"SLONYSET"}, "\n";
-  }
-  print qq{
+    print "Slony Configuration\n-------------------------------------\n";
+    if ( $ENV{"SLONYNODES"} ) {
+        print "With node configuration from ", $ENV{"SLONYNODES"}, "\n";
+    }
+    if ( $ENV{"SLONYSET"} ) {
+        print "With set configuration from ", $ENV{"SLONYSET"}, "\n";
+    }
+    print qq{
 Slony-I Cluster: $CLUSTER_NAME
 Logs stored under $LOGDIR
 Slony Binaries in: @@SLONBINDIR@@
 };
-  if ($APACHE_ROTATOR) {
-    print "Rotating logs using Apache Rotator: $APACHE_ROTATOR\n";
-  }
-  print qq{
+    if ($APACHE_ROTATOR) {
+        print "Rotating logs using Apache Rotator: $APACHE_ROTATOR\n";
+    }
+    print qq{
 Node information
 --------------------------------
 };
-  for $node (@NODES) {
-    printf("Node: %2d Host: %15s User: %8s Port: %4d Forwarding? %4s Parent: %2d Database: %10s\n         DSN: %s\n",
-         $node, $HOST[$node], $USER[$node], $PORT[$node], $NOFORWARD[$node],
-         $PARENT[$node], $DBNAME[$node], $DSN[$node]);
-  }
+    for $node (@NODES) {
+        printf(
+"Node: %2d Host: %15s User: %8s Port: %4d Forwarding? %4s Parent: %2d Database: %10s\n         DSN: %s\n",
+            $node, $HOST[$node], $USER[$node], $PORT[$node], $NOFORWARD[$node],
+            $PARENT[$node], $DBNAME[$node], $DSN[$node] );
+    }
 }
 
 sub print_property_value {
-  switch($nodeproperty) {
-    # connection configs
-    case "host"      { print $HOST[$nodenum], "\n"; }
-    case "port"      { print $PORT[$nodenum], "\n"; }
-    case "user"      { print $USER[$nodenum], "\n"; }
-    case "dbname"    { print $DBNAME[$nodenum], "\n"; }
-    case "dsn"       { print $DSN[$nodenum], "\n"; }
-    # replication configs
-    case "parent"    { print $PARENT[$nodenum], "\n"; }
-    case "noforward" { print $NOFORWARD[$nodenum], "\n"; }
-    # Misc
-    case "cluster"   { print $CLUSTER_NAME, "\n"; }
-    # config files
-    case "node-config-file"           { print $CONFIG[$nodenum], "\n"; }
-    case "node-config-file-quotemeta" { print quotemeta( $CONFIG[$nodenum] ), "\n"; }
-    case "config-file"           { print $CONFIG_FILE, "\n"; }
-    case "config-file-quotemeta" { print quotemeta( $CONFIG_FILE ), "\n"; }
-    else                         { print $USAGE; }
-  }
+    switch ($nodeproperty) {
+
+        # connection configs
+        case "host"   { print $HOST[$nodenum],   "\n"; }
+        case "port"   { print $PORT[$nodenum],   "\n"; }
+        case "user"   { print $USER[$nodenum],   "\n"; }
+        case "dbname" { print $DBNAME[$nodenum], "\n"; }
+        case "dsn"    { print $DSN[$nodenum],    "\n"; }
+
+        # replication configs
+        case "parent"    { print $PARENT[$nodenum],    "\n"; }
+        case "noforward" { print $NOFORWARD[$nodenum], "\n"; }
+
+        # Misc
+        case "cluster" { print $CLUSTER_NAME, "\n"; }
+
+        # config files
+        case "node-config-file" { print $CONFIG[$nodenum], "\n"; }
+        case "node-config-file-quotemeta" {
+            print quotemeta( $CONFIG[$nodenum] ), "\n";
+        }
+        case "config-file" { print $CONFIG_FILE, "\n"; }
+        case "config-file-quotemeta" { print quotemeta($CONFIG_FILE), "\n"; }
+        else { print $USAGE; }
+    }
 }