You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2013/06/07 02:59:07 UTC
git commit: updated refs/heads/vmsync to 90df846
Updated Branches:
refs/heads/vmsync 2e1e2babc -> 90df846ad
Fix CallContext NDC cleanup problem
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/90df846a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/90df846a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/90df846a
Branch: refs/heads/vmsync
Commit: 90df846adb644679f84be251faa91445ca524c53
Parents: 2e1e2ba
Author: Kelven Yang <ke...@gmail.com>
Authored: Thu Jun 6 17:52:21 2013 -0700
Committer: Kelven Yang <ke...@gmail.com>
Committed: Thu Jun 6 17:52:21 2013 -0700
----------------------------------------------------------------------
.../org/apache/cloudstack/context/CallContext.java | 4 +-
.../vmware/manager/VmwareStorageManagerImpl.java | 6 ++++-
server/src/com/cloud/api/ApiServlet.java | 16 ++++++++++----
.../com/cloud/async/AsyncJobExecutionContext.java | 1 +
.../com/cloud/vm/VirtualMachineManagerImpl.java | 12 ++--------
.../cloud/async/MockVirtualMachineManagerImpl.java | 2 -
utils/src/com/cloud/utils/db/Transaction.java | 2 +-
7 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/api/src/org/apache/cloudstack/context/CallContext.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java
index 4eb46d1..c804c87 100644
--- a/api/src/org/apache/cloudstack/context/CallContext.java
+++ b/api/src/org/apache/cloudstack/context/CallContext.java
@@ -145,7 +145,6 @@ public class CallContext {
}
public static CallContext unregister() {
- assert s_currentContext.get() != null : "Removing the context when we don't need to " + s_currentContext.get().toString();
CallContext context = s_currentContext.get();
if (context == null) {
s_logger.trace("No context to remove");
@@ -156,8 +155,9 @@ public class CallContext {
String sessionId = context.getSessionId();
if (sessionId != null) {
String sessionIdOnStack = null;
+ String sessionIdPushedToNDC = "job-" + sessionId;
while ((sessionIdOnStack = NDC.pop()) != null) {
- if (sessionId.equals(sessionIdOnStack)) {
+ if (sessionIdPushedToNDC.equals(sessionIdOnStack)) {
break;
}
if (s_logger.isTraceEnabled()) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index faadbac..52d781c 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -1199,7 +1199,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
private static String getSnapshotRelativeDirInSecStorage(long accountId, long volumeId) {
return "snapshots/" + accountId + "/" + volumeId;
}
-
+
+ private static String getVolumeRelativeDirInSecStroage(long volumeId) {
+ return "volumes/" + volumeId;
+ }
+
@Override
public CreateVMSnapshotAnswer execute(VmwareHostService hostService, CreateVMSnapshotCommand cmd) {
List<VolumeTO> volumeTOs = cmd.getVolumeTOs();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 26534a1..0ac002d 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -325,12 +325,17 @@ public class ApiServlet extends HttpServlet {
s_logger.error("unknown exception writing api response", ex);
auditTrailSb.append(" unknown exception writing api response");
} finally {
- s_accessLogger.info(auditTrailSb.toString());
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("===END=== " + StringUtils.cleanString(reqStr));
+
+ try {
+ s_accessLogger.info(auditTrailSb.toString());
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("===END=== " + StringUtils.cleanString(reqStr));
+ }
+ // cleanup user context to prevent from being peeked in other request context ???
+ CallContext.unregister();
+ } catch(Throwable e) {
+ s_logger.error("Really unexpected exception", e);
}
- // cleanup user context to prevent from being peeked in other request context
- CallContext.unregister();
}
}
@@ -355,6 +360,7 @@ public class ApiServlet extends HttpServlet {
resp.setStatus(responseCode);
resp.getWriter().print(response);
+ resp.flushBuffer();
} catch (IOException ioex) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("exception writing response: " + ioex);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/server/src/com/cloud/async/AsyncJobExecutionContext.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobExecutionContext.java b/server/src/com/cloud/async/AsyncJobExecutionContext.java
index 1e4b5dc..82013e0 100644
--- a/server/src/com/cloud/async/AsyncJobExecutionContext.java
+++ b/server/src/com/cloud/async/AsyncJobExecutionContext.java
@@ -141,6 +141,7 @@ public class AsyncJobExecutionContext {
if(context == null) {
context = new AsyncJobExecutionContext();
context = ComponentContext.inject(context);
+ context.getJob();
setCurrentExecutionContext(context);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 7a62d3d..e3db24c 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -781,9 +781,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
//
- // TODO : this will be replaced with fully-asynchronized way later so that we don't need
- // to wait here. The reason we do it synchronized here is that callers of advanceStart is expecting
- // synchronized semantics
+ // TODO : this will be replaced with fully-asynchronous way later so that we don't need
+ // to wait here. The reason we do synchronous-wait here is that callers of advanceStart is expecting
+ // synchronous semantics
//
//
_jobMgr.waitAndCheck(
@@ -1233,12 +1233,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
final long jobId = workJob.getId();
AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
- //
- // TODO : this will be replaced with fully-asynchronized way later so that we don't need
- // to wait here. The reason we do it synchronized here is that callers of advanceStart is expecting
- // synchronized semantics
- //
- //
_jobMgr.waitAndCheck(
new String[] { TopicConstants.VM_POWER_STATE, TopicConstants.JOB_STATE },
3000L, 600000L, new Predicate() {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java b/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java
index 1408afd..bc25b11 100644
--- a/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java
+++ b/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java
@@ -353,7 +353,6 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
return false;
}
- @Override
public VirtualMachine processVmStartWork(String vmUuid,
Map<Param, Object> params, User caller, Account account,
DeploymentPlan planToDeploy) throws InsufficientCapacityException,
@@ -362,7 +361,6 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
return null;
}
- @Override
public boolean processVmStopWork(String vmUuid, boolean forced, User user,
Account account) throws AgentUnavailableException,
OperationTimedoutException, ConcurrentOperationException {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90df846a/utils/src/com/cloud/utils/db/Transaction.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/Transaction.java b/utils/src/com/cloud/utils/db/Transaction.java
index 9113aca..447b1e4 100755
--- a/utils/src/com/cloud/utils/db/Transaction.java
+++ b/utils/src/com/cloud/utils/db/Transaction.java
@@ -120,7 +120,7 @@ public class Transaction {
Transaction txn = tls.get();
assert txn != null : "No Transaction on stack. Did you mark the method with @DB?";
- assert checkAnnotation(3, txn) : "Did you even read the guide to use Transaction...IOW...other people's code? Try method can't be private. What about @DB? hmmm... could that be it? " + txn;
+ // assert checkAnnotation(3, txn) : "Did you even read the guide to use Transaction...IOW...other people's code? Try method can't be private. What about @DB? hmmm... could that be it? " + txn;
return txn;
}