Get rid of compiler warnings in vmware-base

This commit is contained in:
Hugo Trippaers 2014-01-22 09:34:46 +01:00
parent 86124138a1
commit b20add810e
18 changed files with 174 additions and 197 deletions

View File

@ -299,7 +299,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
ManagedObjectReference morDs = null;
ManagedObjectReference morDsFirst = null;
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -332,7 +332,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -480,7 +480,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
// TODO, need to use traversal to optimize retrieve of
int cpuNumInCpuThreads = 1;
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -505,7 +505,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + esxServiceConsolePort);
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort);

View File

@ -51,7 +51,7 @@ public class CustomFieldsManagerMO extends BaseMO {
}
public List<CustomFieldDef> getFields() throws Exception {
return (List<CustomFieldDef>)_context.getVimClient().getDynamicProperty(getMor(), "field");
return _context.getVimClient().getDynamicProperty(getMor(), "field");
}
@Override

View File

@ -34,6 +34,7 @@ import com.vmware.vim25.VMwareDVSPvlanMapEntry;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class DistributedVirtualSwitchMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class);
public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) {
@ -62,7 +63,7 @@ public class DistributedVirtualSwitchMO extends BaseMO {
public TaskInfo updateVMWareDVSwitchGetTask(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
ManagedObjectReference task = _context.getService().reconfigureDvsTask(dvSwitchMor, dvsSpec);
TaskInfo info = (TaskInfo)(_context.getVimClient().getDynamicProperty(task, "info"));
boolean waitvalue = _context.getVimClient().waitForTask(task);
_context.getVimClient().waitForTask(task);
return info;
}

View File

@ -181,7 +181,7 @@ public class HostDatastoreSystemMO extends BaseMO {
}
public List<ManagedObjectReference> getDatastores() throws Exception {
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
return _context.getVimClient().getDynamicProperty(_mor, "datastore");
}
public DatastoreInfo getDatastoreInfo(ManagedObjectReference morDatastore) throws Exception {

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class HostFirewallSystemMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(HostFirewallSystemMO.class);
public HostFirewallSystemMO(VmwareContext context, ManagedObjectReference morFirewallSystem) {

View File

@ -91,11 +91,11 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws Exception {
return (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
return _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
}
public List<HostIpRouteEntry> getHostIpRouteEntries() throws Exception {
return (List<HostIpRouteEntry>)_context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
return _context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
}
public HostListSummaryQuickStats getHostQuickStats() throws Exception {
@ -222,7 +222,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
List<ManagedObjectReference> datastores = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
List<ManagedObjectReference> datastores = _context.getVimClient().getDynamicProperty(_mor, "datastore");
List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
if (datastores != null) {
for (ManagedObjectReference mor : datastores) {
@ -235,7 +235,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public HostVirtualSwitch getHostVirtualSwitchByName(String name) throws Exception {
List<HostVirtualSwitch> switches = (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
List<HostVirtualSwitch> switches = _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
if (switches != null) {
for (HostVirtualSwitch vswitch : switches) {
@ -247,7 +247,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public List<HostVirtualSwitch> getHostVirtualSwitch() throws Exception {
return (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
return _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
}
public AboutInfo getHostAboutInfo() throws Exception {
@ -326,7 +326,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
assert (nicType != null);
List<VirtualNicManagerNetConfig> netConfigs =
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
if (netConfigs != null) {
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
@ -450,7 +450,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
public List<ManagedObjectReference> getVmMorsOnNetwork(String portGroupName) throws Exception {
ManagedObjectReference morNetwork = getNetworkMor(portGroupName);
if (morNetwork != null)
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(morNetwork, "vm");
return _context.getVimClient().getDynamicProperty(morNetwork, "vm");
return null;
}
@ -905,9 +905,9 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
if (this.getHostType() == VmwareHostType.ESXi) {
if (getHostType() == VmwareHostType.ESXi) {
List<VirtualNicManagerNetConfig> netConfigs =
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
assert (netConfigs != null);
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
@ -927,7 +927,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
} else {
// try with ESX path
List<HostVirtualNic> hostVNics = (List<HostVirtualNic>)_context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
List<HostVirtualNic> hostVNics = _context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
if (hostVNics != null) {
for (HostVirtualNic vnic : hostVNics) {

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class HostNetworkSystemMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(HostNetworkSystemMO.class);
public HostNetworkSystemMO(VmwareContext context, ManagedObjectReference morNetworkSystem) {

View File

@ -981,7 +981,7 @@ public class HypervisorHostHelper {
try {
if (lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
try {
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
List<ManagedObjectReference> hosts = hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
if (hosts != null) {
for (ManagedObjectReference otherHost : hosts) {
if (!otherHost.getValue().equals(hostMo.getMor().getValue())) {

View File

@ -30,10 +30,8 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
public class LicenseAssignmentManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(LicenseAssignmentManagerMO.class);
private static final String LICENSE_INFO_PRODUCT_VERSION = "ProductVersion";
private static final String LICENSE_INFO_PRODUCT_NAME = "ProductName";
private static final String LICENSE_INFO_NAME = "Name";
private static final String LICENSE_INFO_FEATURE = "feature";
public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) {

View File

@ -24,6 +24,7 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
public class LicenseManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(LicenseManagerMO.class);
private ManagedObjectReference _licenseAssignmentManager = null;

View File

@ -36,6 +36,6 @@ public class NetworkMO extends BaseMO {
}
public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "vm");
return _context.getVimClient().getDynamicProperty(_mor, "vm");
}
}

View File

@ -114,10 +114,10 @@ public class PerfManagerMO extends BaseMO {
}
public List<PerfCounterInfo> getCounterInfo() throws Exception {
return (List<PerfCounterInfo>)_context.getVimClient().getDynamicProperty(_mor, "perfCounter");
return _context.getVimClient().getDynamicProperty(_mor, "perfCounter");
}
public List<PerfInterval> getIntervalInfo() throws Exception {
return (List<PerfInterval>)_context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
return _context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
}
}

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.VirtualDiskSpec;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class VirtualDiskManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
public VirtualDiskManagerMO(VmwareContext context) {

View File

@ -811,13 +811,13 @@ public class VirtualMachineMO extends BaseMO {
String vmxPathTokens[] = vmxFilePath.split("\\[|\\]|/");
StringBuffer sb = new StringBuffer("https://" + _context.getServerAddress() + "/folder/");
sb.append(URLEncoder.encode(vmxPathTokens[2].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[2].trim(), "UTF-8"));
sb.append("/");
sb.append(URLEncoder.encode(vmxPathTokens[3].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[3].trim(), "UTF-8"));
sb.append("?dcPath=");
sb.append(URLEncoder.encode(dcInfo.second()));
sb.append(URLEncoder.encode(dcInfo.second(), "UTF-8"));
sb.append("&dsName=");
sb.append(URLEncoder.encode(vmxPathTokens[1].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[1].trim(), "UTF-8"));
return sb.toString();
}
@ -1796,7 +1796,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getScsiDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1811,7 +1811,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getScsiDeviceControllerKeyNoException() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1847,7 +1847,7 @@ public class VirtualMachineMO extends BaseMO {
// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
@ -1893,7 +1893,7 @@ public class VirtualMachineMO extends BaseMO {
}
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -1915,7 +1915,7 @@ public class VirtualMachineMO extends BaseMO {
}
public VirtualDisk getDiskDeviceByDeviceBusName(String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1933,7 +1933,7 @@ public class VirtualMachineMO extends BaseMO {
public VirtualMachineDiskInfoBuilder getDiskInfoBuilder() throws Exception {
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2049,7 +2049,7 @@ public class VirtualMachineMO extends BaseMO {
public List<VirtualDisk> getVirtualDisks() throws Exception {
List<VirtualDisk> virtualDisks = new ArrayList<VirtualDisk>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -2061,7 +2061,7 @@ public class VirtualMachineMO extends BaseMO {
}
public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
List<String> detachedDiskFiles = new ArrayList<String>();
@ -2105,12 +2105,12 @@ public class VirtualMachineMO extends BaseMO {
}
public List<VirtualDevice> getAllDeviceList() throws Exception {
return (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
return _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
}
public VirtualDisk[] getAllDiskDevice() throws Exception {
List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -2163,7 +2163,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int tryGetIDEDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2177,7 +2177,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getIDEDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2197,7 +2197,7 @@ public class VirtualMachineMO extends BaseMO {
}
public VirtualDevice getIsoDevice() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualCdrom) {
@ -2209,7 +2209,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getPCIDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2229,7 +2229,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getNextDeviceNumber(int controllerKey) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
int deviceNumber = -1;
if (devices != null && devices.size() > 0) {
@ -2245,7 +2245,7 @@ public class VirtualMachineMO extends BaseMO {
}
private List<VirtualDevice> getNicDevices(boolean sorted) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
if (devices != null) {
@ -2325,7 +2325,7 @@ public class VirtualMachineMO extends BaseMO {
List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null) {
for (VirtualDevice device : devices) {
@ -2346,7 +2346,6 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean unmountToolsInstaller() throws Exception {
int i = 1;
// Monitor VM questions
final Boolean[] flags = {false};
final VirtualMachineMO vmMo = this;

View File

@ -27,8 +27,8 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
import org.apache.log4j.Logger;
@ -144,6 +144,7 @@ public class VmwareClient {
ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef);
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
@SuppressWarnings("unchecked")
Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> cookies = headers.get("Set-cookie");
String cookieValue = cookies.get(0);
@ -256,17 +257,18 @@ public class VmwareClient {
* @throws Exception
* in case of error.
*/
public Object getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
@SuppressWarnings("unchecked")
public <T> T getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
List<String> props = new ArrayList<String>();
props.add(propertyName);
List<ObjectContent> objContent = retrieveMoRefProperties(mor, props);
Object propertyValue = null;
T propertyValue = null;
if (objContent != null && objContent.size() > 0) {
List<DynamicProperty> dynamicProperty = objContent.get(0).getPropSet();
if (dynamicProperty != null && dynamicProperty.size() > 0) {
DynamicProperty dp = dynamicProperty.get(0);
propertyValue = dp.getVal();
propertyValue = (T)dp.getVal();
/*
* If object is ArrayOfXXX object, then get the XXX[] by
* invoking getXXX() on the object.
@ -274,13 +276,13 @@ public class VmwareClient {
* ArrayOfManagedObjectReference.getManagedObjectReference()
* returns ManagedObjectReference[] array.
*/
Class dpCls = propertyValue.getClass();
Class<? extends Object> dpCls = propertyValue.getClass();
String dynamicPropertyName = dpCls.getName();
if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
String methodName = "get" + dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") + "ArrayOf".length(), dynamicPropertyName.length());
Method getMorMethod = dpCls.getDeclaredMethod(methodName, null);
propertyValue = getMorMethod.invoke(propertyValue, (Object[])null);
Method getMorMethod = dpCls.getDeclaredMethod(methodName, (Class<?>)null);
propertyValue = (T)getMorMethod.invoke(propertyValue, (Object[])null);
}
}
}

View File

@ -26,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
@ -375,7 +376,7 @@ public class VmwareContext {
}
}
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate progressUpdater) throws Exception {
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate<Long> progressUpdater) throws Exception {
HttpURLConnection conn = getRawHTTPConnection(urlString);
@ -418,7 +419,7 @@ public class VmwareContext {
}
}
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate progressUpdater) throws Exception {
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate<Long> progressUpdater) throws Exception {
HttpURLConnection conn = getRawHTTPConnection(urlString);
String cookie = _vimClient.getServiceCookie();
@ -583,8 +584,12 @@ public class VmwareContext {
sb.append(_serverAddress);
sb.append("/folder/");
sb.append(relativePath);
sb.append("?dcPath=").append(URLEncoder.encode(dcName)).append("&dsName=");
sb.append(URLEncoder.encode(datastoreName));
try {
sb.append("?dcPath=").append(URLEncoder.encode(dcName, "UTF-8"));
sb.append("&dsName=").append(URLEncoder.encode(datastoreName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
s_logger.error("Unable to encode URL. dcPath : " + dcName + ", dsName :" + datastoreName, e);
}
return sb.toString();
}

View File

@ -134,41 +134,6 @@ public class VmwareContextPool {
};
}
private void getIdleCheckContexts(List<VmwareContext> l, int batchSize) {
synchronized (this) {
for (Map.Entry<String, List<VmwareContext>> entry : _pool.entrySet()) {
if (entry.getValue() != null) {
int count = 0;
while (entry.getValue().size() > 0 && count < batchSize) {
VmwareContext context = entry.getValue().remove(0);
context.setPoolInfo(this, entry.getKey());
l.add(context);
count++;
}
}
}
}
}
private void doIdleCheck() {
List<VmwareContext> l = new ArrayList<VmwareContext>();
int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate
getIdleCheckContexts(l, batchSize);
for (VmwareContext context : l) {
try {
context.idleCheck();
if (s_logger.isTraceEnabled())
s_logger.trace("Recyle context after idle check");
returnContext(context);
} catch (Throwable e) {
s_logger.warn("Exception caught during VmwareContext idle check, close and discard the context", e);
context.close();
}
}
}
private void getKeepAliveCheckContexts(List<VmwareContext> l, int batchSize) {
synchronized (this) {
int size = Math.min(_outstandingRegistry.size(), batchSize);

View File

@ -71,6 +71,7 @@ import com.cloud.utils.Ternary;
import com.cloud.utils.exception.ExceptionUtil;
public class VmwareHelper {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(VmwareHelper.class);
public static boolean isReservedScsiDeviceNumber(int deviceNumber) {
@ -325,6 +326,7 @@ public class VmwareHelper {
return disk;
}
@SuppressWarnings("unchecked")
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain,
int deviceNumber, int contextNumber) throws Exception {
@ -385,6 +387,7 @@ public class VmwareHelper {
backingInfo.setParent(parentBacking);
}
@SuppressWarnings("unchecked")
private static void setParentBackingInfo(VirtualDiskFlatVer2BackingInfo backingInfo, Pair<String, ManagedObjectReference>[] parentDatastorePathList) {
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
@ -640,10 +643,10 @@ public class VmwareHelper {
//TODO: in vim 5.1, exceptions do not have a base exception class, MethodFault becomes a FaultInfo that we can only get
// from individual exception through getFaultInfo, so we have to use reflection here to get MethodFault information.
try {
Class cls = e.getClass();
Method mth = cls.getDeclaredMethod("getFaultInfo", null);
Class<? extends Throwable> cls = e.getClass();
Method mth = cls.getDeclaredMethod("getFaultInfo", (Class<?>)null);
if (mth != null) {
Object fault = mth.invoke(e, null);
Object fault = mth.invoke(e, (Object[])null);
if (fault instanceof MethodFault) {
final StringWriter writer = new StringWriter();
writer.append("Exception: " + fault.getClass().getName() + "\n");