diff --git a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java
new file mode 100644
index 00000000000..858acb46439
--- /dev/null
+++ b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java
@@ -0,0 +1,54 @@
+/* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent.api;
+
+import java.util.HashMap;
+
+import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachine.State;
+
+public class ClusterSyncAnswer extends Answer {
+ long _clusterId;
+ HashMap> _newStates;
+ int _type = -1; // 0 for full, 1 for delta
+
+ public static final int FULL_SYNC=0;
+ public static final int DELTA_SYNC=1;
+
+ public ClusterSyncAnswer() {
+ }
+
+ public ClusterSyncAnswer(long clusterId, HashMap> newStates, int type){
+ _clusterId = clusterId;
+ _newStates = newStates;
+ _type = type;
+ result = true;
+ }
+
+ public long getClusterId() {
+ return _clusterId;
+ }
+
+ public HashMap> getNewStates() {
+ return _newStates;
+ }
+
+ public boolean isFull(){
+ return _type==0;
+ }
+}
\ No newline at end of file
diff --git a/api/src/com/cloud/agent/api/ClusterSyncCommand.java b/api/src/com/cloud/agent/api/ClusterSyncCommand.java
new file mode 100644
index 00000000000..83b79cbbddb
--- /dev/null
+++ b/api/src/com/cloud/agent/api/ClusterSyncCommand.java
@@ -0,0 +1,65 @@
+/* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent.api;
+
+
+public class ClusterSyncCommand extends Command implements CronCommand {
+ int _interval;
+ int _skipSteps; // skip this many steps for full sync
+ int _steps;
+
+ long _clusterId;
+
+ public ClusterSyncCommand() {
+ }
+
+ public ClusterSyncCommand(int interval, int skipSteps, long clusterId){
+ _interval = interval;
+ _skipSteps = skipSteps;
+ _clusterId = clusterId;
+ _steps=0;
+ }
+
+ @Override
+ public int getInterval() {
+ return _interval;
+ }
+
+ public int getSkipSteps(){
+ return _skipSteps;
+ }
+
+ public void incrStep(){
+ _steps++;
+ if (_steps>=_skipSteps)_steps=0;
+ }
+
+ public boolean isRightStep(){
+ return (_steps==0);
+ }
+
+ public long getClusterId() {
+ return _clusterId;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java b/core/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
new file mode 100644
index 00000000000..2927a1388b3
--- /dev/null
+++ b/core/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
@@ -0,0 +1,85 @@
+package com.cloud.hypervisor.xen.resource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachine.State;
+
+
+public class XenServerPoolVms {
+ private static final Logger s_logger = Logger.getLogger(XenServerPoolVms.class);
+ HashMap>> _cluster_vms =
+ new HashMap>>();
+
+ public HashMap> getClusterVmState(String clusterId){
+ HashMap> _vms= _cluster_vms.get(clusterId);
+ if (_vms==null) {
+ HashMap> vmStates = new HashMap>();
+ _cluster_vms.put(clusterId, vmStates);
+ return vmStates;
+ }
+ else return _vms;
+ }
+
+ public void clear(String clusterId){
+ HashMap> _vms= getClusterVmState(clusterId);
+ synchronized (_vms) {
+ _vms.clear();
+ }
+ }
+
+ public State getState(String clusterId, String name){
+ HashMap> vms = getClusterVmState(clusterId);
+ Pair pv = vms.get(name);
+ return pv.second();
+ }
+
+ public void put(String clusterId, String hostUuid, String name, State state){
+ HashMap> vms= getClusterVmState(clusterId);
+ synchronized (vms) {
+ vms.put(name, new Pair(hostUuid, state));
+ }
+ }
+
+ public void remove(String clusterId, String hostUuid, String name){
+ HashMap> vms= getClusterVmState(clusterId);
+ synchronized (vms) {
+ vms.remove(name);
+ }
+ }
+
+ public void putAll(String clusterId, HashMap> new_vms){
+ HashMap> vms= getClusterVmState(clusterId);
+ synchronized (vms) {
+ vms.putAll(new_vms);
+ }
+ }
+
+ public int size(String clusterId){
+ HashMap> vms= getClusterVmState(clusterId);
+ return vms.size();
+ }
+
+
+ public static void main(String args[]){
+ XenServerPoolVms vms = new XenServerPoolVms();
+ }
+
+ @Override
+ public String toString(){
+ StringBuilder sbuf = new StringBuilder("PoolVms=");
+ for (HashMap> clusterVM: _cluster_vms.values()){
+ for (String vmname: clusterVM.keySet()){
+ sbuf.append(vmname).append("-").append(clusterVM.get(vmname).second()).append(",");
+ }
+ }
+ return sbuf.toString();
+ }
+
+}
+