CLOUDSTACK-8656: t-w-r on socket channel like previous in hyperv now in vmware
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ed6e2615 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ed6e2615 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ed6e2615 Branch: refs/heads/master Commit: ed6e26152181d6416f36993a75f8f1465a6e3c87 Parents: 55df067 Author: Daan Hoogland <[email protected]> Authored: Tue Aug 4 14:24:04 2015 +0200 Committer: Daan Hoogland <[email protected]> Committed: Tue Aug 4 14:24:04 2015 +0200 ---------------------------------------------------------------------- .../vmware/resource/VmwareResource.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ed6e2615/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index c649748..97591d2 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -18,6 +18,7 @@ package com.cloud.hypervisor.vmware.resource; import java.io.File; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.InetSocketAddress; import java.net.URI; @@ -33,12 +34,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Random; import java.util.Set; import java.util.TimeZone; import java.util.UUID; -import java.io.UnsupportedEncodingException; import javax.naming.ConfigurationException; @@ -216,8 +215,8 @@ import com.cloud.dc.Vlan; import com.cloud.exception.CloudException; import com.cloud.exception.InternalErrorException; import com.cloud.host.Host.Type; -import com.cloud.hypervisor.guru.VMwareGuru; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.hypervisor.guru.VMwareGuru; import com.cloud.hypervisor.vmware.manager.VmwareHostService; import com.cloud.hypervisor.vmware.manager.VmwareManager; import com.cloud.hypervisor.vmware.manager.VmwareStorageMount; @@ -566,7 +565,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // we need to spawn a worker VM to attach the volume to and // resize the volume. useWorkerVm = true; - vmName = this.getWorkerName(getServiceContext(), cmd, 0); + vmName = getWorkerName(getServiceContext(), cmd, 0); morDS = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId); dsMo = new DatastoreMO(hyperHost.getContext(), morDS); @@ -4800,10 +4799,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // VM patching/rebooting time that may need int retry = _retry; while (System.currentTimeMillis() - startTick <= _opsTimeout || --retry > 0) { - SocketChannel sch = null; - try { - s_logger.info("Trying to connect to " + ipAddress); - sch = SocketChannel.open(); + s_logger.info("Trying to connect to " + ipAddress); + try (SocketChannel sch = SocketChannel.open();) { sch.configureBlocking(true); sch.socket().setSoTimeout(5000); @@ -4822,13 +4819,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.debug("[ignored] interupted while waiting to retry connect after failure.", e); } } - } finally { - if (sch != null) { - try { - sch.close(); - } catch (IOException e) { - } - } } try {
