cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [4/8] Complete the move of the virtualmachinemanager to cloud-engine
Date Thu, 13 Jun 2013 23:34:37 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSync.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSync.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSync.java
new file mode 100644
index 0000000..7a23ddd
--- /dev/null
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSync.java
@@ -0,0 +1,32 @@
+// 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/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
new file mode 100644
index 0000000..e76781c
--- /dev/null
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
@@ -0,0 +1,131 @@
+// 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 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, VirtualMachineManager.Topics.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/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
new file mode 100644
index 0000000..e0be62f
--- /dev/null
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
@@ -0,0 +1,88 @@
+// 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.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);
+        	
+        	if (cmd.equals(Start)) {
+                work = _vmMgr.deserialize(VmWorkStart.class, job.getCmdInfo());
+            } else {
+                work = _vmMgr.deserialize(VmWorkStop.class, 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/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
new file mode 100644
index 0000000..107009e
--- /dev/null
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
@@ -0,0 +1,120 @@
+// 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/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStop.java b/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
new file mode 100644
index 0000000..d6d226f
--- /dev/null
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
@@ -0,0 +1,34 @@
+// 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/framework/jobs/src/com/cloud/async/AsyncJobExecutionContext.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/com/cloud/async/AsyncJobExecutionContext.java b/framework/jobs/src/com/cloud/async/AsyncJobExecutionContext.java
new file mode 100644
index 0000000..0e05a98
--- /dev/null
+++ b/framework/jobs/src/com/cloud/async/AsyncJobExecutionContext.java
@@ -0,0 +1,173 @@
+// 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.async;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJobConstants;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
+import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao;
+import org.apache.cloudstack.framework.jobs.impl.AsyncJobJoinMapVO;
+import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
+import org.apache.cloudstack.framework.jobs.impl.SyncQueueItem;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.utils.component.ComponentContext;
+
+public class AsyncJobExecutionContext  {
+    private AsyncJob _job;
+	
+	@Inject private AsyncJobManager _jobMgr;
+	@Inject private AsyncJobJoinMapDao _joinMapDao;
+	
+	private static ThreadLocal<AsyncJobExecutionContext> s_currentExectionContext = new ThreadLocal<AsyncJobExecutionContext>();
+
+	public AsyncJobExecutionContext() {
+	}
+	
+    public AsyncJobExecutionContext(AsyncJob job) {
+		_job = job;
+	}
+	
+	public SyncQueueItem getSyncSource() {
+		return _job.getSyncSource();
+	}
+	
+	public void resetSyncSource() {
+		_job.setSyncSource(null);
+	}
+	
+    public AsyncJob getJob() {
+		if(_job == null) {
+			_job = _jobMgr.getPseudoJob();
+		}
+		
+		return _job;
+	}
+	
+    public void setJob(AsyncJob job) {
+		_job = job;
+	}
+	
+    public void completeAsyncJob(int jobStatus, int resultCode, Object resultObject) {
+    	assert(_job != null);
+    	_jobMgr.completeAsyncJob(_job.getId(), jobStatus, resultCode, resultObject);
+    }
+    
+    public void updateAsyncJobStatus(int processStatus, Object resultObject) {
+    	assert(_job != null);
+    	_jobMgr.updateAsyncJobStatus(_job.getId(), processStatus, resultObject);
+    }
+    
+    public void updateAsyncJobAttachment(String instanceType, Long instanceId) {
+    	assert(_job != null);
+    	_jobMgr.updateAsyncJobAttachment(_job.getId(), instanceType, instanceId);
+    }
+	
+    public void logJobJournal(AsyncJob.JournalType journalType, String journalText, String journalObjJson) {
+		assert(_job != null);
+		_jobMgr.logJobJournal(_job.getId(), journalType, journalText, journalObjJson);
+	}
+
+    public void log(Logger logger, String journalText) {
+        _jobMgr.logJobJournal(_job.getId(), AsyncJob.JournalType.SUCCESS, journalText, null);
+        logger.debug(journalText);
+    }
+
+    public void joinJob(long joinJobId) {
+    	assert(_job != null);
+    	_jobMgr.joinJob(_job.getId(), joinJobId);
+    }
+	
+    public void joinJob(long joinJobId, String wakeupHandler, String wakeupDispatcher,
+    		String[] wakeupTopcisOnMessageBus, long wakeupIntervalInMilliSeconds, long timeoutInMilliSeconds) {
+    	assert(_job != null);
+    	_jobMgr.joinJob(_job.getId(), joinJobId, wakeupHandler, wakeupDispatcher, wakeupTopcisOnMessageBus,
+    		wakeupIntervalInMilliSeconds, timeoutInMilliSeconds);
+    }
+    
+    //
+	// check failure exception before we disjoin the worker job
+	// TODO : it is ugly and this will become unnecessary after we switch to full-async mode
+	//
+    public void disjoinJob(long joinedJobId) throws InsufficientCapacityException,
+		ConcurrentOperationException, ResourceUnavailableException {
+    	assert(_job != null);
+    	
+    	AsyncJobJoinMapVO record = _joinMapDao.getJoinRecord(_job.getId(), joinedJobId);
+    	if(record.getJoinStatus() == AsyncJobConstants.STATUS_FAILED && record.getJoinResult() != null) {
+    		Object exception = JobSerializerHelper.fromObjectSerializedString(record.getJoinResult());
+    		if(exception != null && exception instanceof Exception) {
+    			if(exception instanceof InsufficientCapacityException)
+    				throw (InsufficientCapacityException)exception;
+    			else if(exception instanceof ConcurrentOperationException)
+    				throw (ConcurrentOperationException)exception;
+    			else if(exception instanceof ResourceUnavailableException)
+    				throw (ResourceUnavailableException)exception;
+    			else
+    				throw new RuntimeException((Exception)exception);
+    		}
+    	}
+    	
+    	_jobMgr.disjoinJob(_job.getId(), joinedJobId);
+    }
+    
+    public void completeJoin(int joinStatus, String joinResult) {
+    	assert(_job != null);
+    	_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
+    }
+    
+    public void completeJobAndJoin(int joinStatus, String joinResult) {
+    	assert(_job != null);
+    	_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
+    	_jobMgr.completeAsyncJob(_job.getId(), joinStatus, 0, null);
+    }
+
+	public static AsyncJobExecutionContext getCurrentExecutionContext() {
+		AsyncJobExecutionContext context = s_currentExectionContext.get();
+		if(context == null) {
+			context = new AsyncJobExecutionContext();
+			context = ComponentContext.inject(context);
+			context.getJob();
+			setCurrentExecutionContext(context);
+		}
+		
+		return context;
+	}
+	
+    public static AsyncJobExecutionContext registerPseudoExecutionContext() {
+        AsyncJobExecutionContext context = s_currentExectionContext.get();
+        if (context == null) {
+            context = new AsyncJobExecutionContext();
+            context = ComponentContext.inject(context);
+            context.getJob();
+            setCurrentExecutionContext(context);
+        }
+
+        return context;
+    }
+
+    // This is intended to be package level access for AsyncJobManagerImpl only.
+    static void setCurrentExecutionContext(AsyncJobExecutionContext currentContext) {
+		s_currentExectionContext.set(currentContext);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
----------------------------------------------------------------------
diff --git a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
index 3b0c8f0..c7a5821 100755
--- a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
+++ b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.agent.manager.allocator.impl;
@@ -19,13 +19,11 @@ package com.cloud.agent.manager.allocator.impl;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.deploy.DeploymentPlan;
@@ -40,7 +38,6 @@ import com.cloud.utils.component.AdapterBase;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Component
 @Local(value=HostAllocator.class)
 public class RandomAllocator extends AdapterBase implements HostAllocator {
     private static final Logger s_logger = Logger.getLogger(RandomAllocator.class);
@@ -55,7 +52,7 @@ public class RandomAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type,
-            ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            ExcludeList avoid, List<Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         long dcId = plan.getDataCenterId();
         Long podId = plan.getPodId();
         Long clusterId = plan.getClusterId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java b/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
deleted file mode 100755
index a75533c..0000000
--- a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
+++ /dev/null
@@ -1,86 +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.agent.manager.allocator;
-
-import java.util.List;
-
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostVO;
-import com.cloud.offering.ServiceOffering;
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-public interface HostAllocator extends Adapter {
-
-	/**
-	 * @param UserVm vm
-	 * @param ServiceOffering offering
-	 **/
-	boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
-
-	/**
-	* Determines which physical hosts are suitable to
-	* allocate the guest virtual machines on
-	* 
-	* @param VirtualMachineProfile vmProfile
-	* @param DeploymentPlan plan
-	* @param GuestType type
-	* @param ExcludeList avoid
-	* @param int returnUpTo (use -1 to return all possible hosts)
-	* @return List<Host> List of hosts that are suitable for VM allocation
-	**/
-	
-    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
-	
-    /**
-    * Determines which physical hosts are suitable to
-    * allocate the guest virtual machines on
-    * 
-    * @param VirtualMachineProfile vmProfile
-    * @param DeploymentPlan plan
-    * @param GuestType type
-    * @param ExcludeList avoid
-    * @param int returnUpTo (use -1 to return all possible hosts)
-    * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
-    * @return List<Host> List of hosts that are suitable for VM allocation
-    **/
-    
-    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
-
-    /**
-     * Determines which physical hosts are suitable to
-     * allocate the guest virtual machines on
-     *
-     * @param VirtualMachineProfile vmProfile
-     * @param DeploymentPlan plan
-     * @param GuestType type
-     * @param ExcludeList avoid
-     * @param List<HostVO> hosts
-     * @param int returnUpTo (use -1 to return all possible hosts)
-     * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
-     * @return List<Host> List of hosts that are suitable for VM allocation
-     **/
-    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<HostVO> hosts, int returnUpTo,
-            boolean considerReservedCapacity);
-
-     public static int RETURN_UPTO_ALL = -1;
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index 29ba837..bb06fd6 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -40,7 +40,6 @@ import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.host.DetailVO;
 import com.cloud.host.Host;
 import com.cloud.host.Host.Type;
-import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
 import com.cloud.offering.ServiceOffering;
@@ -121,7 +120,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         boolean hasSvcOfferingTag = hostTagOnOffering != null ? true : false;
         boolean hasTemplateTag = hostTagOnTemplate != null ? true : false;
         
-        List<HostVO> clusterHosts = new ArrayList<HostVO>();
+        List<? extends Host> clusterHosts = new ArrayList<Host>();
         
         String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
         if (haVmTag != null) {
@@ -130,8 +129,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
             if (hostTagOnOffering == null && hostTagOnTemplate == null){
                 clusterHosts = _resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId);
             } else {
-                List<HostVO> hostsMatchingOfferingTag = new ArrayList<HostVO>();
-                List<HostVO> hostsMatchingTemplateTag = new ArrayList<HostVO>();
+                List<? extends Host> hostsMatchingOfferingTag = new ArrayList<Host>();
+                List<? extends Host> hostsMatchingTemplateTag = new ArrayList<Host>();
                 if (hasSvcOfferingTag){
                     if (s_logger.isDebugEnabled()){
                         s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering);
@@ -170,9 +169,9 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         }
         
         // add all hosts that we are not considering to the avoid list
-        List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
+        List<? extends Host> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
         allhostsInCluster.removeAll(clusterHosts);
-        for (HostVO host : allhostsInCluster) {
+        for (Host host : allhostsInCluster) {
             avoid.addHost(host.getId());
         }
 
@@ -181,7 +180,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan,
-            Type type, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            Type type, ExcludeList avoid, List<Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         long dcId = plan.getDataCenterId();
         Long podId = plan.getPodId();
         Long clusterId = plan.getClusterId();
@@ -226,7 +225,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         return suitableHosts;
     }
 
-    protected List<Host> allocateTo(DeploymentPlan plan, ServiceOffering offering, VMTemplateVO template, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity, Account account) {
+    protected List<Host> allocateTo(DeploymentPlan plan, ServiceOffering offering, VMTemplateVO template, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
+            boolean considerReservedCapacity, Account account) {
         if (_allocationAlgorithm.equals("random") || _allocationAlgorithm.equals("userconcentratedpod_random")) {
         	// Shuffle this so that we don't check the hosts in the same order.
             Collections.shuffle(hosts);
@@ -252,7 +252,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         
         List<Host> suitableHosts = new ArrayList<Host>();
 
-        for (HostVO host : hosts) {
+        for (Host host : hosts) {
         	if(suitableHosts.size() == returnUpTo){
         		break;
         	}
@@ -303,7 +303,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         return suitableHosts;
     }
 
-    private List<HostVO> reorderHostsByNumberOfVms(DeploymentPlan plan, List<HostVO> hosts, Account account) {
+    private List<? extends Host> reorderHostsByNumberOfVms(DeploymentPlan plan, List<? extends Host> hosts, Account account) {
         if(account == null){
             return hosts;
         }
@@ -317,15 +317,15 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         }
         
         //now filter the given list of Hosts by this ordered list
-        Map<Long, HostVO> hostMap = new HashMap<Long, HostVO>();
-        for (HostVO host : hosts) {
+        Map<Long, Host> hostMap = new HashMap<Long, Host>();
+        for (Host host : hosts) {
             hostMap.put(host.getId(), host);
         }
         List<Long> matchingHostIds = new ArrayList<Long>(hostMap.keySet());
         
         hostIdsByVmCount.retainAll(matchingHostIds);
         
-        List<HostVO> reorderedHosts = new ArrayList<HostVO>();
+        List<Host> reorderedHosts = new ArrayList<Host>();
         for(Long id: hostIdsByVmCount){
             reorderedHosts.add(hostMap.get(id));
         }
@@ -340,7 +340,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         return true;
     }
 
-    protected List<HostVO> prioritizeHosts(VMTemplateVO template, List<HostVO> hosts) {
+    protected List<? extends Host> prioritizeHosts(VMTemplateVO template, List<? extends Host> hosts) {
     	if (template == null) {
     		return hosts;
     	}
@@ -348,13 +348,13 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
     	// Determine the guest OS category of the template
     	String templateGuestOSCategory = getTemplateGuestOSCategory(template);
     	
-    	List<HostVO> prioritizedHosts = new ArrayList<HostVO>();
-	List<HostVO> noHvmHosts = new ArrayList<HostVO>();
+        List<Host> prioritizedHosts = new ArrayList<Host>();
+        List<Host> noHvmHosts = new ArrayList<Host>();
     	
     	// If a template requires HVM and a host doesn't support HVM, remove it from consideration
-    	List<HostVO> hostsToCheck = new ArrayList<HostVO>();
+        List<Host> hostsToCheck = new ArrayList<Host>();
     	if (template.isRequiresHvm()) {
-    		for (HostVO host : hosts) {
+            for (Host host : hosts) {
     			if (hostSupportsHVM(host)) {
     				hostsToCheck.add(host);
 			} else {
@@ -372,9 +372,9 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 	}
     	// If a host is tagged with the same guest OS category as the template, move it to a high priority list
     	// If a host is tagged with a different guest OS category than the template, move it to a low priority list
-    	List<HostVO> highPriorityHosts = new ArrayList<HostVO>();
-    	List<HostVO> lowPriorityHosts = new ArrayList<HostVO>();
-    	for (HostVO host : hostsToCheck) {
+        List<Host> highPriorityHosts = new ArrayList<Host>();
+        List<Host> lowPriorityHosts = new ArrayList<Host>();
+        for (Host host : hostsToCheck) {
     		String hostGuestOSCategory = getHostGuestOSCategory(host);
     		if (hostGuestOSCategory == null) {
     			continue;
@@ -389,7 +389,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
     	hostsToCheck.removeAll(lowPriorityHosts);
     	
     	// Prioritize the remaining hosts by HVM capability
-    	for (HostVO host : hostsToCheck) {
+        for (Host host : hostsToCheck) {
     		if (!template.isRequiresHvm() && !hostSupportsHVM(host)) {
     			// Host and template both do not support hvm, put it as first consideration
     			prioritizedHosts.add(0, host);
@@ -406,7 +406,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
     	return prioritizedHosts;
     }
     
-    protected boolean hostSupportsHVM(HostVO host) {
+    protected boolean hostSupportsHVM(Host host) {
         if ( !_checkHvm ) {
             return true;
         }
@@ -425,7 +425,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 		return false;
     }
     
-    protected String getHostGuestOSCategory(HostVO host) {
+    protected String getHostGuestOSCategory(Host host) {
 		DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
 		if (hostDetail != null) {
 			String guestOSCategoryIdString = hostDetail.getValue();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
index b80dddc..042b26e 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
@@ -29,7 +29,6 @@ import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.host.Host;
-import com.cloud.host.HostVO;
 import com.cloud.host.Host.Type;
 import com.cloud.host.dao.HostDao;
 import com.cloud.offering.ServiceOffering;
@@ -53,7 +52,7 @@ public class TestingAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type,
-            ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            ExcludeList avoid, List<Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         return allocateTo(vmProfile, plan, type, avoid, returnUpTo, considerReservedCapacity);
     }
 
@@ -61,7 +60,7 @@ public class TestingAllocator extends AdapterBase implements HostAllocator {
     public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type,
             ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
         List<Host> availableHosts = new ArrayList<Host>();
-        Host host = null;    	
+        Host host = null;
         if (type == Host.Type.Routing && _routingHost != null) {
             host = _hostDao.findById(_routingHost);
         } else if (type == Host.Type.Storage && _storageHost != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/alert/AlertManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManager.java b/server/src/com/cloud/alert/AlertManager.java
deleted file mode 100755
index b6d005a..0000000
--- a/server/src/com/cloud/alert/AlertManager.java
+++ /dev/null
@@ -1,58 +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.alert;
-
-import com.cloud.capacity.CapacityVO;
-import com.cloud.utils.component.Manager;
-
-public interface AlertManager extends Manager {
-    public static final short ALERT_TYPE_MEMORY = CapacityVO.CAPACITY_TYPE_MEMORY;
-    public static final short ALERT_TYPE_CPU = CapacityVO.CAPACITY_TYPE_CPU;
-    public static final short ALERT_TYPE_STORAGE = CapacityVO.CAPACITY_TYPE_STORAGE;
-    public static final short ALERT_TYPE_STORAGE_ALLOCATED = CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED;
-    public static final short ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
-    public static final short ALERT_TYPE_PRIVATE_IP = CapacityVO.CAPACITY_TYPE_PRIVATE_IP;
-    public static final short ALERT_TYPE_SECONDARY_STORAGE = CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE;
-    public static final short ALERT_TYPE_HOST = 7;
-    public static final short ALERT_TYPE_USERVM = 8;
-    public static final short ALERT_TYPE_DOMAIN_ROUTER = 9;
-    public static final short ALERT_TYPE_CONSOLE_PROXY = 10;
-    public static final short ALERT_TYPE_ROUTING = 11; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_STORAGE_MISC = 12; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_USAGE_SERVER = 13; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_MANAGMENT_NODE = 14; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = 15;
-    public static final short ALERT_TYPE_CONSOLE_PROXY_MIGRATE = 16;
-    public static final short ALERT_TYPE_USERVM_MIGRATE = 17;
-    public static final short ALERT_TYPE_VLAN = 18;
-    public static final short ALERT_TYPE_SSVM = 19;
-    public static final short ALERT_TYPE_USAGE_SERVER_RESULT = 20; // Usage job result
-    public static final short ALERT_TYPE_STORAGE_DELETE = 21;
-    public static final short ALERT_TYPE_UPDATE_RESOURCE_COUNT = 22; // Generated when we fail to update the resource
-    // count
-    public static final short ALERT_TYPE_USAGE_SANITY_RESULT = 23;
-    public static final short ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 24;
-    public static final short ALERT_TYPE_LOCAL_STORAGE = 25;
-    public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 26; // Generated when the resource limit exceeds the limit. Currently used for recurring snapshots only
-
-
-    void clearAlert(short alertType, long dataCenterId, long podId);
-
-    void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body);
-
-    void recalculateCapacity();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/api/StringMapTypeAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/StringMapTypeAdapter.java b/server/src/com/cloud/api/StringMapTypeAdapter.java
deleted file mode 100644
index 55f4ae3..0000000
--- a/server/src/com/cloud/api/StringMapTypeAdapter.java
+++ /dev/null
@@ -1,46 +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.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;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/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
deleted file mode 100644
index 0e05a98..0000000
--- a/server/src/com/cloud/async/AsyncJobExecutionContext.java
+++ /dev/null
@@ -1,173 +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.async;
-
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.framework.jobs.AsyncJob;
-import org.apache.cloudstack.framework.jobs.AsyncJobConstants;
-import org.apache.cloudstack.framework.jobs.AsyncJobManager;
-import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao;
-import org.apache.cloudstack.framework.jobs.impl.AsyncJobJoinMapVO;
-import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
-import org.apache.cloudstack.framework.jobs.impl.SyncQueueItem;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.utils.component.ComponentContext;
-
-public class AsyncJobExecutionContext  {
-    private AsyncJob _job;
-	
-	@Inject private AsyncJobManager _jobMgr;
-	@Inject private AsyncJobJoinMapDao _joinMapDao;
-	
-	private static ThreadLocal<AsyncJobExecutionContext> s_currentExectionContext = new ThreadLocal<AsyncJobExecutionContext>();
-
-	public AsyncJobExecutionContext() {
-	}
-	
-    public AsyncJobExecutionContext(AsyncJob job) {
-		_job = job;
-	}
-	
-	public SyncQueueItem getSyncSource() {
-		return _job.getSyncSource();
-	}
-	
-	public void resetSyncSource() {
-		_job.setSyncSource(null);
-	}
-	
-    public AsyncJob getJob() {
-		if(_job == null) {
-			_job = _jobMgr.getPseudoJob();
-		}
-		
-		return _job;
-	}
-	
-    public void setJob(AsyncJob job) {
-		_job = job;
-	}
-	
-    public void completeAsyncJob(int jobStatus, int resultCode, Object resultObject) {
-    	assert(_job != null);
-    	_jobMgr.completeAsyncJob(_job.getId(), jobStatus, resultCode, resultObject);
-    }
-    
-    public void updateAsyncJobStatus(int processStatus, Object resultObject) {
-    	assert(_job != null);
-    	_jobMgr.updateAsyncJobStatus(_job.getId(), processStatus, resultObject);
-    }
-    
-    public void updateAsyncJobAttachment(String instanceType, Long instanceId) {
-    	assert(_job != null);
-    	_jobMgr.updateAsyncJobAttachment(_job.getId(), instanceType, instanceId);
-    }
-	
-    public void logJobJournal(AsyncJob.JournalType journalType, String journalText, String journalObjJson) {
-		assert(_job != null);
-		_jobMgr.logJobJournal(_job.getId(), journalType, journalText, journalObjJson);
-	}
-
-    public void log(Logger logger, String journalText) {
-        _jobMgr.logJobJournal(_job.getId(), AsyncJob.JournalType.SUCCESS, journalText, null);
-        logger.debug(journalText);
-    }
-
-    public void joinJob(long joinJobId) {
-    	assert(_job != null);
-    	_jobMgr.joinJob(_job.getId(), joinJobId);
-    }
-	
-    public void joinJob(long joinJobId, String wakeupHandler, String wakeupDispatcher,
-    		String[] wakeupTopcisOnMessageBus, long wakeupIntervalInMilliSeconds, long timeoutInMilliSeconds) {
-    	assert(_job != null);
-    	_jobMgr.joinJob(_job.getId(), joinJobId, wakeupHandler, wakeupDispatcher, wakeupTopcisOnMessageBus,
-    		wakeupIntervalInMilliSeconds, timeoutInMilliSeconds);
-    }
-    
-    //
-	// check failure exception before we disjoin the worker job
-	// TODO : it is ugly and this will become unnecessary after we switch to full-async mode
-	//
-    public void disjoinJob(long joinedJobId) throws InsufficientCapacityException,
-		ConcurrentOperationException, ResourceUnavailableException {
-    	assert(_job != null);
-    	
-    	AsyncJobJoinMapVO record = _joinMapDao.getJoinRecord(_job.getId(), joinedJobId);
-    	if(record.getJoinStatus() == AsyncJobConstants.STATUS_FAILED && record.getJoinResult() != null) {
-    		Object exception = JobSerializerHelper.fromObjectSerializedString(record.getJoinResult());
-    		if(exception != null && exception instanceof Exception) {
-    			if(exception instanceof InsufficientCapacityException)
-    				throw (InsufficientCapacityException)exception;
-    			else if(exception instanceof ConcurrentOperationException)
-    				throw (ConcurrentOperationException)exception;
-    			else if(exception instanceof ResourceUnavailableException)
-    				throw (ResourceUnavailableException)exception;
-    			else
-    				throw new RuntimeException((Exception)exception);
-    		}
-    	}
-    	
-    	_jobMgr.disjoinJob(_job.getId(), joinedJobId);
-    }
-    
-    public void completeJoin(int joinStatus, String joinResult) {
-    	assert(_job != null);
-    	_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
-    }
-    
-    public void completeJobAndJoin(int joinStatus, String joinResult) {
-    	assert(_job != null);
-    	_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
-    	_jobMgr.completeAsyncJob(_job.getId(), joinStatus, 0, null);
-    }
-
-	public static AsyncJobExecutionContext getCurrentExecutionContext() {
-		AsyncJobExecutionContext context = s_currentExectionContext.get();
-		if(context == null) {
-			context = new AsyncJobExecutionContext();
-			context = ComponentContext.inject(context);
-			context.getJob();
-			setCurrentExecutionContext(context);
-		}
-		
-		return context;
-	}
-	
-    public static AsyncJobExecutionContext registerPseudoExecutionContext() {
-        AsyncJobExecutionContext context = s_currentExectionContext.get();
-        if (context == null) {
-            context = new AsyncJobExecutionContext();
-            context = ComponentContext.inject(context);
-            context.getJob();
-            setCurrentExecutionContext(context);
-        }
-
-        return context;
-    }
-
-    // This is intended to be package level access for AsyncJobManagerImpl only.
-    static void setCurrentExecutionContext(AsyncJobExecutionContext currentContext) {
-		s_currentExectionContext.set(currentContext);
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/async/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobManagerImpl.java b/server/src/com/cloud/async/AsyncJobManagerImpl.java
index d65347c..fd6775e 100644
--- a/server/src/com/cloud/async/AsyncJobManagerImpl.java
+++ b/server/src/com/cloud/async/AsyncJobManagerImpl.java
@@ -58,7 +58,6 @@ import org.apache.cloudstack.framework.jobs.impl.SyncQueueVO;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.framework.messagebus.MessageDetector;
 import org.apache.cloudstack.framework.messagebus.PublishScope;
-import org.apache.cloudstack.messagebus.TopicConstants;
 
 import com.cloud.api.ApiSerializerHelper;
 import com.cloud.cluster.ClusterManager;
@@ -254,7 +253,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
             	    scheduleExecution(jobToWakeup, false);
             }
              
-            _messageBus.publish(null, TopicConstants.JOB_STATE, PublishScope.GLOBAL, jobId);
+            _messageBus.publish(null, AsyncJob.Topics.JOB_STATE, PublishScope.GLOBAL, jobId);
         } catch(Exception e) {
             s_logger.error("Unexpected exception while completing async job-" + jobId, e);
             txn.rollback();
@@ -511,7 +510,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
     
     private long getJobRunNumber() {
     	synchronized(this) {
-    		return this._executionRunNumber++;
+    		return _executionRunNumber++;
     	}
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/capacity/CapacityManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManager.java b/server/src/com/cloud/capacity/CapacityManager.java
index bdd9ccd..e8fdd94 100755
--- a/server/src/com/cloud/capacity/CapacityManager.java
+++ b/server/src/com/cloud/capacity/CapacityManager.java
@@ -18,6 +18,7 @@ package com.cloud.capacity;
 
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
+import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.component.Manager;
@@ -45,7 +46,7 @@ public interface CapacityManager extends Manager {
     
 	/**
      * @param pool storage pool
-     * @param templateForVmCreation template that will be used for vm creation 
+     * @param templateForVmCreation template that will be used for vm creation
      * @return total allocated capacity for the storage pool
      */
     long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation);
@@ -55,5 +56,5 @@ public interface CapacityManager extends Manager {
      * @param host the host to be checked
      * @return true if the count of host's running VMs >= hypervisor limit
      */
-    boolean checkIfHostReachMaxGuestLimit(HostVO host);
+    boolean checkIfHostReachMaxGuestLimit(Host host);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index e58ae40..840ac7b 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -27,11 +27,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.framework.messagebus.PublishScope;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -899,7 +900,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
 	}
 
     @Override
-    public boolean checkIfHostReachMaxGuestLimit(HostVO host) {
+    public boolean checkIfHostReachMaxGuestLimit(Host host) {
         Long vmCount = _vmDao.countRunningByHostId(host.getId());
         HypervisorType hypervisorType = host.getHypervisorType();
         String hypervisorVersion = host.getHypervisorVersion();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 5ee0fad..ed46793 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -160,7 +160,8 @@ public enum Config {
 	HostStatsInterval("Advanced", ManagementServer.class, Integer.class, "host.stats.interval", "60000", "The interval (in milliseconds) when host stats are retrieved from agents.", null),
 	HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null),
 	IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", null, "Defaul API port", null),
-	InvestigateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "investigate.retry.interval", "60", "Time (in seconds) between VM pings when agent is disconnected", null),
+    InvestigateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "investigate.retry.interval", "60",
+            "Time (in seconds) between VM pings when agent is disconnected", null),
 	MigrateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "migrate.retry.interval", "120", "Time (in seconds) between migration retries", null),
 	PingInterval("Advanced", AgentManager.class, Integer.class, "ping.interval", "60", "Ping interval in seconds", null),
 	PingTimeout("Advanced", AgentManager.class, Float.class, "ping.timeout", "2.5", "Multiplier to ping.interval before announcing an agent has timed out", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/configuration/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java
index 01eb679..81c96bb 100755
--- a/server/src/com/cloud/configuration/ConfigurationManager.java
+++ b/server/src/com/cloud/configuration/ConfigurationManager.java
@@ -16,7 +16,6 @@
 // under the License.
 package com.cloud.configuration;
 
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -154,22 +153,6 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
      */
     boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller);
 
-    /**
-     * Converts a comma separated list of tags to a List
-     * 
-     * @param tags
-     * @return List of tags
-     */
-    List<String> csvTagsToList(String tags);
-
-    /**
-     * Converts a List of tags to a comma separated list
-     * 
-     * @param tags
-     * @return String containing a comma separated list of tags
-     */
-    String listToCsvTags(List<String> tags);
-
     void checkZoneAccess(Account caller, DataCenter zone);
 
     void checkDiskOfferingAccess(Account caller, DiskOffering dof);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index a02327e..15f9d0f 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3217,35 +3217,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     }
 
     @Override
-    public List<String> csvTagsToList(String tags) {
-        List<String> tagsList = new ArrayList<String>();
-
-        if (tags != null) {
-            String[] tokens = tags.split(",");
-            for (int i = 0; i < tokens.length; i++) {
-                tagsList.add(tokens[i].trim());
-            }
-        }
-
-        return tagsList;
-    }
-
-    @Override
-    public String listToCsvTags(List<String> tagsList) {
-        String tags = "";
-        if (tagsList.size() > 0) {
-            for (int i = 0; i < tagsList.size(); i++) {
-                tags += tagsList.get(i);
-                if (i != tagsList.size() - 1) {
-                    tags += ",";
-                }
-            }
-        }
-
-        return tags;
-    }
-
-    @Override
     public String cleanupTags(String tags) {
         if (tags != null) {
             String[] tokens = tags.split(",");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/ha/HighAvailabilityManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManager.java b/server/src/com/cloud/ha/HighAvailabilityManager.java
deleted file mode 100644
index dd0b3e6..0000000
--- a/server/src/com/cloud/ha/HighAvailabilityManager.java
+++ /dev/null
@@ -1,114 +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.ha;
-
-import java.util.List;
-
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.utils.component.Manager;
-import com.cloud.vm.VMInstanceVO;
-
-/**
- * HighAvailabilityManager checks to make sure the VMs are running fine.
- */
-public interface HighAvailabilityManager extends Manager {
-    public enum WorkType {
-        Migration,  // Migrating VMs off of a host.
-        Stop,       // Stops a VM for storage pool migration purposes.  This should be obsolete now.
-        CheckStop,  // Checks if a VM has been stopped.
-        ForceStop,  // Force a VM to stop even if the states don't allow it.  Use this only if you know the VM is stopped on the physical hypervisor.
-        Destroy,    // Destroy a VM.
-        HA;         // Restart a VM.
-    }
-
-    enum Step {
-        Scheduled,
-        Investigating,
-        Fencing,
-        Stopping,
-        Restarting,
-        Migrating,
-        Cancelled,
-        Done,
-        Error,
-    }
-
-    /**
-     * Investigate why a host has disconnected and migrate the VMs on it
-     * if necessary.
-     * 
-     * @param host - the host that has disconnected.
-     */
-    Status investigate(long hostId);
-
-    /**
-     * Restart a vm that has gone away due to various reasons.  Whether a
-     * VM is restarted depends on various reasons.
-     *   1. Is the VM really dead.  This method will try to find out.
-     *   2. Is the VM HA enabled?  If not, the VM is simply stopped.
-     * 
-     * All VMs that enter HA mode is not allowed to be operated on until it
-     * has been determined that the VM is dead.
-     * 
-     * @param vm the vm that has gone away.
-     * @param investigate must be investigated before we do anything with this vm.
-     */
-    void scheduleRestart(VMInstanceVO vm, boolean investigate);
-
-    void cancelDestroy(VMInstanceVO vm, Long hostId);
-    
-    void scheduleDestroy(VMInstanceVO vm, long hostId);
-    
-    /**
-     * Schedule restarts for all vms running on the host.
-     * @param host host.
-     * @param investigate TODO
-     */
-    void scheduleRestartForVmsOnHost(HostVO host, boolean investigate);
-
-    /**
-     * Schedule the vm for migration.
-     * 
-     * @param vm
-     * @return true if schedule worked.
-     */
-    boolean scheduleMigration(VMInstanceVO vm);
-    
-    List<VMInstanceVO> findTakenMigrationWork();
-
-    /**
-     * Schedules a work item to stop a VM.  This method schedules a work
-     * item to do one of three things.
-     * 
-     * 1. Perform a regular stop of a VM: WorkType.Stop
-     * 2. Perform a force stop of a VM: WorkType.ForceStop
-     * 3. Check if a VM has been stopped: WorkType.CheckStop
-     * 
-     * @param vm virtual machine to stop.
-     * @param host host the virtual machine is on.
-     * @param type which type of stop is requested. 
-     */
-    void scheduleStop(VMInstanceVO vm, long hostId, WorkType type);
-
-    void cancelScheduledMigrations(HostVO host);
-
-    /**
-     * @return
-     */
-    String getHaTag();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruManager.java b/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
deleted file mode 100644
index 5249750..0000000
--- a/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
+++ /dev/null
@@ -1,27 +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.hypervisor;
-
-import com.cloud.agent.api.Command;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.component.Manager;
-
-public interface HypervisorGuruManager extends Manager {
-	HypervisorGuru getGuru(HypervisorType hypervisorType);
-    long getGuruProcessedCommandTargetHost(long hostId, Command cmd);
-}
-

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/network/rules/RulesManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManager.java b/server/src/com/cloud/network/rules/RulesManager.java
deleted file mode 100644
index 201d79d..0000000
--- a/server/src/com/cloud/network/rules/RulesManager.java
+++ /dev/null
@@ -1,66 +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.network.rules;
-
-import java.util.List;
-
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-import com.cloud.vm.Nic;
-import com.cloud.vm.VirtualMachine;
-
-/**
- * Rules Manager manages the network rules created for different networks.
- */
-public interface RulesManager extends RulesService {
-
-    boolean applyPortForwardingRulesForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    boolean applyStaticNatRulesForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    void checkRuleAndUserVm(FirewallRule rule, UserVm userVm, Account caller);
-
-    boolean revokeAllPFAndStaticNatRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException;
-
-    boolean revokeAllPFStaticNatRulesForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException;
-
-    boolean revokePortForwardingRulesForVm(long vmId);
-
-    FirewallRule[] reservePorts(IpAddress ip, String protocol, FirewallRule.Purpose purpose, boolean openFirewall, Account caller, int... ports) throws NetworkRuleConflictException;
-
-    boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    void getSystemIpAndEnableStaticNatForVm(VirtualMachine vm, boolean getNewIp) throws InsufficientAddressCapacityException;
-
-    boolean disableStaticNat(long ipAddressId, Account caller, long callerUserId, boolean releaseIpIfElastic) throws ResourceUnavailableException;
-
-    /**
-     * @param networkId
-     * @param continueOnError
-     * @param caller
-     * @param forRevoke
-     * @return
-     */
-    boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller, boolean forRevoke);
-
-    List<FirewallRuleVO> listAssociatedRulesForGuestNic(Nic nic);
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/resource/Discoverer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/Discoverer.java b/server/src/com/cloud/resource/Discoverer.java
deleted file mode 100755
index 9af7363..0000000
--- a/server/src/com/cloud/resource/Discoverer.java
+++ /dev/null
@@ -1,51 +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.resource;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.HostVO;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.utils.component.Adapter;
-
-/**
- * Discoverer encapsulates interfaces that will discover resources.
- *
- */
-public interface Discoverer extends Adapter {
-    /**
-     * Given an accessible ip address, find out what it is.
-     * 
-     * @param url
-     * @param username
-     * @param password
-     * @return ServerResource
-     */
-    Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) throws DiscoveryException;
-
-	void postDiscovery(List<HostVO> hosts, long msId)  throws DiscoveryException;
-	
-	boolean matchHypervisor(String hypervisor);
-	Hypervisor.HypervisorType getHypervisorType();
-	public void putParam(Map<String, String> params);
-	
-	ServerResource reloadResource(HostVO host);
-	
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManager.java b/server/src/com/cloud/resource/ResourceManager.java
deleted file mode 100755
index b0ab926..0000000
--- a/server/src/com/cloud/resource/ResourceManager.java
+++ /dev/null
@@ -1,153 +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.resource;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
-import com.cloud.dc.PodCluster;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostStats;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.ResourceState.Event;
-import com.cloud.service.ServiceOfferingVO;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.utils.Pair;
-import com.cloud.utils.fsm.NoTransitionException;
-
-/**
- * ResourceManager manages how physical resources are organized within the
- * CloudStack. It also manages the life cycle of the physical resources.
- */
-public interface ResourceManager extends ResourceService{
-    /**
-     * Register a listener for different types of resource life cycle events.
-     * There can only be one type of listener per type of host.
-     * 
-     * @param Event type see ResourceListener.java, allow combination of multiple events.
-     * @param listener the listener to notify.
-     */
-    public void registerResourceEvent(Integer event, ResourceListener listener);
-    
-    public void unregisterResourceEvent(ResourceListener listener);
-    
-    /**
-     * 
-     * @param name of adapter
-     * @param adapter
-     * @param hates, a list of names which will be eliminated by this adapter. Especially for the case where 
-     * can be only one adapter responds to an event, e.g. startupCommand
-     */
-    public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter);
-    
-    public void unregisterResourceStateAdapter(String name);
-    
-	public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
-	        boolean forRebalance);
-	
-	public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
-	
-	public HostVO createHostVOForConnectedAgent(StartupCommand[] cmds);
-	
-	public void checkCIDR(HostPodVO pod, DataCenterVO dc, String serverPrivateIP, String serverPrivateNetmask);
-	
-	public HostVO fillRoutingHostVO(HostVO host, StartupRoutingCommand ssCmd, HypervisorType hyType, Map<String, String> details, List<String> hostTags);
-	
-	public void deleteRoutingHost(HostVO host, boolean isForced, boolean forceDestroyStorage) throws UnableDeleteHostException;
-	
-    public boolean executeUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException;
-
-	boolean resourceStateTransitTo(Host host, Event event, long msId) throws NoTransitionException;
-
-	boolean umanageHost(long hostId);
-
-	boolean maintenanceFailed(long hostId);
-	
-	public boolean maintain(final long hostId) throws AgentUnavailableException;
-	
-    @Override
-    public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage);
-    
-    public List<HostVO> findDirectlyConnectedHosts();
-    
-    public List<HostVO> listAllUpAndEnabledHosts(Host.Type type, Long clusterId, Long podId, long dcId);
-    
-    public List<HostVO> listAllHostsInCluster(long clusterId);
-    
-    public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status);
-    
-    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Host.Type type, long dcId);
-    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
-    
-    public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);
-    
-    public List<HostVO> listAllHostsInAllZonesByType(Type type);
-    
-    public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId);
-    
-    public HostVO findHostByGuid(String guid);
-    
-    public HostVO findHostByName(String name);
-    
-    public List<HostVO> listHostsByNameLike(String name);
-    
-    /**
-     * Find a pod based on the user id, template, and data center.
-     * 
-     * @param template
-     * @param dc
-     * @param userId
-     * @return
-     */
-    Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId, Set<Long> avoids);
-    
-    HostStats getHostStatistics(long hostId);
-    
-    Long getGuestOSCategoryId(long hostId);
-    
-    String getHostTags(long hostId);
-    
-    List<PodCluster> listByDataCenter(long dcId);
-
-	List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
-
-	HypervisorType getDefaultHypervisor(long zoneId);
-
-	HypervisorType getAvailableHypervisor(long zoneId);
-
-    Discoverer getMatchingDiscover(HypervisorType hypervisorType);
-
-	List<HostVO> findHostByGuid(long dcId, String guid);
-
-    /**
-     * @param type
-     * @param clusterId
-     * @param podId
-     * @param dcId
-     * @return
-     */
-    List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/resource/ResourceStateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceStateAdapter.java b/server/src/com/cloud/resource/ResourceStateAdapter.java
deleted file mode 100755
index 68e43f3..0000000
--- a/server/src/com/cloud/resource/ResourceStateAdapter.java
+++ /dev/null
@@ -1,63 +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.resource;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.agent.api.StartupAnswer;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.exception.ConnectionException;
-import com.cloud.host.HostVO;
-import com.cloud.utils.component.Adapter;
-
-public interface ResourceStateAdapter extends Adapter {
-    static public enum Event {
-        CREATE_HOST_VO_FOR_CONNECTED,
-        CREATE_HOST_VO_FOR_DIRECT_CONNECT,
-        DELETE_HOST,
-    }
-    
-    static public class DeleteHostAnswer {
-        private boolean isContinue;
-        private boolean isException;
-        
-        public DeleteHostAnswer(boolean isContinue) {
-            this.isContinue = isContinue;
-            this.isException = false;
-        }
-        
-        public DeleteHostAnswer(boolean isContinue, boolean isException) {
-            this.isContinue = isContinue;
-            this.isException = isException;
-        }
-        
-        public boolean getIsContinue() {
-            return this.isContinue;
-        }
-        
-        public boolean getIsException() {
-            return this.isException;
-        }
-    }
-    
-    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd);
-    
-    public HostVO createHostVOForDirectConnectAgent(HostVO host, final StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags);
-    
-    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException;
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/server/src/com/cloud/vm/ReservationContextImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/ReservationContextImpl.java b/server/src/com/cloud/vm/ReservationContextImpl.java
deleted file mode 100644
index cab93b4..0000000
--- a/server/src/com/cloud/vm/ReservationContextImpl.java
+++ /dev/null
@@ -1,94 +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 com.cloud.dao.EntityManager;
-import com.cloud.domain.Domain;
-import com.cloud.domain.DomainVO;
-import com.cloud.user.Account;
-import com.cloud.user.User;
-import com.cloud.utils.Journal;
-
-public class ReservationContextImpl implements ReservationContext {
-    User _caller;
-    Account _account;
-    Domain _domain;
-    Journal _journal;
-    String _reservationId;
-    
-    public ReservationContextImpl(String reservationId, Journal journal, User caller) {
-        this(reservationId, journal, caller, null, null);
-    }
-    
-    public ReservationContextImpl(String reservationId, Journal journal, User caller, Account account) {
-        this(reservationId, journal, caller, account, null);
-        
-    }
-    
-    public ReservationContextImpl(String reservationId, Journal journal, User caller, Account account, Domain domain) {
-        _caller = caller;
-        _account = account;
-        _domain = domain;
-        _journal = journal;
-        _reservationId = reservationId;
-    }
-    
-    @Override
-    public long getDomainId() {
-        return 0;
-    }
-
-    @Override
-    public long getAccountId() {
-        return _caller.getAccountId();
-    }
-
-    @Override
-    public User getCaller() {
-        return _caller;
-    }
-
-    @Override
-    public Account getAccount() {
-        return _account;
-    }
-
-    @Override
-    public Domain getDomain() {
-        if (_domain == null) {
-            getAccount();
-            _domain = s_entityMgr.findById(DomainVO.class, _account.getDomainId());
-        }
-        return _domain;
-    }
-
-    @Override
-    public Journal getJournal() {
-        return _journal;
-    }
-
-    @Override
-    public String getReservationId() {
-        return _reservationId;
-    }
-    
-    static EntityManager s_entityMgr;
-    
-    static public void setComponents(EntityManager entityMgr) {
-        s_entityMgr = entityMgr;
-    }
-}


Mime
View raw message