Search in sources :

Example 1 with KojiRepairRequest

use of org.commonjava.indy.koji.model.KojiRepairRequest in project indy by Commonjava.

the class IndyKojiClientModule method repairVol.

public KojiRepairResult repairVol(final String packageType, final StoreType storeType, final String storeName, final boolean dryRun) throws IndyClientException {
    KojiRepairRequest req = new KojiRepairRequest(new StoreKey(packageType, storeType, storeName), dryRun);
    KojiRepairResult result = http.postWithResponse(REPAIR_KOJI_VOL, req, KojiRepairResult.class, HttpStatus.SC_OK);
    return result;
}
Also used : KojiRepairResult(org.commonjava.indy.koji.model.KojiRepairResult) KojiRepairRequest(org.commonjava.indy.koji.model.KojiRepairRequest) StoreKey(org.commonjava.indy.model.core.StoreKey)

Example 2 with KojiRepairRequest

use of org.commonjava.indy.koji.model.KojiRepairRequest in project indy by Commonjava.

the class KojiRepairManager method repairAllPathMasks.

public KojiMultiRepairResult repairAllPathMasks(final String user) throws KojiRepairException, IndyWorkflowException {
    KojiMultiRepairResult result = new KojiMultiRepairResult();
    if (opLock.tryLock()) {
        try {
            List<RemoteRepository> kojiRemotes = getAllKojiRemotes();
            DrainingExecutorCompletionService<KojiRepairResult> repairService = new DrainingExecutorCompletionService<>(repairExecutor);
            detectOverloadVoid(() -> kojiRemotes.forEach(r -> repairService.submit(() -> {
                logger.info("Attempting to repair path masks in Koji remote: {}", r.getKey());
                KojiRepairRequest request = new KojiRepairRequest(r.getKey(), false);
                try {
                    return repairPathMask(request, user, true);
                } catch (KojiRepairException e) {
                    logger.error("Failed to execute repair for: " + r.getKey(), e);
                }
                return null;
            })));
            List<KojiRepairResult> results = new ArrayList<>();
            try {
                repairService.drain(r -> {
                    if (r != null) {
                        results.add(r);
                    }
                });
            } catch (InterruptedException | ExecutionException e) {
                logger.error("Failed to repair path masks.", e);
            }
            result.setResults(results);
        } catch (IndyDataException e) {
            throw new KojiRepairException("Failed to list Koji remote repositories for repair. Reason: %s", e, e.getMessage());
        } finally {
            opLock.unlock();
        }
    } else {
        throw new KojiRepairException("Koji repair manager is busy.");
    }
    return result;
}
Also used : ChangeSummary(org.commonjava.indy.audit.ChangeSummary) IndyKojiContentProvider(org.commonjava.indy.koji.content.IndyKojiContentProvider) LoggerFactory(org.slf4j.LoggerFactory) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) KojiRepairResult(org.commonjava.indy.koji.model.KojiRepairResult) WeftExecutorService(org.commonjava.cdi.util.weft.WeftExecutorService) Group(org.commonjava.indy.model.core.Group) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) SingleThreadedExecutorService(org.commonjava.cdi.util.weft.SingleThreadedExecutorService) WeftManaged(org.commonjava.cdi.util.weft.WeftManaged) ExecutorConfig(org.commonjava.cdi.util.weft.ExecutorConfig) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) KojiPathPatternFormatter(org.commonjava.indy.koji.content.KojiPathPatternFormatter) DrainingExecutorCompletionService(org.commonjava.cdi.util.weft.DrainingExecutorCompletionService) KOJI_ORIGIN_BINARY(org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN_BINARY) KojiArchiveInfo(com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo) KojiClientException(com.redhat.red.build.koji.KojiClientException) StoreKey(org.commonjava.indy.model.core.StoreKey) StoreType.group(org.commonjava.indy.model.core.StoreType.group) Logger(org.slf4j.Logger) SimpleArtifactRef(org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) ReentrantLock(java.util.concurrent.locks.ReentrantLock) MalformedURLException(java.net.MalformedURLException) KojiClient(com.redhat.red.build.koji.KojiClient) CREATION_TRIGGER_GAV(org.commonjava.indy.koji.content.KojiContentManagerDecorator.CREATION_TRIGGER_GAV) KojiRepairRequest(org.commonjava.indy.koji.model.KojiRepairRequest) StoreType(org.commonjava.indy.model.core.StoreType) Set(java.util.Set) KojiUtils(org.commonjava.indy.koji.util.KojiUtils) Collectors(java.util.stream.Collectors) KojiMultiRepairResult(org.commonjava.indy.koji.model.KojiMultiRepairResult) KOJI_ORIGIN(org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) KojiSessionInfo(com.redhat.red.build.koji.model.xmlrpc.KojiSessionInfo) List(java.util.List) KojiBuildInfo(com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) StoreType.remote(org.commonjava.indy.model.core.StoreType.remote) ArtifactRef(org.commonjava.atlas.maven.ident.ref.ArtifactRef) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IndyDataException(org.commonjava.indy.data.IndyDataException) StoreDataManager(org.commonjava.indy.data.StoreDataManager) PoolUtils.detectOverloadVoid(org.commonjava.indy.core.ctl.PoolUtils.detectOverloadVoid) IndyKojiConfig(org.commonjava.indy.koji.conf.IndyKojiConfig) ArrayList(java.util.ArrayList) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) DrainingExecutorCompletionService(org.commonjava.cdi.util.weft.DrainingExecutorCompletionService) IndyDataException(org.commonjava.indy.data.IndyDataException) KojiMultiRepairResult(org.commonjava.indy.koji.model.KojiMultiRepairResult) KojiRepairResult(org.commonjava.indy.koji.model.KojiRepairResult) KojiRepairRequest(org.commonjava.indy.koji.model.KojiRepairRequest) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with KojiRepairRequest

