コード例 #1
0
function register()
{
    $airavataconfig = parse_ini_file("airavata-client-properties.ini");
    $transport = new TSocket($airavataconfig['AIRAVATA_SERVER'], $airavataconfig['AIRAVATA_PORT']);
    $transport->setSendTimeout($airavataconfig['AIRAVATA_TIMEOUT']);
    $protocol = new TBinaryProtocol($transport);
    $transport->open();
    try {
        $airavataclient = new AiravataClient($protocol);
        $registeredModules = getRegisteredModules($airavataclient);
        $modules = getUnregisteredModules($registeredModules);
        // $modules = getModulesNames();
        echo var_dump($registeredModules);
        echo var_dump($modules);
        if (!empty($modules)) {
            $localhostId = registerLocalHost($airavataclient);
            $moduleids = registerApplicationModule($airavataclient, $modules);
            registerApplicationDeployments($airavataclient, $moduleids, $modules, $localhostId);
            registerApplicationInterfaces($airavataclient, $moduleids, $modules, $localhostId);
            // $host = $airavataclient->registerComputeResource();
        }
    } catch (InvalidRequestException $ire) {
        print 'InvalidRequestException: ' . $ire->getMessage() . "\n";
    } catch (AiravataClientException $ace) {
        print 'Airavata System Exception: ' . $ace->getMessage() . "\n";
    } catch (AiravataSystemException $ase) {
        print 'Airavata System Exception: ' . $ase->getMessage() . "\n";
    }
    $transport->close();
}
コード例 #2
0
ファイル: DalSocket.php プロジェクト: packaged/dal
 /**
  * Calling close should disconnect persistent connections.
  */
 public function close()
 {
     $persist = $this->persist_;
     $this->persist_ = false;
     parent::close();
     $this->persist_ = $persist;
 }
コード例 #3
0
ファイル: airavata.php プロジェクト: aditi-srivastava/GenApp
function getOutput($expId)
{
    $transport = new TSocket($GLOBALS['AIRAVATA_SERVER'], $GLOBALS['AIRAVATA_PORT']);
    $transport->setSendTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $protocol = new TBinaryProtocol($transport);
    $errors = array('CANCELED' => "Experiment Cancelled", 'SUSPENDED' => "Experiment Suspended", 'FAILED' => "Experiment Failed");
    try {
        $airavataclient = new AiravataClient($protocol);
        $transport->open();
        while (($status = get_experiment_status($airavataclient, $expId)) != "COMPLETED") {
            if (isset($errors[$status])) {
                $transport->close();
                return "{\"error\":\"" . $errors[$status] . "\"}";
                exit;
            }
            sleep(1);
        }
        $outputs = $airavataclient->getExperimentOutputs($expId);
        $transport->close();
        $outputData = array();
        if (!empty($outputs[0]->value)) {
            $out = json_decode($outputs[0]->value);
            $out->Computational_Host = $GLOBALS["RESOURCE_HOST"];
            $outputData["output"] = json_encode($out);
        } else {
            $outputData["error"] = $outputs[1]->value;
        }
    } catch (InvalidRequestException $ire) {
        $outputData["error"] = 'InvalidRequestException: ' . $ire->getMessage();
    } catch (AiravataClientException $ace) {
        $outputData["error"] = 'Airavata System Exception: ' . $ace->getMessage();
    } catch (AiravataSystemException $ase) {
        $outputData["error"] = 'Airavata System Exception: ' . $ase->getMessage();
    } catch (TException $tx) {
        $outputData["error"] = 'Exception: ' . $tx->getMessage();
    } catch (ExperimentNotFoundException $enf) {
        $outputData["error"] = 'ExperimentNotFoundException: ' . $enf->getMessage();
    } catch (TTransportException $tte) {
        $outputData["error"] = 'TTransportException: ' . $tte->getMessage();
    } catch (\Exception $e) {
        $outputData["error"] = 'Exception: ' . $e->getMessage();
    }
    return json_encode($outputData);
}
コード例 #4
0
function register()
{
    $gatewayId = $GLOBALS['AIRAVATA_GATEWAY'];
    $transport = new TSocket($GLOBALS['AIRAVATA_SERVER'], $GLOBALS['AIRAVATA_PORT']);
    $transport->setSendTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $transport->setRecvTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $protocol = new TBinaryProtocol($transport);
    try {
        $transport->open();
        $airavataclient = new AiravataClient($protocol);
        if (!$airavataclient->isGatewayExist($gatewayId)) {
            $gateway = new Gateway();
            $gateway->gatewayId = $gatewayId;
            $gateway->gatewayName = "GeanApp_GateWaay";
            $gateway->domain = $GLOBALS['AIRAVATA_SERVER'];
            $gateway->emailAddress = $GLOBALS['AIRAVATA_EMAIL'];
            $airavataclient->addGateway($gateway);
            registerComputeResourceHost($airavataclient, $GLOBALS['COMPUTE_RESOURCE']);
        } else {
            if (isGatewayRegistered($airavataclient, $gatewayId)) {
                $cmrf = $airavataclient->getGatewayResourceProfile($gatewayId)->computeResourcePreferences;
                registerComputeResourceHost($airavataclient, getUnRegisteredHost($airavataclient, $cmrf));
            } else {
                registerComputeResourceHost($airavataclient, $GLOBALS['COMPUTE_RESOURCE']);
            }
        }
        $hostIds = getHostIds($airavataclient, $gatewayId);
        $registeredModules = getRegisteredModules($airavataclient, $gatewayId);
        $modulesHost = getUnregisteredModules($airavataclient, $registeredModules);
        foreach ($modulesHost as $hostName => $modules) {
            if (!empty($modules)) {
                $moduleids = registerApplicationModule($gatewayId, $airavataclient, $modules);
                registerApplicationDeployments($gatewayId, $airavataclient, $moduleids, $modules, $hostIds[$hostName]);
                registerApplicationInterfaces($gatewayId, $airavataclient, $moduleids, $modules, $hostName);
            }
        }
        $transport->close();
    } catch (InvalidRequestException $ire) {
        echo 'InvalidRequestException: ' . $ire->getMessage();
    } catch (AiravataClientException $ace) {
        echo 'Airavata System Exception: ' . $ace->getMessage();
    } catch (AiravataSystemException $ase) {
        echo 'Airavata System Exception: ' . $ase->getMessage();
    } catch (TException $tx) {
        echo 'There is some connection problem, please check if airavata is runnig properly and try again later';
    } catch (\Exception $e) {
        echo 'Exception: ' . $e->getMessage();
    }
}