Esempio n. 1
0
 private JobRequest jobToJobRequest(JobInstance job) {
   Builder builder = JobRequestImpl.builder();
   builder
       .withBaselineVirtualUsers(job.getBaselineVirtualUsers())
       .withId(Integer.toString(job.getId()))
       .withIncrementStrategy(job.getIncrementStrategy())
       .withLocation(job.getLocation())
       .withRampTime(job.getRampTime())
       .withLoggingProfile(job.getLoggingProfile())
       .withStopBehavior(job.getStopBehavior())
       .withReportingMode(job.getReportingMode())
       .withUseEips(job.isUseEips())
       .withVmInstanceType(job.getVmInstanceType())
       .withnumUsersPerAgent(job.getNumUsersPerAgent())
       .withSimulationTime(job.getSimulationTime())
       .withStatus(job.getStatus())
       .withTerminationPolicy(job.getTerminationPolicy())
       .withUserIntervalIncrement(job.getUserIntervalIncrement());
   builder.withRegions(getRegions(job));
   builder.withNofitications(getNotifications(job));
   builder.withDataFileIds(getDataFileIds(job));
   if (job.getTerminationPolicy() == TerminationPolicy.script) {
     builder.withSimulationTime(0);
   }
   Workload workload = new WorkloadDao().findById(job.getWorkloadId());
   builder.withScriptXmlUrl(buildScriptXml(Integer.toString(job.getId()), workload));
   return builder.build();
 }
Esempio n. 2
0
 /**
  * @param all
  * @return
  */
 private List<JobReportData> getJobReportData(List<JobInstance> all) {
   Set<Integer> workloadIds = new HashSet<Integer>();
   for (JobInstance job : all) {
     workloadIds.add(job.getWorkloadId());
   }
   List<Workload> workloads =
       workloadIds.isEmpty()
           ? new ArrayList<Workload>()
           : new WorkloadDao().findForIds(new ArrayList<Integer>(workloadIds));
   Map<Integer, Project> projectMap = new HashMap<Integer, Project>();
   for (Workload w : workloads) {
     projectMap.put(w.getId(), w.getProject());
   }
   List<JobReportData> ret = new ArrayList<JobReportData>();
   for (JobInstance job : all) {
     Project p = projectMap.get(job.getWorkloadId());
     String name = p != null ? p.getName() : "N/A (Project Deleted)";
     ret.add(new JobReportData(name, job));
   }
   return ret;
 }
Esempio n. 3
0
 private Set<? extends RegionRequest> getRegions(JobInstance job) {
   Set<JobRegion> ret = new HashSet<JobRegion>();
   JobRegionDao dao = new JobRegionDao();
   HashSet<VMRegion> regionSet = new HashSet<VMRegion>();
   for (EntityVersion version : job.getJobRegionVersions()) {
     JobRegion jobRegion = null;
     if (version.getObjectId() > 0 && version.getVersionId() > 0) {
       try {
         jobRegion = dao.findRevision(version.getObjectId(), version.getVersionId());
       } catch (Exception e) {
         LOG.error("Error getting region revision: " + e.toString(), e);
       }
     }
     if (jobRegion != null) {
       ret.add(fixJobRegion(jobRegion, job));
       if (regionSet.contains(jobRegion.getRegion())) {
         LOG.warn("attempt to add multiple regions to job");
       } else {
         regionSet.add(jobRegion.getRegion());
       }
     } else {
       LOG.warn(
           "Attempt to add jobRegion version that does not exist. id = "
               + version.getObjectId()
               + " : version = "
               + version.getVersionId());
       jobRegion = dao.findById(version.getObjectId());
       if (jobRegion != null) {
         ret.add(fixJobRegion(jobRegion, job));
         if (regionSet.contains(jobRegion.getRegion())) {
           LOG.warn("attempt to add multiple regions to job");
         } else {
           regionSet.add(jobRegion.getRegion());
         }
       } else {
         LOG.warn(
             "Cannot find job region with id "
                 + version.getObjectId()
                 + ". Returning current job Regions.");
         Workload workload = new WorkloadDao().findById(job.getWorkloadId());
         ret = workload.getJobConfiguration().getJobRegions();
         for (JobRegion region : ret) {
           fixJobRegion(region, job);
         }
         break;
         // throw new RuntimeException("Cannot find job region with id " + version.getObjectId());
       }
     }
   }
   ret = JobRegionDao.cleanRegions(ret);
   return ret;
 }