Search in sources :

Example 1 with SharedResourceFactory

use of org.apache.gobblin.broker.iface.SharedResourceFactory in project incubator-gobblin by apache.

the class DefaultGobblinBrokerTest method testExplicitBinding.

@Test
public void testExplicitBinding() throws Exception {
    Config config = ConfigFactory.empty();
    SharedResourcesBrokerImpl<SimpleScopeType> topBroker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(config, SimpleScopeType.GLOBAL.defaultScopeInstance());
    SharedResourceFactory<Long, EmptyKey, SimpleScopeType> factory = new SharedResourceFactory<Long, EmptyKey, SimpleScopeType>() {

        @Override
        public String getName() {
            return "myTestFactory";
        }

        @Override
        public SharedResourceFactoryResponse<Long> createResource(SharedResourcesBroker<SimpleScopeType> broker, ScopedConfigView<SimpleScopeType, EmptyKey> config) throws NotConfiguredException {
            throw new UnsupportedOperationException();
        }

        @Override
        public SimpleScopeType getAutoScope(SharedResourcesBroker<SimpleScopeType> broker, ConfigView<SimpleScopeType, EmptyKey> config) {
            return broker.selfScope().getType();
        }
    };
    topBroker.bindSharedResourceAtScope(factory, new EmptyKey(), SimpleScopeType.GLOBAL, 10l);
    Assert.assertEquals(topBroker.getSharedResource(factory, new EmptyKey()), new Long(10));
}
Also used : SharedResourceFactory(org.apache.gobblin.broker.iface.SharedResourceFactory) ConfigView(org.apache.gobblin.broker.iface.ConfigView) ScopedConfigView(org.apache.gobblin.broker.iface.ScopedConfigView) Config(com.typesafe.config.Config) ScopedConfigView(org.apache.gobblin.broker.iface.ScopedConfigView) SharedResourcesBroker(org.apache.gobblin.broker.iface.SharedResourcesBroker) Test(org.testng.annotations.Test)

Aggregations

Config (com.typesafe.config.Config)1 ConfigView (org.apache.gobblin.broker.iface.ConfigView)1 ScopedConfigView (org.apache.gobblin.broker.iface.ScopedConfigView)1 SharedResourceFactory (org.apache.gobblin.broker.iface.SharedResourceFactory)1 SharedResourcesBroker (org.apache.gobblin.broker.iface.SharedResourcesBroker)1 Test (org.testng.annotations.Test)1