From 04cb92062afb6e11b5c902ad75c36b23e7311e7c Mon Sep 17 00:00:00 2001 From: t92549 <80890692+t92549@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:16:56 +0100 Subject: [PATCH] Gh-1: Create gafferpy standalone repo (#16) * Initial movement of gafferpy * Fixed CI and changed release process * Address review comments --- .github/workflows/continuous-integration.yaml | 69 +--- .github/workflows/create-hotfix-branch.yaml | 79 ---- .github/workflows/create-release-branch.yaml | 79 ---- .github/workflows/release-standalone.yaml | 33 -- .github/workflows/release.yaml | 168 +------- .github/workflows/update-gaffer-version.yaml | 16 +- .gitignore | 192 +++++++-- NOTICES | 30 -- README.md | 111 +++++- cd/check_modules.sh | 25 -- cd/codesigning.asc.enc | Bin 9648 -> 0 bytes cd/mvnsettings.xml | 29 -- cd/updateCopyrightHeaders.sh | 27 -- code-style/checkstyle-suppressions.xml | 24 -- code-style/checkstyle.xml | 201 ---------- code-style/intellij-style.xml | 42 -- code-style/licence-header-java.txt | 16 - code-style/licence-header-pom.txt | 17 - code-style/pmd-ruleset.xml | 113 ------ {python-shell/docs => docs}/Makefile | 0 {python-shell/docs => docs}/make.bat | 0 {python-shell/docs => docs}/source/conf.py | 0 .../docs => docs}/source/gafferpy.client.rst | 0 .../source/gafferpy.generated_api.rst | 0 .../docs => docs}/source/gafferpy.rst | 0 {python-shell/docs => docs}/source/index.rst | 0 .../docs => docs}/source/modules.rst | 0 findbugs-exclude.xml | 22 -- mini-accumulo-cluster/README.md | 76 ---- mini-accumulo-cluster/pom.xml | 132 ------- .../MiniAccumuloClusterController.java | 371 ------------------ ...iniAccumuloClusterWithShellController.java | 96 ----- .../MiniAccumuloShellController.java | 122 ------ .../src/main/resources/log4j.xml | 30 -- .../main/resources/store.properties.template | 23 -- .../MiniAccumuloClusterControllerTest.java | 68 ---- .../src/test/resources/log4j.xml | 30 -- performance-testing/README.md | 26 -- .../pom.xml | 106 ----- .../ingest/AccumuloElementIngestTest.java | 189 --------- .../AccumuloElementIngestTestProperties.java | 56 --- .../ingest/BytesWritableElementGenerator.java | 51 --- .../ingest/BytesWritableMapperGenerator.java | 75 ---- .../ingest/SequenceFileJobInitialiser.java | 42 -- ...tAccumuloStoreRandomElementIngestTest.java | 72 ---- .../src/test/resources/log4j.xml | 30 -- .../performance-testing-aws/pom.xml | 112 ------ .../performancetesting/aws/AwsEmrUtils.java | 59 --- .../aws/CloudWatchMetricsListener.java | 120 ------ .../PublishAccumuloMetricsToCloudWatch.java | 350 ----------------- .../src/main/resources/log4j.xml | 30 -- .../src/test/resources/log4j.xml | 30 -- .../performance-testing-core/pom.xml | 68 ---- .../FileWriterMetricsListener.java | 84 ---- .../gaffer/performancetesting/Metrics.java | 31 -- .../performancetesting/MetricsListener.java | 32 -- .../performancetesting/TestProperties.java | 137 ------- .../ingest/ElementIngestTest.java | 170 -------- .../ingest/ElementIngestTestProperties.java | 52 --- .../ingest/IngestMetrics.java | 62 --- .../query/QueryMetrics.java | 64 --- .../performancetesting/query/QueryTest.java | 181 --------- .../query/QueryTestProperties.java | 48 --- .../ingest/TestElementIngestTest.java | 116 ------ .../ingest/TestQueryTest.java | 126 ------ .../src/test/resources/log4j.xml | 30 -- performance-testing/pom.xml | 19 - pom.xml | 241 ------------ python-shell/LICENSE | 202 ---------- python-shell/README.md | 98 ----- python-shell/src/test/__init__.py | 11 - random-element-generation/README.md | 22 -- random-element-generation/pom.xml | 64 --- .../randomelementgeneration/Constants.java | 36 -- .../randomelementgeneration/cache/Cache.java | 23 -- .../cache/PreferentialAttachmentCache.java | 130 ------ .../cache/ProbabilityGenerator.java | 66 ---- .../ElementGeneratorFromSupplier.java | 44 --- .../supplier/EdgeSeedSupplier.java | 35 -- .../supplier/ElementSeedSupplier.java | 24 -- .../supplier/ElementsSupplier.java | 78 ---- .../supplier/ElementsSupplierWithRepeats.java | 83 ---- .../supplier/EntitySeedSupplier.java | 42 -- .../supplier/RmatElementSupplier.java | 145 ------- .../main/resources/accumuloStore.properties | 21 - .../src/main/resources/log4j.xml | 30 -- .../resources/randomIngestTest.properties | 23 -- .../src/main/resources/schema/elements.json | 21 - .../src/main/resources/schema/types.json | 39 -- .../TestPreferentialAttachmentCache.java | 87 ---- .../cache/TestProbabilityGenerator.java | 73 ---- .../src/test/resources/log4j.xml | 30 -- .../requirements.txt => requirements.txt | 0 python-shell/setup.cfg => setup.cfg | 0 python-shell/setup.py => setup.py | 0 {python-shell/src => src}/__init__.py | 2 +- {python-shell/src => src}/fishbowl/README.md | 0 .../src => src}/fishbowl/__init__.py | 4 +- .../src => src}/fishbowl/fishbowl.py | 0 .../src => src}/fishbowl/templates/base.py.j2 | 0 .../fishbowl/templates/config.py.j2 | 0 .../fishbowl/templates/functions.py.j2 | 0 .../fishbowl/templates/operations.py.j2 | 0 .../src => src}/gafferpy/__init__.py | 2 +- .../src => src}/gafferpy/client/__init__.py | 0 .../gafferpy/client/base_client.py | 0 .../src => src}/gafferpy/client/pki_client.py | 0 .../gafferpy/client/requests_client.py | 0 .../gafferpy/client/urllib_client.py | 0 .../src => src}/gafferpy/fromJson.py | 0 {python-shell/src => src}/gafferpy/gaffer.py | 0 .../gafferpy/gaffer_binaryoperators.py | 0 .../src => src}/gafferpy/gaffer_config.py | 0 .../src => src}/gafferpy/gaffer_connector.py | 0 .../gafferpy/gaffer_connector_pki.py | 0 .../src => src}/gafferpy/gaffer_core.py | 0 .../src => src}/gafferpy/gaffer_functions.py | 0 .../src => src}/gafferpy/gaffer_operations.py | 0 .../src => src}/gafferpy/gaffer_predicates.py | 0 .../src => src}/gafferpy/gaffer_types.py | 0 .../gafferpy/generated_api/__init__.py | 0 .../generated_api/binary_operators.py | 0 .../gafferpy/generated_api/config.py | 0 .../gafferpy/generated_api/functions.py | 0 .../gafferpy/generated_api/operations.py | 0 .../gafferpy/generated_api/predicates.py | 0 .../Gaffer-Python-Demo.ipynb | 0 .../src => src}/gafferpy_examples/__init__.py | 4 +- .../src => src}/gafferpy_examples/example.py | 0 .../gafferpy_examples/example_map.py | 0 .../gafferpy_examples/example_map_pki.py | 0 .../gafferpy_examples/example_pki.py | 0 {python-shell/src => src}/generate.py | 0 {python-shell => src/test}/__init__.py | 4 +- .../addOperationsToChain.json | 0 .../federatedGraphConfig.json | 0 .../federatedStore.properties | 0 .../road-traffic-example/graphConfig.json | 0 .../roadTrafficSampleData.csv | 0 .../road-traffic-example/schema/elements.json | 0 .../road-traffic-example/schema/types.json | 0 .../road-traffic-example/store.properties | 0 .../src => src}/test/test_connector.py | 0 .../src => src}/test/test_example.py | 0 .../src => src}/test/test_example_map.py | 0 .../src => src}/test/test_gaffer_functions.py | 0 .../test/test_gaffer_functions_it.py | 0 .../test/test_gaffer_operations.py | 0 .../test/test_gaffer_operations_it.py | 0 .../test/test_gaffer_predicates.py | 0 .../test/test_gaffer_predicates_it.py | 0 .../src => src}/test/test_json_converter.py | 0 152 files changed, 286 insertions(+), 6207 deletions(-) delete mode 100644 .github/workflows/create-hotfix-branch.yaml delete mode 100644 .github/workflows/create-release-branch.yaml delete mode 100644 .github/workflows/release-standalone.yaml delete mode 100755 NOTICES delete mode 100755 cd/check_modules.sh delete mode 100644 cd/codesigning.asc.enc delete mode 100644 cd/mvnsettings.xml delete mode 100755 cd/updateCopyrightHeaders.sh delete mode 100644 code-style/checkstyle-suppressions.xml delete mode 100644 code-style/checkstyle.xml delete mode 100644 code-style/intellij-style.xml delete mode 100644 code-style/licence-header-java.txt delete mode 100644 code-style/licence-header-pom.txt delete mode 100644 code-style/pmd-ruleset.xml rename {python-shell/docs => docs}/Makefile (100%) rename {python-shell/docs => docs}/make.bat (100%) rename {python-shell/docs => docs}/source/conf.py (100%) rename {python-shell/docs => docs}/source/gafferpy.client.rst (100%) rename {python-shell/docs => docs}/source/gafferpy.generated_api.rst (100%) rename {python-shell/docs => docs}/source/gafferpy.rst (100%) rename {python-shell/docs => docs}/source/index.rst (100%) rename {python-shell/docs => docs}/source/modules.rst (100%) delete mode 100644 findbugs-exclude.xml delete mode 100644 mini-accumulo-cluster/README.md delete mode 100755 mini-accumulo-cluster/pom.xml delete mode 100644 mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterController.java delete mode 100644 mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterWithShellController.java delete mode 100644 mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloShellController.java delete mode 100755 mini-accumulo-cluster/src/main/resources/log4j.xml delete mode 100644 mini-accumulo-cluster/src/main/resources/store.properties.template delete mode 100644 mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java delete mode 100644 mini-accumulo-cluster/src/test/resources/log4j.xml delete mode 100644 performance-testing/README.md delete mode 100644 performance-testing/performance-testing-accumulo-store/pom.xml delete mode 100644 performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTest.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTestProperties.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableElementGenerator.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/SequenceFileJobInitialiser.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java delete mode 100644 performance-testing/performance-testing-accumulo-store/src/test/resources/log4j.xml delete mode 100644 performance-testing/performance-testing-aws/pom.xml delete mode 100644 performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/AwsEmrUtils.java delete mode 100644 performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/CloudWatchMetricsListener.java delete mode 100644 performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java delete mode 100755 performance-testing/performance-testing-aws/src/main/resources/log4j.xml delete mode 100644 performance-testing/performance-testing-aws/src/test/resources/log4j.xml delete mode 100644 performance-testing/performance-testing-core/pom.xml delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/FileWriterMetricsListener.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/Metrics.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/MetricsListener.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/TestProperties.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTest.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTestProperties.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/IngestMetrics.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryMetrics.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTest.java delete mode 100644 performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTestProperties.java delete mode 100644 performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java delete mode 100644 performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java delete mode 100644 performance-testing/performance-testing-core/src/test/resources/log4j.xml delete mode 100644 performance-testing/pom.xml delete mode 100755 pom.xml delete mode 100755 python-shell/LICENSE delete mode 100644 python-shell/README.md delete mode 100644 python-shell/src/test/__init__.py delete mode 100644 random-element-generation/README.md delete mode 100644 random-element-generation/pom.xml delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/Constants.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/Cache.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/PreferentialAttachmentCache.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/ProbabilityGenerator.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/generator/ElementGeneratorFromSupplier.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EdgeSeedSupplier.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementSeedSupplier.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplier.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplierWithRepeats.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EntitySeedSupplier.java delete mode 100644 random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/RmatElementSupplier.java delete mode 100644 random-element-generation/src/main/resources/accumuloStore.properties delete mode 100755 random-element-generation/src/main/resources/log4j.xml delete mode 100644 random-element-generation/src/main/resources/randomIngestTest.properties delete mode 100644 random-element-generation/src/main/resources/schema/elements.json delete mode 100644 random-element-generation/src/main/resources/schema/types.json delete mode 100644 random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java delete mode 100644 random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java delete mode 100644 random-element-generation/src/test/resources/log4j.xml rename python-shell/requirements.txt => requirements.txt (100%) rename python-shell/setup.cfg => setup.cfg (100%) rename python-shell/setup.py => setup.py (100%) rename {python-shell/src => src}/__init__.py (82%) rename {python-shell/src => src}/fishbowl/README.md (100%) rename {python-shell/src => src}/fishbowl/__init__.py (72%) rename {python-shell/src => src}/fishbowl/fishbowl.py (100%) rename {python-shell/src => src}/fishbowl/templates/base.py.j2 (100%) rename {python-shell/src => src}/fishbowl/templates/config.py.j2 (100%) rename {python-shell/src => src}/fishbowl/templates/functions.py.j2 (100%) rename {python-shell/src => src}/fishbowl/templates/operations.py.j2 (100%) rename {python-shell/src => src}/gafferpy/__init__.py (82%) rename {python-shell/src => src}/gafferpy/client/__init__.py (100%) rename {python-shell/src => src}/gafferpy/client/base_client.py (100%) rename {python-shell/src => src}/gafferpy/client/pki_client.py (100%) rename {python-shell/src => src}/gafferpy/client/requests_client.py (100%) rename {python-shell/src => src}/gafferpy/client/urllib_client.py (100%) rename {python-shell/src => src}/gafferpy/fromJson.py (100%) rename {python-shell/src => src}/gafferpy/gaffer.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_binaryoperators.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_config.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_connector.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_connector_pki.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_core.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_functions.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_operations.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_predicates.py (100%) rename {python-shell/src => src}/gafferpy/gaffer_types.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/__init__.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/binary_operators.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/config.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/functions.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/operations.py (100%) rename {python-shell/src => src}/gafferpy/generated_api/predicates.py (100%) rename {python-shell/src => src}/gafferpy_examples/Gaffer-Python-Demo.ipynb (100%) rename {python-shell/src => src}/gafferpy_examples/__init__.py (73%) rename {python-shell/src => src}/gafferpy_examples/example.py (100%) rename {python-shell/src => src}/gafferpy_examples/example_map.py (100%) rename {python-shell/src => src}/gafferpy_examples/example_map_pki.py (100%) rename {python-shell/src => src}/gafferpy_examples/example_pki.py (100%) rename {python-shell/src => src}/generate.py (100%) rename {python-shell => src/test}/__init__.py (72%) rename {cd => src/test}/road-traffic-example/addOperationsToChain.json (100%) rename {cd => src/test}/road-traffic-example/federatedGraphConfig.json (100%) rename {cd => src/test}/road-traffic-example/federatedStore.properties (100%) rename {cd => src/test}/road-traffic-example/graphConfig.json (100%) rename {cd => src/test}/road-traffic-example/roadTrafficSampleData.csv (100%) rename {cd => src/test}/road-traffic-example/schema/elements.json (100%) rename {cd => src/test}/road-traffic-example/schema/types.json (100%) rename {cd => src/test}/road-traffic-example/store.properties (100%) rename {python-shell/src => src}/test/test_connector.py (100%) rename {python-shell/src => src}/test/test_example.py (100%) rename {python-shell/src => src}/test/test_example_map.py (100%) rename {python-shell/src => src}/test/test_gaffer_functions.py (100%) rename {python-shell/src => src}/test/test_gaffer_functions_it.py (100%) rename {python-shell/src => src}/test/test_gaffer_operations.py (100%) rename {python-shell/src => src}/test/test_gaffer_operations_it.py (100%) rename {python-shell/src => src}/test/test_gaffer_predicates.py (100%) rename {python-shell/src => src}/test/test_gaffer_predicates_it.py (100%) rename {python-shell/src => src}/test/test_json_converter.py (100%) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index c0b7daa9..a6c8e2bb 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -4,8 +4,7 @@ on: pull_request: push: branches: - - 'release/**' - - 'hotfix/**' + - 'main' jobs: autopep8: @@ -35,13 +34,6 @@ jobs: if: steps.autopep8.outputs.exit-code == 2 run: exit 1 - check-all-modules-are-tested: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Check all modules are tested - run: ./cd/check_modules.sh - python-tests: runs-on: ubuntu-latest steps: @@ -56,58 +48,21 @@ jobs: uses: actions/cache@v2 with: path: | - ~/.m2/repository - !~/.m2/repository/uk - key: gaffer-tools-dependencies + jetty-runner.jar + road-traffic-rest-2.0.0.war + key: road-traffic-dependencies - name: Start road-traffic example run: | - mvn verify -ntp -Proad-traffic-demo & + curl -o jetty-runner.jar https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.4.52.v20230823/jetty-runner-9.4.52.v20230823.jar + curl -o road-traffic-rest-2.0.0.war https://repo1.maven.org/maven2/uk/gov/gchq/gaffer/road-traffic-rest/2.0.0/road-traffic-rest-2.0.0.war + java \ + -Dgaffer.storeProperties=src/test/road-traffic-example/store.properties \ + -Dgaffer.graph.config=src/test/road-traffic-example/graphConfig.json \ + -Dgaffer.schemas=src/test/road-traffic-example/schema \ + -DroadTraffic.dataLoader.dataPath=src/test/road-traffic-example/roadTrafficSampleData.csv \ + -jar jetty-runner.jar --path rest road-traffic-rest-2.0.0.war & sleep 1m - name: Run Python tests - working-directory: python-shell run: python3 -m unittest discover -s src - - java-build: - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - modules: - - :gaffer-tools,:mini-accumulo-cluster - - :random-element-generation,:performance-testing,:performance-testing-core,:performance-testing-accumulo-store,:performance-testing-aws - - env: - MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '8' - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: | - ~/.m2/repository - !~/.m2/repository/uk - key: gaffer-tools-dependencies - - - name: Install - run: mvn -B -q clean install -P quick -pl ${{matrix.modules}} -am - - - name: Test - run: mvn verify -B -P coverage -pl ${{matrix.modules}} - - - name: Check Copyright Headers - if: github.event_name == 'pull_request' - run: mvn -B -q spotless:check -pl ${{matrix.modules}} - - - name: Upload Coverage - uses: codecov/codecov-action@v2 diff --git a/.github/workflows/create-hotfix-branch.yaml b/.github/workflows/create-hotfix-branch.yaml deleted file mode 100644 index 83c25b43..00000000 --- a/.github/workflows/create-hotfix-branch.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: Create Hotfix Branch - -on: - workflow_dispatch: - inputs: - version: - description: 'Hotfix Branch Version' - required: false - -env: - artifactId: gaffer-tools - MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 - -jobs: - create-hotfix-branch: - runs-on: ubuntu-latest - - steps: - - name: Checkout master - uses: actions/checkout@v3 - with: - ref: master - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Set version from input - if: ${{ github.event.inputs.version }} - run: echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} | sed 's/^v//')" >> $GITHUB_ENV - - - name: Get latest tag - if: ${{ !github.event.inputs.version }} - uses: actions-ecosystem/action-get-latest-tag@v1 - id: get-latest-tag - - - name: Format latest tag - if: ${{ !github.event.inputs.version }} - run: echo "CURRENT_VERSION=$(echo ${{ steps.get-latest-tag.outputs.tag }} | sed 's/^gaffer-tools-//')" >> $GITHUB_ENV - - - name: Bump latest tag variable - if: ${{ !github.event.inputs.version }} - uses: actions-ecosystem/action-bump-semver@v1 - id: bump-semver - with: - current_version: ${{ env.CURRENT_VERSION }} - level: patch - - - name: Set version automatically - if: ${{ !github.event.inputs.version }} - run: echo "RELEASE_VERSION=$(echo ${{ steps.bump-semver.outputs.new_version }} )" >> $GITHUB_ENV - - - name: Verify version regex - uses: actions-ecosystem/action-regex-match@v2 - id: regex-match - with: - text: ${{ env.RELEASE_VERSION }} - # Ensure version doesn't end in .0 - regex: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.([1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' - - - name: Fail if incorrect version - if: ${{ !steps.regex-match.outputs.match }} - run: exit 1 - - - name: Set hotfix branch - run: echo "BRANCH_NAME=$(echo hotfix/${{ env.RELEASE_VERSION }} )" >> $GITHUB_ENV - - - name: Set up Github credentials - run: | - git config user.name Gaffer - git config user.email github-actions@github.com - - - name: Update versions - run: | - mvn versions:set -DnewVersion=$RELEASE_VERSION -DgenerateBackupPoms=false - - - name: Push to hotfix branch - run: | - git checkout -b $BRANCH_NAME - git commit -a -m "prepare release $artifactId-$RELEASE_VERSION" - git push --set-upstream origin $BRANCH_NAME diff --git a/.github/workflows/create-release-branch.yaml b/.github/workflows/create-release-branch.yaml deleted file mode 100644 index 6e19b058..00000000 --- a/.github/workflows/create-release-branch.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: Create Release Branch - -on: - workflow_dispatch: - inputs: - version: - description: 'Release Branch Version' - required: false - -env: - artifactId: gaffer-tools - MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 - -jobs: - create-release-branch: - runs-on: ubuntu-latest - - steps: - - name: Checkout develop - uses: actions/checkout@v3 - with: - ref: develop - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Set version from input - if: ${{ github.event.inputs.version }} - run: echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} | sed 's/^v//')" >> $GITHUB_ENV - - - name: Get latest tag - if: ${{ !github.event.inputs.version }} - uses: actions-ecosystem/action-get-latest-tag@v1 - id: get-latest-tag - - - name: Format latest tag - if: ${{ !github.event.inputs.version }} - run: echo "CURRENT_VERSION=$(echo ${{ steps.get-latest-tag.outputs.tag }} | sed 's/^gaffer-tools-//')" >> $GITHUB_ENV - - - name: Bump latest tag variable - if: ${{ !github.event.inputs.version }} - uses: actions-ecosystem/action-bump-semver@v1 - id: bump-semver - with: - current_version: ${{ env.CURRENT_VERSION }} - level: minor - - - name: Set version automatically - if: ${{ !github.event.inputs.version }} - run: echo "RELEASE_VERSION=$(echo ${{ steps.bump-semver.outputs.new_version }} )" >> $GITHUB_ENV - - - name: Verify version regex - uses: actions-ecosystem/action-regex-match@v2 - id: regex-match - with: - text: ${{ env.RELEASE_VERSION }} - # Ensure valid semver version - regex: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' - - - name: Fail if incorrect version - if: ${{ !steps.regex-match.outputs.match }} - run: exit 1 - - - name: Set release branch - run: echo "BRANCH_NAME=$(echo release/${{ env.RELEASE_VERSION }} )" >> $GITHUB_ENV - - - name: Set up Github credentials - run: | - git config user.name Gaffer - git config user.email github-actions@github.com - - - name: Update versions - run: | - mvn versions:set -DnewVersion=$RELEASE_VERSION -DgenerateBackupPoms=false - - - name: Push to release branch - run: | - git checkout -b $BRANCH_NAME - git commit -a -m "prepare release $artifactId-$RELEASE_VERSION" - git push --set-upstream origin $BRANCH_NAME diff --git a/.github/workflows/release-standalone.yaml b/.github/workflows/release-standalone.yaml deleted file mode 100644 index e66c06c8..00000000 --- a/.github/workflows/release-standalone.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Release To Nexus as standalone - -on: [ workflow_dispatch ] - -jobs: - run-maven-release: - runs-on: ubuntu-latest - steps: - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '8' - - - name: Checkout Branch - uses: actions/checkout@v3 - - - name: Decode CodeSigning key - env: - CODE_SIGNING_KEY: ${{ secrets.CODE_SIGNING_KEY }} - CODE_SIGNING_IV: ${{ secrets.CODE_SIGNING_IV }} - run: openssl aes-256-cbc -K "$CODE_SIGNING_KEY" -iv "$CODE_SIGNING_IV" -in cd/codesigning.asc.enc -out cd/codesigning.asc -d - - - name: Import CodeSigning key - run: gpg --batch --fast-import cd/codesigning.asc - - - name: Release to Nexus - env: - GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - OSS_NEXUS_USERNAME: ${{ secrets.OSS_NEXUS_USERNAME }} - OSS_NEXUS_PASSWORD: ${{ secrets.OSS_NEXUS_PASSWORD }} - run: mvn deploy -P quick,ossrh-release --settings cd/mvnsettings.xml -B diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 51cf21c9..4afcbc14 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,60 +1,34 @@ name: Full Release on: - milestone: - types: - - closed + workflow_dispatch: + inputs: + version: + description: 'Release Branch Version' + required: true env: - artifactId: gaffer-tools - MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 + artifactId: gafferpy jobs: create-release-tag: runs-on: ubuntu-latest - outputs: - branch_name: ${{ steps.branch.outputs.branch_name }} - steps: - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '8' - - - name: Checkout master + - name: Checkout main uses: actions/checkout@v3 with: - ref: master + ref: main token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - fetch-depth: 0 - name: Set up Github credentials run: | - git config user.name Gaffer - git config user.email github-actions@github.com + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com - name: Set release version - run: echo "RELEASE_VERSION=$(echo ${{ github.event.milestone.title }} | cut -c 2-)" >> $GITHUB_ENV - - - name: Set branch name - run: echo "BRANCH_NAME=$(git branch -a | grep $RELEASE_VERSION | tail -n 1 | cut -c 18-)" >> $GITHUB_ENV - - - name: Output branch name - id: branch - run: echo "::set-output name=branch_name::$BRANCH_NAME" - - - name: Fail if no branch found - if: ${{ !env.BRANCH_NAME }} - run: exit 1 - - - name: Merge release into master - run: | - git checkout ${{ env.BRANCH_NAME }} - git checkout master - git merge ${{ env.BRANCH_NAME }} + run: echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} | cut -c 2-)" >> $GITHUB_ENV - name: Push changes run: | @@ -62,53 +36,16 @@ jobs: git push origin $artifactId-$RELEASE_VERSION git push - update-develop: - runs-on: ubuntu-latest - needs: - - create-release-tag - - steps: - - name: Checkout develop - uses: actions/checkout@v3 - with: - ref: develop - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Set up Github credentials - run: | - git config user.name Gaffer - git config user.email github-actions@github.com - - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '8' - - - name: Merge release into develop - run: | - git checkout ${{ needs.create-release-tag.outputs.branch_name }} - git checkout develop - git merge ${{ needs.create-release-tag.outputs.branch_name }} --strategy-option theirs - - - name: Update develop branch - run: | - git checkout develop - mvn release:update-versions -B - git commit -a -m "prepare for next development iteration" - git push - update-github-releases: runs-on: ubuntu-latest needs: - create-release-tag steps: - - name: Checkout Master + - name: Checkout Main uses: actions/checkout@v3 with: - ref: master + ref: main - name: Create Release Notes uses: docker://decathlon/release-notes-generator-action:2.1.0 @@ -116,7 +53,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set version - run: echo "RELEASE_VERSION=$(echo ${{ github.event.milestone.title }} | cut -c 2-)" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} | cut -c 2-)" >> $GITHUB_ENV - name: Upload notes uses: softprops/action-gh-release@v1 @@ -124,80 +61,5 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.artifactId }}-${{ env.RELEASE_VERSION }} - name: Gaffer Tools ${{ env.RELEASE_VERSION }} + name: gafferpy ${{ env.RELEASE_VERSION }} body_path: release_file.md - - generate-javadoc: - runs-on: ubuntu-latest - needs: - - create-release-tag - - steps: - - name: Checkout Master - uses: actions/checkout@v3 - with: - ref: master - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - - - name: Set up Github credentials - run: | - git config user.name Gaffer - git config user.email github-actions@github.com - - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '11' - - - name: Set version - run: echo "RELEASE_VERSION=$(echo ${{ github.event.milestone.title }} | cut -c 2-)" >> $GITHUB_ENV - - - name: Upload Javadoc - run: | - git remote set-branches --add origin gh-pages - git pull - mvn -q clean install -Pquick -Dskip.jar-with-dependencies=true -Dshaded.jar.phase=true - mvn -q javadoc:aggregate - git checkout gh-pages - rm -rf uk - rm -rf jquery - rm -rf resources - mv target/site/apidocs/* . - git add . - git commit -a -m "Updated javadoc - $RELEASE_VERSION" - git push - - release-to-nexus: - runs-on: ubuntu-latest - needs: - - create-release-tag - - steps: - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '8' - - - name: Checkout release - uses: actions/checkout@v3 - with: - ref: ${{ needs.create-release-tag.outputs.branch_name }} - - - name: Decode CodeSigning key - env: - CODE_SIGNING_KEY: ${{ secrets.CODE_SIGNING_KEY }} - CODE_SIGNING_IV: ${{ secrets.CODE_SIGNING_IV }} - run: openssl aes-256-cbc -K "$CODE_SIGNING_KEY" -iv "$CODE_SIGNING_IV" -in cd/codesigning.asc.enc -out cd/codesigning.asc -d - - - name: Import CodeSigning key - run: gpg --batch --fast-import cd/codesigning.asc - - - name: Release to Nexus - env: - GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - OSS_NEXUS_USERNAME: ${{ secrets.OSS_NEXUS_USERNAME }} - OSS_NEXUS_PASSWORD: ${{ secrets.OSS_NEXUS_PASSWORD }} - run: mvn deploy -P quick,ossrh-release --settings cd/mvnsettings.xml -B diff --git a/.github/workflows/update-gaffer-version.yaml b/.github/workflows/update-gaffer-version.yaml index c84177b7..5df7515c 100644 --- a/.github/workflows/update-gaffer-version.yaml +++ b/.github/workflows/update-gaffer-version.yaml @@ -10,7 +10,6 @@ jobs: update-gaffer-version: runs-on: ubuntu-latest env: - MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 VERSION_UPDATE_BRANCH: updating-gaffer-version-${{ github.event.inputs.version }} steps: @@ -25,24 +24,19 @@ jobs: - name: Update Gaffer Version run: | - mvn -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.parent.version - oldVersion=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.parent.version | grep -v '\['` + oldVersion=`sed -n '/^__version__\ =\ / {s///p;q;}' src/__init__.py | tr -d '"'` newVersion=${{ github.event.inputs.version }} - sed -i'' "s#version>$oldVersion<#version>$newVersion<#g" pom.xml - sed -i'' "s#gaffer2:$oldVersion#gaffer2:$newVersion#g" NOTICES - - sed -i'' "s#__version__ = \"$oldVersion\"#__version__ = \"$newVersion\"#g" python-shell/__init__.py - sed -i'' "s#__version__ = \"$oldVersion\"#__version__ = \"$newVersion\"#g" python-shell/src/__init__.py - sed -i'' "s#__version__ = \"$oldVersion\"#__version__ = \"$newVersion\"#g" python-shell/src/*/__init__.py + sed -i'' "s#__version__ = \"$oldVersion\"#__version__ = \"$newVersion\"#g" src/__init__.py + sed -i'' "s#__version__ = \"$oldVersion\"#__version__ = \"$newVersion\"#g" src/*/__init__.py - name: Update gafferpy run: | newVersion=${{ github.event.inputs.version }} curl -o spring-rest.jar https://repo.maven.apache.org/maven2/uk/gov/gchq/gaffer/spring-rest/$newVersion/spring-rest-$newVersion-exec.jar - java -Dgaffer.schemas=cd/road-traffic-example/schema -Dgaffer.storeProperties=cd/road-traffic-example/federatedStore.properties -Dgaffer.graph.config=cd/road-traffic-example/federatedGraphConfig.json -jar spring-rest.jar & + java -Dgaffer.schemas=src/test/road-traffic-exampleschema -Dgaffer.storeProperties=src/test/road-traffic-examplefederatedStore.properties -Dgaffer.graph.config=src/test/road-traffic-examplefederatedGraphConfig.json -jar spring-rest.jar & sleep 1m - python python-shell/src/generate.py + python src/generate.py rm spring-rest.jar - name: Submit PR diff --git a/.gitignore b/.gitignore index f26ca60a..252e3f51 100755 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,155 @@ -# Copyright 2016 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 -*/target/ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ target/ -*/*.iml -*.iml -.settings/ -*/.settings/ -*/.project -.project -*/bin -bin/ -*/*.class -*/atlassian-ide* -*/.idea -.idea/* -.idea -.classpath -*/.classpath -__pycache__ -*.pem -*.pyc -.DS_Store -*/.DS_Store -.vscode/ + +# Jupyter Notebook .ipynb_checkpoints -*.ScriptBin -*.egg-info/ -**/generated -# nohup -nohup.out +# IPython +profile_default/ +ipython_config.py + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +.venv-python-example +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# PyCharm +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# vim +*~ +.*.sw[po] + +# MacOS +.DS_Store + +# Private PyPI integration +.tox.pip.conf diff --git a/NOTICES b/NOTICES deleted file mode 100755 index 18300e63..00000000 --- a/NOTICES +++ /dev/null @@ -1,30 +0,0 @@ -Copyright 2016-2023 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. - - -Sample road traffic data taken from GB Road Traffic Counts (Department for Transport, http://data.dft.gov.uk/gb-traffic-matrix/Raw_count_data_major_roads.zip) - -Gaffer tools is built using maven. This process will automatically pull in dependencies. We list gaffer-tools's dependencies, - and their licenses, below. For information on the dependencies of these dependencies, see the websites of the - projects below. - - -Gaffer (uk.gov.gchq.gaffer:gaffer2:2.0.0): - -- Apache License, Version 2.0 - - -Apache Accumulo (org.apache.accumulo:accumulo-core:1.6.5, org.apache.accumulo:accumulo-minicluster:1.6.5): - -- Apache License, Version 2.0 diff --git a/README.md b/README.md index c51f4185..1363c084 100755 --- a/README.md +++ b/README.md @@ -1,23 +1,100 @@ -# Gaffer Tools + -A repository for Gaffer Tools. Please refer to the README.md files in the -subfolders for information on how to use each tool. -- [gafferpy](python-shell/README.md) -- [mini-accumulo-cluster](mini-accumulo-cluster/README.md) -- [performance-testing](performance-testing/README.md) -- [random-element-generation](random-element-generation/README.md) +# Gaffer Python Client + +![ci](https://github.com/gchq/gafferpy/actions/workflows/continuous-integration.yaml/badge.svg) +[](https://gchq.github.io/gaffer-doc/latest/) + +## Features + +- Persistently connect to a Gaffer rest api to run operations +- Connect using PKI certificates and SSL +- Generate Python client code for custom Operations, Predicates, Binary Operators and Functions +- Turn existing json queries into Python objects + +## Installation + +Gafferpy requires Python 3.6+. We don't currently release gafferpy on pypi, but you can install it over ssh with: + +```bash +pip install git+https://github.com/gchq/gafferpy.git +``` + +Or if you have the source code locally and want any changes you make reflected in your installation, you can run: + +```bash +pip install -e . +``` + +## Quick Start + +The python shell connects to a running Gaffer REST API. +You can start the Gaffer road-traffic-demo rest server from the Gaffer repository, using the command: + +```bash +mvn verify -Proad-traffic-demo +``` + +```python +# Import the client library and connector +from gafferpy import gaffer as g +from gafferpy import gaffer_connector + +# Instantiate a connector +gc = gaffer_connector.GafferConnector("http://localhost:8080/rest/latest") + +# You can use the connector to perform get requests +schema = gc.execute_get(g.GetSchema()) + +# And also run operations +elements = gc.execute_operation( + operation=g.GetAllElements() +) + +# Multiple operations +elements = gc.execute_operations( + operations=[ + g.GetAllElements(), + g.Limit(result_limit=3) + ] +) + +# And operation chains +elements = gc.execute_operation_chain( + operation_chain=g.OperationChain( + operations=[ + g.GetAllElements(), + g.Limit( + truncate=True, + result_limit=3 + ) + ] + ) +) +``` + +See [operation examples](https://gchq.github.io/gaffer-doc/v1docs/getting-started/operations/contents) for more examples of operations in python. + +## Coding Style +Please ensure that your coding style is consistent with the rest of the Gaffer project. Guides on the coding style for Gaffer can be found [here](https://gchq.github.io/gaffer-doc/latest/ways-of-working/#coding-style) + +## Testing + +```bash +# To run all of the tests, first deploy the road traffic example +# This needs to be done from the Gaffer java repository +mvn verify -Proad-traffic-demo + +# Then run +python -m unittest discover +``` ## License -Copyright 2016-2023 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 +Copyright 2016-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 +[http://www.apache.org/licenses/LICENSE-2.0](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. +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. diff --git a/cd/check_modules.sh b/cd/check_modules.sh deleted file mode 100755 index 552abce9..00000000 --- a/cd/check_modules.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Need to list all the modules. This needs to be done without using maven -# as we don't want to download dependencies and compile the code first. -# This method isn't very nice but we needed a simple approach that didn't -# require external dependencies that weren't available on travis. -allModules="" -pomPaths=`find . -name "pom.xml"` - -for pomPath in $pomPaths -do - currentModule=`cat $pomPath | grep '^ *' | sort -r | head -1 | cut -d '>' -f 2 | cut -d '<' -f 1` - allModules="$allModules $currentModule" -done - -for module in $allModules -do - if ! grep -q :$module .github/workflows/continuous-integration.yaml - then - echo ".github/workflows/continuous-integration.yaml is missing module $module"; - exit 1; - fi -done diff --git a/cd/codesigning.asc.enc b/cd/codesigning.asc.enc deleted file mode 100644 index 3fde4f85f820d9d728de6d2790df95c2f7e32182..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9648 zcmV;hB~RMPA5JpKaOgXDI|vfd3mopm+^jCzVJnA;VQ&R7(Xb$Dp1U6axT%dqQ^fL- zj|!CC!Cm;aQL%5ZSMWsVazfvqEXX39od8z}4GMQ$@WEBL7YYCoz=^zsk3)pvnXF&Y z&uMUHGNQ9JYTgroQIvzqk79SRsnj!PoOYs6D6Zo89Dg5cCFatydB$>e_(jG%3ore} z=h}QW?;Y8JJ>f~Ke;o+`)lx1^2W`SxSf2No1jW10b%fL2Yjchbwew%H- z@$-=r8TqO7N&@{ly$AkwirnBqcQ�AH9k>;!y65vu&_0t<#o!EgpaB)TW~N;Tl+) zKdFIr8eCbTJjAu^cuYF4&q-J`*gN08W!Aa$!ZM=k4bvh)C#O`~Yz;RKzR?a+20f$- zl@&i+{&^;xC{SrzR@J-xOBG0HPd5TUp_kqL$G}Y>RI-sy)nHdb%_Fi0){4{8Rl^87 z6L9pzHaaD3Jvvm32r#U z$Cjdn-}+$7#4)<^$zCNu3Gz3neA>`-sslft{@iaad&Sv z^yftX{FiYr^9RB$yb#Ml5X8?luwbMo59T2rzGFe6s~>7x^1FX-lI1`NA7x6Cw}X^C zrfgVHvCofhik)(-$3DCtUYaF+d$fzp1=Tss_D;%7r0;@KH1M@y+`)CGOC6=m^QyfR z@xRR?G=|f4vPW&-mBnUR$npEUPWkyiJ9U-sWf6K{Pl~%9ub8A1KHW0DTuaYB;5_Qr za!>^@cb~I{CSpshX2Pl2PHwSQVua)v9AUKX%7GwVEBY5`E*N`4w`*LZSaecB@@HTu zdi-VPE~PQdJpxFtCQK7Nk4%?og%DN+r#>2MY( zNx)5fsle08QD?9GL(Ovz9?mOnmBO@l?@Biq%O62I*V>G1bWCSc4o=p?f5KP6-#Ob) z_I0;OwyL>n!S&`janeUyea#^AYLt19GDQ*#_Fi9sm9VS6gG>rTq7q3iNni}j<26C| z6Y11Y>vAhoru#n@mYbaO5ap6hSlpss&c$x1W*)wZ^W~JDRk_4j!Pyn5W`^en71ZpB zbAA8*3Y}@x8mgK7ZIr^|=@Y=xhZ{BJbqT1GU2pU8*hXh?=+Qy$+ajS>ug-$|uUcO2 zPB=K%MC$sct}oNfYUtZ$JH!0ctiX4NCWGqct{3jLIMRMIHTLbP0AHC39^<21CNNTY zZ%4lBZ>q^;lcrQC8Avk4{04x*nUNHkU|DPH4v>Q-JO?xOvFV&5cn48Nu70&fBQ^l! z)iMrKs;4C7iF==Yi3dR^VJ$~}rIPtMJkT8i0j?&vY&_0R*3O2j9+=6#;;uNFG`d0m z1-v6#VR|trrR+7jSwxq8v$mH^*~+vLe-k$VP0zKal;=@gg!t$0Y;p=xJc!nzd=pzQ zqTg~>+E6Wrr1<)m@L_j?s4*qIbU9!iNhv4y@cX)YZ4ZOq|EB3mT1lVer*-ucVi>-4 zzp{eBg-{fvnTkD5x3K>f*4e+mkI zgbFOqc?9z4ktYC4`~WoLH`{Z@P^faXj#W=PJ{pN2*3VNy-%!xR=kL){rg1X>_d?j! zf1oHpJQb?IiSt*9v~e9@QjS_&2%urk+)0??xgXL6UdpDXGv*v!u>ml!{uh=9>} zP_`7foDEH<@v{j!Mi(_A}+I&F;ew-TH6Pc?YrU2DI_{;l6CCPQfBs;~|d*u|peHW=u1o)ne4;NZ7@CcS5istHg^bFZOYVc9K|8 z^jPhZkSqk@Uqwy!b9_WLES-F6*UR20!a$gcYSYRiSg-4!`;uMl15J_Jn{Jc-{)(fR zEieimky@o9g-9LN;Kl=-?k)NE3mH3#Ln(8sHUVV^-0O!cD)o zFANu9flwi#3njTGS(`4`$>+m4bmJDo6oD%cHbg;ZumZa7b?p}{Ly5MM-Z!3k2Y|Jo z|DtY%aAPV*n5(;!amG+h4>j=4GSDh5=1WQVy)aG;s>ZLhIlY}p298ICC=knllkkdl z;PZAbOr8HnZ+I-oTfEE-brzc2&QV+98Ig*AzI~uYbF&jOsRZG8%gS*OWDWlohfmuX zqO9anRzJ>u1g72$4A3*bo2qH&zEW`8Zq9vJS9#*jCOg#k1p`hemDRUj(der*5^-ck z16Cq2JN&J^8C`^gPB$2{fpJ~z368Xm1Gp9|dBJ0dJg1cFhNJxSH}&FLK-Yz#pcv54 z9%<>P^+CZ?1aOHk1&2fZ@J0`BKWhcLed?sCwrPds{Q_7Katcxsq9T-1n}K&{JbJIA z^(rG6>bnd3B=f!xuUh~AjFz`yK!O&NQH$jkzlcZ_y4)US?zx@_zmfEJ^5SvBnN2abLf zJ`BL^p8ptjq{Q#&qtC>uM3FLd9GM-c{ygX_sKGp+V#)Iv)DBp+`v+j&eDr7|Bi&8Z zLEh%s0f5%f8s}p03 z*W@8n21=-nPc7qHf^rmRX6iGND+Sohp%w>%A@aZ8(tFN2yFV&bCD*5kp3hBkNLZ%w z&V6Rh-$y{QnQJ%wrr2NBg}%X*=BnByhN52FyG_u|>CYoHC4mP6$1f10w3AXxe|au5 z<)>lvnfOK^b{t<^KrC>cDR$%Mc>ozGcu5%lw`jG)&PwrUrjdwW~q!r&$^Z{+y<-@(Z1rb z#K$wKIacXOlAhn%^8K9as1KT$g+?*L{mU*1}6z)_+9y}yA6H1@b=Vb6!e`E%dNT`}@OjNo- z-h_9+L^gS`iWZv~5jjdX>!22ZO3=wWV?Mp=^Mh%TfgYVTSexdO+KC)19G6+AtN_O# zk&*ZFs7R$TF1JL+-fao0(9W9sqT44AsEs4gNTh8dg5`twS@N_GU`LOzv zL>>%dB=|6q_4`lB!uV-r+pD=xe+*s@Wl!fham{UAmSGCYAlV0G=)W#6i-e)*FqtG$ z;UfU^X5BYNP@2jxedb4!0ir1rOM$8(68TLKCx?SME?`I-J#0*#?J;cpfrx`y<6ab9 zFRj+fMMY1^NdP@`a)8gH&N0QQXFu0>H;mPDkY67A#{DG($5mtZY+CBgT-;m&L|>n3 zUrFAL$j!4_ax&uqdsO27$X^z!vcpGhV*6No9dL(I(~%Ykk2X zl`N9lwhPC|^;g$}yv zGPAoX%Uq(hA@R1ddK5S4*MFIMU>r#9e?6Mx8TOk^iLJx~tSwCOx-pEx<$PfmtGt;4 zbr`^fM*wTOJN|*1m{TEAJ30(Z0%QigOu8yKV=C!?!Vmg*jnM2vHc#)IQwK z_{h^bIvlMVwT`!p3b+v&|MvV$i0{0-W_ITBCvYCIx|6jT#U5N6Rzg?!5NF5*UTttz zrLRRiBlUs@loSXhX4Kg6#FdC2;xTRJVQbgvZGHuatPh#TCIQ5Aq#+$_-Uz|<%rIHY zmm1y_O0TT$TEvzY6P|FGL(*X2sJ_>S-;$F++4D;WbyjwReosk$Z>K2~JcL`M$`(@L zQZnv*#r?w+Q_@-BTloJJWCSxwgC>7sDHR7NS)q{yVMY7UWt8^VwAQj|1B-&q2yWQjwX#O3Dl&^={R=kH2%L;{LjI)v~1U3Wlo>mv+{Y zXPNeQQtFLNmds!M{5z?YxI#NM5tbCTNx&Z4Azq~7_JI#veiU~DhkLXUiYihOZAdZ2 z$`=(hHXuKcO>MQ%ImcX9nj%tu)gEHN+_!IB zN_69n%M+aHXfa@m?42z~bG`3hbejE}vrj;x1T~x277z~@f_d#ByoaIBhO+Hp1@8C< zO+Ce>&7&DBNVs7?EF~hDgJeLmHYN?qV#7x0fd#rAfdRoyTF@y$}eEqhV`{e~xK^t#-cTb5KtOf-?lGzakbW!HX7#pq& z2=Pm&xrV@IE1}B`;Ap*Az|OWs;^_eTjS^HD#P{8}dmARUpG|P+j8{w-_qwZ{jmqT zgqP5h>e$oH^jpt%uS}3~;oWor~R^1|()cUq6xCcls5rF9=?S~ZPM=bp=&!w&C_;io^j`0ChWF{VUtrJB4eJ2A|o3xuO;@SW#K;6(ePV$o^;8il$7$(#t zgN{J^U$GPHi5O?yy!L^{qO`4ZKl_KcNsxrx<}GtH=WW*u8EI)j?eLy;`0=DQ8xc6;^8;m%z`ya{M#Og>dcc!Cm;;sfb)<-N5#5 zI#GW@7&t>o-xo$2v~9%WruSB{24ZyTZh2c?hNZJ8hZr%e3PF2Ixt{R4lPc=SMk34}UDn#M94{!0$18nKzW&oeK|Uv2BuG z`J|HNvOv@V!7x@~0K6UiA*KcwS*}qBzde0>>^x*Zp@0FC{Je+oYi01v(J^#qIdTi_ zTlg;k@_y0_bdq0yItKn)Y5loJ>azhi+!jI-DC&y?Wtw1Jwk>rO_R~fT!_$*(02rVo zNzb+gUHMnfgAYK~OXdJxoUY0-F3QW`nox2;DgG_pqc^e}&leh@E zp>zn}cBW)PqRz<|2mX>viag-izKW(J!C1Bgx$bi&;?rDdQ6bTF4O{B%j=$WnWf^o? zX+y@+%EqBN1?RhFrgi^oe=(mE!-T zHGr0Q<}Pn7%A8+nqGT6Hs9w8=>LL{#b!jSRbl0@xaNqE-weDjX;E#9^loAno)p5FS z1nH}mlrcl0bY-Vjy-i-U7ZLpL0bJK1Vk9x0IJMXmcEj4}AA>(giUtz$w^&2}$LYcX z1SeUpcLzHKB3#lbd*|(*>Rw0lRN_xixdv4Nt3a@-#|DAS_m&U}wws5*8DB|bOt;&s zkHs^DK$jJJOpRnSimtV2RK~%K4mSisHWh3k3P^$9_-TnL?3%YIjZbMFeJZ2j9nEMh zvqq`S%aEkLv^fFGGK@BzCzfb>|EC>`o8#j-Ra%0}yJ*|oZUTD*eg*+-G zr6_ks#yqNt_|BhD-}9H$VoN?JV*^gjjQ#Y>{tm6E*u42cv!s$+PxF zQM)g;(i2mC4?Of6ayy9>jwo^ZQp$2rCc^&|kg1*!ZJ&#CPY{GJ1HSmi(3qGxM6C)B z5mz+=K3`vZW_(xoV)kyH`R`*qpA3`1rB|N?)RIOD+hAp;IR0Nt3R2*MKakW(0|Qzg zh1rPM3YDzx24J#mzhB+$jiV~&$v5u!K%boy5ri&TFBs7FR&wm^L1HQY2HbK^B%3GD z{qD13w#8fr8u5l|H%AdN?M@%MJ37U?_eqs^COT~e+pgEInk`p@KKR%XJ;*k&ITbGJ zY?C!T?@7z}ZZtYHPW-c)AYE!A@K`iMOv2np@>vhacIjjr0!1u+A|}<-(WT*xVp+`&qR09Dd^z8`A-st%~kosD@kjWk4fmd zL1D%f;6sNa1-iB0SmEy7e%vuPbb@+rqH~N$JLK9$x&e_4qHth{*?F=U>GVTLyOuh6v;9Kxp^ z6Db;FwOM0IG6yMYRrRC0eyCTiHk1c9#V$=1R?@&F{}4dRvx~pjTCg9D=O~9rvvNf?z2j%IlHhieeJSoibI6msRf*d<6)7 zHi7+#f|>{R_{~V;GHRiIoF4zWcZ-rS>wOm>c+l?3CP!dqty60$xBEdFEUV}`t_Ml)lq~#-_g~4URm^^ZGiCZ~1WUw3Igqpw=F(m^3;hBVp} zM6=Pi+)Hz6*@vlOJOPIhEK&`tf-TZWF{$6ltvxKKyV&-0LPF_(i)Ln&bJ0n4WPJ{9 zT<%8wAG7QJSQkiCn0I4NS>m?a4ctuimMa!gDLw_D?Iv@j?y6sVPfCwWzrxzb^!(1W z_l0hJu+X+hEp}-vpZupnt|L2$oYUkN5mH@-^g%U=68l6f*KNXl9%yR5(eUrg7?VbR z7wqxE323OzXW9Xgfs}XKENbsrma2@YU;r+IvfZMWn@GnX*dSsYO|~5+*^VVa!CkmCx-!ttwgkZTY=A%a`eJz47q~)5N0MM!U3e%tP143_?j}Ln&Iug0v zyy?G6w@^|FHtkUD7qQ->*dQt}(Kg3M{G4mbg!<~FqZ_ike@IO@Oiv#H*#)%9)1Jz& zShiJ+&_QrKd87bCI96N@v8&E{9pA1+ZC?CJO?GYSaPR;G(;{}kH#WW^n>?Zg`O^3E z;iR-jQSn@ejwX5Q=dlsm0KI8p;jfG+Djj$_j@)QG1lpRKOw4qUWMf4%Abwum{ECUJB zdnBTtF6pQGl?kOM(#>Tv`d%${4MN`%-aX?E6RE%v38G@WH(@0oGzwep=n*XoKM6|C zRCz{Bv`~;cJ{%bFznqZH@oucJK@*SLc9lc7JN(?6Nizi^W*Ar|@I&FemY8>ZMh-(z75ukKBFf!6+JTiWA3^bIrhbAZvvNe)wcn$hh{7%yh zbewXzwy)|&O|p@GFs$9EIPFVa^bDq^DgE9%F@bi1~LRFu*HJGJc%To@q$^xWi zvbU}l0)!V^DTZ5ZfHYwH5L?1viZ;8sj+YhhmR*UEiTB-CN6xn>x9Va)M>bAC2@O(- zME40Af~>P$h8QZY+xl<#X*O-#!R-EW1n@Z-AvIq#4J{&&e1Z-gZMju)_cx}cu2(%0 zCN5Dv5$y~ng~A&o$BjS~4iu5p{FL(Fp%G(OAM?F^s;MlMfKkbxS%12zf$=3CN!Ntr zZ%tHwF(p>EE^+^HbCgf^l#&J*G)g(W2k;TdY&N| zu4A1q3die;9363wAWk+nHce28g)xAcM1+*-rY|M4f@q#e$GA(P0Kz!Z*s|7ajl*Zy)g7T0RngION%>Bk_91rJgKGnM`_{gA0 zuj;zgh$w)Cc+0-E5sKmiXT2@F^n<+9b=S)9w%pwW6_|#8|A`@4XQ?LeplcF5kX!k> zwlakedC5evc@imEzEVTK;4Gs-R6PAZ96_wjY@Ikc42#UIWo@UNLJKi*b+xP_ODY-D z?4@YuealKkz#vWT0|0-ZZoePNap(ZxVuA%z)P zVfM4fzN*azAQ)*%)AFU8))7*B8y&aWYt6IY68upiaJ~*1Rzj7e4+v;#A=yNo5gaKS zyj1VaGIx@obX|hk-c99S_q2DmxApzGEPI*xBIm{W0ap)J)qD|8sIn{oU>Y?p@{^FH zd|nVM7H8&Wh<%u9B?`8EXtkIIqg5tnI7-n?lLRxTiwqdSa>O-`h6NK9!n?nl0KkO| zl_gtR&^&7CcKb3#0Jeeqj{Cqp^5`2YR*M*jyI1IMvb)M44i6*Rcki`N3Q0s2y z>lHCMpUc3K1*;eU*UI7+De2BS;@{P2oI&cMld`4-H59KnQDKgAA84)-r!)tQsTVhJs%obT@4y;kFu*_ew;wy$4fLVVfO z1vX^@a7{t&3f$_a?p}r2xwNIig_^pm+S@@U1m@Bqqik(c4DE5(pVhO-;bRqYwaf%- z#ErW2I=8?Mme8Zm-v`{WlqlykKwweS1GnFjwcU<5>k+mj@NHQLT`H4^-vN#?T8$gX zZVY&ssalg4NSac7H*h42P^5yx$H26>3`GtPR62Gmn%g6e4dyrI#a1Gb0o20p7SL81 zWxF0DZ!gG8ETL;%NkCb|W+3}iY;BcPaM2I+J`TN7Wru@f{AE57xE4W>k(E_|)o1VA zjFtlIGOlDFxmEmY141&FB5f(Nlz16o`vA(eDS27D2k3<2LU+K9%T}2e9WRBhRnCfaj@kzX;bjpiI$X)D7Z-xxy5<8Ph*MZSq*{KKVZc`J zoj_fw99z)%>Sn9)7_uW&_4x!YB`M}1Jb-v@-K~F@rG=hv23wLHycIy0DF78tn}+ZH zB`eFNM@7ni>e)@@2Z65}FXtvq6R^aTD%++*T4NlVzr-S`t}=hD{2f#q75$DC8Iw=% zM4g&oS(wORLHM0Z`$$ctNlvrolq(&9k(p7c7;qnWHiDZSB@=KYB3wDEj2&7`@f@3z z&R;k8C>Q2AR7v$S$Dli*&@~uxNX~apr#S(<1>vfAnYDSkWL0$t}V&xj6*WGXm#M)R0%i3Bd@$)RA zCPe7fc^|3U`%2@5?Q)tSUTM)M^kJjbW8|aHKtNj;!p|`f$*^V3%etztp5e4OX_b7% z!@&CAzN^Hd(2%X2hy>Iu-GMy}kRDZisR!E2HUG1#-J_>4vimljGj9 zc~?C**uH{`L+31U!glTi6n?DD1rr{iA-a+yNU$4{R@EMt - - - ossrh - ${env.OSS_NEXUS_USERNAME} - ${env.OSS_NEXUS_PASSWORD} - - - ossrh-snapshots - ${env.OSS_NEXUS_USERNAME} - ${env.OSS_NEXUS_PASSWORD} - - - - - - ossrh - - true - - - gpg - ${env.GPG_KEY_NAME} - ${env.GPG_PASSPHRASE} - - - - - diff --git a/cd/updateCopyrightHeaders.sh b/cd/updateCopyrightHeaders.sh deleted file mode 100755 index 498ba24c..00000000 --- a/cd/updateCopyrightHeaders.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -e - -currentYear=$(date +%Y) - -for f in $(find . -type f -name '*.txt' -o -name '*.xml' -o -name '*.java' -o -name '*.js' -o -name '*.html' -o -name '*.sh' -o -name '*.cs' -o -name '*.py' -o -name '*.yml' -o -name '*.md' -o -name '*.yaml' -o -name '*.properties' -o -name 'NOTICES'); -do - echo ${f} - for startYear in `seq 2016 1 $((currentYear - 1))`; - do - sedCmd="s/Copyright ${startYear} Crown Copyright/Copyright ${startYear}-${currentYear} Crown Copyright/g" - #echo "sed -i'' -e "$sedCmd" ${f}" - sed -i'' -e "$sedCmd" ${f} - rm -f ${f}-e - if [ $((startYear+1)) -lt ${currentYear} ]; then - for endYear in `seq $((startYear + 1)) 1 $((currentYear - 1))`; - do - sedCmd="s/Copyright ${startYear}-${endYear} Crown Copyright/Copyright ${startYear}-${currentYear} Crown Copyright/g" - #echo "sed -i'' -e "$sedCmd" ${f}" - sed -i'' -e "$sedCmd" ${f} - rm -f ${f}-e - done - fi - done -done - diff --git a/code-style/checkstyle-suppressions.xml b/code-style/checkstyle-suppressions.xml deleted file mode 100644 index 6556dc7f..00000000 --- a/code-style/checkstyle-suppressions.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - diff --git a/code-style/checkstyle.xml b/code-style/checkstyle.xml deleted file mode 100644 index 145d8321..00000000 --- a/code-style/checkstyle.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/code-style/intellij-style.xml b/code-style/intellij-style.xml deleted file mode 100644 index c958b2c9..00000000 --- a/code-style/intellij-style.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - diff --git a/code-style/licence-header-java.txt b/code-style/licence-header-java.txt deleted file mode 100644 index 83bd240d..00000000 --- a/code-style/licence-header-java.txt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright $YEAR 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. - */ - diff --git a/code-style/licence-header-pom.txt b/code-style/licence-header-pom.txt deleted file mode 100644 index 9c80942a..00000000 --- a/code-style/licence-header-pom.txt +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/code-style/pmd-ruleset.xml b/code-style/pmd-ruleset.xml deleted file mode 100644 index b2372603..00000000 --- a/code-style/pmd-ruleset.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - Set of PMD Rules which expands the default set (https://github.com/apache/maven-pmd-plugin/blob/master/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml). - Some rules which duplicate Spotbugs or Checkstyle are not included. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/python-shell/docs/Makefile b/docs/Makefile similarity index 100% rename from python-shell/docs/Makefile rename to docs/Makefile diff --git a/python-shell/docs/make.bat b/docs/make.bat similarity index 100% rename from python-shell/docs/make.bat rename to docs/make.bat diff --git a/python-shell/docs/source/conf.py b/docs/source/conf.py similarity index 100% rename from python-shell/docs/source/conf.py rename to docs/source/conf.py diff --git a/python-shell/docs/source/gafferpy.client.rst b/docs/source/gafferpy.client.rst similarity index 100% rename from python-shell/docs/source/gafferpy.client.rst rename to docs/source/gafferpy.client.rst diff --git a/python-shell/docs/source/gafferpy.generated_api.rst b/docs/source/gafferpy.generated_api.rst similarity index 100% rename from python-shell/docs/source/gafferpy.generated_api.rst rename to docs/source/gafferpy.generated_api.rst diff --git a/python-shell/docs/source/gafferpy.rst b/docs/source/gafferpy.rst similarity index 100% rename from python-shell/docs/source/gafferpy.rst rename to docs/source/gafferpy.rst diff --git a/python-shell/docs/source/index.rst b/docs/source/index.rst similarity index 100% rename from python-shell/docs/source/index.rst rename to docs/source/index.rst diff --git a/python-shell/docs/source/modules.rst b/docs/source/modules.rst similarity index 100% rename from python-shell/docs/source/modules.rst rename to docs/source/modules.rst diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml deleted file mode 100644 index baa1c78b..00000000 --- a/findbugs-exclude.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/mini-accumulo-cluster/README.md b/mini-accumulo-cluster/README.md deleted file mode 100644 index f851b392..00000000 --- a/mini-accumulo-cluster/README.md +++ /dev/null @@ -1,76 +0,0 @@ -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](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. - -# Gaffer Mini Accumulo Cluster - -This project allows you to easily spin up a mini accumulo cluster. There are two options 1. Run a Cluster with a Shell as one program \(cluster-with-shell\) 2. Run the cluster separately and open shells as required. \(cluster and shell working together\) - -## Building - -From the gaffer-tools root directory run `mvn package -Pquick -pl :mini-accumulo-cluster` to build and package the JAR, without running any tests. - -To run tests use `mvn verify -Pcoverage -pl :mini-accumulo-cluster`. - -### Using Windows - -If you are using Windows, you'll need to have installed the Hadoop native libraries (at least hadoop.dll - from [hadoop-common](https://github.com/apache/hadoop/tree/trunk/hadoop-common-project/hadoop-common)) and to have added the location of these libraries to your `PATH` environment variable. - -## Usage - -### cluster-with-shell - -To use run MiniAccumuloClusterWithShellController.main\(\) It doesn't require any arguments, however the following can be used: \[directory\_name\] \[is\_temp\_directory\] \[root\_password\] \[instance\_name\] - -Can be run directly in your IDE - -or - -Can be built using 'mvn package' and run from the command line using: - -```bash -java -cp target/mini-accumulo-cluster-*-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterWithShellController -``` - -When starting up it will print out something similar to: - -``` -Cluster started: - Location - miniAccumuloCLuster - Zookeepers - localhost: - Instance name - instance -``` - -It will also create a store.properties file for you in the cluster directory. This can be used for connecting to the cluster via a Gaffer Accumulo store. Once running it will open an Accumulo shell. You can users from the shell if required. To stop, enter the 'quit' command in the accumulo shell. - -### cluster - -This requires the same arguments as the cluster-with-shell, but it will not open a shell. It will monitor a file called shutdown within its directory. Once that file is created, it shuts down the cluster. This allows external scripts to close the cluster, they can simply 'touch $MINIACCUMULODIR/shutdown' To run from command line, for example - -```bash -java -cp target/mini-accumulo-cluster-*-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance -``` - -It may be necessary to add other libraries to the accumulo classpath, to allow things like Gaffer to work. In this case you can use the following command to add libraries to the classpath. - -```bash -java -cp target/mini-accumulo-cluster-*-jar-with-dependencies.jar:otherFile1.jar:otherFile2.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance -``` - -### shell - -This can be run in one of two ways - -1. Open an interactive shell -2. Open a shell, run commands from a file, quit the shell - -In either case, the first argument must be the store.properties filename created by the cluster. In the second case, add another argument that points to the file containing the commands to run. - -```bash -java -cp target/mini-accumulo-cluster-*-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloShellController ~/miniAccumuloCluster/store.properties -``` - diff --git a/mini-accumulo-cluster/pom.xml b/mini-accumulo-cluster/pom.xml deleted file mode 100755 index 88d30c24..00000000 --- a/mini-accumulo-cluster/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - 4.0.0 - - uk.gov.gchq.gaffer - gaffer-tools - 2.0.0 - - - mini-accumulo-cluster - - - - uk.gov.gchq.gaffer - accumulo-store - ${gaffer.version} - - - uk.gov.gchq.gaffer - graph - ${gaffer.version} - - - org.apache.accumulo - accumulo-minicluster - ${accumulo.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - org.apache.accumulo - accumulo-core - ${accumulo.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - org.apache.hadoop - hadoop-hdfs - ${hadoop.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - org.apache.accumulo - accumulo-shell - ${accumulo.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.3.0 - - ${skip.jar-with-dependencies} - - - - mini-accumulo-cluster - package - - single - - - - jar-with-dependencies - - - - - - - - - diff --git a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterController.java b/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterController.java deleted file mode 100644 index bb7b391d..00000000 --- a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterController.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright 2016-2023 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.miniaccumulocluster; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.apache.accumulo.minicluster.MemoryUnit; -import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.accumulo.minicluster.MiniAccumuloConfig; -import org.apache.commons.cli.BasicParser; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.apache.commons.io.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.WatchEvent; -import java.nio.file.WatchKey; -import java.nio.file.WatchService; - -import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; -import static java.nio.file.StandardWatchEventKinds.OVERFLOW; - -/** - * Starts a mini accumulo cluster. Can be run directly from an IDE or compiled and - * the main method invoked from the command line using: - * java -jar target/mini-accumulo-cluster-jar-with-dependencies.jar - * - * @see uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController.Builder - */ -@SuppressFBWarnings("DM_EXIT") -public class MiniAccumuloClusterController { - public static final String DEFAULT_DIR_NAME = "miniAccumuloCluster"; - public static final String DEFAULT_PASSWORD = "password"; - public static final String DEFAULT_INSTANCE_NAME = "instance"; - public static final String SHUTDOWN_FILENAME = "shutdown"; - public static final boolean DEFAULT_IS_TEMP_DIR = false; - - private static final Logger LOGGER = LoggerFactory.getLogger(MiniAccumuloClusterController.class); - private static boolean shutdownHookAdded = false; - - protected String dirName; - protected boolean isTempDir; - protected String password; - protected String instanceName; - protected boolean shutdownHook; - protected Integer heapSize; - - protected Path clusterPath; - protected MiniAccumuloCluster cluster; - - protected MiniAccumuloClusterController() { - } - - protected MiniAccumuloClusterController(final String... args) { - final Options options = new Options(); - options.addOption("h", "help", false, "help"); - options.addOption("d", "dirName", true, "directory name"); - options.addOption("p", "password", true, "root password"); - options.addOption("n", "instanceName", true, "instance name"); - options.addOption("t", "useTempDir", false, "use a temporary directory"); - options.addOption("s", "heapSize", true, "heap size"); - - final CommandLineParser parser = new BasicParser(); - try { - final CommandLine cmd = parser.parse(options, args); - if (cmd.hasOption("h")) { - printHelp(options); - System.exit(0); - } - if (cmd.getOptions().length == 0 && args.length > 0) { - parseArgsOldFormat(args, options); - } else { - dirName = cmd.getOptionValue("d", DEFAULT_DIR_NAME); - isTempDir = cmd.hasOption("t") || DEFAULT_IS_TEMP_DIR; - password = cmd.getOptionValue("p", DEFAULT_PASSWORD); - instanceName = cmd.getOptionValue("i", DEFAULT_INSTANCE_NAME); - final String heapSizeStr = cmd.getOptionValue("s"); - if (null != heapSizeStr) { - heapSize = Integer.parseInt(heapSizeStr); - } - } - } catch (final ParseException e) { - parseArgsOldFormat(args, options); - } - - shutdownHook = true; - } - - public static void main(final String[] args) throws ParseException { - final MiniAccumuloClusterController instance = new MiniAccumuloClusterController(args); - instance.start(); - } - - public void start() { - if (shutdownHook) { - createShutdownHook(); - } - - // If it has already been started then do nothing - if (null == cluster) { - createDirectory(); - createMiniCluster(); - } - } - - public void stop() { - LOGGER.info("Attempting Shutdown"); - - if (null != cluster) { - try { - cluster.stop(); - cluster = null; - LOGGER.info("Cluster stopped"); - } catch (final IOException | InterruptedException e) { - LOGGER.warn("Shutdown Error", e); - } - } - - if (null != clusterPath) { - try { - FileUtils.deleteDirectory(clusterPath.toFile()); - clusterPath = null; - } catch (final IOException e) { - LOGGER.warn("Delete directory Error", e); - } - } - } - - public String getClusterZooKeepers() { - return null != cluster ? cluster.getZooKeepers() : null; - } - - protected void printHelp(final Options options) { - final HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp( - "java -cp mini-accumulo-cluster-*-jar-with-dependencies.jar " - + getClass().getName(), - options); - } - - protected void parseArgsOldFormat(final String[] args, final Options options) { - // Try to parse the arguments using the old format. - if (null != args && args.length > 4) { - printHelp(options); - System.exit(2); - } - - LOGGER.warn("Warning - please update your command line arguments."); - printHelp(options); - dirName = getDirName(args); - isTempDir = isTempDir(args); - password = getPassword(args); - instanceName = getInstanceName(args); - } - - protected void createShutdownHook() { - if (!shutdownHookAdded) { - shutdownHookAdded = true; - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - MiniAccumuloClusterController.this.stop(); - } - }); - } - } - - protected void createMiniCluster() { - try { - final MiniAccumuloConfig config = new MiniAccumuloConfig(clusterPath.toFile(), password); - if (heapSize != null) { - config.setDefaultMemory(heapSize, MemoryUnit.MEGABYTE); - } - config.setInstanceName(instanceName); - cluster = new MiniAccumuloCluster(config); - cluster.start(); - } catch (final InterruptedException | IOException e) { - LOGGER.error("Failed to configure cluster", e); - throw new RuntimeException("Failed to start cluster", e); - } - - LOGGER.info("Cluster started:"); - LOGGER.info("\tLocation - " + cluster.getConfig().getDir().getAbsolutePath()); - LOGGER.info("\tZookeepers - " + cluster.getZooKeepers()); - LOGGER.info("\tInstance name - " + cluster.getInstanceName()); - - try { - final File propsFile = new File(clusterPath + "/store.properties"); - FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("/store.properties.template"), propsFile); - FileUtils.write(propsFile, "accumulo.zookeepers=" + cluster.getZooKeepers(), true); - } catch (final IOException e) { - LOGGER.error("Failed to write properties file", e); - } - - watchShutdown(); - } - - protected void watchShutdown() { - LOGGER.info("Watching Shutdown File " + clusterPath + "/" + SHUTDOWN_FILENAME); - - try { - WatchService watcher = FileSystems.getDefault().newWatchService(); - clusterPath.register(watcher, ENTRY_CREATE); - - OUTER: - while (true) { - WatchKey key; - try { - key = watcher.take(); - } catch (final InterruptedException e) { - return; - } - - for (final WatchEvent event : key.pollEvents()) { - final WatchEvent.Kind kind = event.kind(); - - if (kind == OVERFLOW) { - continue; - } - - final WatchEvent ev = (WatchEvent) event; - final Path filename = ev.context(); - - LOGGER.debug("Filename changed " + filename); - - if (filename.toString().equals(SHUTDOWN_FILENAME)) { - this.stop(); - break OUTER; - } - } - - boolean valid = key.reset(); - if (!valid) { - break; - } - } - - LOGGER.info("Finished Watching Shutdown"); - } catch (final IOException e) { - LOGGER.error("Failed to watch shutdown", e); - } - } - - - private void createDirectory() { - clusterPath = Paths.get(dirName); - if (Files.exists(clusterPath)) { - try { - FileUtils.deleteDirectory(clusterPath.toFile()); - } catch (final IOException e1) { - LOGGER.error("Failed to delete old directory", e1); - } - } - - try { - if (isTempDir) { - clusterPath = Files.createTempDirectory(dirName); - } else { - clusterPath = Files.createDirectory(clusterPath); - } - } catch (final IOException e) { - LOGGER.error("Failed to create temp dir", e); - throw new RuntimeException("Unable to create directory", e); - } - } - - int getHeapSize() { - return heapSize; - } - - private static String getDirName(final String... args) { - return getArgOrDefault(0, DEFAULT_DIR_NAME, args); - } - - private static boolean isTempDir(final String... args) { - return Boolean.parseBoolean(getArgOrDefault(1, Boolean.toString(DEFAULT_IS_TEMP_DIR), args)); - } - - private static String getPassword(final String... args) { - return getArgOrDefault(2, DEFAULT_PASSWORD, args); - } - - private static String getInstanceName(final String... args) { - return getArgOrDefault(3, DEFAULT_INSTANCE_NAME, args); - } - - private static String getArgOrDefault(final int index, final String defaultValue, final String... args) { - return hasArg(index, args) ? args[index] : defaultValue; - } - - private static boolean hasArg(final int index, final String... args) { - return null != args && args.length > index && null != args[index]; - } - - public static class Builder { - final MiniAccumuloClusterController instance; - - public Builder() { - this(new MiniAccumuloClusterController()); - } - - protected Builder(final MiniAccumuloClusterController instance) { - this.instance = instance; - } - - public Builder dirName(final String dirName) { - instance.dirName = dirName; - return this; - } - - public Builder tempDir(final boolean tempDir) { - instance.isTempDir = tempDir; - return this; - } - - public Builder tempDir() { - return tempDir(true); - } - - public Builder password(final String password) { - instance.password = password; - return this; - } - - public Builder instanceName(final String instanceName) { - instance.instanceName = instanceName; - return this; - } - - public Builder shutdownHook() { - return shutdownHook(true); - } - - public Builder shutdownHook(final boolean shutdownHook) { - instance.shutdownHook = shutdownHook; - return this; - } - - public Builder heapSize(final int heapSize) { - instance.heapSize = heapSize; - return this; - } - - public MiniAccumuloClusterController build() { - return instance; - } - } -} diff --git a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterWithShellController.java b/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterWithShellController.java deleted file mode 100644 index fc7c108b..00000000 --- a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterWithShellController.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016-2023 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.miniaccumulocluster; - -import org.apache.accumulo.shell.Shell; - -import java.io.IOException; - -/** - * Starts a mini accumulo cluster. Can be run directly from an IDE or compiled and - * the main method invoked from the command line using: - * java -jar target/mini-accumulo-cluster-jar-with-dependencies.jar - * - * @see MiniAccumuloClusterWithShellController.Builder - */ -public class MiniAccumuloClusterWithShellController extends MiniAccumuloClusterController { - private Shell shell; - - public MiniAccumuloClusterWithShellController() { - super(); - } - - public MiniAccumuloClusterWithShellController(final String... args) { - super(args); - } - - public static void main(final String[] args) { - final MiniAccumuloClusterWithShellController instance = new MiniAccumuloClusterWithShellController(args); - instance.start(); - instance.startShell(); - } - - public void startShell() { - if (null == cluster) { - start(); - } - - final String[] shellArgs = {"-u", "root", - "-p", cluster.getConfig().getRootPassword(), - "-z", cluster.getInstanceName(), cluster.getZooKeepers()}; - - try { - shell = new Shell(); - if (!shell.config(shellArgs)) { - throw new RuntimeException("Shell failed with code: " + shell.getExitCode()); - } - shell.start(); - } catch (final IOException e) { - throw new RuntimeException("Failed to start shell", e); - } - } - - @Override - public void stop() { - if (null != shell) { - shell.shutdown(); - shell = null; - } - - super.stop(); - } - - @Override - protected void watchShutdown() { - // don't watch the shutdown file. - } - - public static class Builder extends MiniAccumuloClusterController.Builder { - public Builder() { - this(new MiniAccumuloClusterWithShellController()); - } - - protected Builder(final MiniAccumuloClusterWithShellController instance) { - super(instance); - } - - @Override - public MiniAccumuloClusterWithShellController build() { - return (MiniAccumuloClusterWithShellController) super.build(); - } - } -} diff --git a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloShellController.java b/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloShellController.java deleted file mode 100644 index 61f49bef..00000000 --- a/mini-accumulo-cluster/src/main/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloShellController.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2016-2023 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.miniaccumulocluster; - -import org.apache.accumulo.shell.Shell; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - - -public final class MiniAccumuloShellController { - private static final Logger LOGGER = LoggerFactory.getLogger(MiniAccumuloShellController.class); - - private static final String ACCUMULO_INSTANCE = "accumulo.instance"; - private static final String ACCUMULO_USER = "accumulo.user"; - private static final String ACCUMULO_PASSWORD = "accumulo.password"; - private static final String ACCUMULO_ZK = "accumulo.zookeepers"; - - public static void main(final String[] args) { - final String propertiesFilename = args[0]; - String commandFilename = null; - if (args.length > 1) { - commandFilename = args[1]; - } - - new MiniAccumuloShellController(propertiesFilename).run(commandFilename); - } - - private final String instance; - private final String user; - private final String password; - private final String zookeepers; - private Shell shell; - - private MiniAccumuloShellController(final String propertiesFilename) { - if (null == propertiesFilename) { - throw new IllegalArgumentException("Properties file null"); - } - - try (final InputStream is = Files.newInputStream(Paths.get(propertiesFilename))) { - final Properties props = new Properties(); - props.load(is); - - instance = props.getProperty(ACCUMULO_INSTANCE); - user = props.getProperty(ACCUMULO_USER); - password = props.getProperty(ACCUMULO_PASSWORD); - zookeepers = props.getProperty(ACCUMULO_ZK); - - } catch (final IOException e) { - LOGGER.error("Failed to initialise MiniAccumuloShell", e); - throw new IllegalArgumentException("Properties file failed to load", e); - } - } - - private void stop() { - if (null != shell) { - shell.shutdown(); - } - } - - public void run(final String commandFilename) { - final List shellArgs = new ArrayList<>(); - shellArgs.add("-u"); - shellArgs.add(user); - shellArgs.add("-p"); - shellArgs.add(password); - shellArgs.add("-z"); - shellArgs.add(instance); - shellArgs.add(zookeepers); - - try { - shell = new Shell(); - if (!shell.config(shellArgs.toArray(new String[0]))) { - throw new RuntimeException("Shell failed with code: " + shell.getExitCode()); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - MiniAccumuloShellController.this.stop(); - } - }); - - if (null != commandFilename) { - final String cmd = IOUtils.toString(Files.newInputStream(Paths.get(commandFilename)), StandardCharsets.UTF_8); - LOGGER.info("Executing Command " + cmd); - shell.execCommand(cmd, false, true); - } else { - shell.start(); - } - } catch (final IOException e) { - LOGGER.error("Failed to run shell", e); - } finally { - if (null != shell) { - shell.shutdown(); - } - } - } -} diff --git a/mini-accumulo-cluster/src/main/resources/log4j.xml b/mini-accumulo-cluster/src/main/resources/log4j.xml deleted file mode 100755 index 3e702d7b..00000000 --- a/mini-accumulo-cluster/src/main/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/mini-accumulo-cluster/src/main/resources/store.properties.template b/mini-accumulo-cluster/src/main/resources/store.properties.template deleted file mode 100644 index 0c888cd1..00000000 --- a/mini-accumulo-cluster/src/main/resources/store.properties.template +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright 2016 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. -# -gaffer.store.class=uk.gov.gchq.gaffer.accumulostore.AccumuloStore -gaffer.store.properties.class=uk.gov.gchq.gaffer.accumulostore.AccumuloProperties -accumulo.instance=instance -accumulo.user=root -accumulo.password=password - -# Add the port when the cluster has started -#accumulo.zookeepers=localhost: diff --git a/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java b/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java deleted file mode 100644 index 85e04611..00000000 --- a/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016-2019 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.miniaccumulocluster; - -import org.junit.jupiter.api.Test; - -import java.io.File; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MiniAccumuloClusterControllerTest { - @Test - public void shouldStartAndStopCluster() throws Exception { - // Given - final String miniAccumuloClusterName = "miniAccumuloCluster"; - final Exception[] accumuloException = new Exception[1]; - final MiniAccumuloClusterController[] runner = new MiniAccumuloClusterController[1]; - - // When - try { - new Thread(() -> { - try { - runner[0] = new MiniAccumuloClusterController.Builder() - .dirName(miniAccumuloClusterName) - .instanceName("instance") - .password("password") - .heapSize(1024) - .build(); - runner[0].start(); - } catch (final Exception e) { - accumuloException[0] = e; - } - }).start(); - - // Wait for accumulo to start - int maxAttempts = 500; - int attempts = 0; - while (!new File(miniAccumuloClusterName + "/store.properties").exists() && attempts < maxAttempts && null == accumuloException[0]) { - attempts++; - Thread.sleep(500); - } - Thread.sleep(5000); - - // Then - assertThat(accumuloException[0]).withFailMessage(null != accumuloException[0] ? accumuloException[0].getMessage() : "").isNull(); - assertThat(new File(miniAccumuloClusterName + "/store.properties").exists()).withFailMessage("store.properties was not generated").isTrue(); - assertThat(1024).isEqualTo(runner[0].getHeapSize()); - } finally { - if (null != runner[0]) { - runner[0].stop(); - } - } - } -} diff --git a/mini-accumulo-cluster/src/test/resources/log4j.xml b/mini-accumulo-cluster/src/test/resources/log4j.xml deleted file mode 100644 index 2bcf2626..00000000 --- a/mini-accumulo-cluster/src/test/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/performance-testing/README.md b/performance-testing/README.md deleted file mode 100644 index b12814bf..00000000 --- a/performance-testing/README.md +++ /dev/null @@ -1,26 +0,0 @@ - - -Performance testing -=================== - -This module allows the performance of operations against graphs to be measured. Currently there are simple tests of both ingest and query performance. - -The `performance-testing-core` module contains tests that are independent of any particular `Store`. The `ElementIngestTest` class can be used to measure the time taken to ingest elements to a `Graph`. The `QueryTest` class can be used to measure the time taken for queries to return elements from a graph. - -The `performance-testing-accumulo-store` module contains a test that initialises an empty Accumulo table with sensible split points and then calls the standard `RandomElementIngestTest` to run the ingest test. - -The `performance-testing-aws` module contains a listener that forwards results from a test to CloudWatch. diff --git a/performance-testing/performance-testing-accumulo-store/pom.xml b/performance-testing/performance-testing-accumulo-store/pom.xml deleted file mode 100644 index cc186ea0..00000000 --- a/performance-testing/performance-testing-accumulo-store/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - uk.gov.gchq.gaffer - performance-testing - 2.0.0 - - 4.0.0 - - performance-testing-accumulo-store - - - - uk.gov.gchq.gaffer - accumulo-store - ${gaffer.version} - - - uk.gov.gchq.gaffer - performance-testing-core - ${project.parent.version} - - - uk.gov.gchq.gaffer - accumulo-store - ${gaffer.version} - test-jar - test - - - org.apache.accumulo - accumulo-minicluster - ${accumulo.version} - test - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - org.apache.hadoop - hadoop-hdfs - ${hadoop.version} - test - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - uk.gov.gchq.gaffer - common-util - ${gaffer.version} - test-jar - test - - - - - - - maven-shade-plugin - ${shade.plugin.version} - - - full - package - - shade - - - true - - full - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTest.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTest.java deleted file mode 100644 index 93b8a158..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2017-2023 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.accumulostore.performancetesting.ingest; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.conf.Configured; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.io.BytesWritable; -import org.apache.hadoop.io.NullWritable; -import org.apache.hadoop.io.SequenceFile; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import uk.gov.gchq.gaffer.accumulostore.AccumuloStore; -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints; -import uk.gov.gchq.gaffer.operation.OperationException; -import uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile; -import uk.gov.gchq.gaffer.performancetesting.ingest.ElementIngestTest; -import uk.gov.gchq.gaffer.randomelementgeneration.generator.ElementGeneratorFromSupplier; -import uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser; -import uk.gov.gchq.gaffer.store.Context; -import uk.gov.gchq.gaffer.store.StoreException; -import uk.gov.gchq.gaffer.store.StoreProperties; -import uk.gov.gchq.gaffer.store.schema.Schema; -import uk.gov.gchq.gaffer.store.serialiser.ElementSerialiser; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.function.Supplier; - -public class AccumuloElementIngestTest extends Configured { - private static final Logger LOGGER = LoggerFactory.getLogger(AccumuloElementIngestTest.class); - - private final Graph graph; - private final AccumuloStore accumuloStore; - private final AccumuloElementIngestTestProperties testProperties; - - public AccumuloElementIngestTest(final Graph graph, - final AccumuloStore accumuloStore, - final AccumuloElementIngestTestProperties testProperties) { - this.graph = graph; - this.accumuloStore = accumuloStore; - this.testProperties = testProperties; - } - - protected void run() throws OperationException { - // Configuration - final Configuration conf = getConf(); - final FileSystem fs; - try { - fs = FileSystem.get(conf); - } catch (final IOException e) { - throw new OperationException("IOException obtaining FileSystem from conf", e); - } - - // Create generator - final Supplier elementSupplier = new ElementIngestTest.ElementSupplierFactory(testProperties).get(); - final ElementGeneratorFromSupplier generator = new ElementGeneratorFromSupplier( - Long.parseLong(testProperties.getNumElementsForSplitEstimation()), elementSupplier); - - // Serialiser to go from elements to a byte array and back - final ToBytesSerialiser serialisation = new ElementSerialiser(accumuloStore.getSchema()); - - // Write random data to a sequence file - LOGGER.info("Writing random elements to a temporary file"); - if (null == testProperties.getTempDirectory()) { - throw new OperationException("Missing temporary directory"); - } - final String tmpData = testProperties.getTempDirectory() + "/tmp_random_data/"; - try { - final SequenceFile.Writer writer = SequenceFile.createWriter(conf, - SequenceFile.Writer.file(new Path(tmpData)), - SequenceFile.Writer.compression(SequenceFile.CompressionType.NONE), - SequenceFile.Writer.keyClass(NullWritable.class), - SequenceFile.Writer.valueClass(BytesWritable.class)); - for (final Element element : generator.apply(Collections.singletonList("DUMMY"))) { - writer.append(NullWritable.get(), new BytesWritable(serialisation.serialise(element))); - } - writer.close(); - } catch (final IOException e) { - throw new OperationException("IOException creating SequenceFile of random data", e); - } - - // Find out number of tablet servers so that we can create the correct number of split points - final int numTabletServers; - try { - numTabletServers = accumuloStore.getConnection().instanceOperations().getTabletServers().size(); - } catch (final StoreException e) { - throw new OperationException("StoreException obtaining the number of tablet servers", e); - } - final int numSplitPoints = numTabletServers * Integer.parseInt(testProperties.getNumSplitPointsPerTabletServer()); - - // Sample this data to estimate split points. - // NB: Use a sample proportion of 1 to indicate that all the data should be sampled as we only wrote out - // enough data to create a good size sample. - final String splitsFile = testProperties.getTempDirectory() + "/splits_file"; - final String splitsOutputPath = testProperties.getTempDirectory() + "/splits_output/"; - LOGGER.info("Running SampleDataForSplitPoints job"); - final SampleDataForSplitPoints sample = new SampleDataForSplitPoints.Builder() - .numSplits(numSplitPoints) - .addInputMapperPair(tmpData, BytesWritableMapperGenerator.class.getName()) - .splitsFilePath(splitsFile) - .outputPath(splitsOutputPath) - .jobInitialiser(new SequenceFileJobInitialiser()) - .validate(false) - .proportionToSample(1.0F) - .build(); - accumuloStore.execute(sample, new Context()); - - // Check if split points were output (if there was only 1 tablet server then no split points will be output) - boolean splitsFileExists = false; - try { - if (fs.exists(new Path(splitsFile))) { - splitsFileExists = true; - } - } catch (final IOException e) { - throw new OperationException("IOException finding out if splits file exists", e); - } - - if (!splitsFileExists) { - LOGGER.info("No splits file was written by SampleDataForSplitPoints so not adding split points to table"); - } else { - // Add the splits point to the table - LOGGER.info("Adding split points to table"); - final SplitStoreFromFile splitTable = new SplitStoreFromFile.Builder() - .inputPath(splitsFile) - .build(); - accumuloStore.execute(splitTable, new Context()); - } - - // Run test - LOGGER.info("Running ElementIngestTest"); - final ElementIngestTest test = new ElementIngestTest(graph, testProperties); - test.run(); - } - - public static void main(final String[] args) throws StoreException, IOException { - if (args.length != 3) { - throw new RuntimeException("Usage: "); - } - final Schema schema = Schema.fromJson(new File(args[0]).toPath()); - LOGGER.info("Using schema of {}", schema); - final StoreProperties storeProperties = StoreProperties.loadStoreProperties(args[1]); - final AccumuloElementIngestTestProperties testProperties = new AccumuloElementIngestTestProperties(); - testProperties.loadTestProperties(args[2]); - final AccumuloStore accumuloStore = new AccumuloStore(); - accumuloStore.initialise(testProperties.getGraphId(), schema, storeProperties); - LOGGER.info("Initialised Accumulo store (instance name is {}, graph id is {})", - accumuloStore.getProperties().getInstance(), - accumuloStore.getTableName()); - LOGGER.info("Using test properties of {}", testProperties); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder() - .graphId(testProperties.getGraphId()) - .build()) - .store(accumuloStore) - .addSchema(schema) - .build(); - final AccumuloElementIngestTest test = new AccumuloElementIngestTest(graph, accumuloStore, testProperties); - Configuration conf = new Configuration(); - test.setConf(conf); - LOGGER.info("Running test"); - try { - test.run(); - LOGGER.info("Test ran successfully"); - } catch (final OperationException e) { - LOGGER.error("Error running test: ", e); - } - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTestProperties.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTestProperties.java deleted file mode 100644 index 02874226..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/AccumuloElementIngestTestProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2017-2019 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.accumulostore.performancetesting.ingest; - -import uk.gov.gchq.gaffer.performancetesting.ingest.ElementIngestTestProperties; - -public class AccumuloElementIngestTestProperties extends ElementIngestTestProperties { - private static final long serialVersionUID = -5817791421306186151L; - - private static final String TEMP_DIRECTORY = "gaffer.accumulostore.performancetesting.ingest.tempDirectory"; - private static final String NUM_ELEMENTS_FOR_SPLIT_ESTIMATION = - "gaffer.accumulostore.performancetesting.ingest.numElementsForSplitEstimation"; - private static final String NUM_SPLIT_POINTS_PER_TABLET_SERVER = - "gaffer.accumulostore.performancetesting.ingest.numSplitPointsPerTabletServer"; - - public AccumuloElementIngestTestProperties() { - super(); - } - - public String getTempDirectory() { - return getProperty(TEMP_DIRECTORY); - } - - public void setTempDirectory(final String tempDirectory) { - setProperty(TEMP_DIRECTORY, tempDirectory); - } - - public String getNumElementsForSplitEstimation() { - return getProperty(NUM_ELEMENTS_FOR_SPLIT_ESTIMATION, "10000"); - } - - public void setNumElementsForSplitEstimation(final String numElementsForSplitEstimation) { - setProperty(NUM_ELEMENTS_FOR_SPLIT_ESTIMATION, numElementsForSplitEstimation); - } - - public String getNumSplitPointsPerTabletServer() { - return getProperty(NUM_SPLIT_POINTS_PER_TABLET_SERVER, "1"); - } - - public void setNumSplitPointsPerTabletServer(final String numSplitPointsPerTabletServer) { - setProperty(NUM_SPLIT_POINTS_PER_TABLET_SERVER, numSplitPointsPerTabletServer); - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableElementGenerator.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableElementGenerator.java deleted file mode 100644 index bf4f93fd..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableElementGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2017-2023 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.accumulostore.performancetesting.ingest; - -import org.apache.hadoop.io.BytesWritable; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.data.generator.ElementGenerator; -import uk.gov.gchq.gaffer.exception.SerialisationException; -import uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser; - -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -public class BytesWritableElementGenerator implements ElementGenerator { - - private final ToBytesSerialiser elementSerialisation; - - public BytesWritableElementGenerator(final ToBytesSerialiser elementSerialisation) { - this.elementSerialisation = elementSerialisation; - } - - @Override - public Iterable apply(final Iterable domainObjects) { - final Stream elementStream = StreamSupport - .stream(domainObjects.spliterator(), false) - .map(bw -> { - try { - return elementSerialisation.deserialise(bw.getBytes()); - } catch (final SerialisationException e) { - throw new RuntimeException("SerialisationException getting elements from BytesWritable", e); - } - }); - final Iterable elementIterable = elementStream::iterator; - return elementIterable::iterator; - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java deleted file mode 100644 index 42d17f2f..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2017-2023 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.accumulostore.performancetesting.ingest; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.io.BytesWritable; -import org.apache.hadoop.io.NullWritable; -import org.apache.hadoop.mapreduce.MapContext; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.data.generator.ElementGenerator; -import uk.gov.gchq.gaffer.hdfs.operation.handler.job.factory.SampleDataForSplitPointsJobFactory; -import uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator; -import uk.gov.gchq.gaffer.store.schema.Schema; -import uk.gov.gchq.gaffer.store.serialiser.ElementSerialiser; - -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -public class BytesWritableMapperGenerator implements MapperGenerator { - - private final List singleItemList = new ArrayList<>(1); - private ElementGenerator elementGenerator; - - public BytesWritableMapperGenerator() { - } - - public BytesWritableMapperGenerator(final BytesWritableElementGenerator elementGenerator) { - this.elementGenerator = elementGenerator; - } - - private void createElementGenerator(final Configuration conf) { - final Schema schema = Schema.fromJson(conf - .get(SampleDataForSplitPointsJobFactory.SCHEMA) - .getBytes(StandardCharsets.UTF_8)); - this.elementGenerator = new BytesWritableElementGenerator(new ElementSerialiser(schema)); - } - - @Override - public Iterable getElements(final NullWritable nullWritable, - final BytesWritable bytesWritable, - final MapContext context) { - if (null == elementGenerator) { - createElementGenerator(context.getConfiguration()); - } - singleItemList.clear(); - singleItemList.add(bytesWritable); - - elementGenerator.apply(singleItemList).forEach(System.out::println); - return elementGenerator.apply(singleItemList); - } - - public ElementGenerator getElementGenerator() { - return elementGenerator; - } - - public void setElementGenerator(final ElementGenerator elementGenerator) { - this.elementGenerator = elementGenerator; - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/SequenceFileJobInitialiser.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/SequenceFileJobInitialiser.java deleted file mode 100644 index e10c0bd2..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/SequenceFileJobInitialiser.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017-2019 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.accumulostore.performancetesting.ingest; - -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.mapreduce.Job; -import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; - -import uk.gov.gchq.gaffer.hdfs.operation.MapReduce; -import uk.gov.gchq.gaffer.hdfs.operation.handler.job.initialiser.JobInitialiser; -import uk.gov.gchq.gaffer.store.Store; - -import java.io.IOException; -import java.util.Map; - -public class SequenceFileJobInitialiser implements JobInitialiser { - @Override - public void initialiseJob(final Job job, final MapReduce operation, final Store store) throws IOException { - initialiseInput(job, operation); - } - - private void initialiseInput(final Job job, final MapReduce operation) throws IOException { - job.setInputFormatClass(SequenceFileInputFormat.class); - final Map mapperPairs = operation.getInputMapperPairs(); - for (final String path : mapperPairs.keySet()) { - SequenceFileInputFormat.addInputPath(job, new Path(path)); - } - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java b/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java deleted file mode 100644 index 0a22bbf8..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2017-2019 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.accumulostore.performancetesting.ingest; - -import org.apache.hadoop.conf.Configuration; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; -import uk.gov.gchq.gaffer.accumulostore.AccumuloStore; -import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.StreamUtil; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.operation.OperationException; -import uk.gov.gchq.gaffer.randomelementgeneration.Constants; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier; -import uk.gov.gchq.gaffer.store.StoreException; -import uk.gov.gchq.gaffer.store.schema.Schema; - -import java.io.File; -import java.io.IOException; - -public class TestAccumuloStoreRandomElementIngestTest { - - @TempDir - public File tempFolder; - - @Test - public void testAccumuloStoreRandomElementIngestTestRuns() throws StoreException, OperationException, IOException { - // Given - final AccumuloElementIngestTestProperties testProperties = new AccumuloElementIngestTestProperties(); - testProperties.setNumElements(100L); - testProperties.setBatchSize(10); - testProperties.setElementSupplierClass(RmatElementSupplier.class.getName()); - testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); - testProperties.setRmatMaxNodeId(100L); - testProperties.setTempDirectory(tempFolder.getCanonicalPath()); - - final Schema schema = Schema.fromJson(StreamUtil.schemas(Constants.class)); - final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( - StreamUtil.openStream(Constants.class, "accumuloStore.properties") - ); - final AccumuloStore accumuloStore = new MiniAccumuloStore(); - accumuloStore.initialise("1", schema, storeProperties); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder().graphId("1").build()) - .store(accumuloStore) - .build(); - - Configuration conf = new Configuration(); - conf.set("io.seqfile.compression.type", "NONE"); - - // When, then should run successfully - AccumuloElementIngestTest test = new AccumuloElementIngestTest(graph, accumuloStore, testProperties); - test.setConf(conf); - test.run(); - } -} diff --git a/performance-testing/performance-testing-accumulo-store/src/test/resources/log4j.xml b/performance-testing/performance-testing-accumulo-store/src/test/resources/log4j.xml deleted file mode 100644 index 2bcf2626..00000000 --- a/performance-testing/performance-testing-accumulo-store/src/test/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/performance-testing/performance-testing-aws/pom.xml b/performance-testing/performance-testing-aws/pom.xml deleted file mode 100644 index a6abe902..00000000 --- a/performance-testing/performance-testing-aws/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - uk.gov.gchq.gaffer - performance-testing - 2.0.0 - - 4.0.0 - - performance-testing-aws - - - - com.amazonaws - aws-java-sdk-cloudwatch - 1.11.158 - - - - uk.gov.gchq.gaffer - performance-testing-core - ${project.parent.version} - - - - com.googlecode.json-simple - json-simple - 1.1.1 - - - - org.apache.accumulo - accumulo-server-base - ${accumulo.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - org.apache.httpcomponents - httpclient - 4.5.13 - - - - org.apache.httpcomponents - httpcore - 4.4.4 - - - org.apache.accumulo - accumulo-core - ${accumulo.version} - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - - - maven-shade-plugin - ${shade.plugin.version} - - - full - package - - shade - - - true - full - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - diff --git a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/AwsEmrUtils.java b/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/AwsEmrUtils.java deleted file mode 100644 index 4ffcf92e..00000000 --- a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/AwsEmrUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.aws; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; - -@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") -public final class AwsEmrUtils { - - private static final Logger LOGGER = LoggerFactory.getLogger(AwsEmrUtils.class); - - private static final String EMR_JOB_FLOW_FILE_LOCATION = "/mnt/var/lib/info/job-flow.json"; - - private static String emrJobFlowId = null; - - private AwsEmrUtils() { - } - - public static String getJobFlowId() { - if (emrJobFlowId == null) { - try { - final BufferedReader emrFlowFileReader = Files.newBufferedReader(Paths.get(EMR_JOB_FLOW_FILE_LOCATION), StandardCharsets.UTF_8); - final JSONObject info = (JSONObject) JSONValue.parse(emrFlowFileReader); - if (info.containsKey("jobFlowId")) { - emrJobFlowId = info.get("jobFlowId").toString(); - } - } catch (final IOException e) { - LOGGER.error("Unable to open EMR job flow file: " + EMR_JOB_FLOW_FILE_LOCATION, e); - } - } - - return emrJobFlowId; - } - -} diff --git a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/CloudWatchMetricsListener.java b/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/CloudWatchMetricsListener.java deleted file mode 100644 index c318c08e..00000000 --- a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/CloudWatchMetricsListener.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.aws; - -import com.amazonaws.services.cloudwatch.AmazonCloudWatch; -import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; -import com.amazonaws.services.cloudwatch.model.Dimension; -import com.amazonaws.services.cloudwatch.model.MetricDatum; -import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; -import com.amazonaws.services.cloudwatch.model.PutMetricDataResult; -import com.amazonaws.services.cloudwatch.model.StandardUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import uk.gov.gchq.gaffer.performancetesting.Metrics; -import uk.gov.gchq.gaffer.performancetesting.MetricsListener; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -public class CloudWatchMetricsListener implements MetricsListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(CloudWatchMetricsListener.class); - - public static final String NAMESPACE_PROP = "gaffer.performancetesting.cloudwatchmetricslistener.namespace"; - public static final String DIMENSION_PROP_PREFIX = "gaffer.performancetesting.cloudwatchmetricslistener.dimensions."; - public static final String DIMENSION_PROP_NAME_SUFFIX = ".name"; - public static final String DIMENSION_PROP_VALUE_SUFFIX = ".value"; - - private AmazonCloudWatch cloudwatch = null; - private String namespace = null; - private final List dimensions = new ArrayList<>(); - - @Override - public void initialise(final Properties properties) { - if (!properties.containsKey(NAMESPACE_PROP)) { - throw new IllegalArgumentException("Properties should contain the CloudWatch namespace that the metrics should be pushed to (" + NAMESPACE_PROP + ")"); - } - - this.namespace = properties.getProperty(NAMESPACE_PROP); - - // Up to 10 dimensions can be assigned to each CloudWatch metric: - // http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Dimension - for (int i = 1; i <= 10; i++) { - final String dimensionNameProperty = DIMENSION_PROP_PREFIX + i + DIMENSION_PROP_NAME_SUFFIX; - final String dimensionValueProperty = DIMENSION_PROP_PREFIX + i + DIMENSION_PROP_VALUE_SUFFIX; - - if (properties.containsKey(dimensionNameProperty) && properties.containsKey(dimensionValueProperty)) { - this.dimensions.add( - new Dimension() - .withName(properties.getProperty(dimensionNameProperty)) - .withValue(properties.getProperty(dimensionValueProperty)) - ); - } - } - - this.cloudwatch = AmazonCloudWatchClientBuilder.defaultClient(); - } - - @Override - public void update(final Metrics metrics) { - List cloudwatchMetrics = new ArrayList<>(); - - Date now = new Date(); - - for (final String name : metrics.getMetricNames()) { - Object value = metrics.getMetric(name); - - if (value instanceof Double) { - cloudwatchMetrics.add( - new MetricDatum() - .withMetricName(name) - .withValue((Double) value) - .withUnit(StandardUnit.CountSecond) - .withTimestamp(now) - .withDimensions(this.dimensions) - ); - } - } - - if (cloudwatchMetrics.size() > 0) { - PutMetricDataResult response = this.cloudwatch.putMetricData( - new PutMetricDataRequest() - .withNamespace(this.namespace) - .withMetricData(cloudwatchMetrics) - ); - - LOGGER.info( - "AWS CloudWatch responseCode: {} requestId: {}", - response.getSdkHttpMetadata().getHttpStatusCode(), - response.getSdkResponseMetadata().getRequestId() - ); - } - } - - @Override - public void close() { - if (this.cloudwatch != null) { - this.cloudwatch.shutdown(); - this.cloudwatch = null; - } - } - -} diff --git a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java b/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java deleted file mode 100644 index e8cec2d5..00000000 --- a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.aws; - -import com.amazonaws.services.cloudwatch.AmazonCloudWatch; -import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; -import com.amazonaws.services.cloudwatch.model.AmazonCloudWatchException; -import com.amazonaws.services.cloudwatch.model.Dimension; -import com.amazonaws.services.cloudwatch.model.MetricDatum; -import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; -import com.amazonaws.services.cloudwatch.model.PutMetricDataResult; -import com.amazonaws.services.cloudwatch.model.StandardUnit; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.apache.accumulo.core.client.Accumulo; -import org.apache.accumulo.core.client.AccumuloClient; -import org.apache.accumulo.core.clientImpl.MasterClient; -import org.apache.accumulo.core.clientImpl.Tables; -import org.apache.accumulo.core.conf.SiteConfiguration; -import org.apache.accumulo.core.data.TableId; -import org.apache.accumulo.core.master.thrift.MasterClientService; -import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; -import org.apache.accumulo.core.master.thrift.TableInfo; -import org.apache.accumulo.core.master.thrift.TabletServerStatus; -import org.apache.accumulo.core.trace.TraceUtil; -import org.apache.accumulo.core.util.Pair; -import org.apache.accumulo.server.ServerContext; -import org.apache.thrift.TException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/* - * This utility periodically collects metrics from an Accumulo Master and publishes them to AWS CloudWatch - */ -@SuppressWarnings("UnusedPrivateField") -public class PublishAccumuloMetricsToCloudWatch implements Runnable { - - private static final Logger LOGGER = LoggerFactory.getLogger(PublishAccumuloMetricsToCloudWatch.class); - - private final String instanceName; - private final String zookeepers; - private final int interval; - - private AccumuloClient instance; - private ServerContext context; - private MasterClientService.Client client; - private AmazonCloudWatch cloudwatch; - - private Map tableIdToNameMap; - private Date previousCaptureDate = null; - private Map>, Double> previousMetrics = null; - - public PublishAccumuloMetricsToCloudWatch(final String instanceName, final String zookeepers) { - this(instanceName, zookeepers, 60); - } - - public PublishAccumuloMetricsToCloudWatch(final String instanceName, final String zookeepers, final int interval) { - this.instanceName = instanceName; - this.zookeepers = zookeepers; - this.interval = interval; - } - - private void connect() { - // Connect to Accumulo Master - this.instance = Accumulo.newClient().to(instanceName, zookeepers).as("admin", "admin").build(); - this.context = new ServerContext(new SiteConfiguration()); - this.client = MasterClient.getConnection(this.context); - - // Set up connection to AWS CloudWatch - this.cloudwatch = AmazonCloudWatchClientBuilder.defaultClient(); - } - - private void disconnect() { - if (this.cloudwatch != null) { - this.cloudwatch.shutdown(); - this.cloudwatch = null; - } - } - - @SuppressFBWarnings(value = "GC_UNRELATED_TYPES", justification = "Appears to be a intentional") - private String getTableNameForId(final String id) { - if (this.tableIdToNameMap == null || !this.tableIdToNameMap.containsKey(id)) { - // Refresh the cache as a table may have just been created - this.tableIdToNameMap = Tables.getIdToNameMap(this.context); - } - - return this.tableIdToNameMap.get(id); - } - - - @SuppressFBWarnings("ICAST_IDIV_CAST_TO_DOUBLE") - private List gatherMetrics() throws TException { - final String awsEmrJobFlowId = AwsEmrUtils.getJobFlowId(); - - final MasterMonitorInfo stats = this.client.getMasterStats(TraceUtil.traceInfo(), this.context.rpcCreds()); - LOGGER.trace(stats.toString()); - - final Date now = new Date(); - final List metrics = new ArrayList<>(); - final Map>, Double> metricsToCache = new HashMap<>(); - - // Master Metrics - final List masterDimensions = new ArrayList<>(); - if (awsEmrJobFlowId != null) { - masterDimensions.add(new Dimension().withName("EmrJobFlowId").withValue(awsEmrJobFlowId)); - } - masterDimensions.add(new Dimension().withName("InstanceName").withValue(this.instanceName)); - - metrics.addAll(this.generateCountMetricForEachDimensionCombination("TabletServerCount", (double) stats.getTServerInfoSize(), masterDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("BadTabletServerCount", (double) stats.getBadTServersSize(), masterDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("DeadTabletServerCount", (double) stats.getDeadTabletServersSize(), masterDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("ServersShuttingDownCount", (double) stats.getServersShuttingDownSize(), masterDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("TableCount", (double) stats.getTableMapSize(), masterDimensions, now)); - - // Tablet Server Metrics - for (final TabletServerStatus tserver : stats.getTServerInfo()) { - // Trimming off the port from the tablet server name as (at the moment) we only deploy a single tablet server per YARN node - // This makes it easier to locate the metrics in CloudWatch - // @TODO: Make this optional via a command line flag? - String tabletServerHostName = tserver.getName(); - if (tabletServerHostName.contains(":")) { - tabletServerHostName = tabletServerHostName.substring(0, tabletServerHostName.lastIndexOf(':')); - } - - final List tserverDimensions = new ArrayList<>(); - if (awsEmrJobFlowId != null) { - tserverDimensions.add(new Dimension().withName("EmrJobFlowId").withValue(awsEmrJobFlowId)); - } - tserverDimensions.add(new Dimension().withName("InstanceName").withValue(this.instanceName)); - tserverDimensions.add(new Dimension().withName("TabletServerName").withValue(tabletServerHostName)); - - metrics.addAll(this.generateCountMetricForEachDimensionCombination("DataCacheRequests", (double) tserver.getDataCacheRequest(), tserverDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("DataCacheHits", (double) tserver.getDataCacheHits(), tserverDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("IndexCacheRequests", (double) tserver.getIndexCacheRequest(), tserverDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("IndexCacheHits", (double) tserver.getIndexCacheHits(), tserverDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("Lookups", (double) tserver.getLookups(), tserverDimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("OsLoad", tserver.getOsLoad(), tserverDimensions, now)); - - // Table Metrics - for (final Map.Entry tableEntry : tserver.getTableMap().entrySet()) { - final String tableId = tableEntry.getKey(); - final TableInfo info = tableEntry.getValue(); - - final String tableName = this.getTableNameForId(tableId); - if (tableName != null) { - final List dimensions = new ArrayList<>(); - if (awsEmrJobFlowId != null) { - dimensions.add(new Dimension().withName("EmrJobFlowId").withValue(awsEmrJobFlowId)); - } - dimensions.add(new Dimension().withName("InstanceName").withValue(this.instanceName)); - dimensions.add(new Dimension().withName("TableName").withValue(tableName)); - dimensions.add(new Dimension().withName("TabletServerName").withValue(tabletServerHostName)); - - metrics.addAll(this.generateCountMetricForEachDimensionCombination("TabletCount", (double) info.getTablets(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("OnlineTabletCount", (double) info.getOnlineTablets(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("RecordCount", (double) info.getRecs(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("RecordsInMemoryCount", (double) info.getRecsInMemory(), dimensions, now)); - if (info.getScans() != null) { - metrics.addAll(this.generateCountMetricForEachDimensionCombination("ScansRunning", (double) info.getScans().getRunning(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("ScansQueued", (double) info.getScans().getQueued(), dimensions, now)); - } - if (info.getMinors() != null) { - metrics.addAll(this.generateCountMetricForEachDimensionCombination("MinorCompactionCount", (double) info.getMinors().getRunning(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("MinorCompactionQueuedCount", (double) info.getMinors().getQueued(), dimensions, now)); - } - if (info.getMajors() != null) { - metrics.addAll(this.generateCountMetricForEachDimensionCombination("MajorCompactionCount", (double) info.getMajors().getRunning(), dimensions, now)); - metrics.addAll(this.generateCountMetricForEachDimensionCombination("MajorCompactionQueuedCount", (double) info.getMajors().getQueued(), dimensions, now)); - } - - // The 'IngestRate' metric reported by Accumulo updates every ~5 seconds, so generate our own - // version of the metric for our interval using 'RecordCount'. Note that our version is affected by - // MinC + MajC that reduce the number of records so -ve rates are possible! - final Pair> metricCacheKey = new Pair<>("RecordCount", dimensions); - if (this.previousMetrics != null && this.previousMetrics.containsKey(metricCacheKey)) { - final double change = (double) info.getRecs() - this.previousMetrics.get(metricCacheKey); - final double rate = change / ((now.getTime() - this.previousCaptureDate.getTime()) / 1000); - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("CalculatedIngestRate").withValue(rate) - .withUnit(StandardUnit.CountSecond).withTimestamp(now), - dimensions - ) - ); - } - metricsToCache.put(metricCacheKey, (double) info.getRecs()); - - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("IngestRate").withValue(info.getIngestRate()) - .withUnit(StandardUnit.CountSecond).withTimestamp(now), - dimensions - ) - ); - - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("IngestByteRate").withValue(info.getIngestByteRate()) - .withUnit(StandardUnit.BytesSecond).withTimestamp(now), - dimensions - ) - ); - - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("QueryRate").withValue(info.getQueryRate()) - .withUnit(StandardUnit.CountSecond).withTimestamp(now), - dimensions - ) - ); - - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("QueryByteRate").withValue(info.getQueryByteRate()) - .withUnit(StandardUnit.BytesSecond).withTimestamp(now), - dimensions - ) - ); - - metrics.addAll( - this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName("ScanRate").withValue(info.getScanRate()) - .withUnit(StandardUnit.CountSecond).withTimestamp(now), - dimensions - ) - ); - } - } - } - - this.previousCaptureDate = now; - this.previousMetrics = metricsToCache; - - return metrics; - } - - private void publishMetrics(final List metrics) { - LOGGER.info("Submitting " + metrics.size() + " metrics to CloudWatch"); - - // CloudWatch throws InvalidParameterValue if a value has a high level of precision and is very close to 0 - for (final MetricDatum metric : metrics) { - if (Math.abs(metric.getValue()) < 0.0001) { - metric.setValue(0.0); - } - } - - // There's a limit on the AWS API which means only 20 metrics can be submitted at once! - for (int i = 0; i < metrics.size(); i += 20) { - final List metricBatch = metrics.subList(i, i + 20 > metrics.size() ? metrics.size() : i + 20); - try { - final PutMetricDataResult response = this.cloudwatch.putMetricData( - new PutMetricDataRequest() - .withNamespace("Accumulo") - .withMetricData(metricBatch) - ); - - LOGGER.debug(response.getSdkResponseMetadata().getRequestId()); - } catch (final AmazonCloudWatchException e) { - LOGGER.error("Failed publishing the following metrics to CloudWatch: " + metricBatch, e); - } - } - } - - private List generateCountMetricForEachDimensionCombination(final String name, final double value, final List dimensions, final Date tstamp) { - return this.generateMetricForEachDimensionCombination( - new MetricDatum() - .withMetricName(name) - .withValue(value) - .withUnit(StandardUnit.Count) - .withTimestamp(tstamp), - dimensions - ); - } - - private List generateMetricForEachDimensionCombination(final MetricDatum metric, final List dimensions) { - final List metrics = new ArrayList<>(); - for (int i = 0; i < dimensions.size(); i++) { - metrics.add(metric.clone().withDimensions(dimensions.subList(0, i + 1))); - } - return metrics; - } - - public void run() { - this.connect(); - - boolean run = true; - while (run) { - long startTime = System.currentTimeMillis(); - - try { - final List metrics = this.gatherMetrics(); - this.publishMetrics(metrics); - } catch (final TException e) { - LOGGER.warn("Thrift Exception", e); - } - - long finishTime = System.currentTimeMillis(); - long delay = (this.interval * 1000) - (finishTime - startTime); - - if (delay > 0) { - try { - Thread.sleep(delay); - } catch (final InterruptedException e) { - run = false; - } - } - } - - this.disconnect(); - } - - public static void main(final String[] args) { - if (args.length != 2) { - LOGGER.warn("Syntax: " + PublishAccumuloMetricsToCloudWatch.class.getSimpleName() + " "); - System.exit(1); - } - - final String instanceName = args[0]; - final String zookeepers = args[1]; - - PublishAccumuloMetricsToCloudWatch metricCollection = new PublishAccumuloMetricsToCloudWatch(instanceName, zookeepers); - metricCollection.run(); - } - -} diff --git a/performance-testing/performance-testing-aws/src/main/resources/log4j.xml b/performance-testing/performance-testing-aws/src/main/resources/log4j.xml deleted file mode 100755 index f145a51c..00000000 --- a/performance-testing/performance-testing-aws/src/main/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/performance-testing/performance-testing-aws/src/test/resources/log4j.xml b/performance-testing/performance-testing-aws/src/test/resources/log4j.xml deleted file mode 100644 index 2bcf2626..00000000 --- a/performance-testing/performance-testing-aws/src/test/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/performance-testing/performance-testing-core/pom.xml b/performance-testing/performance-testing-core/pom.xml deleted file mode 100644 index c47c2224..00000000 --- a/performance-testing/performance-testing-core/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - uk.gov.gchq.gaffer - performance-testing - 2.0.0 - - 4.0.0 - - performance-testing-core - - - - uk.gov.gchq.gaffer - random-element-generation - ${project.parent.version} - - - uk.gov.gchq.gaffer - accumulo-store - ${gaffer.version} - test-jar - test - - - org.apache.accumulo - accumulo-minicluster - ${accumulo.version} - test - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - org.apache.hadoop - hadoop-hdfs - ${hadoop.version} - test - - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - uk.gov.gchq.gaffer - common-util - ${gaffer.version} - test-jar - test - - - - diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/FileWriterMetricsListener.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/FileWriterMetricsListener.java deleted file mode 100644 index 8538fd0b..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/FileWriterMetricsListener.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting; - -import uk.gov.gchq.gaffer.commonutil.ToStringBuilder; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Properties; - -public class FileWriterMetricsListener implements MetricsListener { - public static final String FILENAME = "gaffer.performancetesting.filewritermetricslistener.filename"; - private String filename = null; - private BufferedWriter writer = null; - - public FileWriterMetricsListener() { - } - - @Override - public void initialise(final Properties properties) { - if (!properties.containsKey(FILENAME)) { - throw new IllegalArgumentException("Properties should contain the filename to write to (property " - + FILENAME + ")"); - } - filename = properties.getProperty(FILENAME); - try { - writer = Files.newBufferedWriter(Paths.get(filename), StandardCharsets.UTF_8); - } catch (final IOException e) { - throw new RuntimeException("IOException opening file", e); - } - } - - @Override - public void update(final Metrics metrics) { - try { - int i = 0; - for (final String metricName : metrics.getMetricNames()) { - if (i > 0) { - writer.write(", "); - } - writer.write(metricName + ": " + metrics.getMetric(metricName)); - i++; - } - writer.write("\n"); - } catch (final IOException e) { - throw new RuntimeException("IOException writing metrics to file", e); - } - } - - @Override - public void close() { - if (null != writer) { - try { - writer.close(); - } catch (final IOException e) { - throw new RuntimeException("IOException closing file", e); - } - } - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("filename", filename) - .build(); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/Metrics.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/Metrics.java deleted file mode 100644 index c2dbb015..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/Metrics.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting; - -import java.util.SortedSet; - -/** - * An implementation of this interface contains information about the performance of a test. Each metric has a name - * and a value. The name is just a {@link String} and the value can be any {@link Object}. - */ -public interface Metrics { - - SortedSet getMetricNames(); - - Object getMetric(String metricName); - - void putMetric(String metricName, Object metric); -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/MetricsListener.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/MetricsListener.java deleted file mode 100644 index 5c246a9a..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/MetricsListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting; - -import java.util.Properties; - -/** - * An implementation of this interface receives a {@link Metrics} object describing the current performance of a test. - * It can then choose what to do with this information, e.g. store it in a file or database, or display it in a - * dashboard. - */ -public interface MetricsListener { - - void initialise(Properties properties); - - void update(Metrics metrics); - - void close(); -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/TestProperties.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/TestProperties.java deleted file mode 100644 index 2ec90cf0..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/TestProperties.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting; - -import uk.gov.gchq.gaffer.randomelementgeneration.Constants; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -public class TestProperties extends Properties { - private static final String GRAPH_ID = "gaffer.graph.id"; - private static final String METRICS_LISTENER_CLASS = "gaffer.performancetesting.metricsListener"; - private static final String BATCH_SIZE = "gaffer.performancetesting.batchSize"; - private static final String RMAT_PROBABILITIES = "gaffer.performancetesting.rmat.probabilities"; - private static final String RMAT_INCLUDE_ENTITIES = "gaffer.performancetesting.rmat.includeEntities"; - private static final String RMAT_MAX_NODEID = "gaffer.performancetesting.rmat.maxNodeId"; - - public String getGraphId() { - return getProperty(GRAPH_ID); - } - - public void setGraphId(final String graphId) { - setProperty(GRAPH_ID, graphId); - } - - public String getMetricsListenerClass() { - return getProperty(METRICS_LISTENER_CLASS); - } - - public void setMetricsListenerClass(final String metricsListenerClass) { - setProperty(METRICS_LISTENER_CLASS, metricsListenerClass); - } - - public int getBatchSize() { - return Integer.parseInt(getProperty(BATCH_SIZE)); - } - - public void setBatchSize(final long batchSize) { - if (batchSize <= 0L) { - throw new IllegalArgumentException("The batch size must be greater than 0."); - } - setProperty(BATCH_SIZE, String.valueOf(batchSize)); - } - - public double[] getRmatProbabilities() { - if (null == getProperty(RMAT_PROBABILITIES)) { - return Constants.RMAT_PROBABILITIES; - } - return stringToDoubleArray(getProperty(RMAT_PROBABILITIES)); - } - - public void setRmatProbabilities(final double... rmatProbabilities) { - if (rmatProbabilities == null || rmatProbabilities.length != 4) { - throw new IllegalArgumentException("Probabilities should be non-null and of length 4."); - } - final double min = Arrays.stream(rmatProbabilities).min().getAsDouble(); - if (min <= 0.0) { - throw new IllegalArgumentException("Every entry in probabilities must be strictly positive."); - } - final double sum = Arrays.stream(rmatProbabilities).sum(); - if (sum < 0.999999999 || sum > 1.00000001) { - throw new IllegalArgumentException("The entries in probabilities must sum to 1."); - } - setProperty(RMAT_PROBABILITIES, doubleArrayToString(rmatProbabilities)); - } - - public boolean getRmatIncludeEntities() { - return Boolean.parseBoolean(getProperty(RMAT_INCLUDE_ENTITIES)); - } - - public void setRmatIncludeEntities(final boolean includeEntities) { - setProperty(RMAT_INCLUDE_ENTITIES, Boolean.toString(includeEntities)); - } - - public long getRmatMaxNodeId() { - return Long.parseLong(getProperty(RMAT_MAX_NODEID)); - } - - public void setRmatMaxNodeId(final long maxNodeId) { - setProperty(RMAT_MAX_NODEID, String.valueOf(maxNodeId)); - } - - private static String doubleArrayToString(final double... values) { - if (null == values) { - throw new IllegalArgumentException("Cannot convert null array to a string"); - } - final StringBuilder builder = new StringBuilder(); - for (final double value : values) { - builder.append(value); - builder.append(','); - } - return builder.substring(0, builder.length() - 1); - } - - private static double[] stringToDoubleArray(final String s) { - if (null == s) { - throw new IllegalArgumentException("Cannot convert null string to an array of doubles"); - } - final List values = new ArrayList<>(); - for (final String item : s.split(",")) { - values.add(Double.parseDouble(item)); - } - return values.stream().mapToDouble(Double::doubleValue).toArray(); - } - - public void loadTestProperties(final String pathStr) { - loadTestProperties(Paths.get(pathStr)); - } - - public void loadTestProperties(final Path testPropertiesPath) { - try { - super.load(Files.newInputStream(testPropertiesPath)); - } catch (final IOException e) { - throw new RuntimeException("Failed to load test properties file: " + e.getMessage(), e); - } - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTest.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTest.java deleted file mode 100644 index b3854c6e..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.ingest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.operation.OperationException; -import uk.gov.gchq.gaffer.operation.impl.add.AddElements; -import uk.gov.gchq.gaffer.performancetesting.MetricsListener; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.ElementsSupplier; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier; -import uk.gov.gchq.gaffer.store.StoreProperties; -import uk.gov.gchq.gaffer.store.schema.Schema; -import uk.gov.gchq.gaffer.user.User; - -import java.io.File; -import java.util.function.Supplier; -import java.util.stream.Stream; - -/** - * This class measures the time taken to add some elements to the provided {@link Graph}. - * - *

The test is configured using a {@link ElementIngestTestProperties}. This specifies the class to be - * used to generate the random elements and the number of random elements. - */ -public class ElementIngestTest { - private static final Logger LOGGER = LoggerFactory.getLogger(ElementIngestTest.class); - - private final Graph graph; - private final ElementIngestTestProperties testProperties; - private MetricsListener metricsListener; - - public ElementIngestTest(final Graph graph, - final ElementIngestTestProperties testProperties) { - this.graph = graph; - this.testProperties = testProperties; - if (null != testProperties.getMetricsListenerClass()) { - try { - metricsListener = Class.forName(testProperties.getMetricsListenerClass()) - .asSubclass(MetricsListener.class).newInstance(); - metricsListener.initialise(testProperties); - LOGGER.info("Initialised MetricsListener of {}", metricsListener); - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new IllegalArgumentException("MetricsListener could not be created: " - + testProperties.getMetricsListenerClass(), e); - } - } - } - - /** - * Runs a test of adding elements in batches. - * - * @return The rate at which elements were added (number of elements per second). - */ - public double run() { - final long numElements = testProperties.getNumElements(); - final long batchSize = testProperties.getBatchSize(); - final Supplier elementSupplier = new ElementSupplierFactory(testProperties).get(); - long totalAdded = 0L; - long batchNumber = 0L; - final long startTime = System.currentTimeMillis(); - while (totalAdded < numElements) { - batchNumber++; - addBatch(elementSupplier, batchSize, batchNumber); - totalAdded += batchSize; - } - final long endTime = System.currentTimeMillis(); - final double durationInSeconds = (endTime - startTime) / 1000.0; - final double rate = (double) numElements / durationInSeconds; - LOGGER.info("Test result: " + numElements + " elements added in " + durationInSeconds + " seconds (rate was " - + rate + " per second)"); - log(numElements, true); - if (null != metricsListener) { - metricsListener.close(); - } - return rate; - } - - private void addBatch(final Supplier elementSupplier, final long batchSize, final long batchNumber) { - final Iterable elements = Stream.generate(elementSupplier).limit(batchSize)::iterator; - final AddElements addElements = new AddElements.Builder() - .input(elements) - .validate(false) - .build(); - final long startTime = System.currentTimeMillis(); - try { - graph.execute(addElements, new User()); - } catch (final OperationException e) { - LOGGER.error("OperationException thrown after " + (System.currentTimeMillis() - startTime) / 1000.0 - + " seconds"); - throw new RuntimeException("Exception thrown adding elements", e); - } - final long endTime = System.currentTimeMillis(); - final double durationInSeconds = (endTime - startTime) / 1000.0; - final double rate = batchSize / durationInSeconds; - LOGGER.info("Batch number = " + batchNumber + ": " + batchSize + " elements added in " + durationInSeconds - + " seconds (rate was " + rate + " per second)"); - log(rate, false); - } - - private void log(final double elementsPerSecond, final boolean finalResult) { - if (null != metricsListener) { - final IngestMetrics metrics = new IngestMetrics(); - if (finalResult) { - metrics.putMetric(IngestMetrics.ELEMENTS_PER_SECOND_OVERALL, elementsPerSecond); - } else { - metrics.putMetric(IngestMetrics.ELEMENTS_PER_SECOND_BATCH, elementsPerSecond); - } - metricsListener.update(metrics); - } - } - - public static class ElementSupplierFactory { - private final ElementIngestTestProperties testProperties; - - public ElementSupplierFactory(final ElementIngestTestProperties testProperties) { - this.testProperties = testProperties; - } - - public Supplier get() { - final String elementSupplierClass = testProperties.getElementSupplierClass(); - if (elementSupplierClass.equals(RmatElementSupplier.class.getName())) { - final double[] rmatProbabilities = testProperties.getRmatProbabilities(); - final long maxNodeId = testProperties.getRmatMaxNodeId(); - final boolean includeEntities = testProperties.getRmatIncludeEntities(); - return new ElementsSupplier(new RmatElementSupplier(rmatProbabilities, maxNodeId, includeEntities)); - } else { - throw new RuntimeException("Unknown ElementSupplier class of " + elementSupplierClass); - } - } - } - - public static void main(final String[] args) { - if (args.length != 3) { - throw new RuntimeException("Usage: "); - } - final Schema schema = Schema.fromJson(new File(args[0]).toPath()); - final StoreProperties storeProperties = StoreProperties.loadStoreProperties(args[1]); - final ElementIngestTestProperties testProperties = new ElementIngestTestProperties(); - testProperties.loadTestProperties(args[2]); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder() - .graphId(testProperties.getGraphId()) - .build()) - .storeProperties(storeProperties) - .addSchema(schema) - .build(); - final ElementIngestTest test = new ElementIngestTest(graph, testProperties); - final double result = test.run(); - LOGGER.info("Test result: elements were added at a rate of " + result + " per second"); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTestProperties.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTestProperties.java deleted file mode 100644 index 72ba0615..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/ElementIngestTestProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.ingest; - -import uk.gov.gchq.gaffer.performancetesting.TestProperties; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier; - -/** - * These properties are used to specify a {@link uk.gov.gchq.gaffer.performancetesting.ingest.IngestMetrics}. - */ -public class ElementIngestTestProperties extends TestProperties { - private static final long serialVersionUID = 8594474188709038747L; - private static final String ELEMENT_SUPPLIER_CLASS = "gaffer.performancetesting.ingest.elementSupplierClass"; - private static final String NUMBER_OF_ELEMENTS = "gaffer.performancetesting.ingest.numberOfElements"; - - public ElementIngestTestProperties() { - - } - - public String getElementSupplierClass() { - return getProperty(ELEMENT_SUPPLIER_CLASS, RmatElementSupplier.class.getName()); - } - - public void setElementSupplierClass(final String elementSupplierClass) { - setProperty(ELEMENT_SUPPLIER_CLASS, elementSupplierClass); - } - - public long getNumElements() { - return Long.parseLong(getProperty(NUMBER_OF_ELEMENTS)); - } - - public void setNumElements(final long numEdges) { - if (numEdges <= 0L) { - throw new IllegalArgumentException("The number of edges must be greater than 0."); - } - setProperty(NUMBER_OF_ELEMENTS, String.valueOf(numEdges)); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/IngestMetrics.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/IngestMetrics.java deleted file mode 100644 index 58819c2c..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/ingest/IngestMetrics.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting.ingest; - -import uk.gov.gchq.gaffer.performancetesting.Metrics; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * This class contains the results from a {@link uk.gov.gchq.gaffer.performancetesting.ingest.ElementIngestTest}. It - * provides the number of {@link uk.gov.gchq.gaffer.data.element.Element}s ingested per second. - */ -public class IngestMetrics implements Metrics { - public static final String ELEMENTS_PER_SECOND_BATCH = "elements_per_second_batch"; - public static final String ELEMENTS_PER_SECOND_OVERALL = "elements_per_second_overall"; - private static final SortedSet METRIC_NAMES = Collections.unmodifiableSortedSet(new TreeSet<>( - Arrays.asList(ELEMENTS_PER_SECOND_BATCH, ELEMENTS_PER_SECOND_OVERALL))); - private final Map metrics; - - public IngestMetrics() { - this.metrics = new HashMap<>(); - } - - @Override - public SortedSet getMetricNames() { - return METRIC_NAMES; - } - - @Override - public Object getMetric(final String metricName) { - return metrics.get(metricName); - } - - @Override - public void putMetric(final String metricName, final Object metric) { - if (!METRIC_NAMES.contains(metricName)) { - throw new IllegalArgumentException("Unrecognised metric " + metricName); - } - if (!(metric instanceof Double)) { - throw new IllegalArgumentException("Metric must be a double (got " + metricName.getClass().getName() + ")"); - } - metrics.put(metricName, (Double) metric); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryMetrics.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryMetrics.java deleted file mode 100644 index ea58de60..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryMetrics.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting.query; - -import uk.gov.gchq.gaffer.performancetesting.Metrics; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * This class contains the results from a {@link uk.gov.gchq.gaffer.performancetesting.query.QueryTest}. It provides - * the number of seeds queried for per second and the number of results per second. - */ -public class QueryMetrics implements Metrics { - public static final String SEEDS_PER_SECOND = "seeds_per_second"; - public static final String RESULTS_PER_SECOND = "results_per_second"; - private static final SortedSet METRIC_NAMES = Collections.unmodifiableSortedSet( - new TreeSet<>(Arrays.asList(SEEDS_PER_SECOND, RESULTS_PER_SECOND))); - private final Map metrics; - - public QueryMetrics(final double seedsPerSecond, final double resultsPerSecond) { - this.metrics = new HashMap<>(); - metrics.put(SEEDS_PER_SECOND, seedsPerSecond); - metrics.put(RESULTS_PER_SECOND, resultsPerSecond); - } - - @Override - public SortedSet getMetricNames() { - return METRIC_NAMES; - } - - @Override - public Object getMetric(final String metricName) { - return metrics.get(metricName); - } - - @Override - public void putMetric(final String metricName, final Object metric) { - if (!METRIC_NAMES.contains(metricName)) { - throw new IllegalArgumentException("Unrecognised metric " + metricName); - } - if (!(metric instanceof Double)) { - throw new IllegalArgumentException("Metric must be a double (got " + metricName.getClass().getName() + ")"); - } - metrics.put(metricName, (Double) metric); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTest.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTest.java deleted file mode 100644 index 4b4a42af..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.query; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.operation.OperationException; -import uk.gov.gchq.gaffer.operation.data.ElementSeed; -import uk.gov.gchq.gaffer.operation.impl.get.GetElements; -import uk.gov.gchq.gaffer.performancetesting.MetricsListener; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.EdgeSeedSupplier; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.EntitySeedSupplier; -import uk.gov.gchq.gaffer.store.StoreProperties; -import uk.gov.gchq.gaffer.store.schema.Schema; -import uk.gov.gchq.gaffer.user.User; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.StreamSupport; - -/** - * This class measures the time taken to query for a given number of {@link ElementSeed}s. The query is broken up into - * batches of a user specified size. For every batch, the number of seeds queried for per second and the number of - * results returned per second are recorded. - * - *

The test is configured using a {@link QueryTestProperties}. This specifies the class to be - * used to generate the random seeds and the number of seeds to be queried for. - * - *

Optionally, a {@link MetricsListener} can be provided. This will receive an update of the performance at the end - * of every batch. This update is an instance of {@link QueryMetrics}. - */ -public class QueryTest { - private static final Logger LOGGER = LoggerFactory.getLogger(QueryTest.class); - - private final Graph graph; - private final QueryTestProperties testProperties; - private MetricsListener metricsListener; - - public QueryTest(final Graph graph, - final QueryTestProperties testProperties) { - this.graph = graph; - this.testProperties = testProperties; - if (null != testProperties.getMetricsListenerClass()) { - try { - metricsListener = Class.forName(testProperties.getMetricsListenerClass()) - .asSubclass(MetricsListener.class).newInstance(); - metricsListener.initialise(testProperties); - LOGGER.info("Initialised MetricsListener of {}", metricsListener); - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new IllegalArgumentException("MetricsListener could not be created: " - + testProperties.getMetricsListenerClass(), e); - } - } - } - - /** - * Runs a test of querying for the seeds in batches. - * - * @return The rate at which seeds were queried for (number of seeds per second). - */ - public double run() { - final long numSeeds = testProperties.getNumSeeds(); - final long batchSize = testProperties.getBatchSize(); - final Supplier elementIdSupplier = new ElementIdSupplierFactory(testProperties).get(); - long totalQueried = 0L; - long batchNumber = 0L; - final long startTime = System.currentTimeMillis(); - while (totalQueried < numSeeds) { - batchNumber++; - queryBatch(elementIdSupplier, batchSize, batchNumber); - totalQueried += batchSize; - } - final long endTime = System.currentTimeMillis(); - final double durationInSeconds = (endTime - startTime) / 1000.0; - final double rate = (double) totalQueried / durationInSeconds; - LOGGER.info("Test result: " + totalQueried + " ids queried for in " + durationInSeconds + " seconds (rate was " - + rate + " per second)"); - if (null != metricsListener) { - metricsListener.close(); - } - return rate; - } - - private void queryBatch(final Supplier elementSeedSupplier, final long batchSize, - final long batchNumber) { - // Create an in-memory list of seeds, so that expense of creating random seeds is not included in the test results - final List seeds = new ArrayList<>(); - for (int i = 0; i < batchSize; i++) { - seeds.add(elementSeedSupplier.get()); - } - final GetElements getElements = new GetElements.Builder() - .input(seeds) - .build(); - final long startTime = System.currentTimeMillis(); - final long numResults; - try { - final Iterable results = graph.execute(getElements, new User()); - numResults = StreamSupport.stream(results.spliterator(), false).count(); - } catch (final OperationException e) { - LOGGER.error("OperationException thrown after " + (System.currentTimeMillis() - startTime) / 1000.0 - + " seconds"); - throw new RuntimeException("Exception thrown getting elements", e); - } - final long endTime = System.currentTimeMillis(); - final double durationInSeconds = (endTime - startTime) / 1000.0; - final double seedRate = batchSize / durationInSeconds; - final double resultsRate = numResults / durationInSeconds; - LOGGER.info("Batch number = " + batchNumber + ": " + batchSize + " ids queried for in " + durationInSeconds - + " seconds (rate was " + seedRate + " per second), " + numResults + " results were returned " - + "(rate was " + resultsRate + " per second)"); - log(seedRate, resultsRate); - } - - private void log(final double seedsPerSecond, final double resultsPerSecond) { - if (null != metricsListener) { - final QueryMetrics metrics = new QueryMetrics(seedsPerSecond, resultsPerSecond); - metricsListener.update(metrics); - } - } - - public static class ElementIdSupplierFactory { - private final QueryTestProperties testProperties; - - public ElementIdSupplierFactory(final QueryTestProperties testProperties) { - this.testProperties = testProperties; - } - - public Supplier get() { - final String elementIdSupplierClass = testProperties.getElementIdSupplierClass(); - if (elementIdSupplierClass.equals(EntitySeedSupplier.class.getName())) { - final long maxNodeId = testProperties.getRmatMaxNodeId(); - return new EntitySeedSupplier(maxNodeId); - } else if (elementIdSupplierClass.equals(EdgeSeedSupplier.class.getName())) { - final long maxNodeId = testProperties.getRmatMaxNodeId(); - return new EdgeSeedSupplier(maxNodeId); - } else { - throw new RuntimeException("Unknown ElementIdSupplier class of " + elementIdSupplierClass); - } - } - } - - public static void main(final String[] args) { - if (args.length != 3) { - throw new RuntimeException("Usage: "); - } - final Schema schema = Schema.fromJson(new File(args[0]).toPath()); - final StoreProperties storeProperties = StoreProperties.loadStoreProperties(args[1]); - final QueryTestProperties testProperties = new QueryTestProperties(); - testProperties.loadTestProperties(args[2]); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder() - .graphId(testProperties.getGraphId()) - .build()) - .storeProperties(storeProperties) - .addSchema(schema) - .build(); - final QueryTest test = new QueryTest(graph, testProperties); - final double result = test.run(); - LOGGER.info("Test result: seeds were queried for at a rate of " + result + " per second"); - } -} diff --git a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTestProperties.java b/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTestProperties.java deleted file mode 100644 index 70953183..00000000 --- a/performance-testing/performance-testing-core/src/main/java/uk/gov/gchq/gaffer/performancetesting/query/QueryTestProperties.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2017-2023 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.performancetesting.query; - -import uk.gov.gchq.gaffer.performancetesting.TestProperties; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.EntitySeedSupplier; - -/** - * These properties are used to specify a {@link uk.gov.gchq.gaffer.performancetesting.query.QueryTest}. - */ -public class QueryTestProperties extends TestProperties { - private static final long serialVersionUID = 3639506677531571597L; - private static final String ID_SUPPLIER_CLASS = "gaffer.performancetesting.query.idSupplierClass"; - private static final String NUM_SEEDS = "gaffer.performancetesting.query.numSeeds"; - - public QueryTestProperties() { - } - - public String getElementIdSupplierClass() { - return getProperty(ID_SUPPLIER_CLASS, EntitySeedSupplier.class.getName()); - } - - public void setElementIdSupplierClass(final String elementSupplierClass) { - setProperty(ID_SUPPLIER_CLASS, elementSupplierClass); - } - - public long getNumSeeds() { - return Long.parseLong(getProperty(NUM_SEEDS, String.valueOf(1000L))); - } - - public void setNumSeeds(final Long numSeeds) { - setProperty(NUM_SEEDS, numSeeds.toString()); - } -} diff --git a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java deleted file mode 100644 index 1847abed..00000000 --- a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting.ingest; - -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; -import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.StreamUtil; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.performancetesting.FileWriterMetricsListener; -import uk.gov.gchq.gaffer.randomelementgeneration.Constants; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestElementIngestTest { - - @TempDir - public File folder; - - @Test - public void testElementIngestTestRuns() { - // Given - final ElementIngestTestProperties testProperties = new ElementIngestTestProperties(); - testProperties.setNumElements(100L); - testProperties.setBatchSize(10); - testProperties.setElementSupplierClass(RmatElementSupplier.class.getName()); - testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); - testProperties.setRmatMaxNodeId(100L); - final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( - StreamUtil.openStream(Constants.class, "accumuloStore.properties") - ); - storeProperties.setStoreClass(MiniAccumuloStore.class.getName()); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder().graphId("id").build()) - .storeProperties(storeProperties) - .addSchemas(StreamUtil.schemas(Constants.class)) - .build(); - - // When - final ElementIngestTest test = new ElementIngestTest(graph, testProperties); - final double result = test.run(); - - // Then - assertThat(result > 0.0D).isTrue(); - } - - @Test - public void testElementIngestTestOutputsToListener() throws IOException { - // Given - final ElementIngestTestProperties testProperties = new ElementIngestTestProperties(); - testProperties.setNumElements(100L); - testProperties.setBatchSize(10); - testProperties.setElementSupplierClass(RmatElementSupplier.class.getName()); - testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); - testProperties.setRmatMaxNodeId(100L); - testProperties.setMetricsListenerClass(FileWriterMetricsListener.class.getName()); - final File metricsResults = new File(folder, "metricsResults.txt"); - final String metricsResultsFilename = metricsResults.getPath(); - testProperties.setProperty(FileWriterMetricsListener.FILENAME, metricsResultsFilename); - final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( - StreamUtil.openStream(Constants.class, "accumuloStore.properties") - ); - storeProperties.setStoreClass(MiniAccumuloStore.class.getName()); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder().graphId("id").build()) - .storeProperties(storeProperties) - .addSchemas(StreamUtil.schemas(Constants.class)) - .build(); - - // When - final ElementIngestTest test = new ElementIngestTest(graph, testProperties); - test.run(); - final List lines = FileUtils.readLines(new File(metricsResultsFilename)); - - // Then - assertThat(lines.size() > 0).isTrue(); - final int offsetBatch = IngestMetrics.ELEMENTS_PER_SECOND_BATCH.length() + 1; - final int offsetOverall = IngestMetrics.ELEMENTS_PER_SECOND_OVERALL.length() + 1; - for (int i = 0; i < lines.size() - 2; i++) { - final String[] tokens = lines.get(i).split(","); - assertThat(tokens[0].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_BATCH + ":")).isTrue(); - assertThat(nullOrPositive(tokens[0].substring(offsetBatch))).isTrue(); - assertThat(tokens[1].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_OVERALL + ":")).isTrue(); - assertThat(nullOrPositive(tokens[1].substring(offsetOverall))).isTrue(); - } - } - - private boolean nullOrPositive(final String string) { - if (string.equals(": null")) { - return true; - } - return Double.parseDouble(string) > 0.0D; - } -} diff --git a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java deleted file mode 100644 index 937e927c..00000000 --- a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2017-2019 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.performancetesting.ingest; - -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; -import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.StreamUtil; -import uk.gov.gchq.gaffer.graph.Graph; -import uk.gov.gchq.gaffer.graph.GraphConfig; -import uk.gov.gchq.gaffer.operation.OperationException; -import uk.gov.gchq.gaffer.operation.impl.add.AddElements; -import uk.gov.gchq.gaffer.performancetesting.FileWriterMetricsListener; -import uk.gov.gchq.gaffer.performancetesting.query.QueryMetrics; -import uk.gov.gchq.gaffer.performancetesting.query.QueryTest; -import uk.gov.gchq.gaffer.performancetesting.query.QueryTestProperties; -import uk.gov.gchq.gaffer.randomelementgeneration.Constants; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.ElementsSupplier; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.EntitySeedSupplier; -import uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier; -import uk.gov.gchq.gaffer.user.User; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestQueryTest { - - @TempDir - public File folder; - - @Test - public void testQueryTestRuns() throws OperationException { - // Given - final QueryTestProperties testProperties = new QueryTestProperties(); - testProperties.setNumSeeds(100L); - testProperties.setBatchSize(10); - testProperties.setElementIdSupplierClass(EntitySeedSupplier.class.getName()); - testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); - testProperties.setRmatMaxNodeId(100L); - final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( - StreamUtil.openStream(Constants.class, "accumuloStore.properties") - ); - storeProperties.setStoreClass(MiniAccumuloStore.class.getName()); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder().graphId("id").build()) - .storeProperties(storeProperties) - .addSchemas(StreamUtil.schemas(Constants.class)) - .build(); - graph.execute(new AddElements.Builder() - .input(Stream - .generate(new ElementsSupplier(new RmatElementSupplier(Constants.RMAT_PROBABILITIES, 100L, true))) - .limit(1000L)::iterator) - .build(), new User()); - - // When - final QueryTest test = new QueryTest(graph, testProperties); - final double result = test.run(); - - // Then - assertThat(result > 0.0D).isTrue(); - } - - @Test - public void testQueryTestOutputsToListener() throws IOException, OperationException { - // Given - final QueryTestProperties testProperties = new QueryTestProperties(); - testProperties.setNumSeeds(100L); - testProperties.setBatchSize(10); - testProperties.setElementIdSupplierClass(EntitySeedSupplier.class.getName()); - testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); - testProperties.setRmatMaxNodeId(100L); - testProperties.setMetricsListenerClass(FileWriterMetricsListener.class.getName()); - final File metricsResults = new File(folder, "metricsResults.txt"); - final String metricsResultsFilename = metricsResults.getPath(); - testProperties.setProperty(FileWriterMetricsListener.FILENAME, metricsResultsFilename); - final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( - StreamUtil.openStream(Constants.class, "accumuloStore.properties") - ); - storeProperties.setStoreClass(MiniAccumuloStore.class.getName()); - final Graph graph = new Graph.Builder() - .config(new GraphConfig.Builder().graphId("id").build()) - .storeProperties(storeProperties) - .addSchemas(StreamUtil.schemas(Constants.class)) - .build(); - graph.execute(new AddElements.Builder() - .input(Stream - .generate(new ElementsSupplier(new RmatElementSupplier(Constants.RMAT_PROBABILITIES, 100L, true))) - .limit(1000L)::iterator) - .build(), new User()); - - // When - final QueryTest test = new QueryTest(graph, testProperties); - test.run(); - final List lines = FileUtils.readLines(new File(metricsResultsFilename)); - - // Then - assertThat(lines.size() > 0).isTrue(); - lines.forEach(line -> { - final String[] fields = line.split(", "); - assertThat(fields[0].startsWith(QueryMetrics.RESULTS_PER_SECOND)).isTrue(); - assertThat(Double.parseDouble(fields[0].split(":")[1]) > 0.0D).isTrue(); - assertThat(fields[1].startsWith(QueryMetrics.SEEDS_PER_SECOND)).isTrue(); - assertThat(Double.parseDouble(fields[1].split(":")[1]) > 0.0D).isTrue(); - }); - } -} diff --git a/performance-testing/performance-testing-core/src/test/resources/log4j.xml b/performance-testing/performance-testing-core/src/test/resources/log4j.xml deleted file mode 100644 index 2bcf2626..00000000 --- a/performance-testing/performance-testing-core/src/test/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/performance-testing/pom.xml b/performance-testing/pom.xml deleted file mode 100644 index 51457b1b..00000000 --- a/performance-testing/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - uk.gov.gchq.gaffer - gaffer-tools - 2.0.0 - - 4.0.0 - - performance-testing - pom - - - performance-testing-core - performance-testing-accumulo-store - performance-testing-aws - - - diff --git a/pom.xml b/pom.xml deleted file mode 100755 index a53c4436..00000000 --- a/pom.xml +++ /dev/null @@ -1,241 +0,0 @@ - - - - - 4.0.0 - - - uk.gov.gchq.gaffer - gaffer2 - 2.0.0 - - - gaffer-tools - 2.0.0 - pom - - - - - 2.0.0 - - https://github.com/gchq/gaffer-tools - - - scm:git:https://github.com/gchq/gaffer-tools.git - - - scm:git:https://github.com/gchq/gaffer-tools.git - - - - - - GafferDevelopers - GCHQ - https://github.com/gchq - - - - - ${scm.url} - ${scm.connection} - ${scm.developer.connection} - HEAD - - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - code-style/checkstyle.xml - - code-style/checkstyle-suppressions.xml - - checkstyle.suppressions.file - - UTF-8 - true - true - **/generated/**/* - - ${project.build.sourceDirectory} - - ${project.build.testSourceDirectory} - - - - - - validate - test - - code-style/checkstyle.xml - - UTF-8 - true - true - - - check - - - - - - - - - - sign - - - - org.apache.maven.plugins - maven-gpg-plugin - ${gpg.plugin.version} - - - sign-artifacts - verify - - sign - - - - - - - - - - - - default - - true - - - - mini-accumulo-cluster - performance-testing - random-element-generation - - - - road-traffic-demo - - - true - true - true - true - rest - 8080 - - - - uk.gov.gchq.gaffer - road-traffic-rest - ${gaffer.version} - war - test - - - - - - org.codehaus.cargo - cargo-maven3-plugin - ${cargo.plugin.version} - - - - uk.gov.gchq.gaffer - road-traffic-rest - war - - /${standalone-rest-path} - - - - - tomcat9x - - - uk.gov.gchq.gaffer - road-traffic-rest - war - - - - - Road Traffic Example - - - ${standalone-rest-path} - - - ${project.basedir}/cd/road-traffic-example/graphConfig.json - - - ${project.basedir}/cd/road-traffic-example/schema - - - ${project.basedir}/cd/road-traffic-example/store.properties - - - ${project.basedir}/cd/road-traffic-example/roadTrafficSampleData.csv - - - ${project.basedir}/cd/road-traffic-example/addOperationsToChain.json - - - false - - - - - - ${standalone-port} - - - - - - deploy - integration-test - - run - - - - - - - - - diff --git a/python-shell/LICENSE b/python-shell/LICENSE deleted file mode 100755 index d6456956..00000000 --- a/python-shell/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/python-shell/README.md b/python-shell/README.md deleted file mode 100644 index fb1c596d..00000000 --- a/python-shell/README.md +++ /dev/null @@ -1,98 +0,0 @@ - - -# Gaffer Python Client - -![ci](https://github.com/gchq/gaffer-tools/actions/workflows/continuous-integration.yaml/badge.svg) -[](https://gchq.github.io/gaffer-doc/latest/) - -## Features - -- Persistently connect to a Gaffer rest api to run operations -- Connect using PKI certificates and SSL -- Generate Python client code for custom Operations, Predicates, Binary Operators and Functions -- Turn existing json queries into Python objects - -## Installation - -Gafferpy requires Python 3.6+. We don't currently release gafferpy on pypi, but you can install it over ssh with: - -```bash -pip install git+https://github.com/gchq/gaffer-tools.git#subdirectory=python-shell -``` - -Or if you have the source code locally and want any changes you make reflected in your installation, you can go to the python-shell directory and run: - -```bash -pip install -e . -``` - -## Quick Start - -The python shell connects to a running Gaffer REST API. You can start the Gaffer road-traffic-demo rest server using the command: - -```bash -mvn verify -Proad-traffic-demo -``` - -```python -# Import the client library and connector -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - -# Instantiate a connector -gc = gaffer_connector.GafferConnector("http://localhost:8080/rest/latest") - -# You can use the connector to perform get requests -schema = gc.execute_get(g.GetSchema()) - -# And also run operations -elements = gc.execute_operation( - operation=g.GetAllElements() -) - -# Multiple operations -elements = gc.execute_operations( - operations=[ - g.GetAllElements(), - g.Limit(result_limit=3) - ] -) - -# And operation chains -elements = gc.execute_operation_chain( - operation_chain=g.OperationChain( - operations=[ - g.GetAllElements(), - g.Limit( - truncate=True, - result_limit=3 - ) - ] - ) -) -``` - -See [operation examples](https://gchq.github.io/gaffer-doc/v1docs/getting-started/operations/contents) for more examples of operations in python. - -## Coding Style -Please ensure that your coding style is consistent with the rest of the Gaffer project. Guides on the coding style for Gaffer can be found [here](https://gchq.github.io/gaffer-doc/latest/ways-of-working/#coding-style) - -## Testing - -```bash -# To run all of the tests, first deploy the road traffic example -mvn verify -Proad-traffic-demo - -# Then from within the python-shell folder run -python -m unittest discover -``` - -## License - -Copyright 2016-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](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. diff --git a/python-shell/src/test/__init__.py b/python-shell/src/test/__init__.py deleted file mode 100644 index 1091487b..00000000 --- a/python-shell/src/test/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -__version__ = "2.0.0-alpha-0.6" - -__title__ = "gafferpy" -__description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" -__doc__ = __description__ + " <" + __uri__ + ">" - -__author__ = "GCHQ" - -__license__ = "Apache 2.0" -__copyright__ = "Crown Copyright (c) 2016-2022" diff --git a/random-element-generation/README.md b/random-element-generation/README.md deleted file mode 100644 index b760a48d..00000000 --- a/random-element-generation/README.md +++ /dev/null @@ -1,22 +0,0 @@ - - -Random element generation -========================= - -This module allows the creation of randomly generated large-scale graphs. It is extensible in that new random element generation techniques can be used. Currently it provides an implementation of the [RMAT](http://www.cs.cmu.edu/~christos/PUBLICATIONS/siam04.pdf) graph generation technique. The user specifies the number of elements the graph should have. The nodes are longs between 0 and the number of nodes specified. Edges are generated at random between nodes. The RMAT technique ensures that the degree distribution is roughly power-law. The Edges have a simple count. The Entities also have a count and a HyperLogLogPlusPlus sketch which gives an approximation of the degree. - -The class `RandomElementGenerator` can be used to produce an `Iterable` of random elements. diff --git a/random-element-generation/pom.xml b/random-element-generation/pom.xml deleted file mode 100644 index 0bf24421..00000000 --- a/random-element-generation/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - uk.gov.gchq.gaffer - gaffer-tools - 2.0.0 - - 4.0.0 - - random-element-generation - - - - uk.gov.gchq.gaffer - data - ${gaffer.version} - - - uk.gov.gchq.gaffer - graph - ${gaffer.version} - - - uk.gov.gchq.gaffer - accumulo-store - ${gaffer.version} - - - - - - - maven-shade-plugin - ${shade.plugin.version} - - - full - package - - shade - - - true - - full - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/Constants.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/Constants.java deleted file mode 100644 index d071adb6..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/Constants.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * - */ -public final class Constants { - - /** - * These values are taken from @see - * the Graph500 specifications. - */ - @SuppressFBWarnings("MS_MUTABLE_ARRAY") - public static final double[] RMAT_PROBABILITIES = {0.57, 0.19, 0.19, 1.0 - 0.57 - 0.19 - 0.19}; - - private Constants() { - - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/Cache.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/Cache.java deleted file mode 100644 index 2eb0874b..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/Cache.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.cache; - -public interface Cache { - - void add(T t); - - T get(); -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/PreferentialAttachmentCache.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/PreferentialAttachmentCache.java deleted file mode 100644 index 97b92b0e..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/PreferentialAttachmentCache.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.cache; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.TreeMap; - -/** - * A {@link Cache} that has a maximum size. Each item is associated with a count. As an item is added that count is - * incremented. If more than the maximum number of items are added then the one with the smallest count is removed. - * When the get() method is called, one of the items is returned at random. The probability of each item - * being returned is proportional to its count - items with large counts are more likely to be returned. When the - * get() method is called the count of that item is incremented. The result is that the rich grow richer - * --- items that are returned become more likely to be returned, and over time some items in the cache will be - * returned much more often than others. - * - *

This can be used to generate graphs which are power-law in the number of times elements are added, i.e. by - * adding elements to both a graph and this cache, and repeatedly also adding the result of calling get() - * on this cache, then some elements will be added many more times that others. This can be used to test the performance - * when the same element is added multiple times causing many aggregations. - */ -public class PreferentialAttachmentCache implements Cache { - private static final Logger LOGGER = LoggerFactory.getLogger(PreferentialAttachmentCache.class); - - private final Random random = new Random(); - private final TreeMap> mapFreqToItems; - private final TreeMap itemsToFreq; - private final int maxSize; - - public PreferentialAttachmentCache(final int maxSize) { - this.mapFreqToItems = new TreeMap<>(Collections.reverseOrder()); - this.itemsToFreq = new TreeMap<>(); - this.maxSize = maxSize; - } - - @Override - public void add(final T t) { - if (!itemsToFreq.containsKey(t)) { - itemsToFreq.put(t, 1L); - if (mapFreqToItems.containsKey(1L)) { - mapFreqToItems.get(1L).add(t); - } else { - mapFreqToItems.put(1L, new HashSet<>(Arrays.asList(t))); - } - if (itemsToFreq.keySet().size() > maxSize) { - final Set items = mapFreqToItems.get(mapFreqToItems.lastKey()); // Last key as stored in reverse order - final int itemToRemove = random.nextInt(items.size()); - int count = 0; - final Iterator it = items.iterator(); - while (it.hasNext()) { - T x = it.next(); - if (count == itemToRemove) { - items.remove(x); - itemsToFreq.remove(x); - } - count++; - if (count > itemToRemove) { - break; - } - } - } - } else { - incrementFrequency(t); - } - } - - private void incrementFrequency(final T t) { - long currentFreq = itemsToFreq.get(t); - long newFreq = currentFreq + 1L; - itemsToFreq.put(t, newFreq); - mapFreqToItems.get(currentFreq).remove(t); - if (mapFreqToItems.get(currentFreq).size() == 0) { - mapFreqToItems.remove(currentFreq); - } - if (!mapFreqToItems.containsKey(newFreq)) { - mapFreqToItems.put(newFreq, new HashSet<>()); - } - mapFreqToItems.get(newFreq).add(t); - } - - /** - * Returns a random element in proportion to the frequencies. The frequency of the returned item is increased by 1. - * - * @return A random element from the cache with probability proportional to the frequency with which it has been returned. - */ - @Override - public T get() { - final long totalCount = getNumberOfElements(); - if (totalCount == 0) { - LOGGER.warn("get() called on empty cache"); - return null; - } - final ProbabilityGenerator generator = new ProbabilityGenerator<>(itemsToFreq); - final T sample = generator.sample(); - // Increment current count for the sample - itemsToFreq.put(sample, itemsToFreq.get(sample) + 1L); - return sample; - } - - public long getNumberOfElements() { - return itemsToFreq.values().stream().mapToLong(Long::longValue).sum(); - } - - public Map getItemsAndFrequencies() { - return Collections.unmodifiableMap(itemsToFreq); - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/ProbabilityGenerator.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/ProbabilityGenerator.java deleted file mode 100644 index 94339cae..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/ProbabilityGenerator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.cache; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.SortedMap; - -public class ProbabilityGenerator { - private final Random random = new Random(); - private final T[] items; - private final long totalCount; - private final List probabilities; - private final List cumulativeProbabilities; - - public ProbabilityGenerator(final SortedMap itemsToFrequency) { - this.items = (T[]) new Object[itemsToFrequency.size()]; - int i = 0; - for (final T item : itemsToFrequency.keySet()) { - items[i++] = item; - } - this.totalCount = itemsToFrequency.values().stream().mapToLong(Long::longValue).sum(); - // Probability of choosing an item x is itemsToFrequency(x) / totalCount - this.probabilities = new ArrayList<>(itemsToFrequency.size()); - itemsToFrequency.entrySet() - .forEach(entry -> { - probabilities.add(((double) entry.getValue()) / totalCount); - }); - // Create cumulative probability distribution - this.cumulativeProbabilities = new ArrayList<>(itemsToFrequency.size()); - double cumulative = 0.0D; - for (final double p : probabilities) { - cumulative += p; - cumulativeProbabilities.add(cumulative); - } - } - - public T sample() { - // Generate a random number between 0 and 1 - final double sample = random.nextDouble(); - // Iterate through the cumulative probabilities until find the first value greater than the sample - int i = 0; - for (final double p : cumulativeProbabilities) { - if (sample < p) { - return items[i]; - } - i++; - } - return items[items.length - 1]; - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/generator/ElementGeneratorFromSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/generator/ElementGeneratorFromSupplier.java deleted file mode 100644 index f2fc2a51..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/generator/ElementGeneratorFromSupplier.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.generator; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.data.generator.OneToManyElementGenerator; - -import java.util.function.Supplier; -import java.util.stream.Stream; - -/** - * Given a {@link Supplier} of {@link Element}s, this class generates an {@link Iterable} of {@link Element}s, limited - * in size to the specified maximum number. - */ -public class ElementGeneratorFromSupplier implements OneToManyElementGenerator { - protected long maximumNumberOfElements; - protected Supplier elementSupplier; - - public ElementGeneratorFromSupplier(final long maximumNumberOfElements, - final Supplier elementSupplier) { - this.maximumNumberOfElements = maximumNumberOfElements; - this.elementSupplier = elementSupplier; - } - - @Override - public Iterable _apply(final String domainObject) { - return Stream.generate(elementSupplier) - .limit(maximumNumberOfElements) - ::iterator; - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EdgeSeedSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EdgeSeedSupplier.java deleted file mode 100644 index 3770d3f8..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EdgeSeedSupplier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.supplier; - -import uk.gov.gchq.gaffer.data.element.id.DirectedType; -import uk.gov.gchq.gaffer.operation.data.EdgeSeed; - -import java.util.Random; - -public class EdgeSeedSupplier implements ElementSeedSupplier { - protected final Random random = new Random(); - private final EntitySeedSupplier entitySeedSupplier; - - public EdgeSeedSupplier(final long maxNodeId) { - this.entitySeedSupplier = new EntitySeedSupplier(maxNodeId); - } - - @Override - public EdgeSeed get() { - return new EdgeSeed(entitySeedSupplier.get(), entitySeedSupplier.get(), DirectedType.EITHER); - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementSeedSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementSeedSupplier.java deleted file mode 100644 index f3deaadc..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementSeedSupplier.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.supplier; - -import uk.gov.gchq.gaffer.operation.data.ElementSeed; - -import java.util.function.Supplier; - -public interface ElementSeedSupplier extends Supplier { - -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplier.java deleted file mode 100644 index 19dacb98..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplier.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.supplier; - -import uk.gov.gchq.gaffer.data.element.Element; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.function.Supplier; - -/** - * This class is a {@link Supplier} of {@link Element}s. It is formed from a {@link Supplier} of {@link Set}s of - * {@link Element}s by repeatedly calling that {@link Supplier}'s get() method. - */ -public class ElementsSupplier implements Supplier { - private final Iterator elementIterator; - - public ElementsSupplier(final Supplier> elementSupplier) { - this.elementIterator = new ElementIterator(elementSupplier); - } - - @Override - public Element get() { - if (elementIterator.hasNext()) { - return elementIterator.next(); - } - return null; - } - - protected static class ElementIterator implements Iterator { - private final Supplier> elementSupplier; - private final List cache; - - ElementIterator(final Supplier> elementSupplier) { - this.elementSupplier = elementSupplier; - this.cache = new ArrayList<>(); - } - - @Override - public boolean hasNext() { - if (cache.isEmpty()) { - final Set fromSupplier = elementSupplier.get(); - if (null == fromSupplier || 0 == fromSupplier.size()) { - return false; - } - cache.addAll(fromSupplier); - } - return true; - } - - @Override - public Element next() { - if (!hasNext()) { - throw new NoSuchElementException("Supplier is exhausted"); - } - final Element elementToReturn = cache.get(0); - cache.remove(0); - return elementToReturn; - } - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplierWithRepeats.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplierWithRepeats.java deleted file mode 100644 index 3575e7b4..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/ElementsSupplierWithRepeats.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.supplier; - -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.randomelementgeneration.cache.Cache; - -import java.util.Iterator; -import java.util.Random; -import java.util.Set; -import java.util.function.Supplier; - -/** - * This class extends {@link ElementsSupplier} by maintaining a cache of some of the {@link Element}s - * that have previously been output, and with a certain probability, reoutputting an {@link Element} that has - * previously been output. - */ -public class ElementsSupplierWithRepeats extends ElementsSupplier { - private final Iterator elementIterator; - - public ElementsSupplierWithRepeats(final Supplier> elementSupplier, - final double repeatProb, - final Cache cache) { - super(elementSupplier); - this.elementIterator = new ElementIteratorWithRepeats(new ElementIterator(elementSupplier), repeatProb, cache); - } - - @Override - public Element get() { - if (elementIterator.hasNext()) { - return elementIterator.next(); - } - return null; - } - - protected static class ElementIteratorWithRepeats implements Iterator { - private final Random random = new Random(); - private final Iterator elementIterator; - private final double repeatProb; - private final Cache cache; - - ElementIteratorWithRepeats(final Iterator elementIterator, - final double repeatProb, - final Cache cache) { - this.elementIterator = elementIterator; - this.repeatProb = repeatProb; - this.cache = cache; - } - - @Override - public boolean hasNext() { - return elementIterator.hasNext(); - } - - @Override - public Element next() { - final double prob = random.nextDouble(); - if (prob < repeatProb) { - final Element element = cache.get(); - return element == null ? elementIterator.next() : element; - } - final Element element = elementIterator.next(); - final Element clonedElement = element.emptyClone(); - clonedElement.copyProperties(element.getProperties()); - cache.add(clonedElement); - return element; - } - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EntitySeedSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EntitySeedSupplier.java deleted file mode 100644 index 929ac407..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/EntitySeedSupplier.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.supplier; - -import uk.gov.gchq.gaffer.operation.data.EntitySeed; - -import java.util.Random; - -public class EntitySeedSupplier implements ElementSeedSupplier { - protected final Random random = new Random(); - private final int numBits; - - public EntitySeedSupplier(final long maxNodeId) { - this.numBits = (int) (Math.log(maxNodeId) / Math.log(2)); - } - - @Override - public EntitySeed get() { - // Random number in range 0 to 1 << (numBits - 1) - long id = 0L; - for (int i = 0; i < numBits; i++) { - if (random.nextDouble() < 0.5D) { - id = id ^ (1 << i); - } - } - return new EntitySeed(id); - } -} diff --git a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/RmatElementSupplier.java b/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/RmatElementSupplier.java deleted file mode 100644 index 4b85689b..00000000 --- a/random-element-generation/src/main/java/uk/gov/gchq/gaffer/randomelementgeneration/supplier/RmatElementSupplier.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2017-2023 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.randomelementgeneration.supplier; - -import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; - -import uk.gov.gchq.gaffer.data.element.Edge; -import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.data.element.Entity; -import uk.gov.gchq.gaffer.randomelementgeneration.Constants; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; -import java.util.function.Supplier; - -/** - * This class uses the RMAT random graph generation method (http://www.cs.cmu.edu/~christos/PUBLICATIONS/siam04.pdf) - * to generate random {@link Element}s. The vertices are {@link java.lang.Long}s in the range 0 to a user defined - * maximum value. - * - *

Each call to get() returns a {@link Set} of {@link Element}s. If the includeEntities - * option is true, then the set will contain a single {@link Edge} and an {@link Entity} for each vertex in the - * {@link Edge}. If the includeEntities option is false, then the set will contain a single {@link Edge}. - * - *

By default, the probabilities used for the generation of the edges are the same as those specified in the - * Graph500 challenge, but other probabilities can be specified if desired. - */ -public class RmatElementSupplier implements Supplier> { - protected final Random random = new Random(); - private double[] cumulativeProbs; - private final int numBits; - private final boolean includeEntities; - - public RmatElementSupplier(final double[] probabilities, final long maxNodeId, final boolean includeEntities) { - validateProbabilities(probabilities); - setCumulativeProbs(probabilities); - this.numBits = (int) (Math.log(maxNodeId) / Math.log(2)); - this.includeEntities = includeEntities; - } - - public RmatElementSupplier(final long maxNodeId, final boolean includeEntities) { - this(Constants.RMAT_PROBABILITIES, maxNodeId, includeEntities); - } - - /** - * destination - * +---+---+ - * | 0 | 1 | - * source +---+---+ - * | 2 | 3 | - * +---+---+ - */ - @Override - public Set get() { - // Generate random source and destination nodes - long source = 0L; - long destination = 0L; - for (int i = 0; i < numBits; i++) { - final int quadrant = generateRandomQuadrant(); - // Do nothing if quadrant == 0 - if (quadrant == 1) { - destination = destination ^ (1 << i); - } else if (quadrant == 2) { - source = source ^ (1 << i); - } else { - source = source ^ (1 << i); - destination = destination ^ (1 << i); - } - } - final Set results = new HashSet<>(); - // Create edge, and source and destination entities - final Edge edge = new Edge("edgeGroup", source, destination, true); - edge.putProperty("count", 1L); - results.add(edge); - if (includeEntities) { - final Entity sourceEntity = new Entity("entityGroup", source); - sourceEntity.putProperty("count", 1L); - final HyperLogLogPlus sourceHLLPP = new HyperLogLogPlus(5, 5); - sourceHLLPP.offer(destination); - sourceEntity.putProperty("approxDegree", sourceHLLPP); - results.add(sourceEntity); - final Entity destinationEntity = new Entity("entityGroup", destination); - destinationEntity.putProperty("count", 1L); - final HyperLogLogPlus destinationHLLPP = new HyperLogLogPlus(5, 5); - destinationHLLPP.offer(destination); - destinationEntity.putProperty("approxDegree", destinationHLLPP); - results.add(destinationEntity); - } - return results; - } - - private int generateRandomQuadrant() { - final double d = random.nextDouble(); - if (d < cumulativeProbs[0]) { - return 0; - } - if (d < cumulativeProbs[1]) { - return 1; - } - if (d < cumulativeProbs[2]) { - return 2; - } - return 3; - } - - private void validateProbabilities(final double... probabilities) { - // There should be 4 probabilities, they should all be greater than 0 and they should sum to 1. - if (probabilities == null || probabilities.length != 4) { - throw new IllegalArgumentException("Probabilities should be non-null and of length 4."); - } - final double min = Arrays.stream(probabilities).min().getAsDouble(); - if (min <= 0.0) { - throw new IllegalArgumentException("Every entry in probabilities must be strictly positive."); - } - final double sum = Arrays.stream(probabilities).sum(); - if (sum < 0.999999999 || sum > 1.00000001) { - throw new IllegalArgumentException("The entries in probabilities must sum to 1."); - } - } - - private void setCumulativeProbs(final double... probabilities) { - // Should probably check the array has length 4? - this.cumulativeProbs = new double[4]; - this.cumulativeProbs[0] = probabilities[0]; - this.cumulativeProbs[1] = probabilities[1] + this.cumulativeProbs[0]; - this.cumulativeProbs[2] = probabilities[2] + this.cumulativeProbs[1]; - this.cumulativeProbs[3] = probabilities[3] + this.cumulativeProbs[2]; - } -} diff --git a/random-element-generation/src/main/resources/accumuloStore.properties b/random-element-generation/src/main/resources/accumuloStore.properties deleted file mode 100644 index ed9e01c9..00000000 --- a/random-element-generation/src/main/resources/accumuloStore.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright 2020 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. -# -gaffer.store.class=uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore -gaffer.store.properties.class=uk.gov.gchq.gaffer.accumulostore.AccumuloProperties -accumulo.instance=someInstanceName -accumulo.zookeepers=localhost -accumulo.user=user01 -accumulo.password=password diff --git a/random-element-generation/src/main/resources/log4j.xml b/random-element-generation/src/main/resources/log4j.xml deleted file mode 100755 index 3e702d7b..00000000 --- a/random-element-generation/src/main/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/random-element-generation/src/main/resources/randomIngestTest.properties b/random-element-generation/src/main/resources/randomIngestTest.properties deleted file mode 100644 index 39977974..00000000 --- a/random-element-generation/src/main/resources/randomIngestTest.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright 2017 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. -# - -gaffer.performancetesting.ingest.elementSupplierClass=uk.gov.gchq.gaffer.randomelementgeneration.supplier.RmatElementSupplier -gaffer.performancetesting.ingest.numberOfElements=1000 -gaffer.performancetesting.rmat.includeEntities=true -gaffer.performancetesting.rmat.maxNodeId=10000 -gaffer.accumulostore.performancetesting.ingest.tempDirectory=/tmp/performancetesting -gaffer.accumulostore.performancetesting.ingest.numElementsForSplitEstimation=1000000 -gaffer.accumulostore.performancetesting.ingest.numTabletServers=5 diff --git a/random-element-generation/src/main/resources/schema/elements.json b/random-element-generation/src/main/resources/schema/elements.json deleted file mode 100644 index cf3f7c86..00000000 --- a/random-element-generation/src/main/resources/schema/elements.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "entities": { - "entityGroup": { - "vertex": "long", - "properties": { - "count": "count.long", - "approxDegree": "hllp" - } - } - }, - "edges": { - "edgeGroup": { - "source": "long", - "destination": "long", - "directed": "true", - "properties": { - "count": "count.long" - } - } - } -} \ No newline at end of file diff --git a/random-element-generation/src/main/resources/schema/types.json b/random-element-generation/src/main/resources/schema/types.json deleted file mode 100644 index a0d9e374..00000000 --- a/random-element-generation/src/main/resources/schema/types.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "types": { - "long": { - "class": "java.lang.Long", - "validateFunctions": [ - { - "class": "uk.gov.gchq.koryphe.impl.predicate.Exists" - } - ] - }, - "count.long": { - "class": "java.lang.Long", - "aggregateFunction": { - "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" - } - }, - "hllp": { - "class": "com.clearspring.analytics.stream.cardinality.HyperLogLogPlus", - "validateFunctions": [ - { - "class": "uk.gov.gchq.koryphe.impl.predicate.Exists" - } - ], - "aggregateFunction": { - "class": "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.binaryoperator.HyperLogLogPlusAggregator" - }, - "serialiserClass": "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.serialisation.HyperLogLogPlusSerialiser" - }, - "true": { - "class": "java.lang.Boolean", - "validateFunctions": [ - { - "class": "uk.gov.gchq.koryphe.impl.predicate.Exists" - } - ] - } - }, - "vertexSerialiserClass": "uk.gov.gchq.gaffer.serialisation.implementation.raw.CompactRawLongSerialiser" -} \ No newline at end of file diff --git a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java deleted file mode 100644 index 10fd0dce..00000000 --- a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.cache; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.IntStream; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestPreferentialAttachmentCache { - - @Test - public void testGetReturnsOneOfTheElementsAdded() { - // Given - final PreferentialAttachmentCache cache = new PreferentialAttachmentCache<>(10); - final Set data = new HashSet<>(); - IntStream.range(0, 5).forEach(i -> data.add("" + i)); - data.forEach(cache::add); - - // When - final List results = new ArrayList<>(); - IntStream.range(0, 100).forEach(i -> results.add(cache.get())); - - // Then - results.forEach(i -> assertThat(data.contains(i)).isTrue()); - } - - @Test - public void testMaxSizeIsRespected() { - // Given - final PreferentialAttachmentCache cache = new PreferentialAttachmentCache<>(10); - IntStream.range(0, 20).forEach(i -> cache.add("A" + i)); - - // When - final long numberOfElements = cache.getNumberOfElements(); - - // Then - assertThat(numberOfElements).isEqualTo(10); - } - - /** - * This test could be made sophisticated, e.g. checking that the exponent of the power-law lies within a certain - * range. Currently, this test simply checks that the frequency of the most popular item is several orders of - * magnitude greater than the least frequent item. - */ - @Test - public void testPowerLaw() { - // Given - final PreferentialAttachmentCache cache = new PreferentialAttachmentCache<>(10); - IntStream.range(0, 10).forEach(i -> cache.add("A" + i)); - final Map itemToCount = new HashMap<>(); - - // When - IntStream.range(0, 1000000).forEach(i -> { - final String item = cache.get(); - if (!itemToCount.containsKey(item)) { - itemToCount.put(item, 0L); - } - itemToCount.put(item, itemToCount.get(item) + 1L); - }); - final long maxFrequency = itemToCount.values().stream().mapToLong(Long::longValue).max().getAsLong(); - final long minFrequency = itemToCount.values().stream().mapToLong(Long::longValue).min().getAsLong(); - - // Then - assertThat(maxFrequency / minFrequency > 5).isTrue(); - } -} diff --git a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java deleted file mode 100644 index 3777da4a..00000000 --- a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2017-2019 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.randomelementgeneration.cache; - -import org.junit.jupiter.api.Test; - -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.IntStream; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestProbabilityGenerator { - - @Test - public void testWhenUniform() { - // Given - final SortedMap itemsToFrequency = new TreeMap<>(); - itemsToFrequency.put("A", 100L); - itemsToFrequency.put("B", 100L); - final ProbabilityGenerator generator = new ProbabilityGenerator<>(itemsToFrequency); - - // When - final Map counts = new ConcurrentHashMap<>(); - counts.put("A", 0L); - counts.put("B", 0L); - IntStream.range(0, 1000000).asDoubleStream().forEach(i -> { - final String sample = generator.sample(); - counts.put(sample, counts.get(sample) + 1L); - }); - - // Then - final double ratio = ((double) counts.get("A")) / counts.get("B"); - assertThat(0.99D < ratio && ratio < 1.01D).isTrue(); - } - - @Test - public void testWhenUnbalanced() { - // Given - final SortedMap itemsToFrequency = new TreeMap<>(); - itemsToFrequency.put("A", 10000L); - itemsToFrequency.put("B", 10L); - final ProbabilityGenerator generator = new ProbabilityGenerator<>(itemsToFrequency); - - // When - final Map counts = new ConcurrentHashMap<>(); - counts.put("A", 0L); - counts.put("B", 0L); - IntStream.range(0, 10000000).forEach(i -> { - final String sample = generator.sample(); - counts.put(sample, counts.get(sample) + 1L); - }); - - // Then - final double ratio = ((double) counts.get("A")) / counts.get("B"); - assertThat(ratio > 100.0D).isTrue(); - } -} diff --git a/random-element-generation/src/test/resources/log4j.xml b/random-element-generation/src/test/resources/log4j.xml deleted file mode 100644 index 2bcf2626..00000000 --- a/random-element-generation/src/test/resources/log4j.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/python-shell/requirements.txt b/requirements.txt similarity index 100% rename from python-shell/requirements.txt rename to requirements.txt diff --git a/python-shell/setup.cfg b/setup.cfg similarity index 100% rename from python-shell/setup.cfg rename to setup.cfg diff --git a/python-shell/setup.py b/setup.py similarity index 100% rename from python-shell/setup.py rename to setup.py diff --git a/python-shell/src/__init__.py b/src/__init__.py similarity index 82% rename from python-shell/src/__init__.py rename to src/__init__.py index 8ca7547d..d04722b9 100644 --- a/python-shell/src/__init__.py +++ b/src/__init__.py @@ -2,7 +2,7 @@ __title__ = "gafferpy" __description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" +__uri__ = "https://github.com/gchq/gafferpy" __doc__ = __description__ + " <" + __uri__ + ">" __author__ = "GCHQ" diff --git a/python-shell/src/fishbowl/README.md b/src/fishbowl/README.md similarity index 100% rename from python-shell/src/fishbowl/README.md rename to src/fishbowl/README.md diff --git a/python-shell/src/fishbowl/__init__.py b/src/fishbowl/__init__.py similarity index 72% rename from python-shell/src/fishbowl/__init__.py rename to src/fishbowl/__init__.py index 9f302242..4757cd70 100644 --- a/python-shell/src/fishbowl/__init__.py +++ b/src/fishbowl/__init__.py @@ -1,8 +1,8 @@ -__version__ = "2.0.0-alpha-0.6" +__version__ = "2.0.0" __title__ = "fishbowl" __description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" +__uri__ = "https://github.com/gchq/gafferpy" __doc__ = __description__ + " <" + __uri__ + ">" __author__ = "GCHQ" diff --git a/python-shell/src/fishbowl/fishbowl.py b/src/fishbowl/fishbowl.py similarity index 100% rename from python-shell/src/fishbowl/fishbowl.py rename to src/fishbowl/fishbowl.py diff --git a/python-shell/src/fishbowl/templates/base.py.j2 b/src/fishbowl/templates/base.py.j2 similarity index 100% rename from python-shell/src/fishbowl/templates/base.py.j2 rename to src/fishbowl/templates/base.py.j2 diff --git a/python-shell/src/fishbowl/templates/config.py.j2 b/src/fishbowl/templates/config.py.j2 similarity index 100% rename from python-shell/src/fishbowl/templates/config.py.j2 rename to src/fishbowl/templates/config.py.j2 diff --git a/python-shell/src/fishbowl/templates/functions.py.j2 b/src/fishbowl/templates/functions.py.j2 similarity index 100% rename from python-shell/src/fishbowl/templates/functions.py.j2 rename to src/fishbowl/templates/functions.py.j2 diff --git a/python-shell/src/fishbowl/templates/operations.py.j2 b/src/fishbowl/templates/operations.py.j2 similarity index 100% rename from python-shell/src/fishbowl/templates/operations.py.j2 rename to src/fishbowl/templates/operations.py.j2 diff --git a/python-shell/src/gafferpy/__init__.py b/src/gafferpy/__init__.py similarity index 82% rename from python-shell/src/gafferpy/__init__.py rename to src/gafferpy/__init__.py index 8ca7547d..d04722b9 100644 --- a/python-shell/src/gafferpy/__init__.py +++ b/src/gafferpy/__init__.py @@ -2,7 +2,7 @@ __title__ = "gafferpy" __description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" +__uri__ = "https://github.com/gchq/gafferpy" __doc__ = __description__ + " <" + __uri__ + ">" __author__ = "GCHQ" diff --git a/python-shell/src/gafferpy/client/__init__.py b/src/gafferpy/client/__init__.py similarity index 100% rename from python-shell/src/gafferpy/client/__init__.py rename to src/gafferpy/client/__init__.py diff --git a/python-shell/src/gafferpy/client/base_client.py b/src/gafferpy/client/base_client.py similarity index 100% rename from python-shell/src/gafferpy/client/base_client.py rename to src/gafferpy/client/base_client.py diff --git a/python-shell/src/gafferpy/client/pki_client.py b/src/gafferpy/client/pki_client.py similarity index 100% rename from python-shell/src/gafferpy/client/pki_client.py rename to src/gafferpy/client/pki_client.py diff --git a/python-shell/src/gafferpy/client/requests_client.py b/src/gafferpy/client/requests_client.py similarity index 100% rename from python-shell/src/gafferpy/client/requests_client.py rename to src/gafferpy/client/requests_client.py diff --git a/python-shell/src/gafferpy/client/urllib_client.py b/src/gafferpy/client/urllib_client.py similarity index 100% rename from python-shell/src/gafferpy/client/urllib_client.py rename to src/gafferpy/client/urllib_client.py diff --git a/python-shell/src/gafferpy/fromJson.py b/src/gafferpy/fromJson.py similarity index 100% rename from python-shell/src/gafferpy/fromJson.py rename to src/gafferpy/fromJson.py diff --git a/python-shell/src/gafferpy/gaffer.py b/src/gafferpy/gaffer.py similarity index 100% rename from python-shell/src/gafferpy/gaffer.py rename to src/gafferpy/gaffer.py diff --git a/python-shell/src/gafferpy/gaffer_binaryoperators.py b/src/gafferpy/gaffer_binaryoperators.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_binaryoperators.py rename to src/gafferpy/gaffer_binaryoperators.py diff --git a/python-shell/src/gafferpy/gaffer_config.py b/src/gafferpy/gaffer_config.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_config.py rename to src/gafferpy/gaffer_config.py diff --git a/python-shell/src/gafferpy/gaffer_connector.py b/src/gafferpy/gaffer_connector.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_connector.py rename to src/gafferpy/gaffer_connector.py diff --git a/python-shell/src/gafferpy/gaffer_connector_pki.py b/src/gafferpy/gaffer_connector_pki.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_connector_pki.py rename to src/gafferpy/gaffer_connector_pki.py diff --git a/python-shell/src/gafferpy/gaffer_core.py b/src/gafferpy/gaffer_core.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_core.py rename to src/gafferpy/gaffer_core.py diff --git a/python-shell/src/gafferpy/gaffer_functions.py b/src/gafferpy/gaffer_functions.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_functions.py rename to src/gafferpy/gaffer_functions.py diff --git a/python-shell/src/gafferpy/gaffer_operations.py b/src/gafferpy/gaffer_operations.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_operations.py rename to src/gafferpy/gaffer_operations.py diff --git a/python-shell/src/gafferpy/gaffer_predicates.py b/src/gafferpy/gaffer_predicates.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_predicates.py rename to src/gafferpy/gaffer_predicates.py diff --git a/python-shell/src/gafferpy/gaffer_types.py b/src/gafferpy/gaffer_types.py similarity index 100% rename from python-shell/src/gafferpy/gaffer_types.py rename to src/gafferpy/gaffer_types.py diff --git a/python-shell/src/gafferpy/generated_api/__init__.py b/src/gafferpy/generated_api/__init__.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/__init__.py rename to src/gafferpy/generated_api/__init__.py diff --git a/python-shell/src/gafferpy/generated_api/binary_operators.py b/src/gafferpy/generated_api/binary_operators.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/binary_operators.py rename to src/gafferpy/generated_api/binary_operators.py diff --git a/python-shell/src/gafferpy/generated_api/config.py b/src/gafferpy/generated_api/config.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/config.py rename to src/gafferpy/generated_api/config.py diff --git a/python-shell/src/gafferpy/generated_api/functions.py b/src/gafferpy/generated_api/functions.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/functions.py rename to src/gafferpy/generated_api/functions.py diff --git a/python-shell/src/gafferpy/generated_api/operations.py b/src/gafferpy/generated_api/operations.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/operations.py rename to src/gafferpy/generated_api/operations.py diff --git a/python-shell/src/gafferpy/generated_api/predicates.py b/src/gafferpy/generated_api/predicates.py similarity index 100% rename from python-shell/src/gafferpy/generated_api/predicates.py rename to src/gafferpy/generated_api/predicates.py diff --git a/python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb b/src/gafferpy_examples/Gaffer-Python-Demo.ipynb similarity index 100% rename from python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb rename to src/gafferpy_examples/Gaffer-Python-Demo.ipynb diff --git a/python-shell/src/gafferpy_examples/__init__.py b/src/gafferpy_examples/__init__.py similarity index 73% rename from python-shell/src/gafferpy_examples/__init__.py rename to src/gafferpy_examples/__init__.py index 8f798dee..4e1dab15 100644 --- a/python-shell/src/gafferpy_examples/__init__.py +++ b/src/gafferpy_examples/__init__.py @@ -1,8 +1,8 @@ -__version__ = "2.0.0-alpha-0.6" +__version__ = "2.0.0" __title__ = "gafferpy_examples" __description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" +__uri__ = "https://github.com/gchq/gafferpy" __doc__ = __description__ + " <" + __uri__ + ">" __author__ = "GCHQ" diff --git a/python-shell/src/gafferpy_examples/example.py b/src/gafferpy_examples/example.py similarity index 100% rename from python-shell/src/gafferpy_examples/example.py rename to src/gafferpy_examples/example.py diff --git a/python-shell/src/gafferpy_examples/example_map.py b/src/gafferpy_examples/example_map.py similarity index 100% rename from python-shell/src/gafferpy_examples/example_map.py rename to src/gafferpy_examples/example_map.py diff --git a/python-shell/src/gafferpy_examples/example_map_pki.py b/src/gafferpy_examples/example_map_pki.py similarity index 100% rename from python-shell/src/gafferpy_examples/example_map_pki.py rename to src/gafferpy_examples/example_map_pki.py diff --git a/python-shell/src/gafferpy_examples/example_pki.py b/src/gafferpy_examples/example_pki.py similarity index 100% rename from python-shell/src/gafferpy_examples/example_pki.py rename to src/gafferpy_examples/example_pki.py diff --git a/python-shell/src/generate.py b/src/generate.py similarity index 100% rename from python-shell/src/generate.py rename to src/generate.py diff --git a/python-shell/__init__.py b/src/test/__init__.py similarity index 72% rename from python-shell/__init__.py rename to src/test/__init__.py index 1091487b..d04722b9 100644 --- a/python-shell/__init__.py +++ b/src/test/__init__.py @@ -1,8 +1,8 @@ -__version__ = "2.0.0-alpha-0.6" +__version__ = "2.0.0" __title__ = "gafferpy" __description__ = "Gaffer Python Shell" -__uri__ = "https://github.com/gchq/gaffer-tools" +__uri__ = "https://github.com/gchq/gafferpy" __doc__ = __description__ + " <" + __uri__ + ">" __author__ = "GCHQ" diff --git a/cd/road-traffic-example/addOperationsToChain.json b/src/test/road-traffic-example/addOperationsToChain.json similarity index 100% rename from cd/road-traffic-example/addOperationsToChain.json rename to src/test/road-traffic-example/addOperationsToChain.json diff --git a/cd/road-traffic-example/federatedGraphConfig.json b/src/test/road-traffic-example/federatedGraphConfig.json similarity index 100% rename from cd/road-traffic-example/federatedGraphConfig.json rename to src/test/road-traffic-example/federatedGraphConfig.json diff --git a/cd/road-traffic-example/federatedStore.properties b/src/test/road-traffic-example/federatedStore.properties similarity index 100% rename from cd/road-traffic-example/federatedStore.properties rename to src/test/road-traffic-example/federatedStore.properties diff --git a/cd/road-traffic-example/graphConfig.json b/src/test/road-traffic-example/graphConfig.json similarity index 100% rename from cd/road-traffic-example/graphConfig.json rename to src/test/road-traffic-example/graphConfig.json diff --git a/cd/road-traffic-example/roadTrafficSampleData.csv b/src/test/road-traffic-example/roadTrafficSampleData.csv similarity index 100% rename from cd/road-traffic-example/roadTrafficSampleData.csv rename to src/test/road-traffic-example/roadTrafficSampleData.csv diff --git a/cd/road-traffic-example/schema/elements.json b/src/test/road-traffic-example/schema/elements.json similarity index 100% rename from cd/road-traffic-example/schema/elements.json rename to src/test/road-traffic-example/schema/elements.json diff --git a/cd/road-traffic-example/schema/types.json b/src/test/road-traffic-example/schema/types.json similarity index 100% rename from cd/road-traffic-example/schema/types.json rename to src/test/road-traffic-example/schema/types.json diff --git a/cd/road-traffic-example/store.properties b/src/test/road-traffic-example/store.properties similarity index 100% rename from cd/road-traffic-example/store.properties rename to src/test/road-traffic-example/store.properties diff --git a/python-shell/src/test/test_connector.py b/src/test/test_connector.py similarity index 100% rename from python-shell/src/test/test_connector.py rename to src/test/test_connector.py diff --git a/python-shell/src/test/test_example.py b/src/test/test_example.py similarity index 100% rename from python-shell/src/test/test_example.py rename to src/test/test_example.py diff --git a/python-shell/src/test/test_example_map.py b/src/test/test_example_map.py similarity index 100% rename from python-shell/src/test/test_example_map.py rename to src/test/test_example_map.py diff --git a/python-shell/src/test/test_gaffer_functions.py b/src/test/test_gaffer_functions.py similarity index 100% rename from python-shell/src/test/test_gaffer_functions.py rename to src/test/test_gaffer_functions.py diff --git a/python-shell/src/test/test_gaffer_functions_it.py b/src/test/test_gaffer_functions_it.py similarity index 100% rename from python-shell/src/test/test_gaffer_functions_it.py rename to src/test/test_gaffer_functions_it.py diff --git a/python-shell/src/test/test_gaffer_operations.py b/src/test/test_gaffer_operations.py similarity index 100% rename from python-shell/src/test/test_gaffer_operations.py rename to src/test/test_gaffer_operations.py diff --git a/python-shell/src/test/test_gaffer_operations_it.py b/src/test/test_gaffer_operations_it.py similarity index 100% rename from python-shell/src/test/test_gaffer_operations_it.py rename to src/test/test_gaffer_operations_it.py diff --git a/python-shell/src/test/test_gaffer_predicates.py b/src/test/test_gaffer_predicates.py similarity index 100% rename from python-shell/src/test/test_gaffer_predicates.py rename to src/test/test_gaffer_predicates.py diff --git a/python-shell/src/test/test_gaffer_predicates_it.py b/src/test/test_gaffer_predicates_it.py similarity index 100% rename from python-shell/src/test/test_gaffer_predicates_it.py rename to src/test/test_gaffer_predicates_it.py diff --git a/python-shell/src/test/test_json_converter.py b/src/test/test_json_converter.py similarity index 100% rename from python-shell/src/test/test_json_converter.py rename to src/test/test_json_converter.py