use of io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService in project gravitee-management-rest-api by gravitee-io.
the class DynamicPropertiesService method startDynamicProperties.
private void startDynamicProperties(ApiEntity api) {
if (api.getState() == Lifecycle.State.STARTED) {
DynamicPropertyService dynamicPropertyService = api.getServices().get(DynamicPropertyService.class);
if (dynamicPropertyService != null && dynamicPropertyService.isEnabled()) {
DynamicPropertyUpdater updater = new DynamicPropertyUpdater(api);
if (dynamicPropertyService.getProvider() == DynamicPropertyProvider.HTTP) {
HttpProvider provider = new HttpProvider(dynamicPropertyService);
provider.setVertx(vertx);
updater.setProvider(provider);
updater.setApiService(apiService);
logger.info("Add a scheduled task to poll dynamic properties each {} {} ", dynamicPropertyService.getTrigger().getRate(), dynamicPropertyService.getTrigger().getUnit());
// Force the first refresh, and then run it periodically
updater.handle(null);
long periodicTimer = vertx.setPeriodic(getDelayMillis(dynamicPropertyService.getTrigger()), updater);
timers.put(api, periodicTimer);
}
} else {
logger.info("Dynamic properties service is disabled for: {} [{}]", api.getName(), api.getVersion());
}
}
}
use of io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService in project gravitee-management-rest-api by gravitee-io.
the class DynamicPropertiesService method startDynamicProperties.
private void startDynamicProperties(ApiEntity api) {
if (api.getState() == Lifecycle.State.STARTED) {
DynamicPropertyService dynamicPropertyService = api.getServices().get(DynamicPropertyService.class);
if (dynamicPropertyService != null && dynamicPropertyService.isEnabled()) {
DynamicPropertyUpdater updater = new DynamicPropertyUpdater(api);
if (dynamicPropertyService.getProvider() == DynamicPropertyProvider.HTTP) {
HttpProvider provider = new HttpProvider(dynamicPropertyService);
provider.setVertx(vertx);
provider.setNode(node);
updater.setProvider(provider);
updater.setApiService(apiService);
logger.info("Add a scheduled task to poll dynamic properties each {}", dynamicPropertyService.getSchedule());
// Force the first refresh, and then run it periodically
updater.handle(null);
CronHandler cronHandler = new CronHandler(vertx, dynamicPropertyService.getSchedule());
cronHandler.schedule(updater);
handlers.put(api, cronHandler);
}
} else {
logger.info("Dynamic properties service is disabled for: {} [{}]", api.getName(), api.getVersion());
}
}
}
use of io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method shouldNotBeEnabledWithAnotherService.
@Test
public void shouldNotBeEnabledWithAnotherService() {
ApiEntity api = mock(ApiEntity.class);
DynamicPropertyService dpSrv = mock(DynamicPropertyService.class);
when(dpSrv.isEnabled()).thenReturn(Boolean.TRUE);
Services services = new Services();
services.set(Collections.singletonList(dpSrv));
when(api.getServices()).thenReturn(services);
mockProxy(api, false);
boolean valid = apiService.hasHealthCheckEnabled(api, true);
assertFalse(valid);
}
Aggregations