ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSTaskScheduler Class Reference
+ Collaboration diagram for ilECSTaskScheduler:

Public Member Functions

 getServer ()
 Get server setting.
 startTaskExecution ()
 Start Tasks.
 checkNextExecution ()
 Start.

Static Public Member Functions

static _getInstanceByServerId ($a_server_id)
 get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTaskExecution
static start ()
 Start task scheduler for each server instance.
static startExecution ()
 Static version iterates over all active instances.

Data Fields

const MAX_TASKS = 30

Protected Member Functions

 initNextExecution ()
 Call next task scheduler run.

Protected Attributes

 $settings = null
 $log = null
 $db

Private Member Functions

 __construct (ilECSSetting $setting)
 Singleton constructor.
 readEvents ()
 Read EContent.
 handleEvents ()
 Handle events.
 handleDeprecatedAccounts ()
 Delete deprecate ECS accounts.
 readMIDs ()
 Read MID's of this installation.

Private Attributes

 $event_reader = null
 $mids = array()

Static Private Attributes

static $instances = array()

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 32 of file class.ilECSTaskScheduler.php.

Constructor & Destructor Documentation

ilECSTaskScheduler::__construct ( ilECSSetting  $setting)
private

Singleton constructor.

public

Definition at line 52 of file class.ilECSTaskScheduler.php.

References $ilLog.

{
global $ilDB,$ilLog;
$this->db = $ilDB;
$this->log = $ilLog;
include_once('./Services/WebServices/ECS/classes/class.ilECSSetting.php');
$this->settings = $setting;
}

Member Function Documentation

static ilECSTaskScheduler::_getInstanceByServerId (   $a_server_id)
static

get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTaskExecution

private

Returns
ilECSTaskScheduler

Definition at line 75 of file class.ilECSTaskScheduler.php.

References ilECSSetting\getInstanceByServerId().

Referenced by ilSoapUtils\handleECSTasks(), and ilECSSettingsGUI\readAll().

