Search in sources :

Example 1 with ImmediatelyInvalidResourceEntry

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

the class DataPublisherFactory method createResource.

@Override
public SharedResourceFactoryResponse<DataPublisher> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, DataPublisherKey> config) throws NotConfiguredException {
    try {
        DataPublisherKey key = config.getKey();
        String publisherClassName = key.getPublisherClassName();
        State state = key.getState();
        Class<? extends DataPublisher> dataPublisherClass = (Class<? extends DataPublisher>) Class.forName(publisherClassName);
        log.info("Creating data publisher with class {} in scope {}. ", publisherClassName, config.getScope().toString());
        DataPublisher publisher = DataPublisher.getInstance(dataPublisherClass, state);
        // once from the broker.
        if (isPublisherCacheable(publisher)) {
            return new ResourceInstance<>(publisher);
        } else {
            return new ImmediatelyInvalidResourceEntry<>(publisher);
        }
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException(e);
    }
}
Also used : ImmediatelyInvalidResourceEntry(org.apache.gobblin.broker.ImmediatelyInvalidResourceEntry) State(org.apache.gobblin.configuration.State) ResourceInstance(org.apache.gobblin.broker.ResourceInstance)

Aggregations

ImmediatelyInvalidResourceEntry (org.apache.gobblin.broker.ImmediatelyInvalidResourceEntry)1 ResourceInstance (org.apache.gobblin.broker.ResourceInstance)1 State (org.apache.gobblin.configuration.State)1