コード例 #1
1
ファイル: GitVcsSupport.java プロジェクト: idlsoft/git-plugin
 @NotNull
 private Map<String, Ref> getRemoteRefs(@NotNull Repository db, @NotNull GitVcsRoot gitRoot)
     throws Exception {
   long retryInterval = myConfig.getConnectionRetryIntervalMillis();
   int attemptsLeft = myConfig.getConnectionRetryAttempts();
   while (true) {
     final long start = System.currentTimeMillis();
     Transport transport = null;
     FetchConnection connection = null;
     try {
       transport =
           myTransportFactory.createTransport(
               db, gitRoot.getRepositoryFetchURL(), gitRoot.getAuthSettings());
       connection = transport.openFetch();
       return connection.getRefsMap();
     } catch (NotSupportedException nse) {
       throw friendlyNotSupportedException(gitRoot, nse);
     } catch (TransportException te) {
       attemptsLeft--;
       if (isRecoverable(te) && attemptsLeft > 0) {
         LOG.warn(
             "List remote refs failed: "
                 + te.getMessage()
                 + ", "
                 + attemptsLeft
                 + " attempt(s) left");
       } else {
         throw friendlyTransportException(te, gitRoot);
       }
     } catch (WrongPassphraseException e) {
       throw new VcsException(e.getMessage(), e);
     } finally {
       if (connection != null) connection.close();
       if (transport != null) transport.close();
       final long finish = System.currentTimeMillis();
       PERFORMANCE_LOG.debug(
           "[getRemoteRefs] repository: "
               + LogUtil.describe(gitRoot)
               + ", took "
               + (finish - start)
               + "ms");
     }
     Thread.sleep(retryInterval);
     retryInterval *= 2;
   }
 }
コード例 #2
0
  private boolean selectNextNode() {
    if (nextClient >= nodes.size()) {
      return false;
    }

    if (currentTransport != null) {
      stats.nodeRetries++;
    }

    closeTransport();
    currentNode = nodes.get(nextClient++);
    SettingsUtils.pinNode(settings, currentNode);
    currentTransport = transportFactory.create(settings, currentNode);
    return true;
  }
コード例 #3
0
  protected StubConnection createConnection() throws Exception {
    URI bindURI = getBindURI();

    // Note: on platforms like OS X we cannot bind to the actual hostname, so we
    // instead use the original host name (typically localhost) to bind to

    URI actualURI = this.broker.getConnectURI();
    URI connectURI =
        new URI(
            actualURI.getScheme(),
            actualURI.getUserInfo(),
            bindURI.getHost(),
            actualURI.getPort(),
            actualURI.getPath(),
            bindURI.getQuery(),
            bindURI.getFragment());

    Transport transport = TransportFactory.connect(connectURI);
    StubConnection connection = new StubConnection(transport);
    connections.add(connection);
    return connection;
  }