示例#1
0
  private DaemonClientConnection findConnection(
      List<DaemonInfo> daemonInfos, ExplainingSpec<DaemonContext> constraint) {
    for (final DaemonInfo daemonInfo : daemonInfos) {
      if (!constraint.isSatisfiedBy(daemonInfo.getContext())) {
        LOGGER.debug(
            "Found daemon (address: {}, idle: {}) however its context does not match the desired criteria.\n"
                + constraint.whyUnsatisfied(daemonInfo.getContext())
                + "\n"
                + "  Looking for a different daemon...",
            daemonInfo.getAddress(),
            daemonInfo.isIdle());
        continue;
      }

      try {
        return connectToDaemon(daemonInfo, new CleanupOnStaleAddress(daemonInfo, true));
      } catch (ConnectException e) {
        LOGGER.debug(
            "Cannot connect to the daemon at "
                + daemonInfo.getAddress()
                + " due to "
                + e
                + ". Trying a different daemon...");
      }
    }
    return null;
  }
 private DaemonClientConnection connectToDaemonWithId(
     DaemonStartupInfo startupInfo, ExplainingSpec<DaemonContext> constraint)
     throws ConnectException {
   // Look for 'our' daemon among the busy daemons - a daemon will start in busy state so that
   // nobody else will grab it.
   for (DaemonInfo daemonInfo : daemonRegistry.getBusy()) {
     if (daemonInfo.getContext().getUid().equals(startupInfo.getUid())) {
       try {
         if (!constraint.isSatisfiedBy(daemonInfo.getContext())) {
           throw new GradleException(
               "The newly created daemon process has a different context than expected."
                   + "\nIt won't be possible to reconnect to this daemon. Context mismatch: "
                   + "\n"
                   + constraint.whyUnsatisfied(daemonInfo.getContext()));
         }
         return connectToDaemon(daemonInfo, startupInfo.getDiagnostics());
       } catch (ConnectException e) {
         throw new GradleException(
             "The forked daemon process died before we could connect.\n" + startupInfo.describe(),
             e);
       }
     }
   }
   return null;
 }
  private DaemonClientConnection findConnection(
      List<DaemonInfo> daemons, ExplainingSpec<DaemonContext> constraint) {
    for (DaemonInfo daemon : daemons) {
      if (!constraint.isSatisfiedBy(daemon.getContext())) {
        LOGGER.debug(
            "Found daemon {} however its context does not match the desired criteria.\n"
                + constraint.whyUnsatisfied(daemon.getContext())
                + "\n"
                + "  Looking for a different daemon...",
            daemon);
        continue;
      }

      try {
        return connectToDaemon(daemon, new CleanupOnStaleAddress(daemon, true));
      } catch (ConnectException e) {
        LOGGER.debug(
            "Cannot connect to daemon {} due to {}. Trying a different daemon...", daemon, e);
      }
    }
    return null;
  }