@SuppressWarnings("unchecked") private CustomAction createCustomAction(BasicCustomActionContext context, InstantiatorFactory instantiator, ClassLoader classLoader) throws Exception { Class<?> clz = Class.forName(context.getSpecification().getClassName(), true, classLoader); Preconditions.checkArgument(CustomAction.class.isAssignableFrom(clz), "%s is not a CustomAction.", clz); CustomAction action = instantiator.get(TypeToken.of((Class<? extends CustomAction>) clz)).create(); Reflections.visit(action, action.getClass(), new PropertyFieldSetter(context.getSpecification().getProperties()), new DataSetFieldSetter(context), new MetricsFieldSetter(context.getMetrics())); return action; }
@Override public void visit(Object instance, Type inspectType, Type declareType, Field field) throws Exception { if (field.isAnnotationPresent(Property.class)) { String key = TypeToken.of(declareType).getRawType().getName() + '.' + field.getName(); String value = properties.get(key); if (value == null) { return; } setValue(instance, field, value); } }
@SuppressWarnings("unchecked") private CustomAction createCustomAction(BasicCustomActionContext context, InstantiatorFactory instantiator, ClassLoader classLoader) throws Exception { Class<?> clz = Class.forName(context.getSpecification().getClassName(), true, classLoader); Preconditions.checkArgument(CustomAction.class.isAssignableFrom(clz), "%s is not a CustomAction.", clz); CustomAction action = instantiator.get(TypeToken.of((Class<? extends CustomAction>) clz)).create(); Reflections.visit(action, action.getClass(), new PropertyFieldSetter(context.getSpecification().getProperties()), new DataSetFieldSetter(context), new MetricsFieldSetter(context.getMetrics())); return action; }
@Override public void visit(Object instance, Type inspectType, Type declareType, Field field) throws Exception { if (field.isAnnotationPresent(Property.class)) { String key = TypeToken.of(declareType).getRawType().getName() + '.' + field.getName(); String value = properties.get(key); if (value == null) { return; } setValue(instance, field, value); } }
new PropertyFieldSetter(runtimeContext.getSparkSpecification().getProperties()), new DataSetFieldSetter(runtimeContext.getDatasetCache()), new MetricsFieldSetter(runtimeContext));
new PropertyFieldSetter(runtimeContext.getSparkSpecification().getProperties()), new DataSetFieldSetter(runtimeContext.getDatasetCache()), new MetricsFieldSetter(runtimeContext));
new PropertyFieldSetter(runtimeContext.getSparkSpecification().getProperties()), new DataSetFieldSetter(runtimeContext.getDatasetCache()), new MetricsFieldSetter(runtimeContext));
@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(context.getLoggingContext()); // Instantiate worker instance Class<?> workerClass = program.getClassLoader().loadClass(spec.getClassName()); @SuppressWarnings("unchecked") TypeToken<Worker> workerType = (TypeToken<Worker>) TypeToken.of(workerClass); worker = new InstantiatorFactory(false).get(workerType).create(); // Fields injection Reflections.visit(worker, workerType.getType(), new MetricsFieldSetter(context.getMetrics()), new PropertyFieldSetter(spec.getProperties())); LOG.debug("Starting Worker Program {}", program.getId()); // Initialize worker // Worker is always using Explicit transaction TransactionControl txControl = Transactions.getTransactionControl(TransactionControl.EXPLICIT, Worker.class, worker, "initialize", WorkerContext.class); context.initializeProgram(worker, txControl, false); }
@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(context.getLoggingContext()); // Instantiate worker instance Class<?> workerClass = program.getClassLoader().loadClass(spec.getClassName()); @SuppressWarnings("unchecked") TypeToken<Worker> workerType = (TypeToken<Worker>) TypeToken.of(workerClass); worker = new InstantiatorFactory(false).get(workerType).create(); // Fields injection Reflections.visit(worker, workerType.getType(), new MetricsFieldSetter(context.getMetrics()), new PropertyFieldSetter(spec.getProperties())); LOG.debug("Starting Worker Program {}", program.getId()); // Initialize worker // Worker is always using Explicit transaction TransactionControl txControl = Transactions.getTransactionControl(TransactionControl.EXPLICIT, Worker.class, worker, "initialize", WorkerContext.class); context.initializeProgram(worker, txControl, false); }
new PropertyFieldSetter(basicMapReduceContext.getSpecification().getProperties()), new MetricsFieldSetter(basicMapReduceContext.getMetrics()), new DataSetFieldSetter(basicMapReduceContext));
new PropertyFieldSetter(basicMapReduceContext.getSpecification().getProperties()), new MetricsFieldSetter(basicMapReduceContext.getMetrics()), new DataSetFieldSetter(basicMapReduceContext));
new PropertyFieldSetter(flowletDef.getFlowletSpec().getProperties()), new DataSetFieldSetter(flowletContext), new MetricsFieldSetter(flowletContext.getMetrics()),
new PropertyFieldSetter(context.getSpecification().getProperties()), new MetricsFieldSetter(context.getMetrics()), new DataSetFieldSetter(context));
new PropertyFieldSetter(node.getConditionSpecification().getProperties()), new DataSetFieldSetter(context), new MetricsFieldSetter(context.getMetrics()));
new PropertyFieldSetter(node.getConditionSpecification().getProperties()), new DataSetFieldSetter(context), new MetricsFieldSetter(context.getMetrics()));
new PropertyFieldSetter(basicMapReduceContext.getSpecification().getProperties()), new MetricsFieldSetter(basicMapReduceContext.getMetrics()), new DataSetFieldSetter(basicMapReduceContext));
new PropertyFieldSetter(context.getSpecification().getProperties()), new MetricsFieldSetter(context.getMetrics()), new DataSetFieldSetter(context));
new PropertyFieldSetter(basicMapReduceContext.getSpecification().getProperties()), new MetricsFieldSetter(basicMapReduceContext.getMetrics()), new DataSetFieldSetter(basicMapReduceContext));
new MetricsFieldSetter(context.getMetrics()), new DataSetFieldSetter(context), new PropertyFieldSetter(spec.getProperties()));
new MetricsFieldSetter(context.getMetrics()), new DataSetFieldSetter(runtimeContext.getDatasetCache()), new PropertyFieldSetter(spec.getProperties()));