/** * Create a new {@link ColumnProjectionPolicy} using the alias or cannonical classname specified at {@value #COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY} in the <code>config</code> * The {@link ColumnProjectionPolicy} class MUST have an accessible constructor <code>abc(Config config, TableMetadata tableMetadata)</code> * <b>Note : Must have the key {@value #COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY} set in <code>config</code> to create the {@link ColumnProjectionPolicy}</b> * * @param config job configs, Must have the key {@value #COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY} set to create the {@link ColumnProjectionPolicy} * @param tableMetadata runtime table metadata * * @return a new instance of {@link ColumnProjectionPolicy} */ public ColumnProjectionPolicy create(Config config, ValueAuditRuntimeMetadata.TableMetadata tableMetadata) { Preconditions.checkArgument(config.hasPath(COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY)); log.info("Using column projection class name/alias " + config.getString(COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY)); try { return (ColumnProjectionPolicy)ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( config.getString(COLUMN_PROJECTION_POLICY_CLASS_NAME_KEY))), config, tableMetadata); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } }
/** * Create a new {@link RowSelectionPolicy} using the alias or cannonical classname specified at {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} in the <code>config</code> * The {@link RowSelectionPolicy} class MUST have an accessible constructor <code>abc(Config config, TableMetadata tableMetadata, ColumnProjectionPolicy columnProjectionPolicy)</code> * <b>Note : must have the key {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} set in <code>config</code> to create the {@link RowSelectionPolicy}</b> * * @param config job configs, must have the key {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} set to create the {@link RowSelectionPolicy} * @param tableMetadata runtime table metadata * @param columnProjectionPolicy used by the {@link ValueAuditGenerator} * * @return a new instance of {@link RowSelectionPolicy} */ public RowSelectionPolicy create(Config config, ValueAuditRuntimeMetadata.TableMetadata tableMetadata, ColumnProjectionPolicy columnProjectionPolicy) { Preconditions.checkArgument(config.hasPath(ROW_SELECTION_POLICY_CLASS_NAME_KEY)); log.info("Using row selection class name/alias " + config.getString(ROW_SELECTION_POLICY_CLASS_NAME_KEY)); try { return (RowSelectionPolicy)ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( config.getString(ROW_SELECTION_POLICY_CLASS_NAME_KEY))), config, tableMetadata, columnProjectionPolicy); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } }
/** * Create a new {@link AuditSink} using the alias or cannonical classname specified at {@value #AUDIT_SINK_CLASS_NAME_KEY} in the <code>config</code> * The {@link AuditSink} class MUST have an accessible constructor <code>abc(Config config, TableMetadata tableMetadata)</code> * <br> * If {@value #AUDIT_SINK_CLASS_NAME_KEY} is not set in <code>config</code>, a default {@link #DEFAULT_AUDIT_SINK_CLASS} is used * * @param config job configs * @param auditRuntimeMetadata runtime table metadata * * @return a new instance of {@link AuditSink} */ public AuditSink create(Config config, ValueAuditRuntimeMetadata auditRuntimeMetadata) { String sinkClassName = DEFAULT_AUDIT_SINK_CLASS; if (config.hasPath(AUDIT_SINK_CLASS_NAME_KEY)) { sinkClassName = config.getString(AUDIT_SINK_CLASS_NAME_KEY); } log.info("Using audit sink class name/alias " + sinkClassName); try { return (AuditSink)ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( sinkClassName)), config, auditRuntimeMetadata); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } }
/** * @return A {@link SpecExecutor}'s instance defined by <Technology, Location, Communication Mechanism> */ public synchronized SpecExecutor getSpecExecutor() { if (null == specExecutorInstance) { String specExecutorClass = DEFAULT_SPEC_EXECUTOR_INSTANCE; if (config.hasPath(SPEC_EXECUTOR_INSTANCE_KEY)) { specExecutorClass = config.getString(SPEC_EXECUTOR_INSTANCE_KEY); } try { ClassAliasResolver<SpecExecutor> _aliasResolver = new ClassAliasResolver<>(SpecExecutor.class); specExecutorInstance = (SpecExecutor) ConstructorUtils .invokeConstructor(Class.forName(_aliasResolver .resolve(specExecutorClass)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } } return specExecutorInstance; }
public ScheduledJobConfigurationManager(EventBus eventBus, Config config) { super(eventBus, config); this.jobSpecs = Maps.newHashMap(); this.refreshIntervalInSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.JOB_SPEC_REFRESH_INTERVAL, DEFAULT_JOB_SPEC_REFRESH_INTERVAL); this.fetchJobSpecExecutor = Executors.newSingleThreadScheduledExecutor( ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("FetchJobSpecExecutor"))); this.aliasResolver = new ClassAliasResolver<>(SpecConsumer.class); try { String specConsumerClassName = GobblinClusterConfigurationKeys.DEFAULT_SPEC_CONSUMER_CLASS; if (config.hasPath(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY)) { specConsumerClassName = config.getString(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY); } LOGGER.info("Using SpecConsumer ClassNameclass name/alias " + specConsumerClassName); this._specConsumer = (SpecConsumer) ConstructorUtils .invokeConstructor(Class.forName(this.aliasResolver.resolve(specConsumerClassName)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } }
@Test public void testResolveComGobblinPackage() { ClassAliasResolver<IDummyAliasCom> resolver = new ClassAliasResolver<>(IDummyAliasCom.class); Assert.assertEquals(resolver.resolve("com.alias"), DummyAliasCom.class.getName()); // Resolve returns the passed string if alias mapping does not exist Assert.assertEquals(resolver.resolve("abcd"), "abcd"); }
@Test public void testResolve() { ClassAliasResolver<IDummyAliasTest> resolver = new ClassAliasResolver<>(IDummyAliasTest.class); Assert.assertEquals(resolver.resolve("abc"), DummyAliasTest.class.getName()); // Resolve returns the passed string if alias mapping does not exist Assert.assertEquals(resolver.resolve("abcd"), "abcd"); }
public StreamingJobConfigurationManager(EventBus eventBus, Config config, MutableJobCatalog jobCatalog) { super(eventBus, config); this.stopTimeoutSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.STOP_TIMEOUT_SECONDS, GobblinClusterConfigurationKeys.DEFAULT_STOP_TIMEOUT_SECONDS); this.fetchJobSpecExecutor = Executors.newSingleThreadExecutor( ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("FetchJobSpecExecutor"))); String specExecutorInstanceConsumerClassName = ConfigUtils.getString(config, GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY, GobblinClusterConfigurationKeys.DEFAULT_STREAMING_SPEC_CONSUMER_CLASS); LOGGER.info("Using SpecConsumer ClassNameclass name/alias " + specExecutorInstanceConsumerClassName); try { ClassAliasResolver<SpecConsumer> aliasResolver = new ClassAliasResolver<>(SpecConsumer.class); this.specConsumer = (SpecConsumer) GobblinConstructorUtils.invokeFirstConstructor( Class.forName(aliasResolver.resolve(specExecutorInstanceConsumerClassName)), ImmutableList.<Object>of(config, jobCatalog), ImmutableList.<Object>of(config)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException("Could not construct SpecConsumer " + specExecutorInstanceConsumerClassName, e); } }
this.specCompiler = (SpecCompiler) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specCompilerClassName)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
this.specStore = (SpecStore) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specStoreClassName)), newConfig, this); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
specExecutor = (SpecExecutor) ConstructorUtils .invokeConstructor(Class.forName(_aliasResolver .resolve(specExecutorClass)), topologyConfig); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
this.specStore = (SpecStore) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specStoreClassName)), newConfig, this); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
LOGGER.info("Using TopologySpecFactory class name/alias " + topologySpecFactoryClass); this.topologySpecFactory = (TopologySpecFactory) ConstructorUtils .invokeConstructor(Class.forName(this.aliasResolver.resolve(topologySpecFactoryClass)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
/** * @return A {@link SpecExecutor}'s instance defined by <Technology, Location, Communication Mechanism> */ public synchronized SpecExecutor getSpecExecutor() { if (null == specExecutorInstance) { String specExecutorClass = DEFAULT_SPEC_EXECUTOR_INSTANCE; if (config.hasPath(SPEC_EXECUTOR_INSTANCE_KEY)) { specExecutorClass = config.getString(SPEC_EXECUTOR_INSTANCE_KEY); } try { ClassAliasResolver<SpecExecutor> _aliasResolver = new ClassAliasResolver<>(SpecExecutor.class); specExecutorInstance = (SpecExecutor) ConstructorUtils .invokeConstructor(Class.forName(_aliasResolver .resolve(specExecutorClass)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } } return specExecutorInstance; }
public ScheduledJobConfigurationManager(EventBus eventBus, Config config) { super(eventBus, config); this.jobSpecs = Maps.newHashMap(); this.refreshIntervalInSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.JOB_SPEC_REFRESH_INTERVAL, DEFAULT_JOB_SPEC_REFRESH_INTERVAL); this.fetchJobSpecExecutor = Executors.newSingleThreadScheduledExecutor( ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("FetchJobSpecExecutor"))); this.aliasResolver = new ClassAliasResolver<>(SpecConsumer.class); try { String specConsumerClassName = GobblinClusterConfigurationKeys.DEFAULT_SPEC_CONSUMER_CLASS; if (config.hasPath(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY)) { specConsumerClassName = config.getString(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY); } LOGGER.info("Using SpecConsumer ClassNameclass name/alias " + specConsumerClassName); this._specConsumer = (SpecConsumer) ConstructorUtils .invokeConstructor(Class.forName(this.aliasResolver.resolve(specConsumerClassName)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException(e); } }
public StreamingJobConfigurationManager(EventBus eventBus, Config config, MutableJobCatalog jobCatalog) { super(eventBus, config); this.stopTimeoutSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.STOP_TIMEOUT_SECONDS, GobblinClusterConfigurationKeys.DEFAULT_STOP_TIMEOUT_SECONDS); this.fetchJobSpecExecutor = Executors.newSingleThreadExecutor( ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("FetchJobSpecExecutor"))); String specExecutorInstanceConsumerClassName = ConfigUtils.getString(config, GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY, GobblinClusterConfigurationKeys.DEFAULT_STREAMING_SPEC_CONSUMER_CLASS); LOGGER.info("Using SpecConsumer ClassNameclass name/alias " + specExecutorInstanceConsumerClassName); try { ClassAliasResolver<SpecConsumer> aliasResolver = new ClassAliasResolver<>(SpecConsumer.class); this.specConsumer = (SpecConsumer) GobblinConstructorUtils.invokeFirstConstructor( Class.forName(aliasResolver.resolve(specExecutorInstanceConsumerClassName)), ImmutableList.<Object>of(config, jobCatalog), ImmutableList.<Object>of(config)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new RuntimeException("Could not construct SpecConsumer " + specExecutorInstanceConsumerClassName, e); } }
this.specCompiler = (SpecCompiler) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specCompilerClassName)), config); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
specExecutor = (SpecExecutor) ConstructorUtils .invokeConstructor(Class.forName(_aliasResolver .resolve(specExecutorClass)), topologyConfig); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
this.specStore = (SpecStore) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specStoreClassName)), newConfig, this); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
this.specStore = (SpecStore) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve( specStoreClassName)), newConfig, this); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException