use of org.commonjava.maven.galley.model.Location in project indy by Commonjava.
the class ExpiringMemoryNotFoundCache method addMissing.
@Override
public void addMissing(final ConcreteResource resource) {
long timeout = Long.MAX_VALUE;
if (config.getNotFoundCacheTimeoutSeconds() > 0) {
timeout = System.currentTimeMillis() + config.getNotFoundCacheTimeoutSeconds() * 1000;
}
final Location loc = resource.getLocation();
final Integer to = loc.getAttribute(RepositoryLocation.ATTR_NFC_TIMEOUT_SECONDS, Integer.class);
if (to != null && to > 0) {
timeout = System.currentTimeMillis() + (to * 1000);
}
final long tstamp = timeout;
logger.info("[NFC] '{}' will not be checked again until: {}", new Object() {
@Override
public String toString() {
return normalize(resource.getLocationUri(), resource.getPath());
}
}, new Object() {
@Override
public String toString() {
return new SimpleDateFormat(TIMEOUT_FORMAT).format(new Date(tstamp));
}
});
missingWithTimeout.put(resource, timeout);
}
use of org.commonjava.maven.galley.model.Location in project indy by Commonjava.
the class ExpiringMemoryNotFoundCache method getAllMissing.
@Override
public Map<Location, Set<String>> getAllMissing() {
clearAllExpiredMissing();
final Map<Location, Set<String>> result = new HashMap<Location, Set<String>>();
for (final ConcreteResource resource : missingWithTimeout.keySet()) {
final Location loc = resource.getLocation();
Set<String> paths = result.get(loc);
if (paths == null) {
paths = new HashSet<String>();
result.put(loc, paths);
}
paths.add(resource.getPath());
}
return result;
}
use of org.commonjava.maven.galley.model.Location in project indy by Commonjava.
the class ExpiringMemoryNotFoundCache method getMissing.
@Override
public Set<String> getMissing(final Location location) {
clearAllExpiredMissing();
final Set<String> paths = new HashSet<String>();
for (final ConcreteResource resource : missingWithTimeout.keySet()) {
final Location loc = resource.getLocation();
if (loc.equals(location)) {
paths.add(resource.getPath());
}
}
return paths;
}
use of org.commonjava.maven.galley.model.Location in project indy by Commonjava.
the class NfcController method getAllMissing.
public NotFoundCacheDTO getAllMissing() {
final NotFoundCacheDTO dto = new NotFoundCacheDTO();
final Map<Location, Set<String>> allMissing = cache.getAllMissing();
for (final Location loc : allMissing.keySet()) {
if (loc instanceof KeyedLocation) {
final List<String> paths = new ArrayList<String>(allMissing.get(loc));
Collections.sort(paths);
dto.addSection(((KeyedLocation) loc).getKey(), paths);
}
}
return dto;
}
use of org.commonjava.maven.galley.model.Location in project indy by Commonjava.
the class DefaultDownloadManager method list.
@Override
public List<StoreResource> list(final ArtifactStore store, final String path) throws IndyWorkflowException {
final List<StoreResource> result = new ArrayList<>();
if (store.getKey().getType() == StoreType.group) {
try {
final List<ListingResult> results = transfers.listAll(locationExpander.expand(new VirtualResource(LocationUtils.toLocations(store), path)));
for (final ListingResult lr : results) {
if (lr != null && lr.getListing() != null) {
for (final String file : lr.getListing()) {
result.add(new StoreResource((KeyedLocation) lr.getLocation(), path, file));
}
}
}
} catch (final BadGatewayException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Bad gateway: " + e.getMessage(), e);
} catch (final TransferTimeoutException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Timeout: " + e.getMessage(), e);
} catch (final TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Location Error: " + e.getMessage(), e);
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list ALL paths: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
} else {
final KeyedLocation loc = LocationUtils.toLocation(store);
final StoreResource res = new StoreResource(loc, path);
if (store instanceof RemoteRepository) {
try {
final ListingResult lr = transfers.list(res);
if (lr != null && lr.getListing() != null) {
for (final String file : lr.getListing()) {
result.add(new StoreResource(loc, path, file));
}
}
} catch (final BadGatewayException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Bad gateway: " + e.getMessage(), e);
} catch (final TransferTimeoutException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Timeout: " + e.getMessage(), e);
} catch (final TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Location Error: " + e.getMessage(), e);
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
} else {
try {
final ListingResult listing = transfers.list(res);
if (listing != null && listing.getListing() != null) {
for (final String child : listing.getListing()) {
result.add(new StoreResource(loc, path, child));
}
}
} catch (final TransferLocationException e) {
Location location = res.getLocation();
KeyedLocation kl = (KeyedLocation) location;
logger.warn("Timeout / bad gateway: " + e.getMessage(), e);
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
}
}
return dedupeListing(result);
}
Aggregations