Commit 80b046ba authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #494 in ZP/z-push from feature/ZP-1168-log-wait-time-in-info-level to develop

* commit '90be45b1':
  ZP-1168 Fixed phpdoc descriptions.
  ZP-1168 Log 'idle' time in INFO level.
parents 1e9fddb7 90be45b1
...@@ -223,10 +223,11 @@ include_once(ZPUSH_CONFIG); ...@@ -223,10 +223,11 @@ include_once(ZPUSH_CONFIG);
// end gracefully // end gracefully
ZLog::Write(LOGLEVEL_INFO, ZLog::Write(LOGLEVEL_INFO,
sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='%s' from='%s' version='%s' method='%s' httpcode='%s'", sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='%s' from='%s' idle='%ss' version='%s' method='%s' httpcode='%s'",
Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)), Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)),
number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2), number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2),
Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code() )); Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(),
RequestProcessor::GetWaitTime(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code() ));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End"); ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
...@@ -578,6 +578,9 @@ class SyncCollections implements Iterator { ...@@ -578,6 +578,9 @@ class SyncCollections implements Iterator {
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now-$started), $lifetime, $checkClasses)); ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now-$started), $lifetime, $checkClasses));
$notifications = ZPush::GetBackend()->ChangesSink($nextInterval); $notifications = ZPush::GetBackend()->ChangesSink($nextInterval);
// how long are we waiting for changes
$this->waitingTime = time()-$started;
$validNotifications = false; $validNotifications = false;
foreach ($notifications as $backendFolderId) { foreach ($notifications as $backendFolderId) {
// Check hierarchy notifications // Check hierarchy notifications
...@@ -801,13 +804,24 @@ class SyncCollections implements Iterator { ...@@ -801,13 +804,24 @@ class SyncCollections implements Iterator {
* regular export to find changes * regular export to find changes
* *
* @access public * @access public
* @return array * @return boolean
*/ */
public function WaitedForChanges() { public function WaitedForChanges() {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->WaitedForChanges: waited for %d seconds", $this->waitingTime)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->WaitedForChanges: waited for %d seconds", $this->waitingTime));
return ($this->waitingTime > 0); return ($this->waitingTime > 0);
} }
/**
* Indicates how many seconds the process did wait in a sink, polling or before running a
* regular export to find changes.
*
* @access public
* @return int
*/
public function GetWaitedSeconds() {
return $this->waitingTime;
}
/** /**
* Returns how the current folder should be called in the PING comment. * Returns how the current folder should be called in the PING comment.
* *
......
...@@ -242,6 +242,9 @@ class Ping extends RequestProcessor { ...@@ -242,6 +242,9 @@ class Ping extends RequestProcessor {
self::$encoder->endTag(); self::$encoder->endTag();
// update the waittime waited
self::$waitTime = $sc->GetWaitedSeconds();
return true; return true;
} }
......
...@@ -38,6 +38,7 @@ abstract class RequestProcessor { ...@@ -38,6 +38,7 @@ abstract class RequestProcessor {
static protected $encoder; static protected $encoder;
static protected $userIsAuthenticated; static protected $userIsAuthenticated;
static protected $specialHeaders; static protected $specialHeaders;
static protected $waitTime;
/** /**
* Authenticates the remote user * Authenticates the remote user
...@@ -94,6 +95,7 @@ abstract class RequestProcessor { ...@@ -94,6 +95,7 @@ abstract class RequestProcessor {
self::$decoder = new WBXMLDecoder(Request::GetInputStream()); self::$decoder = new WBXMLDecoder(Request::GetInputStream());
self::$encoder = new WBXMLEncoder(Request::GetOutputStream(), Request::GetGETAcceptMultipart()); self::$encoder = new WBXMLEncoder(Request::GetOutputStream(), Request::GetGETAcceptMultipart());
self::$waitTime = 0;
} }
/** /**
...@@ -137,6 +139,16 @@ abstract class RequestProcessor { ...@@ -137,6 +139,16 @@ abstract class RequestProcessor {
return self::$specialHeaders; return self::$specialHeaders;
} }
/**
* Returns the amount of seconds RequestProcessor waited e.g. during Ping.
*
* @access public
* @return int
*/
public static function GetWaitTime() {
return self::$waitTime;
}
/** /**
* Handles a command * Handles a command
* *
......
...@@ -911,6 +911,9 @@ class Sync extends RequestProcessor { ...@@ -911,6 +911,9 @@ class Sync extends RequestProcessor {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: Processed %d folders", $sc->GetCollectionCount())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: Processed %d folders", $sc->GetCollectionCount()));
} }
// update the waittime waited
self::$waitTime = $sc->GetWaitedSeconds();
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment