Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re #2118: composite sequential execution mode #2120

Merged
merged 5 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ protected <T> T execute(HttpRequestBase request, IOFunction<T> resultConverter,

@PostConstruct
protected void init() {
log.info("Starting up RemoteHttpService " + System.identityHashCode(this));
objectMapper = objectMapperDecorator.decorate(new ObjectMapper());
voidResponseReader = objectMapper.readerFor(VoidResponse.class);

Expand Down Expand Up @@ -190,11 +191,14 @@ protected void init() {
log.error("Unable to retrieve aliases from KeyStore.");
throw new IllegalStateException(e);
}
log.info("Started up RemoteHttpService " + System.identityHashCode(this));
}

@PreDestroy
protected void shutdown() {
log.info("Shutting down RemoteHttpService " + System.identityHashCode(this));
executorService.submit(() -> {
log.info("Executing shutdown RemoteHttpService " + System.identityHashCode(RemoteHttpService.this));
long waitStart = System.currentTimeMillis();
long totalWait = 0;
while (activeExecutions.get() > 0 && totalWait < 60000L) {
Expand All @@ -210,7 +214,7 @@ protected void shutdown() {
} catch (IOException e) {
log.warn("Exception while shutting down HttpClient: " + e.getMessage(), e);
}

log.info("Shutdown RemoteHttpService " + System.identityHashCode(RemoteHttpService.this));
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package datawave.webservice.query.logic.composite;

import datawave.webservice.query.Query;
import datawave.webservice.query.QueryImpl;
import datawave.webservice.query.configuration.GenericQueryConfiguration;

import java.io.Serializable;

public class CompositeQueryConfiguration extends GenericQueryConfiguration implements Serializable {

private Query query = null;

// Specifies whether all queries must succeed initialization
private boolean allMustInitialize = false;

// Specifies whether queries are run sequentially. We stop after the first query that returns any results.
private boolean shortCircuitExecution = false;

public CompositeQueryConfiguration() {
super();
query = new QueryImpl();
}

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

// GenericQueryConfiguration copy first
super(other);
}

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

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

/**
* Factory method that creates a CompositeQueryConfiguration deep copy from a CompositeQueryLogic
*
* @param compositeQueryLogic
* - a configured CompositeQueryLogic
* @return - a CompositeQueryConfiguration
*/
public static CompositeQueryConfiguration create(CompositeQueryLogic compositeQueryLogic) {

CompositeQueryConfiguration config = create(compositeQueryLogic.getConfig());

return config;
}

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

public Query getQuery() {
return query;
}

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

public boolean isAllMustInitialize() {
return allMustInitialize;
}

public void setAllMustInitialize(boolean allMustInitialize) {
this.allMustInitialize = allMustInitialize;
}

public boolean isShortCircuitExecution() {
return shortCircuitExecution;
}

public void setShortCircuitExecution(boolean shortCircuitExecution) {
this.shortCircuitExecution = shortCircuitExecution;
}
}
Loading