コード例 #1
0
  @GET
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  @XmlElementWrapper(name = "memorystats")
  @Path("/interval/{timeWindowsInHours}")
  public List<Memory> loadMemoryStatusInInterval(
      @PathParam("timeWindowsInHours") int timeWindowsInHours) {
    Calendar calendar = Calendar.getInstance();
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    String toDate = df.format(calendar.getTime());
    calendar.add(Calendar.HOUR_OF_DAY, -timeWindowsInHours);
    String fromDate = df.format(calendar.getTime());
    Log.trace(toDate, fromDate);
    List<Memory> memorystats = null;
    try {
      IMemoryDAO mdao = DAOFactory.getInstance().getMemoryDAO();
      List<MemoryPO> memPOs = mdao.getMemoryStats(toDate, fromDate);

      memorystats = new ArrayList<Memory>();
      for (MemoryPO memPO : memPOs) {
        Memory memdto = ConverterUtils.convert(memPO);
        memorystats.add(memdto);
      }
    } catch (Exception e) {
      handleException(e);
    } finally {
      Log.exit(memorystats);
    }
    return memorystats;
  }
コード例 #2
0
 @DELETE
 public void deleteMemoryCrumb() {
   IMemoryDAO mdao = DAOFactory.getInstance().getMemoryDAO();
   mdao.deleteMemoryCrumbData();
   Log.trace("Memory Crumb cleared");
 }