Moti Asayag has uploaded a new change for review. Change subject: engine: Add host poller for setup network actions ......................................................................
engine: Add host poller for setup network actions The poller will monitor the connectivity to vdsm for the liveness of the engine-host communication. Change-Id: Ic11e71f0ee4e4ed4d6ae9a1d8fe4e5613da7a48f Signed-off-by: Moti Asayag <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworkPoller.java 1 file changed, 51 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/34970/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworkPoller.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworkPoller.java new file mode 100644 index 0000000..ed525cd --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworkPoller.java @@ -0,0 +1,51 @@ +package org.ovirt.engine.core.bll.network.host; + +import java.util.concurrent.TimeUnit; + +import org.ovirt.engine.core.bll.Backend; +import org.ovirt.engine.core.common.config.Config; +import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.interfaces.FutureVDSCall; +import org.ovirt.engine.core.common.vdscommands.FutureVDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.compat.Guid; + +/** + * Use {@link FutureVDSCall} to poll the VDSM (with ping verb) while setupNetworks task is not done. During the poll + * task try to fetch the setupNetwork task answer with a timeout equal to connectivity timeout as defined in the command + * parameters and stop both tasks when its done + */ +public class HostSetupNetworkPoller { + + /** Time between polling attempts, to prevent flooding the host/network. */ + private static final long POLLING_BREAK = 500; + private final Guid hostId; + + public HostSetupNetworkPoller(Guid hostId) { + this.hostId = hostId; + } + + public boolean poll() { + long timeBeforePoll = System.currentTimeMillis(); + FutureVDSCall<VDSReturnValue> task = + Backend.getInstance() + .getResourceManager() + .runFutureVdsCommand(FutureVDSCommandType.Poll, new VdsIdVDSCommandParametersBase(hostId)); + try { + VDSReturnValue returnValue = + task.get(Config.<Integer> getValue(ConfigValues.SetupNetworksPollingTimeout), TimeUnit.SECONDS); + if (returnValue.getSucceeded()) { + return true; + } + + if (System.currentTimeMillis() - timeBeforePoll < POLLING_BREAK) { + Thread.sleep(POLLING_BREAK); + } + } catch (Exception e) { + // ignore failure. network can go down due to VDSM changing the network + } + + return false; + } +} -- To view, visit http://gerrit.ovirt.org/34970 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic11e71f0ee4e4ed4d6ae9a1d8fe4e5613da7a48f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Moti Asayag <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
