fetchTxnLogs.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one
  5. * or more contributor license agreements. See the NOTICE file
  6. * distributed with this work for additional information
  7. * regarding copyright ownership. The ASF licenses this file
  8. * to you under the Apache License, Version 2.0 (the
  9. * "License"); you may not use this file except in compliance
  10. * with the License. You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing,
  15. * software distributed under the License is distributed on an
  16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. * KIND, either express or implied. See the License for the
  18. * specific language governing permissions and limitations
  19. * under the License.
  20. *
  21. */
  22. include_once '../util/Logger.php';
  23. include_once '../conf/Config.inc';
  24. include_once 'localDirs.php';
  25. include_once "../util/lock.php";
  26. include_once '../db/HMCDBAccessor.php';
  27. include_once "../orchestrator/HMC.php";
  28. include_once "../orchestrator/Service.php";
  29. include_once "../orchestrator/ServiceComponent.php";
  30. include_once "../db/Transaction.php";
  31. include_once "../db/OrchestratorDB.php";
  32. include_once "../puppet/DBReader.php";
  33. include_once "../puppet/PuppetInvoker.php";
  34. $dbPath = $GLOBALS["DB_PATH"];
  35. $clusterName = $_GET['clusterName'];
  36. $txnId = $_GET['txnId'];
  37. function fetchTxnLogs( $txnId )
  38. {
  39. global $dbPath;
  40. global $clusterName;
  41. $hmc = new HMC($dbPath, $clusterName);
  42. $logs = $hmc->getLogs($txnId);
  43. $progress = $hmc->getProgress($txnId);
  44. //REZXXX $logs = '';
  45. //REZXXX
  46. //REZXXX /* Generate long logs. */
  47. //REZXXX for($i = 0; $i < 100; $i++) {
  48. //REZXXX $logs .= "1111 <br/>";
  49. //REZXXX }
  50. return array ('logs' => $logs['subTxns'],
  51. 'progress' => $progress['subTxns']);
  52. }
  53. $result = fetchTxnLogs($txnId);
  54. /* Create the output data... */
  55. $jsonOutput = array(
  56. 'clusterName' => $clusterName,
  57. 'txnId' => $txnId,
  58. 'logs' => $result['logs'],
  59. 'progress' => $result['progress']);
  60. /* ...and spit it out. */
  61. header("Content-type: application/json");
  62. print (json_encode($jsonOutput));
  63. ?>