@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; } }
public Collection<VcsClientMapping> getClientMapping( final @NotNull VcsRoot root, final @NotNull IncludeRule rule) throws VcsException { final OperationContext context = createContext(root, "client-mapping"); try { GitVcsRoot gitRoot = context.getGitRoot(); URIish uri = gitRoot.getRepositoryFetchURL(); return Collections.singletonList( new VcsClientMapping( String.format("|%s|%s", uri.toString(), rule.getFrom()), rule.getTo())); } finally { context.close(); } }