summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSebastian Wagner2011-07-18 17:17:39 +0200
committerSebastian Wagner2011-07-18 17:17:39 +0200
commit6fead9b9ff1d8caa2dee186ee04e9192272057b1 (patch)
tree1e2ee6b63b4fbd4255d56f224f167af237609d5a /application
parentsomePingWorker in Java (diff)
downloadpoolctrl-6fead9b9ff1d8caa2dee186ee04e9192272057b1.tar.gz
poolctrl-6fead9b9ff1d8caa2dee186ee04e9192272057b1.tar.xz
poolctrl-6fead9b9ff1d8caa2dee186ee04e9192272057b1.zip
some changes
Diffstat (limited to 'application')
-rw-r--r--application/controllers/GearmanController.php41
1 files changed, 26 insertions, 15 deletions
diff --git a/application/controllers/GearmanController.php b/application/controllers/GearmanController.php
index b871207..8538432 100644
--- a/application/controllers/GearmanController.php
+++ b/application/controllers/GearmanController.php
@@ -7,27 +7,38 @@ class GearmanController extends Zend_Controller_Action
public function init()
{
$this->gearmanClient = new GearmanClient();
- $this->gearmanClient->addServer();
+ $this->gearmanClient->addServer('127.0.0.1');
}
-
- public function indexAction()
+
+ public function indexAction()
{
-
+
}
public function somepingAction()
{
- $ipString = '132.230.4.1; 132.230.4.2; 132.230.4.3; 132.230.4.4; 132.230.4.5; 132.230.4.6; 132.230.4.7; 132.230.4.8; 132.230.4.9; 132.230.4.10; 132.230.4.11; 132.230.4.12; 132.230.4.13; 132.230.4.14; 132.230.4.15; 132.230.4.16; 132.230.4.17; 132.230.4.18; 132.230.4.19; 132.230.4.20; 132.230.4.21; 132.230.4.22; 132.230.4.23; 132.230.4.24; 132.230.4.25; 132.230.4.26; 132.230.4.27; 132.230.4.28; 132.230.4.29; 132.230.4.30';
-
- $result = $this->gearmanClient->do("somePing", $ipString);
- $resultsExp = explode('; ', $result);
- foreach($resultsExp as $result) {
- $resultDecode = json_decode($result);
- $resultDecode->rawoutput = sprintf('%s', $resultDecode->rawoutput);
- $resultDecode->alive = sprintf('%s', $resultDecode->alive);
- $resultDecode->rc = sprintf('%s', $resultDecode->rc);
- $results[] = $resultDecode;
+ $gearmanNamespace = Zend_Session::namespaceGet('gearman');
+ if(!isset($gearmanNamespace['somePingJobHandle'])) {
+ $ipString = '132.230.4.1; 132.230.4.2; 132.230.4.3; 132.230.4.4; 132.230.4.5; 132.230.4.6; 132.230.4.7; 132.230.4.8; 132.230.4.9; 132.230.4.10; 132.230.4.11; 132.230.4.12; 132.230.4.13; 132.230.4.14; 132.230.4.15; 132.230.4.16; 132.230.4.17; 132.230.4.18; 132.230.4.19; 132.230.4.20; 132.230.4.21; 132.230.4.22; 132.230.4.23; 132.230.4.24; 132.230.4.25; 132.230.4.26; 132.230.4.27; 132.230.4.28; 132.230.4.29; 132.230.4.30';
+ $jobHandle = $this->gearmanClient->doBackground("somePing", $ipString);
+ $gearmanSession = new Zend_Session_Namespace('gearman');
+ $gearmanSession->somePingJobHandle = $jobHandle;
+ } else {
+ $jobHandle = $gearmanNamespace['somePingJobHandle'];
+ $result = $this->gearmanClient->jobStatus($jobHandle);
+ $resultsExp = explode('; ', $result);
+ print_r($result);
+ if(is_array($resultsExp)) {
+ foreach($resultsExp as $result) {
+ $resultDecode = json_decode($result);
+ $resultDecode->rawoutput = sprintf('%s', $resultDecode->rawoutput);
+ $resultDecode->alive = sprintf('%s', $resultDecode->alive);
+ $resultDecode->rc = sprintf('%s', $resultDecode->rc);
+ $results[] = $resultDecode;
+ }
+ Zend_Session::namespaceUnset('gearman');
+ $this->view->results = $results;
+ }
}
- $this->view->results = $results;
}
} \ No newline at end of file