cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [8/9] git commit: updated refs/heads/vmsync to 309f8da
Date Tue, 18 Jun 2013 00:24:53 GMT
fixes null pointer


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6adf7618
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6adf7618
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6adf7618

Branch: refs/heads/vmsync
Commit: 6adf761848d2844fa6ecd391585e87d201658348
Parents: fa525a7
Author: Alex Huang <alex.huang@gmail.com>
Authored: Mon Jun 17 16:06:04 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Mon Jun 17 17:25:01 2013 -0700

----------------------------------------------------------------------
 .../cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java  |  9 +++++----
 .../cloudstack/framework/jobs/impl/AsyncJobVO.java      |  2 ++
 utils/src/com/cloud/utils/db/GenericDaoBase.java        | 12 ++++++++++--
 utils/src/org/apache/cloudstack/config/ConfigValue.java |  5 +++--
 4 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6adf7618/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
index 96775f7..9b1eda6 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
@@ -161,7 +161,7 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
 	public List<AsyncJobVO> getExpiredUnfinishedJobs(Date cutTime, int limit) {
 		SearchCriteria<AsyncJobVO> sc = expiringUnfinishedAsyncJobSearch.create();
 		sc.setParameters("created", cutTime);
-		sc.setParameters("jobStatus", 0);
+        sc.setParameters("jobStatus", JobInfo.Status.IN_PROGRESS);
 		Filter filter = new Filter(AsyncJobVO.class, "created", true, 0L, (long)limit);
 		return listIncludingRemovedBy(sc, filter);
 	}
@@ -170,7 +170,7 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
 	public List<AsyncJobVO> getExpiredCompletedJobs(Date cutTime, int limit) {
 		SearchCriteria<AsyncJobVO> sc = expiringCompletedAsyncJobSearch.create();
 		sc.setParameters("created", cutTime);
-		sc.setParameters("jobStatus", 0);
+        sc.setParameters("jobStatus", JobInfo.Status.IN_PROGRESS);
 		Filter filter = new Filter(AsyncJobVO.class, "created", true, 0L, (long)limit);
 		return listIncludingRemovedBy(sc, filter);
 	}
@@ -178,8 +178,9 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
 	@Override
     @DB
 	public void resetJobProcess(long msid, int jobResultCode, String jobResultMessage) {
-		String sql = "UPDATE async_job SET job_status=" + JobInfo.Status.FAILED + ", job_result_code="
+ jobResultCode
-			+ ", job_result='" + jobResultMessage + "' where job_status=0 AND (job_complete_msid=?
OR (job_complete_msid IS NULL AND job_init_msid=?))";
+        String sql = "UPDATE async_job SET job_status=" + JobInfo.Status.FAILED.ordinal()
+ ", job_result_code=" + jobResultCode
+                + ", job_result='" + jobResultMessage + "' where job_status=" + JobInfo.Status.IN_PROGRESS.ordinal()
+                + " AND (job_complete_msid=? OR (job_complete_msid IS NULL AND job_init_msid=?))";
 		
         Transaction txn = Transaction.currentTxn();
         PreparedStatement pstmt = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6adf7618/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
index cab047b..89bbd86 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
@@ -133,6 +133,7 @@ public class AsyncJobVO implements AsyncJob, JobInfo {
     public AsyncJobVO() {
         uuid = UUID.randomUUID().toString();
         related = UUID.randomUUID().toString();
+        status = Status.IN_PROGRESS;
     }
 
     public AsyncJobVO(String related, long userId, long accountId, String cmd, String cmdInfo,
Long instanceId, String instanceType) {
@@ -144,6 +145,7 @@ public class AsyncJobVO implements AsyncJob, JobInfo {
         this.related = related;
 	    this.instanceId = instanceId;
 	    this.instanceType = instanceType;
+        status = Status.IN_PROGRESS;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6adf7618/utils/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java
index 9e91ef6..f593c38 100755
--- a/utils/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java
@@ -1485,7 +1485,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable>
extends Compone
             if (type == EnumType.STRING) {
                 pstmt.setString(j, value == null ? null :  value.toString());
             } else if (type == EnumType.ORDINAL) {
-                pstmt.setInt(j, value == null ? null : ((Enum<?>)value).ordinal());
+                if (value == null) {
+                    pstmt.setObject(j, null);
+                } else {
+                    pstmt.setInt(j, ((Enum<?>)value).ordinal());
+                }
             }
         } else if (attr.field.getType() == URI.class) {
             pstmt.setString(j, value == null ? null : value.toString());
@@ -1499,7 +1503,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable>
extends Compone
             if (type == EnumType.STRING) {
                 pstmt.setString(j, value == null ? null : value.toString());
             } else if (type == EnumType.ORDINAL) {
-                pstmt.setLong(j, value == null ? null : (value instanceof Ip) ? ((Ip)value).longValue()
: NetUtils.ip2Long((String)value));
+                if (value == null) {
+                    pstmt.setObject(j, null);
+                } else {
+                    pstmt.setLong(j, (value instanceof Ip) ? ((Ip)value).longValue() : NetUtils.ip2Long((String)value));
+                }
             }
         } else {
             pstmt.setObject(j, value);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6adf7618/utils/src/org/apache/cloudstack/config/ConfigValue.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/config/ConfigValue.java b/utils/src/org/apache/cloudstack/config/ConfigValue.java
index 36ff38a..013b835 100644
--- a/utils/src/org/apache/cloudstack/config/ConfigValue.java
+++ b/utils/src/org/apache/cloudstack/config/ConfigValue.java
@@ -49,7 +49,7 @@ public class ConfigValue<T> {
 
     @SuppressWarnings("unchecked")
     public T value() {
-        if (_config.isDynamic()) {
+        if (_value == null || _config.isDynamic()) {
             Configuration vo = _entityMgr.findById(Configuration.class, _config.key());
             String value = vo != null ? vo.getValue() : _config.defaultValue();
 
@@ -66,8 +66,9 @@ public class ConfigValue<T> {
                 _value = (T)value;
             } else if (type.isAssignableFrom(Float.class)) {
                 _value = (T)new Float(Float.parseFloat(value) * _multiplier.floatValue());
+            } else {
+                throw new CloudRuntimeException("Unsupported data type for config values:
" + type);
             }
-            throw new CloudRuntimeException("Unsupported data type for config values: " +
type);
         }
 
         return _value;


Mime
View raw message