/** * Constructor that extracts the {@link ExecutorContext} internals and turns them into variables. * This method extracts the trasient variables, runtime arguments, environment it's running in and * the context in which it is running as identifiers that can be used within JEXL expression. * * @param context to be examined to be extracted into JEXL expression variables. */ public ELContext(ExecutorContext context) { if (context == null) { return; } // Adds the transient store variables. for (String variable : context.getTransientStore().getVariables()) { values.put(variable, context.getTransientStore().get(variable)); } values.put("runtime", context.getProperties()); values.put("environment", context.getEnvironment().name()); values.put("context", context.getContextName()); }
/** * Returns a instance of {@link SchemaRegistryClient} initialized with service url. * * @param context of the pipeline in which this client is invoked. * @return instance of this class. */ public static SchemaRegistryClient getInstance(ExecutorContext context) { return new SchemaRegistryClient(context.getService("dataprep", "service").toString()); }
private void ensureInitialized(ExecutorContext context) throws DirectiveExecutionException { if (initialized) { return; } Lookup lookup; try { lookup = context.provide(table, Collections.<String, String>emptyMap()); } catch (DatasetInstantiationException e) { throw new DirectiveExecutionException( String.format("%s : Please check that a dataset '%s' of type Table exists.", toString(), table)); } if (!(lookup instanceof co.cask.cdap.etl.api.lookup.TableLookup)) { throw new DirectiveExecutionException(toString() + " : Lookup can be performed only on Tables."); } tableLookup = (co.cask.cdap.etl.api.lookup.TableLookup) lookup; initialized = true; }
throws DirectiveExecutionException, ReportErrorAndProceed { if (context != null) { context.getTransientStore().increment("dq_total", 1); for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); if (result.getBoolean()) { if(metric != null && context != null) { context.getMetrics().count(metric, 1); context.getTransientStore().increment("dq_failure", 1);
private void registerMetric(RuleExecutor executor) { String metricName = String.format("%s.%s.%s.fired", rulebook.getName(), rulebook.getVersion(), executor.getRule().getName()); if (executorContext != null) { executorContext.getMetrics().pipelineCount(metricName, 1); executorContext.getMetrics().pipelineCount(executor.getRule().getName() + ".fired", 1); executorContext.getMetrics().pipelineCount(rulebook.getName() + "." + executor.getRule().getName() + ".fired", 1); } }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException, ErrorRowException { for (Row row : rows) { // Move the fields from the row into the context. ELContext ctx = new ELContext(); ctx.set("this", row); for(String var : el.variables()) { ctx.set(var, row.getValue(var)); } // Transient variables are added. if (context != null) { for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); } } // Execution of the script / expression based on the row data // mapped into context. try { ELResult result = el.execute(ctx); if (result.getBoolean()) { context.getTransientStore().increment(variable, incrementBy); } } catch (ELException e) { throw new DirectiveExecutionException(e.getMessage()); } } return rows; }
if (result.getBoolean()) { if(metric != null && context != null) { context.getMetrics().count(metric, 1);
for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); ELResult result = el.execute(ctx); if (context != null) { context.getTransientStore().set(variable, result.getObject());
for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable));