brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request: Wait to start windows parameter.
Date Wed, 20 Apr 2016 15:47:14 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/110#discussion_r60434447
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
---
    @@ -2742,14 +2744,52 @@ protected LoginCredentials waitForWinRmAvailable(final ComputeService
computeSer
                 Callable<Boolean> checker = new Callable<Boolean>() {
                     public Boolean call() {
                         for (Map.Entry<WinRmMachineLocation, LoginCredentials> entry
: machinesToTry.entrySet()) {
    -                        WinRmMachineLocation machine = entry.getKey();
    +                        final WinRmMachineLocation machine = entry.getKey();
                             WinRmToolResponse response = machine.executeCommand(
                                     ImmutableMap.of(WinRmTool.PROP_EXEC_TRIES.getName(),
1),
                                     ImmutableList.of("echo testing"));
                             boolean success = (response.getStatusCode() == 0);
                             if (success) {
                                 credsSuccessful.set(entry.getValue());
    -                            return true;
    +
    +                            String verifyWindowsUp = getConfig(WinRmMachineLocation.WAIT_WINDOWS_TO_START);
    +                            if (Strings.isBlank(verifyWindowsUp) || verifyWindowsUp.equals("false"))
{
    +                                return true;
    +                            }
    +
    +                            Predicate<WinRmMachineLocation> machineReachable =
new Predicate<WinRmMachineLocation>() {
    +                                @Override
    +                                public boolean apply(@Nullable WinRmMachineLocation machine)
{
    +                                    try {
    +                                        WinRmToolResponse response = machine.executeCommand("echo
testing");
    +                                        int statusCode = response.getStatusCode();
    +                                        return statusCode == 0;
    +                                    } catch (RuntimeException e) {
    +                                        if (getFirstThrowableOfType(e, IOException.class)
== null || getFirstThrowableOfType(e, WebServiceException.class) == null) {
    +                                            LOG.debug("Connectivity check failed", e);
    +                                            return false;
    +                                        } else {
    +                                            throw e;
    +                                        }
    +                                    }
    +                                }
    +                            };
    +                            Duration verifyWindowsUpTime = Duration.of(verifyWindowsUp);
    +                            boolean restartHappened = Predicates2.retry(Predicates.not(machineReachable),
    +                                    verifyWindowsUpTime.toMilliseconds(),
    +                                    Duration.of(5, TimeUnit.SECONDS).toMilliseconds(),
    +                                    Duration.of(30, TimeUnit.SECONDS).toMilliseconds(),
    --- End diff --
    
    There are `Duration.FIVE_SECONDS`, `Duration.THIRTY_SECONDS` constants.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message