use of com.netflix.titus.api.store.v2.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.netflix.titus.api.store.v2.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.netflix.titus.api.store.v2.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.netflix.titus.api.store.v2.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();
}
}
});
}
Aggregations