Search in sources :

Example 1 with NotFoundException

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));
        }
    });
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) NotFoundException(com.netflix.titus.api.store.v2.exception.NotFoundException)

Example 2 with NotFoundException

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) {
    }
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) NotFoundException(com.netflix.titus.api.store.v2.exception.NotFoundException) Test(org.junit.Test)

Example 3 with NotFoundException

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();
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) NotFoundException(com.netflix.titus.api.store.v2.exception.NotFoundException) Activator(com.netflix.titus.common.util.guice.annotation.Activator)

Example 4 with NotFoundException

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();
            }
        }
    });
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) NotFoundException(com.netflix.titus.api.store.v2.exception.NotFoundException)

Aggregations

ApplicationSLA (com.netflix.titus.api.model.ApplicationSLA)4 NotFoundException (com.netflix.titus.api.store.v2.exception.NotFoundException)4 Activator (com.netflix.titus.common.util.guice.annotation.Activator)1 Test (org.junit.Test)1