Skip to content

Commit

Permalink
re #1658: Added a remote query service (#1681)
Browse files Browse the repository at this point in the history
* Added a remote query service to allow the webserver to call through to
  the query microservices
* Added a remote query logic that can invoke a remote query service using
  an injected RemoteQueryService.
* Added the ability to wrap a query logic with a filtered query
  logic that would only invoke the underlying logic if the filter passes.
* Created separate predicates for auths and query parameters that can
  be reused elsewhere
  • Loading branch information
ivakegg authored Sep 13, 2022
1 parent 35abb4f commit a698515
Show file tree
Hide file tree
Showing 29 changed files with 2,129 additions and 55 deletions.
31 changes: 31 additions & 0 deletions contrib/datawave-quickstart/docker/datawave-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ do
--web)
START_WEB=true
;;
--webdebug)
START_WEB_DEBUG=true
;;
--test)
START_TEST=true
START_AS_DAEMON=false
;;
--ingest)
START_INGEST=true
;;
Expand All @@ -29,6 +36,30 @@ done

[ "${START_WEB}" == true ] && datawaveWebStart

[ "${START_WEB_DEBUG}" == true ] && datawaveWebStart --debug

if [ "${START_TEST}" == true ] ; then
datawaveWebStart
status=$?

if [ "$status" != "0" ] ; then
echo "datawaveWebStart Failed"
cat ${WILDFLY_HOME}/standalone/log/server.log
exit $status
else
datawaveWebTest --blacklist-files QueryMetrics
status=$?

if [ "$status" != "0" ] ; then
echo "datawaveWebTest Failed"
cat ${WILDFLY_HOME}/standalone/log/server.log
fi

allStop
exit $status
fi
fi

if [ "${START_AS_DAEMON}" == true ] ; then
while true; do sleep 1000; done
fi
Expand Down
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<version.jcommander>1.72</version.jcommander>
<version.jetty>6.1.26</version.jetty>
<version.jgroups>4.0.19.Final</version.jgroups>
<version.jjwt>0.9.1</version.jjwt>
<version.junit>4.13.1</version.junit>
<version.jjwt>0.11.2</version.jjwt>
<version.junit>4.13.2</version.junit>
<version.kryo>2.20</version.kryo>
<version.kryonet>2.20</version.kryonet>
<version.log4j-extras>1.0</version.log4j-extras>
Expand All @@ -79,7 +79,7 @@
<version.microservice.accumulo-api>1.1</version.microservice.accumulo-api>
<version.microservice.accumulo-utils>1.4</version.microservice.accumulo-utils>
<version.microservice.audit-api>1.4</version.microservice.audit-api>
<version.microservice.authorization-api>1.4</version.microservice.authorization-api>
<version.microservice.authorization-api>1.13</version.microservice.authorization-api>
<version.microservice.base-rest-responses>1.2</version.microservice.base-rest-responses>
<version.microservice.common-utils>1.0</version.microservice.common-utils>
<version.microservice.dictionary-api>1.0</version.microservice.dictionary-api>
Expand Down Expand Up @@ -377,7 +377,12 @@
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<artifactId>jjwt-impl</artifactId>
<version>${version.jjwt}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>${version.jjwt}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package datawave.query.config;

import datawave.query.tables.RemoteEventQueryLogic;
import datawave.webservice.query.Query;
import datawave.webservice.query.configuration.GenericQueryConfiguration;

import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.Objects;

/**
* <p>
* A GenericQueryConfiguration implementation that provides the additional logic on top of the traditional query that is needed to run a remote query logic
*
*/
public class RemoteQueryConfiguration extends GenericQueryConfiguration implements Serializable {

private static final long serialVersionUID = -4354990715046146110L;

// the id of the remote query
private String remoteId;

private String remoteQueryLogic;

private Query query;

/**
* Default constructor
*/
public RemoteQueryConfiguration() {
super();
}

/**
* Performs a deep copy of the provided RemoteQueryConfiguration into a new instance
*
* @param other
* - another RemoteQueryConfiguration instance
*/
public RemoteQueryConfiguration(RemoteQueryConfiguration other) {

// GenericQueryConfiguration copy first
super(other);

// RemoteQueryConfiguration copy
this.remoteId = other.getRemoteId();
this.remoteQueryLogic = other.getRemoteQueryLogic();
this.query = other.getQuery();
}

/**
* Delegates deep copy work to appropriate constructor, sets additional values specific to the provided RemoteRemoteQueryLogic
*
* @param logic
* - a RemoteQueryLogic instance or subclass
*/
public RemoteQueryConfiguration(RemoteEventQueryLogic logic) {
this(logic.getConfig());
}

/**
* Factory method that instantiates an fresh RemoteQueryConfiguration
*
* @return - a clean RemoteQueryConfiguration
*/
public static RemoteQueryConfiguration create() {
return new RemoteQueryConfiguration();
}

/**
* Factory method that returns a deep copy of the provided RemoteQueryConfiguration
*
* @param other
* - another instance of a RemoteQueryConfiguration
* @return - copy of provided RemoteQueryConfiguration
*/
public static RemoteQueryConfiguration create(RemoteQueryConfiguration other) {
return new RemoteQueryConfiguration(other);
}

/**
* Factory method that creates a RemoteQueryConfiguration deep copy from a RemoteQueryLogic
*
* @param remoteQueryLogic
* - a configured RemoteQueryLogic
* @return - a RemoteQueryConfiguration
*/
public static RemoteQueryConfiguration create(RemoteEventQueryLogic remoteQueryLogic) {
return create(remoteQueryLogic.getConfig());
}

/**
* Factory method that creates a RemoteQueryConfiguration from a RemoteQueryLogic and a Query
*
* @param remoteQueryLogic
* - a configured RemoteQueryLogic
* @param query
* - a configured Query object
* @return - a RemoteQueryConfiguration
*/
public static RemoteQueryConfiguration create(RemoteEventQueryLogic remoteQueryLogic, Query query) {
RemoteQueryConfiguration config = create(remoteQueryLogic);
config.setQuery(query);
return config;
}

public String getRemoteId() {
return remoteId;
}

public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}

public String getRemoteQueryLogic() {
return remoteQueryLogic;
}

public void setRemoteQueryLogic(String remoteQueryLogic) {
this.remoteQueryLogic = remoteQueryLogic;
}

public Query getQuery() {
return query;
}

public void setQuery(Query query) {
this.query = query;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
RemoteQueryConfiguration that = (RemoteQueryConfiguration) o;
return Objects.equals(getRemoteId(), that.getRemoteId()) && Objects.equals(getRemoteQueryLogic(), that.getRemoteQueryLogic())
&& Objects.equals(getQuery(), that.getQuery());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getRemoteId(), getRemoteQueryLogic(), getQuery());
}

}
Loading

0 comments on commit a698515

Please sign in to comment.