mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Apply new mechanism to GeodeOqlInterpreter
This commit is contained in:
parent
58cdba2a8c
commit
5dfad61a78
3 changed files with 37 additions and 26 deletions
|
|
@ -21,7 +21,6 @@ import java.util.Properties;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
|
||||
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
|
||||
|
|
@ -38,7 +37,7 @@ import com.gemstone.gemfire.cache.query.Struct;
|
|||
import com.gemstone.gemfire.pdx.PdxInstance;
|
||||
|
||||
/**
|
||||
* Apache Geode OQL Interpreter (http://geode.incubator.apache.org)
|
||||
* Apache Geode OQL Interpreter (http://geode.apache.org)
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code geode.locator.host} - The Geode Locator {@code <HOST>} to connect to.</li>
|
||||
|
|
@ -87,30 +86,12 @@ public class GeodeOqlInterpreter extends Interpreter {
|
|||
|
||||
private Logger logger = LoggerFactory.getLogger(GeodeOqlInterpreter.class);
|
||||
|
||||
public static final String DEFAULT_PORT = "10334";
|
||||
public static final String DEFAULT_HOST = "localhost";
|
||||
public static final String DEFAULT_MAX_RESULT = "1000";
|
||||
|
||||
private static final char NEWLINE = '\n';
|
||||
private static final char TAB = '\t';
|
||||
private static final char WHITESPACE = ' ';
|
||||
|
||||
private static final String TABLE_MAGIC_TAG = "%table ";
|
||||
|
||||
public static final String LOCATOR_HOST = "geode.locator.host";
|
||||
public static final String LOCATOR_PORT = "geode.locator.port";
|
||||
public static final String MAX_RESULT = "geode.max.result";
|
||||
|
||||
static {
|
||||
Interpreter.register(
|
||||
"oql",
|
||||
"geode",
|
||||
GeodeOqlInterpreter.class.getName(),
|
||||
new InterpreterPropertyBuilder().add(LOCATOR_HOST, DEFAULT_HOST, "The Geode Locator Host.")
|
||||
.add(LOCATOR_PORT, DEFAULT_PORT, "The Geode Locator Port")
|
||||
.add(MAX_RESULT, DEFAULT_MAX_RESULT, "Max number of OQL result to display.").build());
|
||||
}
|
||||
|
||||
private ClientCache clientCache = null;
|
||||
private QueryService queryService = null;
|
||||
private Exception exceptionOnConnect;
|
||||
|
|
@ -122,8 +103,8 @@ public class GeodeOqlInterpreter extends Interpreter {
|
|||
|
||||
protected ClientCache getClientCache() {
|
||||
|
||||
String locatorHost = getProperty(LOCATOR_HOST);
|
||||
int locatorPort = Integer.valueOf(getProperty(LOCATOR_PORT));
|
||||
String locatorHost = getProperty("geode.locator.host");
|
||||
int locatorPort = Integer.valueOf(getProperty("geode.locator.port"));
|
||||
|
||||
ClientCache clientCache =
|
||||
new ClientCacheFactory().addPoolLocator(locatorHost, locatorPort).create();
|
||||
|
|
@ -139,7 +120,7 @@ public class GeodeOqlInterpreter extends Interpreter {
|
|||
close();
|
||||
|
||||
try {
|
||||
maxResult = Integer.valueOf(getProperty(MAX_RESULT));
|
||||
maxResult = Integer.valueOf(getProperty("geode.max.result"));
|
||||
|
||||
clientCache = getClientCache();
|
||||
queryService = clientCache.getQueryService();
|
||||
|
|
|
|||
30
geode/src/main/resources/interpreter-setting.json
Normal file
30
geode/src/main/resources/interpreter-setting.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[
|
||||
{
|
||||
"group": "geode",
|
||||
"name": "oql",
|
||||
"className": "org.apache.zeppelin.geode.GeodeOqlInterpreter",
|
||||
"properties": {
|
||||
"geode.locator.host": {
|
||||
"envName": null,
|
||||
"propertyName": "geode.locator.host",
|
||||
"defaultValue": "localhost",
|
||||
"description": "The Geode Locator Host."
|
||||
},
|
||||
"geode.locator.port": {
|
||||
"envName": null,
|
||||
"propertyName": "geode.locator.port",
|
||||
"defaultValue": "10334",
|
||||
"description": "The Geode Locator Port."
|
||||
},
|
||||
"geode.max.result": {
|
||||
"envName": null,
|
||||
"propertyName": "geode.max.result",
|
||||
"defaultValue": "1000",
|
||||
"description": "Max number of OQL result to display."
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"language": "sql"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -58,9 +58,9 @@ public class GeodeOqlInterpreterTest {
|
|||
public void testOpenCommandIndempotency() {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(LOCATOR_HOST, DEFAULT_HOST);
|
||||
properties.put(LOCATOR_PORT, DEFAULT_PORT);
|
||||
properties.put(MAX_RESULT, DEFAULT_MAX_RESULT);
|
||||
properties.put("geode.locator.host", "localhost");
|
||||
properties.put("geode.locator.port", "10334");
|
||||
properties.put("geode.max.result", "1000");
|
||||
|
||||
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(properties));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue