コード例 #1
0
 // requires synchronization between host platform and db.
 public List<Host> loadFromPlatform() {
   List<Host> hosts = adapter.getHosts();
   List<Engine> engines = adapter.bindEngineAndHost(engineService.getAllEngines(), hosts);
   _pm.beginTransaction();
   engines.stream().forEach(e -> _pm.exec(e, HibernateEngine.DB_UPDATE));
   hosts.stream().forEach(h -> _pm.exec(h, HibernateEngine.DB_UPDATE));
   _pm.commit();
   return hosts;
 }
コード例 #2
0
 public Host createHost(String name, String ip) {
   Host host = new Host();
   host.setName(name);
   host.setIp(ip);
   _pm.exec(host, HibernateEngine.DB_INSERT, true);
   return null;
 }
コード例 #3
0
 public Host updateSpeed(Host host) {
   if (host == null) return null;
   double speed =
       host.getEngineList()
           .stream()
           .map(EngineRole::getCurrentSpeed)
           .reduce((double) 0, (a, b) -> a + b);
   HostSpeedRcd speedRcd = new HostSpeedRcd();
   Date time = new Date();
   speedRcd.setHost(host);
   speedRcd.setTime(time);
   speedRcd.setSpeed(speed);
   host.getSpeedRcds().add(speedRcd);
   host.setCurrentSpeed(speed);
   host.setRecordTime(time);
   _pm.exec(speedRcd, HibernateEngine.DB_INSERT, true);
   _pm.exec(host, HibernateEngine.DB_UPDATE, true);
   return host;
 }
コード例 #4
0
 public void removeEngine(Host host, EngineRole e) throws GeneralException {
   if (e != null) {
     if (host.getEngineList().contains(e)) {
       host.getEngineList().remove(e);
       _pm.exec(host, HibernateEngine.DB_UPDATE, true);
     } else {
       throw new GeneralException("invalid engine");
     }
   }
 }
コード例 #5
0
 public void addEngine(Host host, EngineRole e) throws GeneralException {
   if (e != null) {
     if (!host.getEngineList().contains(e)) {
       host.getEngineList().add(e);
       _pm.exec(host, HibernateEngine.DB_UPDATE, true);
     } else {
       throw new GeneralException("duplicated engine");
     }
   }
 }
コード例 #6
0
 public TestPlanEntity createTestPlan(Host host, int eNum, Date endTime) {
   TestPlanEntity testPlan = new TestPlanEntity();
   testPlan.setHost(host);
   testPlan.setEngineNumber(eNum);
   testPlan.setEndTime(endTime);
   testPlan.setStartTime(new Date());
   testPlan.setTestTenant(
       tenantService.getTesterTenant(UUID.randomUUID().toString(), testPlan.getEngineNumber()));
   _pm.exec(testPlan, HibernateEngine.DB_INSERT, true);
   return testPlan;
 }
コード例 #7
0
 public void setHostCapability(long hid, int engineNum, double capability) {
   Host host = (Host) _pm.get(Host.class, hid);
   host.setCapability(engineNum, capability);
   _pm.exec(host, HibernateEngine.DB_UPDATE);
 }
コード例 #8
0
 public Host getHostById(long id) {
   return (Host) _pm.get(Host.class, id);
 }
コード例 #9
0
 @SuppressWarnings("unchecked")
 public List<Host> getAllHosts() {
   return (List<Host>) _pm.getObjectsForClass("Host");
 }
コード例 #10
0
 @SuppressWarnings("unchecked")
 public List<TestPlanEntity> getAllTestPlan() {
   return (List<TestPlanEntity>) _pm.getObjectsForClass("TestPlanEntity");
 }
コード例 #11
0
 public TestPlanEntity getTestPlanByID(long id) {
   return (TestPlanEntity) _pm.get(TestPlanEntity.class, id);
 }