use of io.opencensus.contrib.spring.aop.Traced in project terra-workspace-manager by DataBiosphere.
the class SamService method deleteControlledResource.
/**
* Delete controlled resource with an access token
*
* @param resource the controlled resource whose Sam resource to delete
* @param token access token
* @throws InterruptedException on thread interrupt
*/
@Traced
public void deleteControlledResource(ControlledResource resource, String token) throws InterruptedException {
ResourcesApi resourceApi = samResourcesApi(token);
try {
SamRetry.retry(() -> resourceApi.deleteResourceV2(resource.getCategory().getSamResourceName(), resource.getResourceId().toString()));
logger.info("Deleted Sam controlled resource {}", resource.getResourceId());
} catch (ApiException apiException) {
// Do nothing if the resource to delete is not found, this may not be the first time delete is
// called. Other exceptions still need to be surfaced.
logger.info("Sam API error while deleting a controlled resource, code is " + apiException.getCode());
if (apiException.getCode() == HttpStatus.NOT_FOUND.value()) {
logger.info("Sam error was NOT_FOUND on a deletion call. " + "This just means the deletion was tried twice so no error thrown.");
return;
}
throw SamExceptionFactory.create("Error deleting controlled resource in Sam", apiException);
}
}
use of io.opencensus.contrib.spring.aop.Traced in project terra-workspace-manager by DataBiosphere.
the class JobService method retrieveJob.
@Traced
public ApiJobReport retrieveJob(String jobId, AuthenticatedUserRequest userRequest) {
try {
// jobId=flightId
verifyUserAccess(jobId, userRequest);
FlightState flightState = stairwayComponent.get().getFlightState(jobId);
return mapFlightStateToApiJobReport(flightState);
} catch (StairwayException | InterruptedException stairwayEx) {
throw new InternalStairwayException(stairwayEx);
}
}
use of io.opencensus.contrib.spring.aop.Traced in project terra-workspace-manager by DataBiosphere.
the class BufferService method getPoolInfo.
/**
* Return the PoolInfo object for the ResourceBuffer pool that we are using to create Google Cloud
* projects. Note that this is configured once per Workspace Manager instance (both the instance
* of RBS to use and which pool) so no configuration happens here.
*
* @return PoolInfo
*/
@Traced
public PoolInfo getPoolInfo() {
try {
BufferApi bufferApi = bufferApi(bufferServiceConfiguration.getInstanceUrl());
PoolInfo info = bufferApi.getPoolInfo(bufferServiceConfiguration.getPoolId());
logger.info("Retrieved pool {} on Buffer Service instance {}", bufferServiceConfiguration.getPoolId(), bufferServiceConfiguration.getInstanceUrl());
return info;
} catch (IOException e) {
throw new BufferServiceAuthorizationException("Error reading or parsing credentials file", e.getCause());
} catch (ApiException e) {
if (e.getCode() == HttpStatus.UNAUTHORIZED.value()) {
throw new BufferServiceAuthorizationException("Not authorized to access Buffer Service", e.getCause());
} else {
throw new BufferServiceAPIException(e);
}
}
}
Aggregations