{
if(self::$instances[$a_server_id])
{
return self::$instances[$a_server_id];
}
include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
return self::$instances[$a_server_id] =
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSTaskScheduler::checkNextExecution ( )

Start.

public

Definition at line 358 of file class.ilECSTaskScheduler.php.

References $ilLog, and $query.

{
global $ilLog, $ilDB;
if(!$this->settings->isEnabled())
{
return false;
}
if(!$this->settings->checkImportId())
{
$this->log->write(__METHOD__.': Import ID is deleted or not of type "category". Aborting');
return false;
}
// check next task excecution time:
// If it's greater than time() directly increase this value with the polling time
/* synchronized { */
$query = 'UPDATE settings SET '.
'value = '.$ilDB->quote(time() + $this->settings->getPollingTime(),'text').' '.
'WHERE module = '.$ilDB->quote('ecs','text').' '.
'AND keyword = '.$ilDB->quote('next_execution_'.$this->settings->getServerId(),'text').' '.
'AND value < '.$ilDB->quote(time(),'text');
$affected_rows = $ilDB->manipulate($query);
/* } */
if(!$affected_rows)
{
// Nothing to do
return false;
}
return true;
}
ilECSTaskScheduler::getServer ( )

Get server setting.

Returns
ilECSSetting

Definition at line 129 of file class.ilECSTaskScheduler.php.

References $settings.

Referenced by handleEvents(), readEvents(), and readMIDs().

{
}

+ Here is the caller graph for this function:

ilECSTaskScheduler::handleDeprecatedAccounts ( )
private

Delete deprecate ECS accounts.

private

Definition at line 297 of file class.ilECSTaskScheduler.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and ilObjectFactory\getInstanceByObjId().

Referenced by startTaskExecution().

{
global $ilDB;
$query = "SELECT usr_id FROM usr_data WHERE auth_mode = 'ecs' ".
"AND time_limit_until < ".time()." ".
"AND time_limit_unlimited = 0 ".
"AND (time_limit_until - time_limit_from) < 7200";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if($user_obj = ilObjectFactory::getInstanceByObjId($row->usr_id,false))
{
$this->log->write(__METHOD__.': Deleting deprecated ECS user account '.$user_obj->getLogin());
$user_obj->delete();
}
// only one user
break;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSTaskScheduler::handleEvents ( )
private

Handle events.

private

Definition at line 187 of file class.ilECSTaskScheduler.php.

References $res, ilECSEvent\CREATED, ilECSEvent\DESTROYED, ilRemoteObjectBase\getInstanceByEventType(), getServer(), MAX_TASKS, ilECSEvent\NEW_EXPORT, ilECSEventQueueReader\TYPE_CMS_COURSE_MEMBERS, ilECSEventQueueReader\TYPE_CMS_COURSES, ilECSEventQueueReader\TYPE_COURSE_URLS, ilECSEventQueueReader\TYPE_DIRECTORY_TREES, ilECSEventQueueReader\TYPE_REMOTE_CATEGORY, ilECSEventQueueReader\TYPE_REMOTE_COURSE, ilECSEventQueueReader\TYPE_REMOTE_FILE, ilECSEventQueueReader\TYPE_REMOTE_GLOSSARY, ilECSEventQueueReader\TYPE_REMOTE_GROUP, ilECSEventQueueReader\TYPE_REMOTE_LEARNING_MODULE, ilECSEventQueueReader\TYPE_REMOTE_TEST, ilECSEventQueueReader\TYPE_REMOTE_WIKI, and ilECSEvent\UPDATED.

Referenced by startTaskExecution().

{
include_once './Services/WebServices/ECS/classes/class.ilECSEvent.php';
for($i = 0;$i < self::MAX_TASKS;$i++)
{
if(!$event = $this->event_reader->shift())
{
$this->log->write(__METHOD__.': No more pending events found. DONE');
break;
}
$this->log->write(print_r($event, true));
// determine event handler
$event_ignored = false;
switch($event['type'])
{
include_once 'Services/WebServices/ECS/classes/class.ilRemoteObjectBase.php';
$handler = ilRemoteObjectBase::getInstanceByEventType($event['type']);
$this->log->write("got handler ".get_class($handler));
break;
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTreeCommandQueueHandler.php';
$handler = new ilECSCmsTreeCommandQueueHandler($this->getServer());
break;
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCmsCourseCommandQueueHandler.php';
$handler = new ilECSCmsCourseCommandQueueHandler($this->getServer());
break;
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCmsCourseMemberCommandQueueHandler.php';
break;
$this->log->write(__METHOD__.': Ignoring event type in queue '.$event['type']);
$event_ignored = true;
break;
default:
$this->log->write(__METHOD__.': Unknown event type in queue '.$event['type']);
$event_ignored = true;
break;
}
if($event_ignored)
{
$this->event_reader->delete($event['event_id']);
continue;
}
$res = false;
switch($event['op'])
{
// DEPRECATED?
// $this->handleNewlyCreate($event['id']);
// $this->log->write(__METHOD__.': Handling new creation. DONE');
break;
$res = $handler->handleDelete($this->getServer(), $event['id'],$this->mids);
$this->log->write(__METHOD__.': Handling delete. DONE');
break;
$res = $handler->handleCreate($this->getServer(), $event['id'], $this->mids);
$this->log->write(__METHOD__.': Handling create. DONE');
break;
$res = $handler->handleUpdate($this->getServer(), $event['id'], $this->mids);
$this->log->write(__METHOD__.': Handling update. DONE');
break;
default:
$this->log->write(__METHOD__.': Unknown event operation in queue '.$event['op']);
break;
}
if($res)
{
$this->log->write(__METHOD__.': Processing of event done '.$event['event_id']);
$this->event_reader->delete($event['event_id']);
}
else
{
$this->log->write(__METHOD__.': Processing of event failed '.$event['event_id']);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSTaskScheduler::initNextExecution ( )
protected

Call next task scheduler run.

Definition at line 398 of file class.ilECSTaskScheduler.php.

References $_COOKIE, $client_id, $ilLog, $res, ilSession\_duplicate(), and ilSoapFunctions\handleECSTasks().

{
global $ilLog;
// Start task execution as backend process
include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
$soap_client = new ilSoapClient();
$soap_client->setResponseTimeout(1);
$soap_client->enableWSDL(true);
#$ilLog->write(__METHOD__.': Trying to call Soap client...');
$new_session_id = ilSession::_duplicate($_COOKIE['PHPSESSID']);
$client_id = $_COOKIE['ilClientId'];
if($soap_client->init() and 0)
{
$ilLog->write(__METHOD__.': Calling soap handleECSTasks method...');
$res = $soap_client->call('handleECSTasks',array($new_session_id.'::'.$client_id,$this->settings->getServerId()));
}
else
{
$ilLog->write(__METHOD__.': SOAP call failed. Calling clone method manually. ');
include_once('./webservice/soap/include/inc.soap_functions.php');
$res = ilSoapFunctions::handleECSTasks($new_session_id.'::'.$client_id,$this->settings->getServerId());
}
}

+ Here is the call graph for this function:

ilECSTaskScheduler::readEvents ( )
private

Read EContent.

private

Definition at line 167 of file class.ilECSTaskScheduler.php.

References getServer().

Referenced by startTaskExecution().

{
try
{
include_once('./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
$this->event_reader = new ilECSEventQueueReader($this->getServer()->getServerId());
$this->event_reader->refresh();
}
catch(ilException $exc)
{
throw $exc;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSTaskScheduler::readMIDs ( )
private

Read MID's of this installation.

private

Definition at line 325 of file class.ilECSTaskScheduler.php.

References $reader, ilECSCommunityReader\getInstanceByServerId(), and getServer().

Referenced by startTaskExecution().

{
try
{
$this->mids = array();
include_once('./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php');
foreach($reader->getCommunities() as $com)
{
foreach($com->getParticipants() as $part)
{
if($part->isSelf())
{
$this->mids[] = $part->getMID();
#$this->log->write('Fetch MID: '.$part->getMID());
}
}
}
}
catch(ilException $exc)
{
throw $exc;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilECSTaskScheduler::start ( )
static

Start task scheduler for each server instance.

Definition at line 91 of file class.ilECSTaskScheduler.php.

References $server, ilContext\CONTEXT_WEB, ilECSServerSettings\getInstance(), and ilContext\getType().

Referenced by ilInitialisation\initILIAS().

{
include_once './Services/Context/classes/class.ilContext.php';
{
return;
}
include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
foreach($servers->getServers() as $server)
{
$sched = new ilECSTaskScheduler($server);
if($sched->checkNextExecution())
{
$sched->initNextExecution();
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilECSTaskScheduler::startExecution ( )
static

Static version iterates over all active instances.

Definition at line 114 of file class.ilECSTaskScheduler.php.

References $server, and ilECSServerSettings\getInstance().

{
include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
foreach($server->getServers() as $server)
{
$sched = new ilECSTaskScheduler($server);
$sched->startTaskExecution();
}
}

+ Here is the call graph for this function:

ilECSTaskScheduler::startTaskExecution ( )

Start Tasks.

private

Definition at line 141 of file class.ilECSTaskScheduler.php.

References $ilLog, handleDeprecatedAccounts(), handleEvents(), readEvents(), and readMIDs().

{
global $ilLog;
try
{
$this->readMIDs();
$this->readEvents();
$this->handleEvents();
}
catch(ilException $exc)
{
$this->log->write(__METHOD__.': Caught exception: '.$exc->getMessage());
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilECSTaskScheduler::$db
protected

Definition at line 42 of file class.ilECSTaskScheduler.php.

ilECSTaskScheduler::$event_reader = null
private

Definition at line 38 of file class.ilECSTaskScheduler.php.

ilECSTaskScheduler::$instances = array()
staticprivate

Definition at line 36 of file class.ilECSTaskScheduler.php.

ilECSTaskScheduler::$log = null
protected

Definition at line 41 of file class.ilECSTaskScheduler.php.

ilECSTaskScheduler::$mids = array()
private

Definition at line 44 of file class.ilECSTaskScheduler.php.

ilECSTaskScheduler::$settings = null
protected

Definition at line 40 of file class.ilECSTaskScheduler.php.

Referenced by getServer().

const ilECSTaskScheduler::MAX_TASKS = 30

Definition at line 34 of file class.ilECSTaskScheduler.php.

Referenced by handleEvents().


The documentation for this class was generated from the following file: