-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v2-alpha' into gh-2457-double-ca…
…ching-issue
- Loading branch information
Showing
24 changed files
with
308 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
4 changes: 4 additions & 0 deletions
4
example/federated-demo/src/main/resources/operationDeclarations.json
This file contains 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,4 @@ | ||
{ | ||
"operations": [ | ||
] | ||
} |
This file contains 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,42 @@ | ||
Copyright 2022 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. | ||
|
||
Real FederatedStore Example | ||
============= | ||
This example uses a simple shell script that can build the Gaffer project, gathers | ||
default config files (federatedStore.properties, graphConfig.json, OperationDeclarations.json, schema.json) | ||
and an executable Gaffer Spring REST API. The REST API is then started backed by a real FederatedStore from the current config files. | ||
Users can change these local config files, target/indexed-disk-cache and then reboot the REST API. | ||
The script will keep users changes to config files, it will only re-gather deleted/missing files. | ||
This should give a good foundation for users to learn how to configure, interact and launch a real FederatedStore. | ||
|
||
## Deployment | ||
This example does not start or configure a real accumulo cluster. Without you having access to an Accumulo cluster you will not be able to use a Gaffer Accumulo Store. | ||
|
||
Assuming you have Java 8, Maven and Git installed, you can build and run the latest version of Gaffer FederatedStore locally by doing the following: | ||
```bash | ||
# Clone the Gaffer repository, to reduce the amount you need to download this will only clone the master branch with a depth of 1 so there won't be any history. | ||
git clone --depth 1 https://github.com/gchq/Gaffer.git #--branch master | ||
cd Gaffer/example/real-federated-store/ | ||
|
||
# Run this script from this directory. | ||
# This will download several maven dependencies such as tomcat. | ||
./startRealFederatedStore.sh | ||
``` | ||
|
||
The rest api will be deployed to localhost:8080/rest. | ||
|
||
|
||
## Example Operations | ||
Examples can be found at `have-a-go-at-operations`. |
35 changes: 35 additions & 0 deletions
35
example/real-federated-store/have-a-go-at-operations/README.md
This file contains 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,35 @@ | ||
Copyright 2022-2022 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. | ||
|
||
Have A Go Operations | ||
============= | ||
|
||
Your FederatedStore will be empty the first time, so a graph followed by elements will need to be added. Example operations can be found here. | ||
|
||
## JSON | ||
Example json operations can be found at `json-operation-examples`. | ||
Copy & paste the files contents into the Swaggers execute panel. | ||
|
||
## Curl Command | ||
Example curl commands within shell scripts can be found at `curl-opertion-examples`. | ||
Execute these shell scripts or copy & paste the curl command into your terminal. | ||
Curl commands with the "alternative" in the name are duplicate examples that contain inline JSON | ||
instead of reference to a .json file. This allows users to have a go at changing and editing operations in the command line. | ||
|
||
```bash | ||
cd curl-operation-examples/ | ||
./curl_getAllGraphIds.sh | ||
``` | ||
|
||
The rest api will be deployed to localhost:8080/rest. |
1 change: 1 addition & 0 deletions
1
...eal-federated-store/have-a-go-at-operations/curl-operation-examples/curl_add1BasicEdge.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_add1BasicEdge.json 'http://localhost:8080/rest/graph/operations/execute' |
16 changes: 16 additions & 0 deletions
16
...d-store/have-a-go-at-operations/curl-operation-examples/curl_add1BasicEdge_alternative.sh
This file contains 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,16 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ | ||
"class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements", | ||
"input" : [ { | ||
"group" : "BasicEdge", | ||
"source" : "1", | ||
"destination" : "2", | ||
"directed" : true, | ||
"properties" : { | ||
"count" : 1 | ||
}, | ||
"class" : "uk.gov.gchq.gaffer.data.element.Edge" | ||
} ], | ||
"options": { | ||
"gaffer.federatedstore.operation.graphIds": "mapEdges" | ||
} | ||
}' 'http://localhost:8080/rest/graph/operations/execute' |
1 change: 1 addition & 0 deletions
1
...rated-store/have-a-go-at-operations/curl-operation-examples/curl_addGraphForBasicEdges.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_addGraphMapBasicEdges.json 'http://localhost:8080/rest/graph/operations/execute' |
41 changes: 41 additions & 0 deletions
41
...have-a-go-at-operations/curl-operation-examples/curl_addGraphForBasicEdges_alternative.sh
This file contains 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,41 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ | ||
"class": "AddGraph", | ||
"graphId": "mapEdges", | ||
"storeProperties": { | ||
"gaffer.store.class":"uk.gov.gchq.gaffer.mapstore.MapStore" | ||
}, | ||
"schema": { | ||
"edges": { | ||
"BasicEdge": { | ||
"source": "vertex", | ||
"destination": "vertex", | ||
"directed": "true", | ||
"properties": { | ||
"count": "count" | ||
} | ||
} | ||
}, | ||
"types": { | ||
"vertex": { | ||
"class": "java.lang.String" | ||
}, | ||
"count": { | ||
"class": "java.lang.Integer", | ||
"aggregateFunction": { | ||
"class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" | ||
} | ||
}, | ||
"true": { | ||
"description": "A simple boolean that must always be true.", | ||
"class": "java.lang.Boolean", | ||
"validateFunctions": [ | ||
{ | ||
"class": "uk.gov.gchq.koryphe.impl.predicate.IsTrue" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"isPublic": true | ||
}' 'http://localhost:8080/rest/graph/operations/execute' |
1 change: 1 addition & 0 deletions
1
...al-federated-store/have-a-go-at-operations/curl-operation-examples/curl_getAllElements.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_getAllElements.json 'http://localhost:8080/rest/graph/operations/execute' |
1 change: 1 addition & 0 deletions
1
...al-federated-store/have-a-go-at-operations/curl-operation-examples/curl_getAllGraphIds.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_getAllGraphIds.json 'http://localhost:8080/rest/graph/operations/execute' |
1 change: 1 addition & 0 deletions
1
...le/real-federated-store/have-a-go-at-operations/curl-operation-examples/curl_getSchema.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_getSchema.json 'http://localhost:8080/rest/graph/operations/execute' |
4 changes: 4 additions & 0 deletions
4
...rated-store/have-a-go-at-operations/curl-operation-examples/curl_getSchema_alternative.sh
This file contains 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,4 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d ' | ||
{ | ||
"class":"getSchema" | ||
}' 'http://localhost:8080/rest/graph/operations/execute' |
1 change: 1 addition & 0 deletions
1
...erated-store/have-a-go-at-operations/curl-operation-examples/curl_removeBasicEdgeGraph.sh
This file contains 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 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @../json-operation-examples/operation_removeBasicEdgeGraph.json 'http://localhost:8080/rest/graph/operations/execute' |
4 changes: 4 additions & 0 deletions
4
.../have-a-go-at-operations/curl-operation-examples/curl_removeBasicEdgeGraph_alternative.sh
This file contains 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,4 @@ | ||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ | ||
"class": "removeGraph", | ||
"graphId": "mapEdges" | ||
}' 'http://localhost:8080/rest/graph/operations/execute' |
18 changes: 18 additions & 0 deletions
18
...erated-store/have-a-go-at-operations/json-operation-examples/operation_add1BasicEdge.json
This file contains 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,18 @@ | ||
{ | ||
"class": "uk.gov.gchq.gaffer.operation.impl.add.AddElements", | ||
"input": [ | ||
{ | ||
"group": "BasicEdge", | ||
"source": "1", | ||
"destination": "2", | ||
"directed": true, | ||
"properties": { | ||
"count": 1 | ||
}, | ||
"class": "uk.gov.gchq.gaffer.data.element.Edge" | ||
} | ||
], | ||
"options": { | ||
"gaffer.federatedstore.operation.graphIds": "mapEdges" | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...have-a-go-at-operations/json-operation-examples/operation_addGraphAccumuloBasicEdges.json
This file contains 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,26 @@ | ||
{ | ||
"class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraph", | ||
"graphId" : "ToAccumulo", | ||
"isPublic" : true, | ||
"schema" : { | ||
"edges" : { | ||
"simple" : { | ||
"source" : "String", | ||
"destination" : "String" | ||
} | ||
}, | ||
"types" : { | ||
"String" : { | ||
"class" : "java.lang.String" | ||
} | ||
} | ||
}, | ||
"storeProperties" : { | ||
"gaffer.store.class" : "uk.gov.gchq.gaffer.accumulostore.AccumuloStore", | ||
"accumulo.user" : "root", | ||
"accumulo.instance" : "accumulo", | ||
"gaffer.store.properties.class" : "uk.gov.gchq.gaffer.accumulostore.AccumuloProperties", | ||
"accumulo.zookeepers" : "localhost:2181", | ||
"accumulo.password" : "secret" | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...tore/have-a-go-at-operations/json-operation-examples/operation_addGraphMapBasicEdges.json
This file contains 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,40 @@ | ||
{ | ||
"class": "AddGraph", | ||
"graphId": "mapEdges", | ||
"storeProperties": { | ||
"gaffer.store.class": "uk.gov.gchq.gaffer.mapstore.MapStore" | ||
}, | ||
"schema": { | ||
"edges": { | ||
"BasicEdge": { | ||
"source": "vertex", | ||
"destination": "vertex", | ||
"directed": "true", | ||
"properties": { | ||
"count": "count" | ||
} | ||
} | ||
}, | ||
"types": { | ||
"vertex": { | ||
"class": "java.lang.String" | ||
}, | ||
"count": { | ||
"class": "java.lang.Integer", | ||
"aggregateFunction": { | ||
"class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" | ||
} | ||
}, | ||
"true": { | ||
"description": "A simple boolean that must always be true.", | ||
"class": "java.lang.Boolean", | ||
"validateFunctions": [ | ||
{ | ||
"class": "uk.gov.gchq.koryphe.impl.predicate.IsTrue" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"isPublic": true | ||
} |
3 changes: 3 additions & 0 deletions
3
...rated-store/have-a-go-at-operations/json-operation-examples/operation_getAllElements.json
This file contains 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,3 @@ | ||
{ | ||
"class": "GetAllElements" | ||
} |
3 changes: 3 additions & 0 deletions
3
...rated-store/have-a-go-at-operations/json-operation-examples/operation_getAllGraphIds.json
This file contains 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,3 @@ | ||
{ | ||
"class": "GetAllGraphIds" | ||
} |
3 changes: 3 additions & 0 deletions
3
...-federated-store/have-a-go-at-operations/json-operation-examples/operation_getSchema.json
This file contains 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,3 @@ | ||
{ | ||
"class": "GetSchema" | ||
} |
4 changes: 4 additions & 0 deletions
4
...store/have-a-go-at-operations/json-operation-examples/operation_removeBasicEdgeGraph.json
This file contains 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,4 @@ | ||
{ | ||
"class": "removeGraph", | ||
"graphId": "mapEdges" | ||
} |
This file contains 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,55 @@ | ||
#!/bin/bash | ||
|
||
# Run this script from this repository. | ||
# Usage: ./realFederatedStore.sh | ||
|
||
SPRING_V=$(cat ../pom.xml | grep "^ <version>.*</version>$" | awk -F'[><]' '{print $3}') | ||
SPRING_JAR=spring-rest-$SPRING_V-exec.jar | ||
SPRING_TARGET=../../rest-api/spring-rest/target/$SPRING_JAR | ||
PROP=federatedStore.properties | ||
CONF=graphConfig.json | ||
SCHEMA=schema.json | ||
OP_DEC=operationDeclarations.json | ||
PROP_RESOURCE=../federated-demo/src/main/resources/$PROP | ||
CONF_RESOURCE=../federated-demo/src/main/resources/$CONF | ||
SCHEMA_RESOURCE=../federated-demo/src/main/resources/$SCHEMA | ||
OP_DEC_RESOURCE=../federated-demo/src/main/resources/$OP_DEC | ||
|
||
if [[ ! -f $CONF ]] | ||
then | ||
echo "Getting graph config $CONF_RESOURCE" | ||
cp $CONF_RESOURCE ./$CONF | ||
fi | ||
|
||
if [[ ! -f $PROP ]] | ||
then | ||
echo "Getting properties file: $PROP_RESOURCE" | ||
cp $PROP_RESOURCE ./$PROP | ||
fi | ||
|
||
if [[ ! -f $OP_DEC ]] | ||
then | ||
echo "Getting operationDeclarations file: $OP_DEC_RESOURCE" | ||
cp $OP_DEC_RESOURCE ./$OP_DEC | ||
fi | ||
|
||
if [[ ! -f $SCHEMA ]] | ||
then | ||
echo "Making empty schema" | ||
echo "{}" > $SCHEMA | ||
fi | ||
|
||
if [[ ! -f $SPRING_JAR ]] | ||
then | ||
echo "Getting Spring Jar $SPRING_TARGET" | ||
if [[ ! -f $SPRING_TARGET ]] | ||
then | ||
echo "Spring Jar not found, so building project" | ||
mvn clean install -Pquick -f ../../ | ||
fi | ||
cp $SPRING_TARGET ./$SPRING_JAR | ||
# echo "mvn clean" | ||
# mvn clean -f ../../ | ||
fi | ||
|
||
java -Dgaffer.storeProperties=$PROP -Dgaffer.graph.config=$CONF -Dgaffer.schemas=$SCHEMA -jar $SPRING_JAR |