use of org.commonjava.maven.galley.TransferTimeoutException in project galley by Commonjava.
the class ExistenceHandler method exists.
public boolean exists(final ConcreteResource resource, final Transfer transfer, final int timeoutSeconds, final Transport transport, final boolean suppressFailures) throws TransferException {
if (nfc.isMissing(resource)) {
logger.debug("NFC: Already marked as missing: {}", resource);
return false;
}
if (transport == null) {
logger.warn("No transports available to handle: {} with location type: {}", resource, resource.getLocation().getClass().getSimpleName());
return false;
}
logger.debug("EXISTS {}", resource);
final ExistenceJob job = transport.createExistenceJob(resource, transfer, timeoutSeconds);
// TODO: execute this stuff in a thread just like downloads/publishes. Requires cache storage...
try {
final Boolean result = job.call();
if (job.getError() != null) {
logger.debug("NFC: Download error. Marking as missing: {}", resource);
nfc.addMissing(resource);
if (!suppressFailures) {
throw job.getError();
}
} else if (result == null) {
logger.debug("NFC: Download did not complete. Marking as missing: {}", resource);
nfc.addMissing(resource);
} else if (!result) {
logger.debug("NFC: Existence check returned false. Marking as missing: {}", resource);
nfc.addMissing(resource);
}
return result;
} catch (final TimeoutException e) {
if (!suppressFailures) {
throw new TransferTimeoutException(transfer, "Timed-out existence check: {}. Reason: {}", e, resource, e.getMessage());
}
} catch (final TransferException e) {
if (!suppressFailures) {
throw e;
}
} catch (final Exception e) {
if (!suppressFailures) {
throw new TransferException("Failed existence check: {}. Reason: {}", e, resource, e.getMessage());
}
}
return false;
}
use of org.commonjava.maven.galley.TransferTimeoutException in project galley by Commonjava.
the class ListingHandler method list.
public ListingResult list(final ConcreteResource resource, final Transfer target, final int timeoutSeconds, final Transport transport, final boolean suppressFailures) throws TransferException {
if (nfc.isMissing(resource)) {
logger.debug("NFC: Already marked as missing: {}", resource);
return null;
}
if (transport == null) {
logger.warn("No transports available to handle: {} with location type: {}", resource, resource.getLocation().getClass().getSimpleName());
return null;
}
logger.debug("LIST {}", resource);
final ListingJob job = transport.createListingJob(resource, target, timeoutSeconds);
// TODO: execute this stuff in a thread just like downloads/publishes. Requires cache storage...
try {
final ListingResult result = job.call();
if (job.getError() != null) {
logger.debug("NFC: Download error. Marking as missing: {}", resource);
nfc.addMissing(resource);
if (!suppressFailures) {
throw job.getError();
}
} else if (result == null) {
logger.debug("NFC: Download did not complete. Marking as missing: {}", resource);
nfc.addMissing(resource);
}
return result;
} catch (final TimeoutException e) {
if (!suppressFailures) {
throw new TransferTimeoutException(target, "Timed-out download: {}. Reason: {}", e, resource, e.getMessage());
}
} catch (final TransferException e) {
if (!suppressFailures) {
throw e;
}
} catch (final Exception e) {
if (!suppressFailures) {
throw new TransferException("Failed listing: {}. Reason: {}", e, resource, e.getMessage());
}
}
return null;
}
use of org.commonjava.maven.galley.TransferTimeoutException 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