コード例 #1
0
  protected void join(Connection conn, String masterIp, String username, Queue<String> password)
      throws BadServerResponse, XenAPIException, XmlRpcException,
          Types.JoiningHostCannotContainSharedSrs {

    boolean logged_in = false;
    Exception ex = null;
    while (!logged_in) {
      try {
        Pool.join(conn, masterIp, username, password.peek());
        logged_in = true;
      } catch (BadServerResponse e) {
        logged_in = false;
        ex = e;
      } catch (XenAPIException e) {
        logged_in = false;
        ex = e;
      } catch (XmlRpcException e) {
        logged_in = false;
        ex = e;
      }
      if (logged_in && conn != null) {
        break;
      } else {
        if (password.size() > 1) {
          password.remove();
          continue;
        } else {
          // the last password did not work leave it and flag error
          if (ex instanceof BadServerResponse) {
            throw (BadServerResponse) ex;
          } else if (ex instanceof XmlRpcException) {
            throw (XmlRpcException) ex;
          } else if (ex instanceof Types.SessionAuthenticationFailed) {
            throw (Types.SessionAuthenticationFailed) ex;
          } else if (ex instanceof XenAPIException) {
            throw (XenAPIException) ex;
          }
          break;
        }
      }
    }
  }