http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/VirtualMachinePowerStateSync.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachinePowerStateSync.java 
b/server/src/com/cloud/vm/VirtualMachinePowerStateSync.java
deleted file mode 100644
index 7a23ddd..0000000
--- a/server/src/com/cloud/vm/VirtualMachinePowerStateSync.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-// 
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm;
-
-import java.util.Map;
-
-import com.cloud.agent.api.HostVmStateReportEntry;
-import com.cloud.vm.VirtualMachine.PowerState;
-
-public interface VirtualMachinePowerStateSync {
-       
-       void resetHostSyncState(long hostId);
-       
-       void processHostVmStateReport(long hostId, Map<String, 
HostVmStateReportEntry> report);
-       
-       // to adapt legacy ping report
-       void processHostVmStatePingReport(long hostId, Map<String, PowerState> 
report);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java 
b/server/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
deleted file mode 100644
index 9273ed0..0000000
--- a/server/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.framework.messagebus.MessageBus;
-import org.apache.cloudstack.framework.messagebus.PublishScope;
-import org.apache.cloudstack.messagebus.TopicConstants;
-
-import com.cloud.agent.api.HostVmStateReportEntry;
-import com.cloud.vm.VirtualMachine.PowerState;
-import com.cloud.vm.dao.VMInstanceDao;
-
-public class VirtualMachinePowerStateSyncImpl implements 
VirtualMachinePowerStateSync {
-    private static final Logger s_logger = 
Logger.getLogger(VirtualMachinePowerStateSyncImpl.class);
-
-    @Inject MessageBus _messageBus;
-    @Inject VMInstanceDao _instanceDao;
-    @Inject VirtualMachineManager _vmMgr;
-    
-    public VirtualMachinePowerStateSyncImpl() {
-    }
-    
-    @Override
-       public void resetHostSyncState(long hostId) {
-       s_logger.info("Reset VM power state sync for host: " + hostId);
-       _instanceDao.resetHostPowerStateTracking(hostId);
-    }
-    
-    @Override
-       public void processHostVmStateReport(long hostId, Map<String, 
HostVmStateReportEntry> report) {
-       if(s_logger.isDebugEnabled())
-               s_logger.debug("Process host VM state report from ping process. 
host: " + hostId);
-       
-       Map<Long, VirtualMachine.PowerState> translatedInfo = 
convertToInfos(report);
-       processReport(hostId, translatedInfo);
-    }
-
-    @Override
-       public void processHostVmStatePingReport(long hostId, Map<String, 
PowerState> report) {
-       if(s_logger.isDebugEnabled())
-               s_logger.debug("Process host VM state report from ping process. 
host: " + hostId);
-       
-       Map<Long, VirtualMachine.PowerState> translatedInfo = 
convertHostPingInfos(report);
-       processReport(hostId, translatedInfo);
-    }
-    
-    private void processReport(long hostId, Map<Long, 
VirtualMachine.PowerState> translatedInfo) {
-       
-       
-       for(Map.Entry<Long, VirtualMachine.PowerState> entry : 
translatedInfo.entrySet()) {
-               
-               if(s_logger.isDebugEnabled())
-                       s_logger.debug("VM state report. host: " + hostId + ", 
vm id: " + entry.getKey() + ", power state: " + entry.getValue());
-
-               if(_instanceDao.updatePowerState(entry.getKey(), hostId, 
entry.getValue())) {
-                       
-               if(s_logger.isDebugEnabled())
-                       s_logger.debug("VM state report is updated. host: " + 
hostId + ", vm id: " + entry.getKey() + ", power state: " + entry.getValue());
-                       
-                       _messageBus.publish(null, 
TopicConstants.VM_POWER_STATE, PublishScope.GLOBAL, entry.getKey());
-               }
-       }
-       
-       //
-       // TODO
-       //      1) publish missing report (if VM is missing from host report) 
for KVM/XenServer
-       //
-    }
- 
-    private Map<Long, VirtualMachine.PowerState> 
convertHostPingInfos(Map<String, PowerState> states) {
-        final HashMap<Long, VirtualMachine.PowerState> map = new HashMap<Long, 
VirtualMachine.PowerState>();
-        if (states == null) {
-            return map;
-        }
-       
-        for (Map.Entry<String, PowerState> entry : states.entrySet()) {
-               VMInstanceVO vm = findVM(entry.getKey());
-               if(vm != null) {
-                       map.put(vm.getId(), entry.getValue());
-                       break;
-               } else {
-                       s_logger.info("Unable to find matched VM in CloudStack 
DB. name: " + entry.getKey());
-               }
-        }
-
-        return map;
-    }
-           
-    private Map<Long, VirtualMachine.PowerState> convertToInfos(Map<String, 
HostVmStateReportEntry> states) {
-        final HashMap<Long, VirtualMachine.PowerState> map = new HashMap<Long, 
VirtualMachine.PowerState>();
-        if (states == null) {
-            return map;
-        }
-        
-        for (Map.Entry<String, HostVmStateReportEntry> entry : 
states.entrySet()) {
-               VMInstanceVO vm = findVM(entry.getKey());
-               if(vm != null) {
-                       map.put(vm.getId(), entry.getValue().getState());
-                       break;
-               } else {
-                       s_logger.info("Unable to find matched VM in CloudStack 
DB. name: " + entry.getKey());
-               }
-        }
-
-        return map;
-    }
-    
-    private VMInstanceVO findVM(String vmName) {
-        return _instanceDao.findVMByInstanceName(vmName);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/VmWorkJobDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VmWorkJobDispatcher.java 
b/server/src/com/cloud/vm/VmWorkJobDispatcher.java
deleted file mode 100644
index 3e6dc0b..0000000
--- a/server/src/com/cloud/vm/VmWorkJobDispatcher.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm;
-
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.framework.jobs.AsyncJob;
-import org.apache.cloudstack.framework.jobs.AsyncJobConstants;
-import org.apache.cloudstack.framework.jobs.AsyncJobDispatcher;
-import org.apache.cloudstack.framework.jobs.AsyncJobManager;
-
-import com.cloud.api.ApiSerializerHelper;
-import com.cloud.dao.EntityManager;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.dao.VMInstanceDao;
-
-public class VmWorkJobDispatcher extends AdapterBase implements 
AsyncJobDispatcher {
-    private static final Logger s_logger = 
Logger.getLogger(VmWorkJobDispatcher.class);
-
-    public static final String VM_WORK_QUEUE = "VmWorkJobQueue";
-    public static final String VM_WORK_JOB_DISPATCHER = "VmWorkJobDispatcher";
-    public static final String VM_WORK_JOB_WAKEUP_DISPATCHER = 
"VmWorkJobWakeupDispatcher";
-    public final static String Start = "start";
-    public final static String Stop = "stop";
-
-    @Inject
-    private VirtualMachineManagerImpl _vmMgr;
-       @Inject private AsyncJobManager _asyncJobMgr;
-    @Inject private AccountDao _accountDao;
-    @Inject private VMInstanceDao _instanceDao;
-    @Inject
-    private EntityManager _entityMgr;
-    
-       @Override
-    public void runJob(AsyncJob job) {
-        VmWork work = null;
-        try {
-               String cmd = job.getCmd();
-               assert(cmd != null);
-               
-            work = 
(VmWork)ApiSerializerHelper.fromSerializedString(job.getCmdInfo());
-               assert(work != null);
-               
-            CallContext.register(work.getUserId(), work.getAccountId(), 
job.getRelated());
-
-            VMInstanceVO vm = _instanceDao.findById(work.getVmId());
-            if (vm == null) {
-                s_logger.info("Unable to find vm " + work.getVmId());
-            }
-            assert(vm != null);
-    
-            if (cmd.equals(Start)) {
-                VmWorkStart start = (VmWorkStart)work;
-                _vmMgr.orchestrateStart(vm.getUuid(), start.getParams(), 
start.getPlan());
-            } else if (cmd.equals(Stop)) {
-                VmWorkStop stop = (VmWorkStop)work;
-                _vmMgr.orchestrateStop(vm.getUuid(), stop.isForceStop());
-            }
-            _asyncJobMgr.completeAsyncJob(job.getId(), 
AsyncJobConstants.STATUS_SUCCEEDED, 0, null);
-        } catch(Throwable e) {
-            s_logger.error("Unable to complete " + job, e);
-            _asyncJobMgr.completeAsyncJob(job.getId(), 
AsyncJobConstants.STATUS_FAILED, 0, e.getMessage());
-        } finally {
-            CallContext.unregister();
-        }
-       }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/VmWorkStart.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VmWorkStart.java 
b/server/src/com/cloud/vm/VmWorkStart.java
deleted file mode 100644
index 107009e..0000000
--- a/server/src/com/cloud/vm/VmWorkStart.java
+++ /dev/null
@@ -1,120 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.vm;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
-import org.apache.log4j.Logger;
-
-import com.cloud.deploy.DataCenterDeployment;
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
-import com.cloud.utils.Journal;
-
-public class VmWorkStart extends VmWork {
-    private static final Logger s_logger = Logger.getLogger(VmWorkStart.class);
-
-       long dcId;
-       Long podId;
-       Long clusterId;
-       Long hostId;
-       Long poolId;
-       ExcludeList avoids;
-       Long physicalNetworkId;
-       
-       String reservationId;
-       String journalName;
-       
-       // use serialization friendly map
-       private Map<String, String> rawParams;
-
-       public VmWorkStart() {
-       }
-
-       public DeploymentPlan getPlan() {
-               
-               if(podId != null || clusterId != null || hostId != null || 
poolId != null || physicalNetworkId != null) {
-                       // this is ugly, to work with legacy code, we need to 
re-construct the DeploymentPlan hard-codely
-                       // this has to be refactored together with migrating 
legacy code into the new way
-                       ReservationContext context = null;
-                       if(reservationId != null) {
-                       Journal journal = new Journal.LogJournal("VmWorkStart", 
s_logger);
-                               context = new 
ReservationContextImpl(reservationId, journal, 
CallContext.current().getCallingUser(), 
CallContext.current().getCallingAccount());
-                       }
-                       
-                       DeploymentPlan plan = new DataCenterDeployment(
-                                       dcId, podId, clusterId, hostId, poolId, 
physicalNetworkId, 
-                                       context);
-                       return plan;
-               }
-               
-               return null;
-       }
-
-       public void setPlan(DeploymentPlan plan) {
-               if(plan != null) {
-                       dcId = plan.getDataCenterId();
-                       podId = plan.getPodId();
-                       clusterId = plan.getClusterId();
-                       hostId = plan.getHostId();
-                       poolId = plan.getPoolId();
-                       physicalNetworkId = plan.getPhysicalNetworkId();
-                       avoids = plan.getAvoids();
-                       
-                       if(plan.getReservationContext() != null)
-                               reservationId = 
plan.getReservationContext().getReservationId();
-               }
-       }
-
-       public Map<String, String> getRawParams() {
-               return rawParams;
-       }
-
-       public void setRawParams(Map<String, String> params) {
-               this.rawParams = params;
-       }
-       
-       public Map<VirtualMachineProfile.Param, Object> getParams() {
-               Map<VirtualMachineProfile.Param, Object> map = new 
HashMap<VirtualMachineProfile.Param, Object>();
-               
-               if(rawParams != null) {
-                       // Strong-typing for VirtualMachineProfile.Param is 
really over-kill, have to deal with it anyway
-                       for(Map.Entry<String, String> entry : 
rawParams.entrySet()) {
-                               VirtualMachineProfile.Param key = new 
VirtualMachineProfile.Param(entry.getKey());
-                               Object val = 
JobSerializerHelper.fromObjectSerializedString(entry.getValue());
-                               map.put(key, val);
-                       }
-               }
-               
-               return map;
-       }
-       
-       public void setParams( Map<VirtualMachineProfile.Param, Object> params) 
{
-               if(params != null) {
-                       rawParams = new HashMap<String, String>();
-                       for(Map.Entry<VirtualMachineProfile.Param, Object> 
entry : params.entrySet()) {
-                               rawParams.put(entry.getKey().getName(), 
JobSerializerHelper.toObjectSerializedString(
-                                       entry.getValue() instanceof 
Serializable ? (Serializable)entry.getValue() : entry.getValue().toString()));
-                       }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/VmWorkStop.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VmWorkStop.java 
b/server/src/com/cloud/vm/VmWorkStop.java
deleted file mode 100644
index d6d226f..0000000
--- a/server/src/com/cloud/vm/VmWorkStop.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm;
-
-public class VmWorkStop extends VmWork {
-
-       private boolean forceStop;
-       
-       public VmWorkStop() {
-               forceStop = false;
-       }
-       
-       public void setForceStop(boolean value) {
-               forceStop = value;
-       }
-       
-       public boolean isForceStop() {
-               return forceStop;
-       }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/snapshot/VMSnapshotManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManager.java 
b/server/src/com/cloud/vm/snapshot/VMSnapshotManager.java
deleted file mode 100644
index c609005..0000000
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManager.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.vm.snapshot;
-
-import com.cloud.utils.component.Manager;
-import com.cloud.vm.VMInstanceVO;
-
-public interface VMSnapshotManager extends VMSnapshotService, Manager {
-    public static final int VMSNAPSHOTMAX = 10;
-
-    
-    /**
-     * Delete all VM snapshots belonging to one VM
-     * @param id, VM id
-     * @param type, 
-     * @return true for success, false for failure
-     */
-    boolean deleteAllVMSnapshots(long id, VMSnapshot.Type type);
-
-    /**
-     * Sync VM snapshot state when VM snapshot in reverting or snapshoting or 
expunging state
-     * Used for fullsync after agent connects
-     * 
-     * @param vm, the VM in question
-     * @param hostId
-     * @return true if succeeds, false if fails
-     */
-    boolean syncVMSnapshot(VMInstanceVO vm, Long hostId);
-
-    boolean hasActiveVMSnapshotTasks(Long vmId);
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/org/apache/cloudstack/messagebus/TopicConstants.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/messagebus/TopicConstants.java 
b/server/src/org/apache/cloudstack/messagebus/TopicConstants.java
deleted file mode 100644
index 6f465f4..0000000
--- a/server/src/org/apache/cloudstack/messagebus/TopicConstants.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.messagebus;
-
-public interface TopicConstants {
-       // VM power state messages on message bus
-       public static final String VM_POWER_STATE = "vm.powerstate";    // args 
<Long> vmid
-       
-       // job messages on message bus 
-       public static final String JOB_HEARTBEAT = "job.heartbeat";             
// args <Long> jobid
-       public static final String JOB_STATE = "job.state";                     
        // args <Long> jobid
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/utils/src/com/cloud/api/StringMapTypeAdapter.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/api/StringMapTypeAdapter.java 
b/utils/src/com/cloud/api/StringMapTypeAdapter.java
new file mode 100644
index 0000000..55f4ae3
--- /dev/null
+++ b/utils/src/com/cloud/api/StringMapTypeAdapter.java
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+
+@SuppressWarnings("rawtypes")
+public class StringMapTypeAdapter implements JsonDeserializer<Map> {
+    @Override
+    
+    public Map deserialize(JsonElement src, Type srcType,
+            JsonDeserializationContext context) throws JsonParseException {
+
+        Map<String, String> obj = new HashMap<String, String>();
+        JsonObject json = src.getAsJsonObject();
+        
+        for(Entry<String, JsonElement> entry : json.entrySet()) {
+            obj.put(entry.getKey(), entry.getValue().getAsString());
+        }
+        
+        return obj;
+    }
+}

Reply via email to