Search in sources :

Example 1 with MetaStoreModule

use of org.apache.gobblin.metastore.MetaStoreModule in project incubator-gobblin by apache.

the class TestMetastoreDatabaseServer method getConnector.

private Optional<Connection> getConnector(MySqlJdbcUrl jdbcUrl) throws SQLException {
    Properties properties = new Properties();
    properties.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_URL_KEY, jdbcUrl.toString());
    Injector injector = Guice.createInjector(new MetaStoreModule(properties));
    DataSource dataSource = injector.getInstance(DataSource.class);
    return Optional.of(dataSource.getConnection());
}
Also used : Injector(com.google.inject.Injector) MetaStoreModule(org.apache.gobblin.metastore.MetaStoreModule) Properties(java.util.Properties) DataSource(javax.sql.DataSource)

Example 2 with MetaStoreModule

use of org.apache.gobblin.metastore.MetaStoreModule in project incubator-gobblin by apache.

the class JobExecutionInfoServerTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    testMetastoreDatabase = TestMetastoreDatabaseFactory.get();
    Properties properties = new Properties();
    properties.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_URL_KEY, testMetastoreDatabase.getJdbcUrl());
    int randomPort = new PortUtils.ServerSocketPortLocator().random();
    properties.setProperty(ConfigurationKeys.REST_SERVER_PORT_KEY, Integer.toString(randomPort));
    Injector injector = Guice.createInjector(new MetaStoreModule(properties));
    this.jobHistoryStore = injector.getInstance(JobHistoryStore.class);
    this.client = new JobExecutionInfoClient(String.format("http://%s:%s/", "localhost", randomPort));
    this.server = new JobExecutionInfoServer(properties);
    this.server.startUp();
    this.expected1 = createJobExecutionInfo(1);
    this.expected2 = createJobExecutionInfo(2);
    this.jobHistoryStore.put(this.expected1);
    this.jobHistoryStore.put(this.expected2);
}
Also used : PortUtils(org.apache.gobblin.util.PortUtils) JobHistoryStore(org.apache.gobblin.metastore.JobHistoryStore) Injector(com.google.inject.Injector) MetaStoreModule(org.apache.gobblin.metastore.MetaStoreModule) Properties(java.util.Properties) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with MetaStoreModule

use of org.apache.gobblin.metastore.MetaStoreModule in project incubator-gobblin by apache.

the class JobExecutionInfoServer method startUp.

@Override
protected void startUp() throws Exception {
    // Server configuration
    RestLiConfig config = new RestLiConfig();
    config.addResourcePackageNames(JobExecutionInfoResource.class.getPackage().getName());
    config.setServerNodeUri(serverUri);
    config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler());
    // Handle dependency injection
    Injector injector = Guice.createInjector(new MetaStoreModule(properties));
    JobHistoryStore jobHistoryStore = injector.getInstance(JobHistoryStore.class);
    SimpleBeanProvider beanProvider = new SimpleBeanProvider();
    beanProvider.add("jobHistoryStore", jobHistoryStore);
    // Use InjectMockResourceFactory to keep this Spring free
    ResourceFactory factory = new InjectMockResourceFactory(beanProvider);
    // Create and start the HTTP server
    TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory));
    String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName();
    FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters));
    this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(port, dispatcher));
    LOGGER.info("Starting the job execution information server");
    this.httpServer.get().start();
}
Also used : JobHistoryStore(org.apache.gobblin.metastore.JobHistoryStore) RestLiServer(com.linkedin.restli.server.RestLiServer) SimpleBeanProvider(com.linkedin.restli.server.mock.SimpleBeanProvider) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) HttpNettyServerFactory(com.linkedin.r2.transport.http.server.HttpNettyServerFactory) ServerCompressionFilter(com.linkedin.r2.filter.compression.ServerCompressionFilter) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) FilterChain(com.linkedin.r2.filter.FilterChain) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) ResourceFactory(com.linkedin.restli.server.resources.ResourceFactory) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) Injector(com.google.inject.Injector) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) MetaStoreModule(org.apache.gobblin.metastore.MetaStoreModule) RestLiConfig(com.linkedin.restli.server.RestLiConfig)

Aggregations

Injector (com.google.inject.Injector)3 MetaStoreModule (org.apache.gobblin.metastore.MetaStoreModule)3 Properties (java.util.Properties)2 JobHistoryStore (org.apache.gobblin.metastore.JobHistoryStore)2 FilterChain (com.linkedin.r2.filter.FilterChain)1 ServerCompressionFilter (com.linkedin.r2.filter.compression.ServerCompressionFilter)1 TransportDispatcher (com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)1 HttpNettyServerFactory (com.linkedin.r2.transport.http.server.HttpNettyServerFactory)1 DefaultDocumentationRequestHandler (com.linkedin.restli.docgen.DefaultDocumentationRequestHandler)1 DelegatingTransportDispatcher (com.linkedin.restli.server.DelegatingTransportDispatcher)1 RestLiConfig (com.linkedin.restli.server.RestLiConfig)1 RestLiServer (com.linkedin.restli.server.RestLiServer)1 InjectMockResourceFactory (com.linkedin.restli.server.mock.InjectMockResourceFactory)1 SimpleBeanProvider (com.linkedin.restli.server.mock.SimpleBeanProvider)1 ResourceFactory (com.linkedin.restli.server.resources.ResourceFactory)1 DataSource (javax.sql.DataSource)1 PortUtils (org.apache.gobblin.util.PortUtils)1 BeforeClass (org.testng.annotations.BeforeClass)1