diff --git a/agent-simulator/src/com/cloud/agent/MockVmMetrics.java b/agent-simulator/src/com/cloud/agent/MockVmMetrics.java index a06e4fb8baf..b33040fb56d 100644 --- a/agent-simulator/src/com/cloud/agent/MockVmMetrics.java +++ b/agent-simulator/src/com/cloud/agent/MockVmMetrics.java @@ -10,68 +10,68 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent; - +package com.cloud.agent; + import java.util.HashMap; import java.util.Map; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.apache.log4j.Logger; - -public class MockVmMetrics implements Runnable { + +public class MockVmMetrics implements Runnable { private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class); - - private String vmName; - - public final int MAX_INTERFACES=1; - - public final int MAX_DISKS=8; - - //the last calculated traffic speed (transmit) per interface - private Map netTxKBps = new HashMap(); - - //the last calculated traffic speed (receive) per interface - private Map netRxKBps = new HashMap(); - - //the last calculated disk write speed per disk (Bytes Per Second) - private Map diskWriteKBytesPerSec = new HashMap(); - - //the last calculated disk read speed per disk (Bytes Per Second) - private Map diskReadKBytesPerSec = new HashMap(); - - //Total Bytes Transmitted on network interfaces - private Map netTxTotalBytes = new HashMap(); - - //Total Bytes Received on network interfaces - private Map netRxTotalBytes = new HashMap(); - - //Total Bytes read per disk - private Map diskReadTotalBytes = new HashMap(); - - //Total Bytes written per disk - private Map diskWriteTotalBytes = new HashMap(); - - //CPU time in seconds - private Double cpuSeconds = new Double(0.0); - - //CPU percentage - private Float cpuPercent = new Float(0.0); - - private Map diskMap = new HashMap(); - - private Map vifMap = new HashMap(); - - private Map diskStatTimestamp = new HashMap(); - private Map netStatTimestamp = new HashMap(); - - private long cpuStatTimestamp = 0L; - - private ScheduledFuture future; + + private String vmName; + + public final int MAX_INTERFACES=1; + + public final int MAX_DISKS=8; + + //the last calculated traffic speed (transmit) per interface + private Map netTxKBps = new HashMap(); + + //the last calculated traffic speed (receive) per interface + private Map netRxKBps = new HashMap(); + + //the last calculated disk write speed per disk (Bytes Per Second) + private Map diskWriteKBytesPerSec = new HashMap(); + + //the last calculated disk read speed per disk (Bytes Per Second) + private Map diskReadKBytesPerSec = new HashMap(); + + //Total Bytes Transmitted on network interfaces + private Map netTxTotalBytes = new HashMap(); + + //Total Bytes Received on network interfaces + private Map netRxTotalBytes = new HashMap(); + + //Total Bytes read per disk + private Map diskReadTotalBytes = new HashMap(); + + //Total Bytes written per disk + private Map diskWriteTotalBytes = new HashMap(); + + //CPU time in seconds + private Double cpuSeconds = new Double(0.0); + + //CPU percentage + private Float cpuPercent = new Float(0.0); + + private Map diskMap = new HashMap(); + + private Map vifMap = new HashMap(); + + private Map diskStatTimestamp = new HashMap(); + private Map netStatTimestamp = new HashMap(); + + private long cpuStatTimestamp = 0L; + + private ScheduledFuture future; private boolean stopped = false; - private Random randSeed = new Random(); - - public MockVmMetrics(String vmName) { + private Random randSeed = new Random(); + + public MockVmMetrics(String vmName) { this.vmName = vmName; vifMap.put("eth0", "eth0"); vifMap.put("eth1", "eth1"); @@ -85,117 +85,117 @@ public class MockVmMetrics implements Runnable { netRxTotalBytes.put("eth1", networkStart); netTxTotalBytes.put("eth2", networkStart); - netRxTotalBytes.put("eth2", networkStart); - } + netRxTotalBytes.put("eth2", networkStart); + } private int getIncrementor() { return randSeed.nextInt(100); } - - @Override + + @Override public void run() { if(s_logger.isDebugEnabled()) { s_logger.debug("Generating MockVM metrics"); - } + } for (Map.Entry entry : netRxTotalBytes.entrySet()) { entry.setValue(entry.getValue() + getIncrementor()); } for (Map.Entry entry : netTxTotalBytes.entrySet()) { entry.setValue(entry.getValue() + getIncrementor()); - } - } - - public String getVmName() { - return vmName; - } - - public Map getNetTxKBps() { - return netTxKBps; - } - - public Map getNetRxKBps() { - return netRxKBps; - } - - public Map getDiskWriteBytesPerSec() { - return diskWriteKBytesPerSec; - } - - public Map getDiskReadBytesPerSec() { - return diskReadKBytesPerSec; - } - - public Map getNetTxTotalBytes() { - return netTxTotalBytes; - } - - public Map getNetRxTotalBytes() { - return netRxTotalBytes; - } - - public Map getDiskReadTotalBytes() { - return diskReadTotalBytes; - } - - public Map getDiskWriteTotalBytes() { - return diskWriteTotalBytes; - } - - public Double getNetTxKBps(String intf) { - return netTxKBps.get(intf); - } - - public Double getNetRxKBps(String intf) { - return netRxKBps.get(intf); - } - - public Double getDiskWriteKBytesPerSec(String disk) { - return diskWriteKBytesPerSec.get(disk); - } - - public Double getDiskReadKBytesPerSec(String disk) { - return diskReadKBytesPerSec.get(disk); - } - - public Long getNetTxTotalBytes(String intf) { - return netTxTotalBytes.get(intf); - } - - public Long getNetRxTotalBytes(String intf) { - return netRxTotalBytes.get(intf); - } - - public Long getDiskReadTotalBytes(String disk) { - return diskReadTotalBytes.get(disk); - } - - public Long getDiskWriteTotalBytes(String disk) { - return diskWriteTotalBytes.get(disk); - } - - public Double getCpuSeconds() { - return cpuSeconds; - } - - public Map getDiskMap() { - return diskMap; - } - - public Float getCpuPercent() { - return cpuPercent; - } - - public void setFuture(ScheduledFuture sf) { - this.future = sf; - } - - public ScheduledFuture getFuture() { - return future; - } - - public void stop() { - this.stopped = true; - } -} + } + } + + public String getVmName() { + return vmName; + } + + public Map getNetTxKBps() { + return netTxKBps; + } + + public Map getNetRxKBps() { + return netRxKBps; + } + + public Map getDiskWriteBytesPerSec() { + return diskWriteKBytesPerSec; + } + + public Map getDiskReadBytesPerSec() { + return diskReadKBytesPerSec; + } + + public Map getNetTxTotalBytes() { + return netTxTotalBytes; + } + + public Map getNetRxTotalBytes() { + return netRxTotalBytes; + } + + public Map getDiskReadTotalBytes() { + return diskReadTotalBytes; + } + + public Map getDiskWriteTotalBytes() { + return diskWriteTotalBytes; + } + + public Double getNetTxKBps(String intf) { + return netTxKBps.get(intf); + } + + public Double getNetRxKBps(String intf) { + return netRxKBps.get(intf); + } + + public Double getDiskWriteKBytesPerSec(String disk) { + return diskWriteKBytesPerSec.get(disk); + } + + public Double getDiskReadKBytesPerSec(String disk) { + return diskReadKBytesPerSec.get(disk); + } + + public Long getNetTxTotalBytes(String intf) { + return netTxTotalBytes.get(intf); + } + + public Long getNetRxTotalBytes(String intf) { + return netRxTotalBytes.get(intf); + } + + public Long getDiskReadTotalBytes(String disk) { + return diskReadTotalBytes.get(disk); + } + + public Long getDiskWriteTotalBytes(String disk) { + return diskWriteTotalBytes.get(disk); + } + + public Double getCpuSeconds() { + return cpuSeconds; + } + + public Map getDiskMap() { + return diskMap; + } + + public Float getCpuPercent() { + return cpuPercent; + } + + public void setFuture(ScheduledFuture sf) { + this.future = sf; + } + + public ScheduledFuture getFuture() { + return future; + } + + public void stop() { + this.stopped = true; + } +} diff --git a/agent-simulator/src/com/cloud/agent/MultiCaster.java b/agent-simulator/src/com/cloud/agent/MultiCaster.java index 43b3407d83a..9bfbdf2eefd 100644 --- a/agent-simulator/src/com/cloud/agent/MultiCaster.java +++ b/agent-simulator/src/com/cloud/agent/MultiCaster.java @@ -10,8 +10,8 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent; - +package com.cloud.agent; + import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; @@ -23,126 +23,126 @@ import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; - -public class MultiCaster implements Runnable { - private static final Logger s_logger = Logger.getLogger(MultiCaster.class); - - public final int MAX_PACKET_SIZE = 8096; - - private List listeners; - private DatagramSocket socket; - private byte[] recvBuffer; - - private Thread driver; - private volatile boolean stopRequested = false; - - public MultiCaster() { - listeners = new ArrayList(); - recvBuffer = new byte[MAX_PACKET_SIZE]; - } - - public void addListener(MultiCasterListener listener) { - synchronized(listeners) { - listeners.add(listener); - } - } - - public void removeListener(MultiCasterListener listener) { - synchronized(listeners) { - listeners.remove(listener); - } - } - - public void cast(byte[] buf, int off, int len, - InetAddress toAddress, int nToPort) throws IOException { - - if(socket == null) - throw new IOException("multi caster is not started"); - - if(len >= MAX_PACKET_SIZE) - throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE); - - DatagramPacket packet = new DatagramPacket(buf, off, - len, toAddress, nToPort); - - socket.send(packet); - } - - public void start(String strOutboundAddress, - String strClusterAddress, int nPort) throws SocketException { - assert(socket == null); - - InetAddress addr = null; - try { - addr = InetAddress.getByName(strClusterAddress); - } catch(IOException e) { - s_logger.error("Unexpected exception " , e); - } - - if(addr != null && addr.isMulticastAddress()) { - try { - socket = new MulticastSocket(nPort); - socket.setReuseAddress(true); - - if(s_logger.isInfoEnabled()) - s_logger.info("Join multicast group : " + addr); - - ((MulticastSocket)socket).joinGroup(addr); - ((MulticastSocket)socket).setTimeToLive(1); - - if(strOutboundAddress != null) { - if(s_logger.isInfoEnabled()) - s_logger.info("set outgoing interface to : " + strOutboundAddress); - - InetAddress ia = InetAddress.getByName(strOutboundAddress); - NetworkInterface ni = NetworkInterface.getByInetAddress(ia); - ((MulticastSocket)socket).setNetworkInterface(ni); - } - } catch(IOException e) { - s_logger.error("Unexpected exception " , e); - } - } else { - socket = new DatagramSocket(nPort); - socket.setReuseAddress(true); - } - - driver = new Thread(this, "Multi-caster"); - driver.setDaemon(true); - driver.start(); - } - - public void stop() { - if(socket != null) { - stopRequested = true; - - socket.close(); - if(driver != null) { - try { - driver.join(); - } catch(InterruptedException e) { - } - driver = null; - } - } - - socket = null; - stopRequested = false; - } - - public void run() { - while(!stopRequested) { - try { - DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length); - socket.receive(packet); - - for(Object listener : listeners.toArray()) { - ((MultiCasterListener)listener).onMultiCasting(packet.getData(), - packet.getOffset(), packet.getLength(), packet.getAddress()); - } - } catch(IOException e) { - } catch(Throwable e) { - s_logger.error("Unhandled exception : ", e); - } - } - } -} + +public class MultiCaster implements Runnable { + private static final Logger s_logger = Logger.getLogger(MultiCaster.class); + + public final int MAX_PACKET_SIZE = 8096; + + private List listeners; + private DatagramSocket socket; + private byte[] recvBuffer; + + private Thread driver; + private volatile boolean stopRequested = false; + + public MultiCaster() { + listeners = new ArrayList(); + recvBuffer = new byte[MAX_PACKET_SIZE]; + } + + public void addListener(MultiCasterListener listener) { + synchronized(listeners) { + listeners.add(listener); + } + } + + public void removeListener(MultiCasterListener listener) { + synchronized(listeners) { + listeners.remove(listener); + } + } + + public void cast(byte[] buf, int off, int len, + InetAddress toAddress, int nToPort) throws IOException { + + if(socket == null) + throw new IOException("multi caster is not started"); + + if(len >= MAX_PACKET_SIZE) + throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE); + + DatagramPacket packet = new DatagramPacket(buf, off, + len, toAddress, nToPort); + + socket.send(packet); + } + + public void start(String strOutboundAddress, + String strClusterAddress, int nPort) throws SocketException { + assert(socket == null); + + InetAddress addr = null; + try { + addr = InetAddress.getByName(strClusterAddress); + } catch(IOException e) { + s_logger.error("Unexpected exception " , e); + } + + if(addr != null && addr.isMulticastAddress()) { + try { + socket = new MulticastSocket(nPort); + socket.setReuseAddress(true); + + if(s_logger.isInfoEnabled()) + s_logger.info("Join multicast group : " + addr); + + ((MulticastSocket)socket).joinGroup(addr); + ((MulticastSocket)socket).setTimeToLive(1); + + if(strOutboundAddress != null) { + if(s_logger.isInfoEnabled()) + s_logger.info("set outgoing interface to : " + strOutboundAddress); + + InetAddress ia = InetAddress.getByName(strOutboundAddress); + NetworkInterface ni = NetworkInterface.getByInetAddress(ia); + ((MulticastSocket)socket).setNetworkInterface(ni); + } + } catch(IOException e) { + s_logger.error("Unexpected exception " , e); + } + } else { + socket = new DatagramSocket(nPort); + socket.setReuseAddress(true); + } + + driver = new Thread(this, "Multi-caster"); + driver.setDaemon(true); + driver.start(); + } + + public void stop() { + if(socket != null) { + stopRequested = true; + + socket.close(); + if(driver != null) { + try { + driver.join(); + } catch(InterruptedException e) { + } + driver = null; + } + } + + socket = null; + stopRequested = false; + } + + public void run() { + while(!stopRequested) { + try { + DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length); + socket.receive(packet); + + for(Object listener : listeners.toArray()) { + ((MultiCasterListener)listener).onMultiCasting(packet.getData(), + packet.getOffset(), packet.getLength(), packet.getAddress()); + } + } catch(IOException e) { + } catch(Throwable e) { + s_logger.error("Unhandled exception : ", e); + } + } + } +} diff --git a/agent-simulator/src/com/cloud/agent/MultiCasterListener.java b/agent-simulator/src/com/cloud/agent/MultiCasterListener.java index 1a6addae0e8..0a98b5fba71 100644 --- a/agent-simulator/src/com/cloud/agent/MultiCasterListener.java +++ b/agent-simulator/src/com/cloud/agent/MultiCasterListener.java @@ -10,9 +10,9 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent; +package com.cloud.agent; import java.net.InetAddress; - -public interface MultiCasterListener { - public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom); -} + +public interface MultiCasterListener { + public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom); +} diff --git a/agent-simulator/src/com/cloud/agent/SimulatorCmd.java b/agent-simulator/src/com/cloud/agent/SimulatorCmd.java index 9cc069f3905..fd7cb0aa41e 100644 --- a/agent-simulator/src/com/cloud/agent/SimulatorCmd.java +++ b/agent-simulator/src/com/cloud/agent/SimulatorCmd.java @@ -10,24 +10,24 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent; - +package com.cloud.agent; + import java.io.Serializable; - -public class SimulatorCmd implements Serializable { - private static final long serialVersionUID = 1L; - - private String testCase = "DEFAULT"; - - public SimulatorCmd(String testCase) { - this.testCase = testCase; - } - - public String getTestCase() { - return testCase; - } - - public void setTestCase(String testCase) { - this.testCase = testCase; - } -} + +public class SimulatorCmd implements Serializable { + private static final long serialVersionUID = 1L; + + private String testCase = "DEFAULT"; + + public SimulatorCmd(String testCase) { + this.testCase = testCase; + } + + public String getTestCase() { + return testCase; + } + + public void setTestCase(String testCase) { + this.testCase = testCase; + } +} diff --git a/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java b/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java index ce6474ed5a7..356bef05b3c 100644 --- a/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java +++ b/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java @@ -10,70 +10,70 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent; - -public class SimulatorMigrateVmCmd extends SimulatorCmd { - - private static final long serialVersionUID = 1L; - - private String destIp; - - private String vmName; - private long ramSize; - private int cpuCount; - private int utilization; - - public SimulatorMigrateVmCmd(String testCase) { - super(testCase); - } - - public String getDestIp() { - return destIp; - } - - public void setDestIp(String destIp) { - this.destIp = destIp; - } - - public String getVmName() { - return vmName; - } - - public void setVmName(String vmName) { - this.vmName = vmName; - } - - public long getRamSize() { - return ramSize; - } - - public void setRamSize(long ramSize) { - this.ramSize = ramSize; - } - - public int getCpuCount() { - return cpuCount; - } - - public void setCpuCount(int cpuCount) { - this.cpuCount = cpuCount; - } - - public int getUtilization() { - return utilization; - } - - public void setUtilization(int utilization) { - this.utilization = utilization; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName()); - sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize()); - sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization()); - sb.append("}"); - - return sb.toString(); - } -} +package com.cloud.agent; + +public class SimulatorMigrateVmCmd extends SimulatorCmd { + + private static final long serialVersionUID = 1L; + + private String destIp; + + private String vmName; + private long ramSize; + private int cpuCount; + private int utilization; + + public SimulatorMigrateVmCmd(String testCase) { + super(testCase); + } + + public String getDestIp() { + return destIp; + } + + public void setDestIp(String destIp) { + this.destIp = destIp; + } + + public String getVmName() { + return vmName; + } + + public void setVmName(String vmName) { + this.vmName = vmName; + } + + public long getRamSize() { + return ramSize; + } + + public void setRamSize(long ramSize) { + this.ramSize = ramSize; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getUtilization() { + return utilization; + } + + public void setUtilization(int utilization) { + this.utilization = utilization; + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName()); + sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize()); + sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization()); + sb.append("}"); + + return sb.toString(); + } +} diff --git a/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java b/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java index 1b802f4afd9..86aab82d526 100644 --- a/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java +++ b/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java @@ -10,7 +10,7 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent.manager; +package com.cloud.agent.manager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; @@ -43,8 +43,8 @@ import com.cloud.agent.api.storage.ListTemplateCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.utils.component.Manager; - -public interface MockStorageManager extends Manager { + +public interface MockStorageManager extends Manager { public static final long DEFAULT_HOST_STORAGE_SIZE = 1 * 1024 * 1024 * 1024 * 1024L; //1T public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; //1G @@ -83,5 +83,5 @@ public interface MockStorageManager extends Manager { StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize); - CopyVolumeAnswer CopyVolume(CopyVolumeCommand cmd); -} + CopyVolumeAnswer CopyVolume(CopyVolumeCommand cmd); +} diff --git a/agent-simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java index 9c3eca8c648..92836d6336d 100644 --- a/agent-simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java +++ b/agent-simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java @@ -10,8 +10,8 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.agent.manager; - +package com.cloud.agent.manager; + import java.io.File; import java.math.BigInteger; import java.net.URI; @@ -90,9 +90,9 @@ import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine.State; -@Local(value = { MockStorageManager.class }) -public class MockStorageManagerImpl implements MockStorageManager { - private static final Logger s_logger = Logger.getLogger(MockStorageManagerImpl.class); +@Local(value = { MockStorageManager.class }) +public class MockStorageManagerImpl implements MockStorageManager { + private static final Logger s_logger = Logger.getLogger(MockStorageManagerImpl.class); @Inject MockStoragePoolDao _mockStoragePoolDao = null; @Inject MockSecStorageDao _mockSecStorageDao = null; @Inject MockVolumeDao _mockVolumeDao = null; @@ -724,6 +724,6 @@ public class MockStorageManagerImpl implements MockStorageManager { return new CopyVolumeAnswer(cmd, true, null, primaryStorage.getMountPoint(), vol.getPath()); } } - -} - + +} + diff --git a/agent-simulator/src/com/cloud/simulator/MockVm.java b/agent-simulator/src/com/cloud/simulator/MockVm.java index 2582ba02d3b..93b0a90ef00 100644 --- a/agent-simulator/src/com/cloud/simulator/MockVm.java +++ b/agent-simulator/src/com/cloud/simulator/MockVm.java @@ -10,25 +10,25 @@ // limitations under the License. // // Automatically generated by addcopyright.py at 04/03/2012 -package com.cloud.simulator; - +package com.cloud.simulator; + import com.cloud.vm.VirtualMachine.State; - -// As storage is mapped from storage device, can virtually treat that VM here does -public interface MockVm { - - - public String getName(); - - public State getState(); - - public void setState(State state); + +// As storage is mapped from storage device, can virtually treat that VM here does +public interface MockVm { - public void setHostId(long hostId); - public long getMemory(); - - public int getCpu(); - public String getType(); + + public String getName(); + + public State getState(); + + public void setState(State state); + + public void setHostId(long hostId); + public long getMemory(); + + public int getCpu(); + public String getType(); public int getVncPort(); public void setName(String name); @@ -37,5 +37,5 @@ public interface MockVm { public void setType(String type); public void setVncPort(int vncPort); public long getId(); -} - +} +