Add no-args constructor for ClusterSyncCommand/ClusterSyncAnswer

Otherwise they can't be deserialized.

Fix the following exception on KVM host:

ERROR [agent.transport.Request] (Agent-Handler-2:null)
Caught problem with
[{"ClusterSyncCommand":{"_interval":60,"_skipSteps":20,"_steps":0,"_clusterId":2,"contextMap":{},"wait":0}}]
com.google.gson.JsonParseException: The JsonDeserializer
com.cloud.agent.transport.ArrayTypeAdaptor@44ed904 failed to deserialized json
object
[{"ClusterSyncCommand":{"_interval":60,"_skipSteps":20,"_steps":0,"_clusterId":2,"contextMap":{},"wait":0}}]
given the type class [Lcom.cloud.agent.api.Command;
...
Caused by: java.lang.RuntimeException: No-args constructor for class
com.cloud.agent.api.ClusterSyncCommand does not exist. Register an
InstanceCreator with Gson for this type to fix this problem.
        at
com.google.gson.MappedObjectConstructor.constructWithNoArgConstructor(MappedObjectConstructor.java:64)
...
This commit is contained in:
Sheng Yang 2011-09-29 12:17:45 -07:00
parent b8f8989821
commit ae52867be4
2 changed files with 4 additions and 0 deletions

View File

@ -31,6 +31,8 @@ public class ClusterSyncAnswer extends Answer {
public static final int FULL_SYNC=0;
public static final int DELTA_SYNC=1;
public ClusterSyncAnswer() {
}
public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, State>> newStates, int type){
_clusterId = clusterId;

View File

@ -28,6 +28,8 @@ public class ClusterSyncCommand extends Command implements CronCommand {
long _clusterId;
public ClusterSyncCommand() {
}
public ClusterSyncCommand(int interval, int skipSteps, long clusterId){
_interval = interval;