use of org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor in project metron by apache.
the class MagicListVariablesTest method setup.
@Before
public void setup() throws Exception {
// setup the %magic
magic = new MagicListVariables();
// setup the executor
Properties props = new Properties();
executor = new DefaultStellarShellExecutor(props, Optional.empty());
executor.init();
}
use of org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor in project metron by apache.
the class MagicUndefineGlobalTest method setup.
@Before
public void setup() throws Exception {
// setup the %magic
magic = new MagicUndefineGlobal();
// setup the executor
Properties props = new Properties();
executor = new DefaultStellarShellExecutor(props, Optional.empty());
executor.init();
}
use of org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor in project metron by apache.
the class StellarShell method createExecutor.
/**
* Creates the Stellar execution environment.
* @param commandLine The command line arguments.
* @param console The console which drives the REPL.
* @param properties Stellar properties.
*/
private StellarShellExecutor createExecutor(CommandLine commandLine, Console console, Properties properties, StellarAutoCompleter autoCompleter) throws Exception {
// setup zookeeper client
Optional<String> zookeeperUrl = Optional.empty();
if (commandLine.hasOption("z")) {
zookeeperUrl = Optional.of(commandLine.getOptionValue("z"));
}
StellarShellExecutor executor = new DefaultStellarShellExecutor(properties, zookeeperUrl);
// the 'CONSOLE' capability is only available with the CLI REPL
executor.getContext().addCapability(CONSOLE, () -> console);
// allows some Stellar functions to access Stellar internals; should probably use %magics instead
executor.getContext().addCapability(SHELL_VARIABLES, () -> executor.getState());
// register the auto-completer to be notified when needed
executor.addSpecialListener((special) -> autoCompleter.addCandidateFunction(special.getCommand()));
executor.addFunctionListener((function) -> autoCompleter.addCandidateFunction(function.getName()));
executor.addVariableListener((name, val) -> autoCompleter.addCandidateVariable(name));
executor.init();
return executor;
}
use of org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor in project metron by apache.
the class DocCommandTest method setup.
@Before
public void setup() throws Exception {
// setup the command
command = new DocCommand();
// setup a function resolver - only 3 functions have been defined
SimpleFunctionResolver functionResolver = new SimpleFunctionResolver().withClass(StringFunctions.ToString.class).withClass(StringFunctions.ToLower.class).withClass(StringFunctions.ToUpper.class);
// setup the executor
Properties props = new Properties();
executor = new DefaultStellarShellExecutor(functionResolver, props, Optional.empty());
executor.init();
}
use of org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor in project metron by apache.
the class StellarInterpreter method createExecutor.
/**
* Create an executor that will run the Stellar code for the Zeppelin Notebook.
* @return The stellar executor.
*/
private StellarShellExecutor createExecutor() throws Exception {
Properties props = getProperty();
StellarShellExecutor executor = new DefaultStellarShellExecutor(props, Optional.empty());
// register the auto-completer to be notified
executor.addSpecialListener((magic) -> autoCompleter.addCandidateFunction(magic.getCommand()));
executor.addFunctionListener((fn) -> autoCompleter.addCandidateFunction(fn.getName()));
executor.addVariableListener((name, val) -> autoCompleter.addCandidateVariable(name));
executor.init();
return executor;
}
Aggregations