mirror of https://github.com/apache/nifi.git
NIFI-6425 Made executeQuery able to reconnect to the Gremlin cluster.
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #3572
This commit is contained in:
parent
4c6c1cbb14
commit
768a7b8c00
|
@ -37,9 +37,11 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
|
|||
private Cluster cluster;
|
||||
protected Client client;
|
||||
public static final String NOT_SUPPORTED = "NOT_SUPPORTED";
|
||||
private ConfigurationContext context;
|
||||
|
||||
@OnEnabled
|
||||
public void onEnabled(ConfigurationContext context) {
|
||||
this.context = context;
|
||||
cluster = buildCluster(context);
|
||||
client = cluster.connect();
|
||||
}
|
||||
|
@ -52,8 +54,7 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
|
|||
cluster = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> executeQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
|
||||
public Map<String, String> doQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
|
||||
try {
|
||||
Iterator<Result> iterator = client.submit(query, parameters).iterator();
|
||||
long count = 0;
|
||||
|
@ -86,6 +87,19 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> executeQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
|
||||
try {
|
||||
return doQuery(query, parameters, handler);
|
||||
} catch (Exception ex) {
|
||||
cluster.close();
|
||||
client.close();
|
||||
cluster = buildCluster(context);
|
||||
client = cluster.connect();
|
||||
return doQuery(query, parameters, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTransitUrl() {
|
||||
return transitUrl;
|
||||
|
|
Loading…
Reference in New Issue