This repository was archived by the owner on Jun 6, 2025. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork360
Gh-3322: Cache updates for federated POC#3323
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from9 commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
ceb1df5
better handle cache related operations
tb069041aff14e
basic testing to ensure named ops work
tb06904eff1ddf
sonar smells
tb06904f3870ef
whitespace
tb06904561cb94
add option to let results stay separate #3118
tb06904605963a
add option to specify to use default graph ids
tb0690463f10b0
typo
tb069043468700
Merge branch 'develop' into gh-3322-cache-updates-federated-poc
p2987670a9148
Merge remote-tracking branch 'origin/develop' into gh-3322-cache-upda…
tb06904330e2b3
check style
tb06904File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionscore/graph/src/main/java/uk/gov/gchq/gaffer/graph/hook/NamedOperationResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
56 changes: 44 additions & 12 deletions...ple-federated-store/src/main/java/uk/gov/gchq/gaffer/federated/simple/FederatedStore.java
p29876 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions...ted-store/src/main/java/uk/gov/gchq/gaffer/federated/simple/FederatedStoreProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions...in/java/uk/gov/gchq/gaffer/federated/simple/operation/handler/EitherOperationHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2024 Crown Copyright | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.gchq.gaffer.federated.simple.operation.handler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import uk.gov.gchq.gaffer.operation.Operation; | ||
import uk.gov.gchq.gaffer.operation.OperationException; | ||
import uk.gov.gchq.gaffer.store.Context; | ||
import uk.gov.gchq.gaffer.store.Store; | ||
import uk.gov.gchq.gaffer.store.operation.handler.OperationHandler; | ||
/** | ||
* Custom handler for operations that could in theory target sub graphs or the | ||
* federated store directly. | ||
*/ | ||
public class EitherOperationHandler<O extends Operation> implements OperationHandler<O> { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(EitherOperationHandler.class); | ||
private final OperationHandler<O> standardHandler; | ||
public EitherOperationHandler(final OperationHandler<O> standardHandler) { | ||
this.standardHandler = standardHandler; | ||
} | ||
/** | ||
* If graph IDs are in the options the operation will be handled by a | ||
* {@link FederatedOperationHandler}, otherwise the original handler will be | ||
* used e.g. executed on the federated store directly. | ||
*/ | ||
tb06904 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
@Override | ||
public Object doOperation(final O operation, final Context context, final Store store) throws OperationException { | ||
tb06904 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
LOGGER.debug("Checking if Operation should be handled locally or on sub graphs: {}", operation); | ||
// If we have graph IDs then run as a federated operation | ||
if (operation.containsOption(FederatedOperationHandler.OPT_GRAPH_IDS) || | ||
operation.containsOption(FederatedOperationHandler.OPT_SHORT_GRAPH_IDS) || | ||
operation.containsOption(FederatedOperationHandler.OPT_EXCLUDE_GRAPH_IDS) || | ||
operation.containsOption(FederatedOperationHandler.OPT_USE_DFLT_GRAPH_IDS)) { | ||
LOGGER.debug("Operation has specified graph IDs, it will be handled by sub graphs"); | ||
return new FederatedOperationHandler<>().doOperation(operation, context, store); | ||
} | ||
// No sub graphs involved just run the handler for this operations on the federated store | ||
return standardHandler.doOperation(operation, context, store); | ||
} | ||
} |
49 changes: 18 additions & 31 deletions...java/uk/gov/gchq/gaffer/federated/simple/operation/handler/FederatedOperationHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion...in/java/uk/gov/gchq/gaffer/federated/simple/operation/handler/FederatedOutputHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions...ain/java/uk/gov/gchq/gaffer/federated/simple/operation/handler/SeparateOutputHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2024 Crown Copyright | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.gchq.gaffer.federated.simple.operation.handler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import uk.gov.gchq.gaffer.federated.simple.FederatedStore; | ||
import uk.gov.gchq.gaffer.graph.GraphSerialisable; | ||
import uk.gov.gchq.gaffer.operation.OperationException; | ||
import uk.gov.gchq.gaffer.operation.io.Output; | ||
import uk.gov.gchq.gaffer.store.Context; | ||
import uk.gov.gchq.gaffer.store.Store; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
/** | ||
* Handler for running federated operations but keeping the results separate | ||
* under a key of the graph ID the results come from. | ||
*/ | ||
public class SeparateOutputHandler<P extends Output<O>, O> extends FederatedOperationHandler<P> { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(SeparateOutputHandler.class); | ||
@Override | ||
public Map<String, O> doOperation(final P operation, final Context context, final Store store) throws OperationException { | ||
List<GraphSerialisable> graphsToExecute = this.getGraphsToExecuteOn(operation, context, (FederatedStore) store); | ||
if (graphsToExecute.isEmpty()) { | ||
return new HashMap<>(); | ||
} | ||
// Execute the operation chain on each graph | ||
LOGGER.debug("Returning separated graph results"); | ||
Map<String, O> results = new HashMap<>(); | ||
for (final GraphSerialisable gs : graphsToExecute) { | ||
p29876 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
try { | ||
results.put(gs.getGraphId(), gs.getGraph().execute(operation, context.getUser())); | ||
} catch (final OperationException | UnsupportedOperationException e) { | ||
// Optionally skip this error if user has specified to do so | ||
LOGGER.error("Operation failed on graph: {}", gs.getGraphId()); | ||
if (!Boolean.parseBoolean(operation.getOption(OPT_SKIP_FAILED_EXECUTE, "false"))) { | ||
throw e; | ||
} | ||
} | ||
} | ||
return results; | ||
} | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.