3 * Table Definition for core_notify_server
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'core_notify_server'; // table name
13 public $id; // int(11) not_null primary_key auto_increment
20 function assignQueues($notify)
23 $ns = DB_DataObject::factory('core_notify_server');
24 $ns->poolname = $notify->poolname;
26 $ns->orderBy('id ASC');
27 $ids = $ns->fetchAll('id' );
31 $notify->jerr("no configured servers in core_notify_server for poolname = {$notify->poolname}");
34 $self = $this->getCurrent($notify);
36 // only run this on the first server...
37 if ($self->id != $ids[0]) {
40 foreach($ids as $rn) {
44 $num_servers = count($ids);
46 if ($num_servers == 1) {
47 $p = DB_DataObject::factory($notify->table);
58 act_start < NOW() + INTERVAL 3 HOUR
65 // ((@row_number := CASE WHEN @row_number IS NULL THEN 0 ELSE @row_number END +1) % {$num_servers})
69 $p = DB_DataObject::factory($notify->table);
75 act_start < NOW() + INTERVAL 3 HOUR
80 if ($p->count() < 1) {
85 $p->selectAdd("id, ((@row_number := CASE WHEN @row_number IS NULL THEN 0 ELSE @row_number END +1) % {$num_servers}) as rn");
86 $kv = $p->fetchAll('id,rn');
87 foreach($kv as $id => $r) {
88 $up[ $ids[$r] ][] = $id;
90 foreach($up as $sid => $nids) {
91 $p = DB_DataObject::factory($notify->table);
98 id IN (". implode(",', $nids"). ')'
106 function getCurrent($notify)
108 $ns = DB_DataObject::factory('core_notify_server');
109 $ns->poolname = $notify->poolname;
111 $ns->hostname = gethostname();
113 $notify->jerr("Server not found for this server " . gethostname() . " in core_notify_server" );