vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.0 KiB

9 years ago
  1. 'use strict';
  2. function JobAgentGenerator(id) {
  3. // execute super constructor
  4. eve.Agent.call(this, id);
  5. this.rpc = this.loadModule('rpc', this.rpcFunctions);
  6. this.connect(eve.system.transports.getAll());
  7. }
  8. // extend the eve.Agent prototype
  9. JobAgentGenerator.prototype = Object.create(eve.Agent.prototype);
  10. JobAgentGenerator.prototype.constructor = AgentGenerator;
  11. // define RPC functions, preferably in a separated object to clearly distinct
  12. // exposed functions from local functions.
  13. JobAgentGenerator.prototype.rpcFunctions = {};
  14. JobAgentGenerator.prototype.rpcFunctions.createJob = function(params) {
  15. var jobAgentName = params.type;
  16. if (jobList[jobAgentName] === undefined) {
  17. jobList[jobAgentName] = new JobAgent(jobAgentName);
  18. graph2dGroups.add([
  19. {
  20. id: jobAgentName+'_pred_duration_std_lower',
  21. content: "prediction",
  22. className: 'prediction_std',
  23. options: {drawPoints:false}
  24. },
  25. {
  26. id: jobAgentName+'_pred_durationWithPause_std_lower',
  27. content: "predWithPause",
  28. className: 'prediction_std',
  29. options: {drawPoints:false}
  30. },
  31. {
  32. id: jobAgentName+'_pred_durationWithStartup_std_lower',
  33. content: "predWithStartup",
  34. className: 'prediction_std',
  35. options: {drawPoints:false}
  36. },
  37. {
  38. id: jobAgentName+'_pred_durationWithBoth_std_lower',
  39. content: "predWithBoth",
  40. className: 'prediction_std',
  41. options: {drawPoints:false}
  42. },
  43. {
  44. id: jobAgentName+'_pred_duration_std_higher',
  45. content: "prediction",
  46. className: 'prediction_std',
  47. options: {drawPoints:false}
  48. },
  49. {
  50. id: jobAgentName+'_pred_durationWithPause_std_higher',
  51. content: "predWithPause",
  52. className: 'prediction_std',
  53. options: {drawPoints:false}
  54. },
  55. {
  56. id: jobAgentName+'_pred_durationWithStartup_std_higher',
  57. content: "predWithStartup",
  58. className: 'prediction_std',
  59. options: {drawPoints:false}
  60. },
  61. {
  62. id: jobAgentName+'_pred_durationWithBoth_std_higher',
  63. content: "predWithBoth",
  64. className: 'prediction_std',
  65. options: {drawPoints:false}
  66. },{
  67. id: jobAgentName+'_pred_duration_original',
  68. content: "prediction",
  69. className: 'prediction_original'
  70. },
  71. {
  72. id: jobAgentName+'_pred_durationWithPause_original',
  73. content: "predWithPause",
  74. className: 'prediction_original'
  75. },
  76. {
  77. id: jobAgentName+'_pred_durationWithStartup_original',
  78. content: "predWithStartup",
  79. className: 'prediction_original'
  80. },
  81. {
  82. id: jobAgentName+'_pred_durationWithBoth_original',
  83. content: "predWithBoth",
  84. className: 'prediction_original'
  85. },
  86. {
  87. id: jobAgentName+'_pred_duration',
  88. content: "prediction",
  89. className: 'prediction'
  90. },
  91. {
  92. id: jobAgentName+'_pred_durationWithPause',
  93. content: "predWithPause",
  94. className: 'prediction'
  95. },
  96. {
  97. id: jobAgentName+'_pred_durationWithStartup',
  98. content: "predWithStartup",
  99. className: 'prediction'
  100. },
  101. {
  102. id: jobAgentName+'_pred_durationWithBoth',
  103. content: "predWithBoth",
  104. className: 'prediction'
  105. },
  106. {
  107. id: jobAgentName+'_duration',
  108. content: "duration",
  109. className: 'duration'
  110. },
  111. {
  112. id: jobAgentName+'_durationWithPause',
  113. content: "durationWithPause",
  114. className: 'duration'
  115. },
  116. {
  117. id: jobAgentName+'_durationWithStartup',
  118. content: "durationWithStartup",
  119. className: 'duration'
  120. },
  121. {
  122. id: jobAgentName+'_durationWithBoth',
  123. content: "durationWithBoth",
  124. className: 'duration'
  125. }
  126. ]);
  127. var visibilityUpdate = {};
  128. //visibilityUpdate[jobAgentName+'_pred'] = false;
  129. //visibilityUpdate[jobAgentName+'_predWithPause'] = false;
  130. //visibilityUpdate[jobAgentName+'_predWithStartup'] = false;
  131. //visibilityUpdate[jobAgentName+'_predWithBoth'] = false;
  132. //visibilityUpdate[jobAgentName+'_duration'] = false;
  133. //visibilityUpdate[jobAgentName+'_durationWithPause'] = false;
  134. //visibilityUpdate[jobAgentName+'_durationWithStartup'] = false;
  135. //visibilityUpdate[jobAgentName+'_durationWithBoth'] = false;
  136. graph2d.setOptions({groups:{visible:visibilityUpdate}});
  137. refreshJobs();
  138. }
  139. };
  140. JobAgentGenerator.prototype.rpcFunctions.returnJobAddress = function(params) {
  141. var instanceId = params.instanceId;
  142. var hasJob = false;
  143. for (var jobAgentName in jobList) {
  144. if (jobList.hasOwnProperty(jobAgentName)) {
  145. hasJob = jobList[jobAgentName].hasJob(instanceId);
  146. if (hasJob == true) {
  147. return jobAgentName;
  148. }
  149. }
  150. }
  151. return "doesNotExist";
  152. };
  153. JobAgentGenerator.prototype.getAllJobNames = function() {
  154. var list = [];
  155. for (var jobAgentName in jobList) {
  156. if (jobList.hasOwnProperty(jobAgentName)) {
  157. list.push(jobAgentName);
  158. }
  159. }
  160. return list;
  161. };