Ejemplo n.º 1
0
 function forwardObjects()
 {
     global $db, $config;
     global $page;
     if (!$console && $this->getBool('use_for_outgoing')) {
         debug("node {$this->id} is not used for outgoing sync");
         return;
     }
     debug("FORWARDING TO ", $this->get("node_id"));
     $rpc = new rpc_Utils();
     if ($config['debug']) {
         $rpc->debug = true;
     }
     $timestamp = $db->getTimestampTz();
     $remoteId = $this->get('node_id');
     $url = $this->get('url');
     // remove trailing '/'
     while (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     // calculate chunking
     $thisChunk = 1;
     // do XML-RPC conversation
     $objectsSent = 0;
     $more = sotf_NodeObject::countForwardObjects($remoteId);
     if (!$more) {
         debug("No new objects to send");
     }
     while ($more) {
         $db->begin(true);
         $modifiedObjects = sotf_NodeObject::getForwardObjects($remoteId, $this->objectsPerRPCRequest);
         $more = sotf_NodeObject::countForwardObjects($remoteId);
         $chunkInfo = array('this_chunk' => $thisChunk, 'from_node' => $config['nodeId'], 'objects_remaining' => $more);
         debug("chunk info", $chunkInfo);
         debug("number of sent objects", count($modifiedObjects));
         $objectsSent = $objectsSent + count($modifiedObjects);
         $objs = array($chunkInfo, $modifiedObjects);
         $response = $rpc->call($url . "/xmlrpcServer.php/forward/{$thisChunk}", 'sotf.forward', $objs);
         // error handling
         if (is_null($response)) {
             $db->rollback();
             return;
         }
         $db->commit();
         $replyInfo = $response[0];
         debug("replyInfo", $replyInfo);
         $thisChunk++;
     }
     debug("total number of objects sent", $objectsSent);
     //$this->log($console, "number of updated objects: " .count($updatedObjects));
 }