Package com.appspot.piment.model

Examples of com.appspot.piment.model.Job


  public void doGet(HttpServletRequest req, HttpServletResponse resp) {
  log.info("-- Job1009 start --");

  long startTime = System.currentTimeMillis();
  Job job = null;
  try {

    job = (new JobDao()).getJob(this.getClass().getName());

    job.setStatus(JobStatus.RUNNING);
    PMF.saveEntity(job);
    log.info("job's status:" + job);

    // トークン情報の削除
    AuthTokenDao authTokenDao = new AuthTokenDao();
    authTokenDao.clearTempToken(Integer.valueOf(this.configMap.get("app.piment.temptoken.lifetime")));

    UserMapDao userMapDao = new UserMapDao();
    List<UserMap> allUserMap = userMapDao.getAllUserMaps();

    // メッセージ履歴の掃除
    WeiboMapDao weiboMapDao = new WeiboMapDao();
    weiboMapDao.removeOlder(allUserMap, Integer.valueOf(this.configMap.get("app.piment.weibomap.lifetime")));

    // コメント履歴の掃除
    CommentMapDao commentMapDao = new CommentMapDao();
    commentMapDao.removeOlder(allUserMap, Integer.valueOf(this.configMap.get("app.piment.weibomap.lifetime")));

    // ジョブ状態変更
    job.setStatus(JobStatus.SUCCESSED);

  } catch (Exception e) {
    // ジョブ状態変更
    if (job != null) {
    job.setStatus(JobStatus.FAILED);
    }
    throw new RuntimeException(e);
  } finally {

    long costTime = System.currentTimeMillis() - startTime;
    if (job != null) {
    job.setLastExecuteTime(DateUtils.getSysDate());
    job.setCostTime(costTime);
    PMF.saveEntity(job);
    log.info("job's status:" + job);
    }
    log.info("-- Job1009 end [cost " + costTime + " TimeMillis]--");
  }
View Full Code Here


  super();
  }

  public Job getJob(String jobId) {

  Job result = null;

  try {
    pm = PMF.get().getPersistenceManager();

    @SuppressWarnings("unchecked")
    List<Job> jobStatusList = (List<Job>) pm.newQuery(QL_001).execute(jobId);

    if (jobStatusList == null || jobStatusList.size() == 0) {

    result = new Job();
    result.setJobId(jobId);
    result.setJobName(jobId);
    result.setStatus(JobStatus.UNKNOW);
    result.setDescription(jobId + "'s description");
    result.setLastExecuteTime(DateUtils.getSysDate(Calendar.MINUTE, -30));
    result.setCostTime(0);
    result = pm.makePersistent(result);

    } else {
    result = jobStatusList.get(0);
    }
View Full Code Here

  public void doGet(HttpServletRequest req, HttpServletResponse resp) {

  log.info("-- job1001 start --");
  long startTime = System.currentTimeMillis();
  Job job = null;
  try {

    job = (new JobDao()).getJob(this.getClass().getName());

    job.setStatus(JobStatus.RUNNING);
    PMF.saveEntity(job);
    log.info("job's status:" + job);

    JobServiceController jobService = new JobServiceController();
    jobService.run(job);

    // ジョブ状態変更
    job.setStatus(JobStatus.SUCCESSED);

  } catch (Exception e) {
    // ジョブ状態変更
    if (job != null) {
    job.setStatus(JobStatus.FAILED);
    }
    throw new RuntimeException(e);
  } finally {

    long costTime = System.currentTimeMillis() - startTime;
    if (job != null) {
    job.setLastExecuteTime(DateUtils.getSysDate());
    job.setCostTime(costTime);
    PMF.saveEntity(job);
    log.info("job's status:" + job);
    }
    log.info("-- job1001 end [cost " + costTime + " TimeMillis]--");
  }
View Full Code Here

TOP

Related Classes of com.appspot.piment.model.Job

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.