use of com.recurly.v3.exception.NotFoundException in project titus-control-plane by Netflix.
the class ApplicationSlaStoreCache method findByName.
public Observable<ApplicationSLA> findByName(String applicationName) {
return Observable.create(subscriber -> {
ApplicationSLA applicationSLA = cache.get(applicationName);
if (applicationSLA != null) {
subscriber.onNext(applicationSLA);
subscriber.onCompleted();
} else {
subscriber.onError(new NotFoundException(ApplicationSLA.class, applicationName));
}
});
}
use of com.recurly.v3.exception.NotFoundException in project titus-control-plane by Netflix.
the class ApplicationSlaStoreCacheTest method testRemove.
@Test
public void testRemove() throws Exception {
when(delegate.remove(anyString())).thenReturn(Observable.empty());
ApplicationSLA applicationSLA = initSet.get(0);
store.remove(applicationSLA.getAppName()).toBlocking().firstOrDefault(null);
try {
store.findByName(applicationSLA.getAppName()).toBlocking().first();
fail("Expected to fail as the entity has been removed");
} catch (NotFoundException ignore) {
}
}
use of com.recurly.v3.exception.NotFoundException in project titus-control-plane by Netflix.
the class ManagementSubsystemInitializer method enterActiveMode.
@Activator
public Observable<Void> enterActiveMode() {
logger.info("Entering active mode");
try {
ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first();
logger.info("Default application SLA configured as: {}", defaultSLA);
} catch (NotFoundException e) {
ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration);
applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null);
logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA);
}
return Observable.empty();
}
use of com.recurly.v3.exception.NotFoundException in project titus-control-plane by Netflix.
the class InMemoryApplicationSlaStore method remove.
@Override
public Observable<Void> remove(String applicationName) {
return Observable.create(subscriber -> {
synchronized (lock) {
ApplicationSLA result = applicationSLAs.remove(applicationName);
if (result == null) {
subscriber.onError(new NotFoundException(ApplicationSLA.class, applicationName));
} else {
applicationSLAsBySchedulerName.remove(result.getSchedulerName(), result);
subscriber.onCompleted();
}
}
});
}
use of com.recurly.v3.exception.NotFoundException in project recurly-client-java by recurly.
the class ExceptionFactory method getExceptionClass.
@SuppressWarnings("unchecked")
public static <T extends RecurlyException> T getExceptionClass(Response response) {
String requestId = response.header("X-Request-Id", "none");
int code = response.code();
String message = "Unexpected " + code + " Error. Recurly Request Id: " + requestId;
switch(code) {
case 500:
return (T) new InternalServerException(message, null);
case 502:
return (T) new BadGatewayException(message, null);
case 503:
return (T) new ServiceUnavailableException(message, null);
case 504:
return (T) new TimeoutException(message, null);
case 304:
return (T) new NotModifiedException(message, null);
case 400:
return (T) new BadRequestException(message, null);
case 401:
return (T) new UnauthorizedException(message, null);
case 402:
return (T) new PaymentRequiredException(message, null);
case 403:
return (T) new ForbiddenException(message, null);
case 404:
return (T) new NotFoundException(message, null);
case 406:
return (T) new NotAcceptableException(message, null);
case 412:
return (T) new PreconditionFailedException(message, null);
case 422:
return (T) new UnprocessableEntityException(message, null);
case 429:
return (T) new TooManyRequestsException(message, null);
default:
return (T) new ApiException(message, null);
}
}
Aggregations