Exemple #1
0
 /**
  * Get the attribute of the specified replica set node
  * Ths resolves node inheritance and explicit configuration data 
  * such as alternate database service addresses in slony configurations
  * @param SimpleXMLElement $replica_set
  * @param integer $node_id
  * @param string $attribute
  */
 protected static function get_slony_replica_set_node_attribute($db_doc, $replica_set, $node_id, $attribute)
 {
     $replica_node = NULL;
     // is the node_id specified the origin node?
     if ((int) $replica_set['originNodeId'] == $node_id) {
         $replica_node = $replica_set;
     } else {
         foreach ($replica_set->slonyReplicaSetNode as $set_node) {
             if ((int) $set_node['id'] == $node_id) {
                 $replica_node = $set_node;
             }
         }
     }
     if (!is_object($replica_node)) {
         throw new exception("Replica set " . $replica_set['id'] . " node " . $node_id . " not found");
     }
     // if the replica_node defines this attribute, return it, if not return master node definition value
     if (isset($replica_node[$attribute])) {
         return (string) $replica_node[$attribute];
     }
     $slony_node = pgsql8::get_slony_node($db_doc, $node_id);
     return (string) $slony_node[$attribute];
 }