public RepositoryStatusCheckerThread( final Logger logger, final ProxyRepository repository ) { super( "RepositoryStatusChecker-" + repository.getId() ); this.logger = logger; this.repository = repository; this.running = true; }
@Inject public YumProxyImpl(final ProxyMetadataRequestStrategy proxyMetadataRequestStrategy, final BlockSqliteDatabasesRequestStrategy blockSqliteDatabasesRequestStrategy, final @Assisted ProxyRepository repository) throws MalformedURLException, URISyntaxException { this.repository = checkNotNull(repository); this.baseDir = RepositoryUtils.getBaseDir(repository); this.yumRepository = new YumRepositoryImpl(baseDir, repository.getId(), null); repository.registerRequestStrategy( BlockSqliteDatabasesRequestStrategy.class.getName(), checkNotNull(blockSqliteDatabasesRequestStrategy) ); repository.registerRequestStrategy( ProxyMetadataRequestStrategy.class.getName(), checkNotNull(proxyMetadataRequestStrategy) ); }
protected int executeMethod( ProxyRepository repository, ResourceStoreRequest request, HttpMethod method, URL remoteUrl ) throws RemoteStorageException { final Stopwatch stopwatch = timingLog.isDebugEnabled() ? new Stopwatch().start() : null; try { return doExecuteMethod( repository, request, method, remoteUrl ); } finally { if ( stopwatch != null ) { stopwatch.stop(); timingLog.debug( "[{}] {} {} took {}", new Object[] { repository.getId(), method.getName(), remoteUrl, stopwatch } ); } } }
@Override protected void processFileItem(final WalkerContext context, final StorageFileItem item) throws Exception { if (!item.getPath().equals("/" + Yum.PATH_OF_REPOMD_XML) && !locations.contains(item.getPath().substring(1))) { log.trace("Removing obsolete {}:{}", repository.getId(), item.getPath()); repository.deleteItem(true, item.getResourceStoreRequest()); } } });
@Override public void deleteItem( final ProxyRepository repository, final ResourceStoreRequest request ) throws ItemNotFoundException, UnsupportedStorageOperationException, RemoteStorageException { final URL remoteUrl = appendQueryString( getAbsoluteUrlFromBase( repository, request ), repository ); final HttpDelete method = new HttpDelete( remoteUrl.toExternalForm() ); final HttpResponse httpResponse = executeRequestAndRelease( repository, request, method ); final int statusCode = httpResponse.getStatusLine().getStatusCode(); if ( statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT && statusCode != HttpStatus.SC_ACCEPTED ) { throw new RemoteStorageException( "The response to HTTP " + method.getMethod() + " was unexpected HTTP Code " + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase() + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]" ); } }
if ( timingLog.isDebugEnabled() ) timingLog.debug( "[{}] {} {} took {}", new Object[] { repository.getId(), httpRequest.getMethod(), httpRequest.getURI(), stopwatch } );
if ( !repositoryContexts.containsKey( repository.getId() ) || !ctx.hasContextObject( CONTEXT_UPDATED_KEY ) || ctx.getGeneration() > repositoryContexts.get( repository.getId() ) ) if ( !repositoryContexts.containsKey( repository.getId() ) ) new Object[] { ctx, repositoryContexts.get( repository.getId() ) } ); if ( !repositoryContexts.containsKey( repository.getId() ) ) repositoryContexts.put( repository.getId(), ctx.getGeneration() );
log.debug("Checking if {}:primary.xml locations should be rewritten after being proxied", repository.getId()); final String repositoryUrl = repository.getRemoteUrl(); return processMetadata(
throw new RemoteStorageException( e.getMessage() + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]", e ); + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]. Expected: \"any success (2xx)\". Received: " + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase() );
sb.append("' (ID='").append(revt.getRepository().getId()).append("') was set to ");
if ( isAlreadyBeingIndexed( repository.getId() ) ) Lock lock = getLock( repository.getId() ).writeLock(); lock.lock(); getLogger().info( "Trying to get remote index for repository " + repository.getId() ); getLogger().info( "Remote indexes updated successfully for repository " + repository.getId() ); "Remote indexes unchanged (no update needed) for repository " + repository.getId() ); getLogger().warn( "Cannot fetch remote index for repository " + repository.getId(), e );
+ " method. [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + methodUri.toASCIIString() + "\"]", ex ); throw new RemoteStorageTransportOverloadedException( repository, "Connection pool timeout error while executing " + httpRequest.getMethod() + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + methodUri.toASCIIString() + "\"]", ex ); + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + methodUri.toASCIIString() + "\"]", ex );
if (repository != null && item.getPath().toLowerCase().equals("/" + Yum.PATH_OF_REPOMD_XML)) { try { log.debug("Resetting processed flag... ({}:{} cached)", repository.getId(), item.getPath()); item.getRepositoryItemAttributes().remove(YumProxy.PROCESSED); repository.getAttributesHandler().storeAttributes(item); log.warn("Failed to reset processing flag for {}:{}", repository.getId(), item.getPath(), e); log.debug("Marking group repositories as dirty... ({}:{} cached)", repository.getId(), item.getPath()); List<GroupRepository> groups = repositoryRegistryProvider.get().getGroupsOfRepository(repository); for (GroupRepository group : groups) { log.debug("Removing obsolete metadata files... ({}:{} cached)", repository.getId(), item.getPath()); RepoMD repoMD = new RepoMD(((StorageFileItem) item).getInputStream()); final Collection<String> locations = repoMD.getLocations();
@Override public void deleteItem( ProxyRepository repository, ResourceStoreRequest request ) throws ItemNotFoundException, UnsupportedStorageOperationException, RemoteStorageException { URL remoteURL = getAbsoluteUrlFromBase( repository, request ); DeleteMethod method = new DeleteMethod( remoteURL.toString() ); try { int response = executeMethod( repository, request, method, remoteURL ); if ( response != HttpStatus.SC_OK && response != HttpStatus.SC_NO_CONTENT && response != HttpStatus.SC_ACCEPTED ) { throw new RemoteStorageException( "The response to HTTP " + method.getName() + " was unexpected HTTP Code " + response + " : " + HttpStatus.getStatusText( response ) + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteURL.toString() + "\"]" ); } } finally { method.releaseConnection(); } }
+ " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteURL.toString() + "\"]. Expected: \"any success (2xx)\". Received: " + response + " : " + HttpStatus.getStatusText( response ) ); throw new RemoteStorageException( e.getMessage() + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteURL.toString() + "\"]", e );
+ " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteURL.toString() + "\"]. Expected: \"SUCCESS (200)\". Received: " + response + " : " + HttpStatus.getStatusText( response ) );
String.format( "Proxy repository %s (id=%s) got redirected from %s, please verify your remoteUrl is up-to-date!", repository.getName(), repository.getId(), remoteUrl ) );
+ getRepository().getId() + ") repository by checking its remote peer health will occur in " + DurationFormatUtils.formatDurationWords( sleepTime, true, true ) + "." );