Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/562#discussion_r34351937
  
    --- Diff: 
framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
 ---
    @@ -141,23 +141,46 @@ public int getActiveQueueItemCount(long queueId) {
         }
     
         @Override
    -    public List<SyncQueueItemVO> getBlockedQueueItems(long thresholdMs, 
boolean exclusive) {
    +    public List<SyncQueueItemVO> getBlockedQueueItems(long thresholdMs, 
long snapshotThresholdMs, String jobCmd, boolean exclusive) {
             Date cutTime = DateUtil.currentGMTTime();
    +        List<SyncQueueItemVO> l = new ArrayList<SyncQueueItemVO>();
     
    -        SearchBuilder<SyncQueueItemVO> sbItem = createSearchBuilder();
    -        sbItem.and("lastProcessMsid", 
sbItem.entity().getLastProcessMsid(), SearchCriteria.Op.NNULL);
    -        sbItem.and("lastProcessNumber", 
sbItem.entity().getLastProcessNumber(), SearchCriteria.Op.NNULL);
    -        sbItem.and("lastProcessTime", 
sbItem.entity().getLastProcessTime(), SearchCriteria.Op.NNULL);
    -        sbItem.and("lastProcessTime2", 
sbItem.entity().getLastProcessTime(), SearchCriteria.Op.LT);
    -
    -        sbItem.done();
    +        Date date1 = new Date(cutTime.getTime() - thresholdMs);
    +        String  dateString1 = 
DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), date1);
     
    -        SearchCriteria<SyncQueueItemVO> sc = sbItem.create();
    -        sc.setParameters("lastProcessTime2", new Date(cutTime.getTime() - 
thresholdMs));
    +        Date date2 = new Date(cutTime.getTime() - snapshotThresholdMs);
    +        String  dateString2 = 
DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), date2);
     
    -        if(exclusive)
    -            return lockRows(sc, null, true);
    -        return listBy(sc, null);
    +        String sql = "SELECT s.id, s.queue_id, s.content_type, 
s.content_id, s.queue_proc_msid, s.queue_proc_number, s.queue_proc_time, 
s.created FROM sync_queue_item AS s " +
    +                "JOIN async_job as a ON s.content_id = a.id WHERE 
s.queue_proc_msid IS NOT NULL AND s.queue_proc_number IS NOT NULL AND 
s.queue_proc_time IS NOT NULL" +
    +                " AND ((a.job_cmd NOT LIKE ? AND s.queue_proc_time < ? ) 
OR (a.job_cmd LIKE ? AND s.queue_proc_time < ?))";
    +        TransactionLegacy txn = TransactionLegacy.currentTxn();
    +        PreparedStatement pstmt = null;
    +        try {
    +            pstmt = txn.prepareAutoCloseStatement(sql);
    --- End diff --
    
    please use try-with-resource


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to