public DefaultStellarShellExecutor( Properties properties, Optional<String> zookeeperUrl) throws Exception { this(StellarFunctions.FUNCTION_RESOLVER(), properties, zookeeperUrl); }
public DefaultMessageRouter(Context context) { this.executor = new DefaultStellarStatefulExecutor(); StellarFunctions.initialize(context); executor.setContext(context); clockFactory = new DefaultClockFactory(); }
@Override public void cleanup() { // This method may not be called in production. // See https://storm.apache.org/releases/1.0.6/javadocs/org/apache/storm/task/IBolt.html#cleanup-- for more detail. super.cleanup(); try { StellarFunctions.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } }
protected void initializeStellar() { this.stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); this.functionResolver = StellarFunctions.FUNCTION_RESOLVER(); }
private void transform(Map<String, String> transforms, Map<String, Object> variableMap, MapVariableResolver variableResolver) { for (Map.Entry<String, String> entry : transforms.entrySet()) { Object o = transformProcessor.parse(entry.getValue(), variableResolver, StellarFunctions.FUNCTION_RESOLVER(), stellarContext); if (o == null) { variableMap.remove(entry.getKey()); } else { variableMap.put(entry.getKey(), o); } } }
@Override public void init() { StellarFunctions.initialize(this.context); // notify listeners about the available specials for(SpecialCommand command : specials) { notifySpecialListeners(command); } // notify listeners about the available functions for(StellarFunctionInfo fn : functionResolver.getFunctionInfo()) { notifyFunctionListeners(fn); } }
@Override public void cleanup() { // This method may not be called in production. // See https://storm.apache.org/releases/1.0.6/javadocs/org/apache/storm/task/IBolt.html#cleanup-- for more detail. super.cleanup(); try { StellarFunctions.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } }
private Boolean filter(String filterPredicate, MapVariableResolver variableResolver) { if(StringUtils.isEmpty(filterPredicate)) { return true; } return filterProcessor.parse(filterPredicate, variableResolver, StellarFunctions.FUNCTION_RESOLVER(), stellarContext); }
/** * Private constructor. Use the {@link Builder} to create a new {@link ProfileBuilder). */ private DefaultProfileBuilder(ProfileConfig definition, String entity, long periodDurationMillis, Context stellarContext) { this.isInitialized = false; this.definition = definition; this.profileName = definition.getProfile(); this.entity = entity; this.periodDurationMillis = periodDurationMillis; this.executor = new DefaultStellarStatefulExecutor(); StellarFunctions.initialize(stellarContext); this.executor.setContext(stellarContext); this.maxTimestamp = 0; }
/** * Quits the console. */ private void handleQuit() { try { console.stop(); StellarFunctions.close(); } catch (Throwable e) { e.printStackTrace(); } }
public DefaultStellarStatefulExecutor() { this(StellarFunctions.FUNCTION_RESOLVER(), Context.EMPTY_CONTEXT()); }
/** * Create the execution context for running Stellar. */ public static Context getContext(Map<String, String> globals) { Context context = new Context.Builder() .with(Context.Capabilities.GLOBAL_CONFIG, () -> globals) .with(Context.Capabilities.STELLAR_CONFIG, () -> globals) .build(); StellarFunctions.initialize(context); return context; } }
public String getHdfsPathExtension(String sourceType, String stellarFunction, JSONObject message) { // If no function is provided, just use the sourceType directly if(stellarFunction == null || stellarFunction.trim().isEmpty()) { return sourceType; } //processor is a StellarProcessor(); VariableResolver resolver = new MapVariableResolver(message); Object objResult = stellarProcessor.parse(stellarFunction, resolver, StellarFunctions.FUNCTION_RESOLVER(), Context.EMPTY_CONTEXT()); if(objResult != null && !(objResult instanceof String)) { throw new IllegalArgumentException("Stellar Function <" + stellarFunction + "> did not return a String value. Returned: " + objResult); } return objResult == null ? "" : (String)objResult; }
protected void initializeStellar() { stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); }
/** * Execute a Stellar expression. * * @param expression The expression to execute. * @param variableResolver Variable Resolver to use * @param context The execution context. * @return The result of executing the expression. */ private static Object execute(String expression, VariableResolver variableResolver, Context context) { StellarProcessor processor = new StellarProcessor(); Object result = processor.parse( expression, variableResolver, StellarFunctions.FUNCTION_RESOLVER(), context); return result; }
protected void initializeStellar() { stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); }
@Override public Object initializeState(Map<String, Object> config) { if(STATE_INIT.existsIn(config)) { MapVariableResolver resolver = new MapVariableResolver(globalConfig); return transformProcessor.parse( config.get(STATE_INIT.toString()).toString() , resolver , StellarFunctions.FUNCTION_RESOLVER() , stellarContext ); } return null; }
protected Context initializeStellar() { Map<String, Object> cacheConfig = new HashMap<>(); for (String sensorType: this.parserRunner.getSensorTypes()) { SensorParserConfig config = getSensorParserConfig(sensorType); if (config != null) { cacheConfig.putAll(config.getCacheConfig()); } } Cache<CachingStellarProcessor.Key, Object> cache = CachingStellarProcessor.createCache(cacheConfig); Context.Builder builder = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) ; if(cache != null) { builder = builder.with(Context.Capabilities.CACHE, () -> cache); } Context stellarContext = builder.build(); StellarFunctions.initialize(stellarContext); return stellarContext; }
if(transformObj != null) { try { Object o = processor.parse(transformObj.toString(), resolver, StellarFunctions.FUNCTION_RESOLVER(), context); if (o != null) { if(outputs.contains(oField)) {
@BeforeClass public static void setup() { ConcurrencyContext infrastructure = new ConcurrencyContext(); infrastructure.initialize(5, 100, 10, null, null, false); stellarContext = new Context.Builder() .build(); StellarFunctions.initialize(stellarContext); StellarAdapter adapter = new AccessLoggingStellarAdapter().ofType("ENRICHMENT"); adapter.initializeAdapter(new HashMap<>()); EnrichmentAdapter<CacheKey> dummy = new DummyEnrichmentAdapter(); enrichmentsByType = ImmutableMap.of("stellar", adapter, "dummy", dummy); enricher = new ParallelEnricher(enrichmentsByType, infrastructure, false); }