Search in sources :

Example 1 with EntityChangeEventGenerator

use of org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator in project entity-service by hypertrace.

the class EntityService method doInit.

@Override
protected void doInit() {
    serviceName = getAppConfig().getString(SERVICE_NAME_CONFIG);
    int port = getAppConfig().getInt(SERVICE_PORT_CONFIG);
    Config config = getAppConfig().getConfig(ENTITY_SERVICE_CONFIG);
    EntityServiceConfig entityServiceConfig = new EntityServiceConfig(config);
    Config dataStoreConfig = entityServiceConfig.getDataStoreConfig(entityServiceConfig.getDataStoreType());
    this.datastore = DatastoreProvider.getDatastore(entityServiceConfig.getDataStoreType(), dataStoreConfig);
    GrpcChannelRegistry channelRegistry = new GrpcChannelRegistry();
    this.getLifecycle().shutdownComplete().thenRun(channelRegistry::shutdown);
    Channel localChannel = channelRegistry.forAddress("localhost", port);
    EntityChangeEventGenerator entityChangeEventGenerator = EntityChangeEventGeneratorFactory.getInstance().createEntityChangeEventGenerator(getAppConfig(), Clock.systemUTC());
    server = ServerBuilder.forPort(port).addService(InterceptorUtil.wrapInterceptors(new org.hypertrace.entity.type.service.EntityTypeServiceImpl(datastore))).addService(InterceptorUtil.wrapInterceptors(new EntityTypeServiceImpl(datastore))).addService(InterceptorUtil.wrapInterceptors(new EntityDataServiceImpl(datastore, localChannel, entityChangeEventGenerator))).addService(InterceptorUtil.wrapInterceptors(new EntityQueryServiceImpl(datastore, getAppConfig(), channelRegistry))).build();
    scheduledExecutorService.scheduleAtFixedRate(() -> {
        if (!datastore.healthCheck()) {
            consecutiveFailedHealthCheck++;
            if (consecutiveFailedHealthCheck > 5) {
                LOG.warn("Failed 5 times to connect to data store, shut down EntityService...");
                System.exit(2);
            }
        } else {
            consecutiveFailedHealthCheck = 0;
        }
    }, 60, 60, TimeUnit.SECONDS);
}
Also used : EntityQueryServiceImpl(org.hypertrace.entity.query.service.EntityQueryServiceImpl) GrpcChannelRegistry(org.hypertrace.core.grpcutils.client.GrpcChannelRegistry) EntityDataServiceImpl(org.hypertrace.entity.data.service.EntityDataServiceImpl) Config(com.typesafe.config.Config) Channel(io.grpc.Channel) EntityTypeServiceImpl(org.hypertrace.entity.type.service.v2.EntityTypeServiceImpl) EntityChangeEventGenerator(org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator)

Example 2 with EntityChangeEventGenerator

use of org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator in project entity-service by hypertrace.

the class EntityChangeEventGeneratorFactoryTest method createNoopEntityChangeEventGenerator.

@Test
void createNoopEntityChangeEventGenerator() {
    Config config = ConfigFactory.parseMap(Map.of(ENTITY_SERVICE_CONFIG_PUBLISH_CHANGE_EVENTS, "false"));
    EntityChangeEventGenerator entityChangeEventGenerator = EntityChangeEventGeneratorFactory.getInstance().createEntityChangeEventGenerator(config, Clock.systemUTC());
    assertTrue(entityChangeEventGenerator instanceof NoopEntityChangeEventGenerator);
}
Also used : EntityChangeEventGenerator(org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator) Config(com.typesafe.config.Config) Test(org.junit.jupiter.api.Test)

Example 3 with EntityChangeEventGenerator

use of org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator in project entity-service by hypertrace.

the class EntityChangeEventGeneratorFactoryTest method createEntityChangeEventGeneratorImpl.

@Test
void createEntityChangeEventGeneratorImpl() {
    Config config = getEventStoreConfig();
    EntityChangeEventGenerator entityChangeEventGenerator = EntityChangeEventGeneratorFactory.getInstance().createEntityChangeEventGenerator(config, Clock.systemUTC());
    assertTrue(entityChangeEventGenerator instanceof EntityChangeEventGeneratorImpl);
}
Also used : EntityChangeEventGenerator(org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator) Config(com.typesafe.config.Config) Test(org.junit.jupiter.api.Test)

Aggregations

Config (com.typesafe.config.Config)3 EntityChangeEventGenerator (org.hypertrace.entity.service.change.event.api.EntityChangeEventGenerator)3 Test (org.junit.jupiter.api.Test)2 Channel (io.grpc.Channel)1 GrpcChannelRegistry (org.hypertrace.core.grpcutils.client.GrpcChannelRegistry)1 EntityDataServiceImpl (org.hypertrace.entity.data.service.EntityDataServiceImpl)1 EntityQueryServiceImpl (org.hypertrace.entity.query.service.EntityQueryServiceImpl)1 EntityTypeServiceImpl (org.hypertrace.entity.type.service.v2.EntityTypeServiceImpl)1