Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/ssh/DiffusionGitSSHWorkflow.php
<?php | <?php | ||||
abstract class DiffusionGitSSHWorkflow | abstract class DiffusionGitSSHWorkflow | ||||
extends DiffusionSSHWorkflow | extends DiffusionSSHWorkflow | ||||
implements DiffusionRepositoryClusterEngineLogInterface { | implements DiffusionRepositoryClusterEngineLogInterface { | ||||
private $engineLogProperties = array(); | private $engineLogProperties = array(); | ||||
private $protocolLog; | private $protocolLog; | ||||
private $wireProtocol; | private $wireProtocol; | ||||
private $ioBytesRead = 0; | |||||
private $ioBytesWritten = 0; | |||||
protected function writeError($message) { | protected function writeError($message) { | ||||
// Git assumes we'll add our own newlines. | // Git assumes we'll add our own newlines. | ||||
return parent::writeError($message."\n"); | return parent::writeError($message."\n"); | ||||
} | } | ||||
public function writeClusterEngineLogMessage($message) { | public function writeClusterEngineLogMessage($message) { | ||||
parent::writeError($message); | parent::writeError($message); | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | final protected function setWireProtocol( | ||||
$this->wireProtocol = $protocol; | $this->wireProtocol = $protocol; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function willWriteMessageCallback( | public function willWriteMessageCallback( | ||||
PhabricatorSSHPassthruCommand $command, | PhabricatorSSHPassthruCommand $command, | ||||
$message) { | $message) { | ||||
$this->ioBytesWritten += strlen($message); | |||||
$log = $this->getProtocolLog(); | $log = $this->getProtocolLog(); | ||||
if ($log) { | if ($log) { | ||||
$log->didWriteBytes($message); | $log->didWriteBytes($message); | ||||
} | } | ||||
$protocol = $this->getWireProtocol(); | $protocol = $this->getWireProtocol(); | ||||
if ($protocol) { | if ($protocol) { | ||||
$message = $protocol->willWriteBytes($message); | $message = $protocol->willWriteBytes($message); | ||||
Show All 11 Lines | if ($log) { | ||||
$log->didReadBytes($message); | $log->didReadBytes($message); | ||||
} | } | ||||
$protocol = $this->getWireProtocol(); | $protocol = $this->getWireProtocol(); | ||||
if ($protocol) { | if ($protocol) { | ||||
$message = $protocol->willReadBytes($message); | $message = $protocol->willReadBytes($message); | ||||
} | } | ||||
// Note that bytes aren't counted until they're emittted by the protocol | |||||
// layer. This means the underlying command might emit bytes, but if they | |||||
// are buffered by the protocol layer they won't count as read bytes yet. | |||||
$this->ioBytesRead += strlen($message); | |||||
return $message; | return $message; | ||||
} | } | ||||
final protected function getIOBytesRead() { | |||||
return $this->ioBytesRead; | |||||
} | |||||
final protected function getIOBytesWritten() { | |||||
return $this->ioBytesWritten; | |||||
} | |||||
} | } |