Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
Cloudstack 8612#562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Cloudstack 8612 #562
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -141,23 +141,46 @@ public List<SyncQueueItemVO> getActiveQueueItems(Long msid, boolean exclusive) { | ||
| } | ||
| @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); | ||
| pstmt.setString(1, "%" + jobCmd + "%"); | ||
| pstmt.setString(2, dateString1); | ||
| pstmt.setString(3, "%" + jobCmd + "%"); | ||
| pstmt.setString(4, dateString2); | ||
| ResultSet rs = pstmt.executeQuery(); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use try-with-resource | ||
| while(rs.next()) { | ||
| SyncQueueItemVO item = new SyncQueueItemVO(); | ||
| item.setId(rs.getLong(1)); | ||
| item.setQueueId(rs.getLong(2)); | ||
| item.setContentType(rs.getString(3)); | ||
| item.setContentId(rs.getLong(4)); | ||
| item.setLastProcessMsid(rs.getLong(5)); | ||
| item.setLastProcessNumber(rs.getLong(6)); | ||
| item.setLastProcessTime(rs.getDate(7)); | ||
| item.setCreated(rs.getDate(8)); | ||
| l.add(item); | ||
| } | ||
| } catch (SQLException e) { | ||
| s_logger.error("Unexpected sql excetpion, ", e); | ||
| } catch (Throwable e) { | ||
| s_logger.error("Unexpected excetpion, ", e); | ||
| } | ||
| return l; | ||
| } | ||
| @Override | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -308,7 +308,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | ||
| protected int _portsPerDvPortGroup; | ||
| protected boolean _fullCloneFlag = false; | ||
| protected boolean _instanceNameFlag = false; | ||
| protected int _vCenterSessionTimeout = 1200000; // Timeout in milliseconds | ||
| protected boolean _recycleHungWorker = false; | ||
| protected DiskControllerType _rootDiskController = DiskControllerType.ide; | ||
| @@ -4983,6 +4983,10 @@ public boolean configure(String name, Map<String, Object> params) throws Configu | ||
| _instanceNameFlag = false; | ||
| } | ||
| Integer sessionTimeout = (Integer) params.get("vmware.vcenter.session.timeout"); | ||
| if (sessionTimeout != null) | ||
| _vCenterSessionTimeout = sessionTimeout.intValue(); | ||
| value = (String)params.get("scripts.timeout"); | ||
| int timeout = NumbersUtil.parseInt(value, 1440) * 1000; | ||
| _storageProcessor = new VmwareStorageProcessor((VmwareHostService)this, _fullCloneFlag, (VmwareStorageMount)mgr, timeout, this, _shutdownWaitMs, null); | ||
| @@ -5035,9 +5039,16 @@ public VmwareHypervisorHost getHyperHost(VmwareContext context) { | ||
| @Override | ||
| public VmwareContext getServiceContext(Command cmd) { | ||
| VmwareContext context = null; | ||
| int vCenterSessionTimeout; | ||
| if (cmd != null && cmd.getContextParam("vCenterSessionTimeout") != null) { | ||
| vCenterSessionTimeout = NumbersUtil.parseInt(cmd.getContextParam("vCenterSessionTimeout"), 1200000); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use _vCenterSessionTimeout here? | ||
| } else { | ||
| vCenterSessionTimeout = _vCenterSessionTimeout; | ||
| } | ||
| if(s_serviceContext.get() != null) { | ||
| context = s_serviceContext.get(); | ||
| String poolKey = VmwareContextPool.composePoolKey(_vCenterAddress, _username); | ||
| String poolKey = VmwareContextPool.composePoolKey(_vCenterAddress, _username, vCenterSessionTimeout); | ||
| // Before re-using the thread local context, ensure it corresponds to the right vCenter API session and that it is valid to make calls. | ||
| if(context.getPoolKey().equals(poolKey)) { | ||
| if (context.validate()) { | ||
| @@ -5051,11 +5062,11 @@ public VmwareContext getServiceContext(Command cmd) { | ||
| } | ||
| } else { | ||
| // Exisitng ThreadLocal context corresponds to a different vCenter API session. Why has it not been recycled? | ||
| s_logger.warn("ThreadLocal VMware context: " + poolKey + " doesn't correspond to the right vCenter. Expected VMware context: " + context.getPoolKey()); | ||
| s_logger.warn("ThreadLocal VMware context: " + poolKey + ". Expected VMware context: " + context.getPoolKey()); | ||
| } | ||
| } | ||
| try { | ||
| context = VmwareContextFactory.getContext(_vCenterAddress, _username, _password); | ||
| context = VmwareContextFactory.getContext(_vCenterAddress, _username, _password, vCenterSessionTimeout); | ||
| s_serviceContext.set(context); | ||
| } catch (Exception e) { | ||
| s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use try-with-resource