use of org.commonjava.indy.koji.model.KojiRepairRequest in project indy by Commonjava.

the class KojiRepairManager method repairAllMetadataTimeout.

public KojiMultiRepairResult repairAllMetadataTimeout(final String user, boolean isDryRun) throws KojiRepairException, IndyWorkflowException {
    KojiMultiRepairResult result = new KojiMultiRepairResult();
    if (opLock.tryLock()) {
        try {
            List<RemoteRepository> kojiRemotes = getAllKojiRemotes();
            DrainingExecutorCompletionService<KojiRepairResult> repairService = new DrainingExecutorCompletionService<>(repairExecutor);
            detectOverloadVoid(() -> kojiRemotes.forEach(r -> repairService.submit(() -> {
                logger.info("Attempting to repair path masks in Koji remote: {}", r.getKey());
                KojiRepairRequest request = new KojiRepairRequest(r.getKey(), isDryRun);
                try {
                    return repairMetadataTimeout(request, user, true);
                } catch (KojiRepairException e) {
                    logger.error("Failed to execute repair for: " + r.getKey(), e);
                }
                return null;
            })));
            List<KojiRepairResult> results = new ArrayList<>();
            try {
                repairService.drain(r -> {
                    if (r != null) {
                        results.add(r);
                    }
                });
            } catch (InterruptedException | ExecutionException e) {
                logger.error("Failed to repair metadata timeout.", e);
            }
            result.setResults(results);
        } catch (IndyDataException e) {
            throw new KojiRepairException("Failed to list Koji remote repositories for repair. Reason: %s", e, e.getMessage());
        } finally {
            opLock.unlock();
        }
    } else {
        throw new KojiRepairException("Koji repair manager is busy.");
    }
    return result;
}
Also used : ChangeSummary(org.commonjava.indy.audit.ChangeSummary) IndyKojiContentProvider(org.commonjava.indy.koji.content.IndyKojiContentProvider) LoggerFactory(org.slf4j.LoggerFactory) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) KojiRepairResult(org.commonjava.indy.koji.model.KojiRepairResult) WeftExecutorService(org.commonjava.cdi.util.weft.WeftExecutorService) Group(org.commonjava.indy.model.core.Group) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) SingleThreadedExecutorService(org.commonjava.cdi.util.weft.SingleThreadedExecutorService) WeftManaged(org.commonjava.cdi.util.weft.WeftManaged) ExecutorConfig(org.commonjava.cdi.util.weft.ExecutorConfig) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) KojiPathPatternFormatter(org.commonjava.indy.koji.content.KojiPathPatternFormatter) DrainingExecutorCompletionService(org.commonjava.cdi.util.weft.DrainingExecutorCompletionService) KOJI_ORIGIN_BINARY(org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN_BINARY) KojiArchiveInfo(com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo) KojiClientException(com.redhat.red.build.koji.KojiClientException) StoreKey(org.commonjava.indy.model.core.StoreKey) StoreType.group(org.commonjava.indy.model.core.StoreType.group) Logger(org.slf4j.Logger) SimpleArtifactRef(org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) ReentrantLock(java.util.concurrent.locks.ReentrantLock) MalformedURLException(java.net.MalformedURLException) KojiClient(com.redhat.red.build.koji.KojiClient) CREATION_TRIGGER_GAV(org.commonjava.indy.koji.content.KojiContentManagerDecorator.CREATION_TRIGGER_GAV) KojiRepairRequest(org.commonjava.indy.koji.model.KojiRepairRequest) StoreType(org.commonjava.indy.model.core.StoreType) Set(java.util.Set) KojiUtils(org.commonjava.indy.koji.util.KojiUtils) Collectors(java.util.stream.Collectors) KojiMultiRepairResult(org.commonjava.indy.koji.model.KojiMultiRepairResult) KOJI_ORIGIN(org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) KojiSessionInfo(com.redhat.red.build.koji.model.xmlrpc.KojiSessionInfo) List(java.util.List) KojiBuildInfo(com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) StoreType.remote(org.commonjava.indy.model.core.StoreType.remote) ArtifactRef(org.commonjava.atlas.maven.ident.ref.ArtifactRef) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IndyDataException(org.commonjava.indy.data.IndyDataException) StoreDataManager(org.commonjava.indy.data.StoreDataManager) PoolUtils.detectOverloadVoid(org.commonjava.indy.core.ctl.PoolUtils.detectOverloadVoid) IndyKojiConfig(org.commonjava.indy.koji.conf.IndyKojiConfig) ArrayList(java.util.ArrayList) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) DrainingExecutorCompletionService(org.commonjava.cdi.util.weft.DrainingExecutorCompletionService) IndyDataException(org.commonjava.indy.data.IndyDataException) KojiMultiRepairResult(org.commonjava.indy.koji.model.KojiMultiRepairResult) KojiRepairResult(org.commonjava.indy.koji.model.KojiRepairResult) KojiRepairRequest(org.commonjava.indy.koji.model.KojiRepairRequest) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

KojiRepairRequest (org.commonjava.indy.koji.model.KojiRepairRequest)3 KojiRepairResult (org.commonjava.indy.koji.model.KojiRepairResult)3 KojiClient (com.redhat.red.build.koji.KojiClient)2 KojiClientException (com.redhat.red.build.koji.KojiClientException)2 KojiArchiveInfo (com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo)2 KojiBuildInfo (com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo)2 KojiSessionInfo (com.redhat.red.build.koji.model.xmlrpc.KojiSessionInfo)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2 ExecutionException (java.util.concurrent.ExecutionException)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 Collectors (java.util.stream.Collectors)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Inject (javax.inject.Inject)2 ArtifactRef (org.commonjava.atlas.maven.ident.ref.ArtifactRef)2 SimpleArtifactRef (org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef)2 DrainingExecutorCompletionService (org.commonjava.cdi.util.weft.DrainingExecutorCompletionService)2