public void stopGoal() { if(this.exe!=null) { this.exe.stop(); // Add instrumentation stats (if any) exe.addGoalStats("test", InstrumentationControl.getOverallStatistics()); final List<IInstrumentor> instrumentorList = InstrumentorFactory.getInstrumentors(); final Iterator<IInstrumentor> iter = instrumentorList.iterator(); while(iter.hasNext()){ final IInstrumentor i = iter.next(); exe.addGoalStats("test." + i.getClass().getSimpleName(), i.getStatistics()); } this.exe.upload(); } }
/** * Calls {@link AbstractGoal#executeSync()} for all goals that have been added to the sequence. */ @Override protected void executeTasks() throws Exception { int i = 0; for(AbstractGoal g: this.sequence) { g.executeSync(); this.progress = (double)++i / (double)this.sequence.size(); } }
public String toString() { final StringBuffer b = new StringBuffer(); b.append("Goal [id=").append(this.getId()).append(", type=").append(this.getGoalType()); if(this.goalContext!=null) b.append(", ctx=").append(this.goalContext.toString()); b.append("]"); return b.toString(); }
private final void execute() throws GoalConfigurationException, GoalExecutionException { // Execute the goal and measure execution time try { this.start(); this.executeTasks(); this.stop(); } // Throw as is catch(GoalConfigurationException gce) { this.stop(gce); this.skipGoalUpload(); // Do not upload in case of configuration problems throw gce; } // Throw as is catch(GoalExecutionException gee) { this.stop(gee); throw gee; } // Embedd in GoalExecutionException catch(Exception e) { this.stop(e); throw new GoalExecutionException(e); } finally { if(this.goalUploadEnabled) this.upload(); } }
/** * Starts the goal execution. */ public void start() throws GoalConfigurationException { // Start time taking this.stopWatch = new StopWatch(this.toString()).start(); // Monitor mem consumption? if(this.memoThread!=null) { final Thread t = new Thread(this.memoThread, "vulas-memo"); t.setPriority(Thread.MIN_PRIORITY); t.start(); } // Prepare the execution this.prepareExecution(); // Check whether all conditions to execute the tasks are met this.checkPreconditions(); this.stopWatch.lap("Completed goal preparation", false); }
/** * Stops the goal execution, i.e., takes the time and stops the monitoring thread (if any). */ public void stop() { // Already stopped? if(!this.stopWatch.isRunning()) throw new IllegalStateException("Goal execution already finished"); // Stop! else { this.stopMemo(); this.stopWatch.lap("Completed execution", true); this.cleanAfterExecution(); this.stopWatch.lap("Completed clean-up", false); this.stopWatch.stop(); this.notifyObserver(); } }
public void addGoalStats(String _key, long _val) { this.addGoalStats(_key, (double)_val); }
b.append("{\"executionId\":\"").append(this.getId()).append("\""); b.append(",\"goal\":\"").append(this.goalType).append("\""); b.append(",\"startedAtClient\":\"").append(StringUtil.formatDate(this.stopWatch.getStartMillis())).append("\""); final Iterator<String> iter = this.getConfiguration().getConfiguration().subset("vulas").getKeys(); while(iter.hasNext()) { final String key = iter.next(); final String[] value = this.getConfiguration().getConfiguration().getStringArray("vulas." + key); if(c++>0) b.append(","); b.append("{\"source\":\"GOAL_CONFIG\",\"name\":").append(JsonBuilder.escape(key)).append(",\"value\":").append(JsonBuilder.escape(StringUtil.join(value, ","))).append("}");
final BasicHttpRequest cond_req = new BasicHttpRequest(HttpMethod.OPTIONS, PathBuilder.goalExcecution(null, _ctx.getSpace(), app, _gexe.getId()), null); cond_req.setGoalContext(_ctx); .addCondition(new StatusCondition(HttpURLConnection.HTTP_NOT_FOUND)) .setGoalContext(_ctx) .setPayload(_gexe.toJson(), null, false) ); req_list.addRequest( new ConditionalHttpRequest(HttpMethod.PUT, PathBuilder.goalExcecution(null, _ctx.getSpace(), app, _gexe.getId()), params) .setConditionRequest(cond_req) .addCondition(new StatusCondition(HttpURLConnection.HTTP_OK)) .setGoalContext(_ctx) .setPayload(_gexe.toJson(), null, false) ); BackendConnector.log.info("App " + _ctx.getApplication() + " does not exist in backend, upload of goal execution [" + _gexe.getId() + "] skipped"); ret = true;
/** * Creates a {@link AbstractGoal} for the given {@link GoalType} and (@link GoalClient}. * @param _type */ public static AbstractGoal create(@NotNull GoalType _type, @NotNull GoalClient _client) throws IllegalStateException, IllegalArgumentException { final AbstractGoal goal = GoalFactory.create(_type); goal.setGoalClient(_client); return goal; } }
json.append("\"app\":").append(JacksonUtil.asJsonString(app_ctx)).append(","); json.append("\"bug\":\"").append(bugid).append("\","); json.append("\"executionId\":\"").append(exe.getId()).append("\","); json.append("\"source\":\"").append(PathSource.X2C).append("\","); json.append("\"path\":[");
public void startGoal() throws GoalConfigurationException { if(this.exe!=null) this.exe.start(); }
public final void executeSync() throws GoalConfigurationException, GoalExecutionException { this.execute(); }
public void addGoalStats(String _key, int _val) { this.addGoalStats(_key, (double)_val); }
public ExecutionMonitor() { try { final Application app_ctx = CoreConfiguration.getAppContext(); final Configuration cfg = VulasConfiguration.getGlobal().getConfiguration(); // Always create and register shutdown uploader this.shutdownUploader = new UploadScheduler(this); Runtime.getRuntime().addShutdownHook(new Thread(this.shutdownUploader, "vulas-shutdown-trace-upload")); // Configure uploader: Create and start periodic uploader according to configuration if(cfg.getBoolean(CoreConfiguration.MONI_PERIODIC_UPL_ENABLED, true)) this.enablePeriodicUpload(cfg.getInt(CoreConfiguration.MONI_PERIODIC_UPL_INTERVAL, 300000), cfg.getInt(CoreConfiguration.MONI_PERIODIC_UPL_BATCH_SIZE, 1000)); // Goal execution this.exe = new TestGoal(); this.exe.setGoalClient(GoalClient.AGENT); this.startGoal(); } catch(ConfigurationException ce) { ExecutionMonitor.getLog().error(ce.getMessage()); } catch(GoalConfigurationException gce) { ExecutionMonitor.getLog().error(gce.getMessage()); } }
u.setExecutionId(this.exe.getId());
public final void run() { try { this.execute(); } catch (GoalConfigurationException e) { log.error("Error while configuring " + this + ": " + e.getMessage(), e); } catch (GoalExecutionException e) { log.error("Error while executing " + this + ": " + e.getMessage(), e); } }
public void addGoalStats(String _prefix, Map<String,Long> _stats) { for(Map.Entry<String, Long> entry : _stats.entrySet()) { this.addGoalStats( (_prefix==null || _prefix.equals("") ? entry.getKey() : _prefix + "." + entry.getKey()) , entry.getValue()); } }