Search in sources :

Example 1 with ExpirationSet

use of org.commonjava.indy.core.expire.ExpirationSet in project indy by Commonjava.

the class IndySchedulerClientModule method getDisabledStoreTimeouts.

public Map<StoreKey, Date> getDisabledStoreTimeouts() throws IndyClientException {
    ExpirationSet expSet = getHttp().get(UrlUtils.buildUrl(BY_STORE_BASE, ALL_STORES, DISABLE_TIMEOUT), ExpirationSet.class);
    Logger logger = LoggerFactory.getLogger(getClass());
    if (expSet == null) {
        logger.debug("No disabled stores!");
        return Collections.emptyMap();
    }
    Map<StoreKey, Date> result = new HashMap<>();
    expSet.forEach((exp) -> {
        logger.debug("Mapping expiration for group: {} (parts: {})", exp.getGroup(), Arrays.asList(exp.getGroup().split("\\s*#\\s*")));
        String[] parts = exp.getGroup().split("\\s*#\\s*");
        if (parts.length < 2) {
            logger.warn("Skipping invalid store-disabled timeout group: '{}'", exp.getGroup());
        } else {
            StoreKey key = StoreKey.fromString(parts[0]);
            logger.debug("{} -> {}", key, exp.getExpiration());
            result.put(key, exp.getExpiration());
        }
    });
    return result;
}
Also used : HashMap(java.util.HashMap) Logger(org.slf4j.Logger) ExpirationSet(org.commonjava.indy.core.expire.ExpirationSet) StoreKey(org.commonjava.indy.model.core.StoreKey) Date(java.util.Date)

Example 2 with ExpirationSet

use of org.commonjava.indy.core.expire.ExpirationSet in project indy by Commonjava.

the class SchedulerController method getDisabledStores.

public ExpirationSet getDisabledStores() throws IndyWorkflowException {
    try {
        // This key matcher will compare with the cache key group to see if the group ends with the "Disable-Timeout"(jobtype)
        ExpirationSet expirations = scheduleManager.findMatchingExpirations(StoreEnablementManager.DISABLE_TIMEOUT);
        // TODO: This seems REALLY inefficient...
        storeDataManager.getAllArtifactStores().forEach((store) -> {
            if (store.isDisabled()) {
                expirations.getItems().add(indefiniteDisable(store));
            }
        });
        return expirations;
    } catch (IndyDataException e) {
        throw new IndyWorkflowException("Failed to load stores to check for indefinite disable. Reason: %s", e, e.getMessage());
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ExpirationSet(org.commonjava.indy.core.expire.ExpirationSet)

Aggregations

ExpirationSet (org.commonjava.indy.core.expire.ExpirationSet)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 Logger (org.slf4j.Logger)1