diff --git a/docs/antora.yml b/docs/antora.yml index 886d38c4b..4bf1bd8c4 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,2 +1,2 @@ -name: hazelcast -version: 6.0-snapshot +name: templates +version: ~ diff --git a/docs/modules/ROOT/examples/platform-operator b/docs/modules/ROOT/examples/platform-operator new file mode 120000 index 000000000..8e46ffe1c --- /dev/null +++ b/docs/modules/ROOT/examples/platform-operator @@ -0,0 +1 @@ +../../../../platform-operator \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/build-site.yml new file mode 100644 index 000000000..3f54aab6b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [main] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/integrational-tests.yml b/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/integrational-tests.yml new file mode 100644 index 000000000..ea734d6ad --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/.github/workflows/integrational-tests.yml @@ -0,0 +1,250 @@ +name: Test on GKE +on: + push: + paths-ignore: + - "docs/**" + +env: + GCP_PROJECT_ID: ${{ secrets.GKE_PROJECT }} + GKE_ZONE: europe-west1-b + GCP_NETWORK: tutorial-test-network + EXAMPLES_DIR: docs/modules/ROOT/examples/operator-expose-externally + +jobs: + create-gke-cluster: + name: Create GKE cluster + runs-on: ubuntu-latest + outputs: + CLUSTER_NAME: ${{ steps.cluster.outputs.CLUSTER_NAME }} + + steps: + - name: Authenticate to GCP + uses: "google-github-actions/auth@v0.7.0" + with: + credentials_json: ${{ secrets.GKE_SA_KEY }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0.6.0 + with: + project_id: ${{ env.GCP_PROJECT_ID }} + + - name: Create GKE cluster + id: cluster + run: |- + CLUSTER_NAME="hpo-ex-ex-$GITHUB_RUN_NUMBER" + echo "CLUSTER_NAME=$CLUSTER_NAME" >> $GITHUB_ENV + echo "::set-output name=CLUSTER_NAME::${CLUSTER_NAME}" + + gcloud container clusters create $CLUSTER_NAME \ + --zone=${{ env.GKE_ZONE }} \ + --project=${{ env.GCP_PROJECT_ID }} \ + --network=${{ env.GCP_NETWORK }} \ + --machine-type=n1-standard-2 \ + --num-nodes=2 + sleep 30 + + - name: Connect to the GKE cluster + run: | + gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \ + --zone ${{ env.GKE_ZONE }} \ + --project ${{ env.GCP_PROJECT_ID }} + + - name: Install Kubectl + run: |- + gcloud components install kubectl + + - name: Deploy operator + run: |- + helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/ + helm repo update + helm install operator hazelcast/hazelcast-platform-operator --set installCRDs=true,phoneHomeEnabled=false + + run-tests: + name: Run Integration tests on GKE + runs-on: ubuntu-latest + needs: create-gke-cluster + env: + CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }} + + strategy: + max-parallel: 1 + fail-fast: false + matrix: + include: + - type: smart + suffix: "" + - type: unisocket + suffix: "-unisocket" + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: "adopt" + cache: "maven" + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "14" + cache: "npm" + cache-dependency-path: "**/package-lock.json" + + - name: Set up Golang + uses: actions/setup-go@v2 + with: + go-version: "^1.17.2" + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + cache: "pip" + + - name: Authenticate to GCP + uses: "google-github-actions/auth@v0.7.0" + with: + credentials_json: ${{ secrets.GKE_SA_KEY }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0.6.0 + with: + project_id: ${{ env.GCP_PROJECT_ID }} + + - name: Install Kubectl + run: |- + gcloud components install kubectl + + - name: Connect to the GKE cluster + run: | + gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \ + --zone ${{ env.GKE_ZONE }} \ + --project ${{ env.GCP_PROJECT_ID }} + + - name: Deploy Hazelcast cluster + run: |- + kubectl apply -f $EXAMPLES_DIR/hazelcast${{matrix.suffix}}.yaml + + - name: Waith for Hazelcast cluster to be ready + run: |- + kubectl wait --for='jsonpath={.status.phase}=Running' hazelcast/my-hazelcast${{matrix.suffix}} --timeout 300s + + - name: Wait for external IP to get assigned + timeout-minutes: 5 + run: |- + serviceType=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.spec.type}") + if [ "$serviceType" != "LoadBalancer" ]; then + exit 1 + fi + EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}") + while [ "$EXTERNAL_IP" == "" ]; do + sleep 10 + EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}") + done + + echo "EXTERNAL_IP=${EXTERNAL_IP}" >> $GITHUB_ENV + + - name: Wait for Smart type member IPs to get assigned + if: matrix.type == 'smart' + timeout-minutes: 5 + run: |- + for i in {0..2}; do + SVC_NAME="my-hazelcast${{matrix.suffix}}-${i}" + SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}") + while [ "$SVC_EXTERNAL_IP" == "" ]; do + sleep 10 + SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}") + done + done + + - name: Test Java Client + run: |- + EXTERNAL_IP="${{ env.EXTERNAL_IP }}" + cd $EXAMPLES_DIR/java${{matrix.suffix}} + sed -i "s//$EXTERNAL_IP/g" src/main/java/com/hazelcast/Main.java + mvn package + java -jar target/*jar-with-dependencies*.jar >> output-java.txt & + PID=$! + sleep 30 + kill $PID + + cat output-java.txt | grep 'Successful connection!' -q + + - name: Test Node.js Client + run: |- + EXTERNAL_IP="${{ env.EXTERNAL_IP }}" + cd $EXAMPLES_DIR/nodejs${{matrix.suffix}} + sed -i "s//$EXTERNAL_IP/g" client.js + npm install + npm start >> output-nodejs.txt & + PID=$! + sleep 30 + kill $PID + + cat output-nodejs.txt | grep 'Successful connection!' -q + + - name: Test Go Client + run: |- + EXTERNAL_IP="${{ env.EXTERNAL_IP }}" + cd $EXAMPLES_DIR/go${{matrix.suffix}} + sed -i "s//$EXTERNAL_IP/g" main.go + go run main.go >> output-go.txt & + PID=$! + sleep 30 + kill $PID + + cat output-go.txt | grep 'Successful connection!' -q + + - name: Test Python Client + run: |- + EXTERNAL_IP="${{ env.EXTERNAL_IP }}" + cd $EXAMPLES_DIR/python${{matrix.suffix}} + sed -i "s//$EXTERNAL_IP/g" main.py + pip install -r requirements.txt + python main.py >> output-python.txt & + PID=$! + sleep 30 + kill $PID + + cat output-python.txt | grep 'Successful connection!' -q + + - name: Clean up + if: ${{ always() }} + run: |- + kubectl delete hazelcast my-hazelcast${{matrix.suffix}} + kubectl wait --for=delete pod/my-hazelcast${{matrix.suffix}}-0 --timeout=2m + kubectl get svc my-hazelcast${{matrix.suffix}} || exit 0 + kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}} --timeout=5m + + - name: Clean up Smart services + if: ${{ always() && matrix.type == 'smart' }} + run: |- + kubectl get svc my-hazelcast${{matrix.suffix}}-0 || exit 0 + kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}}-0 --timeout=5m + + clean-up: + name: Clean up GKE cluster + runs-on: ubuntu-latest + needs: [run-tests, create-gke-cluster] + if: ${{ always() }} + env: + CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }} + steps: + - name: Authenticate to GCP + uses: "google-github-actions/auth@v0.7.0" + with: + credentials_json: ${{ secrets.GKE_SA_KEY }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0.6.0 + with: + project_id: ${{ env.GCP_PROJECT_ID }} + + # Clean up + - name: Delete cluster + run: |- + gcloud container clusters delete "$CLUSTER_NAME" --zone="$GKE_ZONE" --quiet diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/.gitignore b/platform-operator/hazelcast-platform-operator-expose-externally/.gitignore new file mode 100644 index 000000000..880fdc9bf --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/.gitignore @@ -0,0 +1,13 @@ +target/ +.idea/ +.vscode/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*node_modules/ diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/README.adoc b/platform-operator/hazelcast-platform-operator-expose-externally/README.adoc new file mode 100644 index 000000000..9ae737076 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/README.adoc @@ -0,0 +1 @@ +See the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-expose-externally[tutorial]. \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/create.sh b/platform-operator/hazelcast-platform-operator-expose-externally/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/csharp_example.cs b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/csharp_example.cs new file mode 100644 index 000000000..d9dac0e36 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/csharp_example.cs @@ -0,0 +1,34 @@ +using Hazelcast; +using Microsoft.Extensions.Logging; + + +class CsharpExample +{ + static async Task Main(string[] args) + { + + var options = new HazelcastOptionsBuilder() + .With(args) + .With((configuration, options) => + { + options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole()); + options.Networking.Addresses.Add(""); + options.Networking.SmartRouting = false; + }) + .Build(); + var client = await HazelcastClientFactory.StartNewClientAsync(options); + + + Console.WriteLine("Successful connection!"); + Console.WriteLine("Starting to fill the map with random entries."); + + var map = await client.GetMapAsync("map"); + var random = new Random(); + while (true) + { + var randomKey = random.Next(100_000); + await map.PutAsync("key-" + randomKey, "value-" + randomKey); + Console.WriteLine("Current map size: " + await map.GetSizeAsync()); + } + } +} \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/dotnet-unisocket.csproj b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/dotnet-unisocket.csproj new file mode 100644 index 000000000..0b2806c1a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet-unisocket/dotnet-unisocket.csproj @@ -0,0 +1,17 @@ + + + + Exe + net8.0 + enable + enable + kuberentesOut + + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/Program.cs b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/Program.cs new file mode 100644 index 000000000..0e8455470 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/Program.cs @@ -0,0 +1,32 @@ +using Hazelcast; +using Microsoft.Extensions.Logging; + +class csharp_example +{ + static async Task Main(string[] args) + { + var options = new HazelcastOptionsBuilder() + .With(args) + .With((configuration, options) => + { + options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole()); + options.Networking.Addresses.Add(""); + options.Networking.UsePublicAddresses = true; + }) + .Build(); + var client = await HazelcastClientFactory.StartNewClientAsync(options); + + + Console.WriteLine("Successful connection!"); + Console.WriteLine("Starting to fill the map with random entries."); + + var map = await client.GetMapAsync("map"); + var random = new Random(); + while (true) + { + var randomKey = random.Next(100_000); + await map.PutAsync("key-" + randomKey, "value-" + randomKey); + Console.WriteLine("Current map size: " + await map.GetSizeAsync()); + } + } +} \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/dotnet.csproj b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/dotnet.csproj new file mode 100644 index 000000000..fde95d038 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/dotnet/dotnet.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.mod b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.mod new file mode 100644 index 000000000..a43e247ea --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.mod @@ -0,0 +1,15 @@ +module github.com/hazelcast-guides/kubernetes/go + +go 1.23 + +require github.com/hazelcast/hazelcast-go-client v1.4.2 + +require ( + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/shirou/gopsutil/v3 v3.21.10 // indirect + github.com/tklauser/go-sysconf v0.3.9 // indirect + github.com/tklauser/numcpus v0.3.0 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.sum b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.sum new file mode 100644 index 000000000..46aae612c --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/go.sum @@ -0,0 +1,42 @@ +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hazelcast/hazelcast-go-client v1.4.2 h1:5WFTm40Sor7Ku0fbhzlCqAq7UXP3sD8WoG7iln3aCTk= +github.com/hazelcast/hazelcast-go-client v1.4.2/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil/v3 v3.21.10 h1:flTg1DrnV/UVrBqjLgVgDJzx6lf+91rC64/dBHmO2IA= +github.com/shirou/gopsutil/v3 v3.21.10/go.mod h1:t75NhzCZ/dYyPQjyQmrAYP6c8+LCdFANeBMdLPCNnew= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/main.go b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/main.go new file mode 100644 index 000000000..5337abb2f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go-unisocket/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "context" + "fmt" + "math/rand" + + "github.com/hazelcast/hazelcast-go-client" +) + +func main() { + config := hazelcast.Config{} + cc := &config.Cluster + cc.Network.SetAddresses("") + cc.Unisocket = true + ctx := context.TODO() + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!") + fmt.Println("Starting to fill the map with random entries.") + m, err := client.GetMap(ctx, "map") + if err != nil { + panic(err) + } + for { + num := rand.Intn(100_000) + key := fmt.Sprintf("key-%d", num) + value := fmt.Sprintf("value-%d", num) + if _, err = m.Put(ctx, key, value); err != nil { + fmt.Println("ERR:", err.Error()) + } else { + if mapSize, err := m.Size(ctx); err != nil { + fmt.Println("ERR:", err.Error()) + } else { + fmt.Println("Current map size:", mapSize) + } + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.mod b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.mod new file mode 100644 index 000000000..a43e247ea --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.mod @@ -0,0 +1,15 @@ +module github.com/hazelcast-guides/kubernetes/go + +go 1.23 + +require github.com/hazelcast/hazelcast-go-client v1.4.2 + +require ( + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/shirou/gopsutil/v3 v3.21.10 // indirect + github.com/tklauser/go-sysconf v0.3.9 // indirect + github.com/tklauser/numcpus v0.3.0 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.sum b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.sum new file mode 100644 index 000000000..46aae612c --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/go.sum @@ -0,0 +1,42 @@ +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hazelcast/hazelcast-go-client v1.4.2 h1:5WFTm40Sor7Ku0fbhzlCqAq7UXP3sD8WoG7iln3aCTk= +github.com/hazelcast/hazelcast-go-client v1.4.2/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil/v3 v3.21.10 h1:flTg1DrnV/UVrBqjLgVgDJzx6lf+91rC64/dBHmO2IA= +github.com/shirou/gopsutil/v3 v3.21.10/go.mod h1:t75NhzCZ/dYyPQjyQmrAYP6c8+LCdFANeBMdLPCNnew= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/main.go b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/main.go new file mode 100644 index 000000000..3465a407a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/go/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "context" + "fmt" + "math/rand" + + "github.com/hazelcast/hazelcast-go-client" +) + +func main() { + config := hazelcast.Config{} + cc := &config.Cluster + cc.Network.SetAddresses("") + cc.Discovery.UsePublicIP = true + ctx := context.TODO() + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!") + fmt.Println("Starting to fill the map with random entries.") + m, err := client.GetMap(ctx, "map") + if err != nil { + panic(err) + } + for { + num := rand.Intn(100_000) + key := fmt.Sprintf("key-%d", num) + value := fmt.Sprintf("value-%d", num) + if _, err = m.Put(ctx, key, value); err != nil { + fmt.Println("ERR:", err.Error()) + } else { + if mapSize, err := m.Size(ctx); err != nil { + fmt.Println("ERR:", err.Error()) + } else { + fmt.Println("Current map size:", mapSize) + } + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-smart.yaml b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-smart.yaml new file mode 100644 index 000000000..08917f67d --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-smart.yaml @@ -0,0 +1,10 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: my-hazelcast-smart +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Smart + discoveryServiceType: LoadBalancer + memberAccess: LoadBalancer \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-unisocket.yaml b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-unisocket.yaml new file mode 100644 index 000000000..e065f06af --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/hazelcast-unisocket.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: my-hazelcast-unisocket +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/pom.xml b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/pom.xml new file mode 100755 index 000000000..0055634ba --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast + 5.5.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.Main + + + + + + assemble-all + package + + single + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/src/main/java/com/hazelcast/Main.java b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/src/main/java/com/hazelcast/Main.java new file mode 100644 index 000000000..672a8f854 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java-unisocket/src/main/java/com/hazelcast/Main.java @@ -0,0 +1,31 @@ +package com.hazelcast; + +import java.util.Random; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.client.config.ClientNetworkConfig; +import com.hazelcast.client.impl.connection.tcp.RoutingMode; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; + +public class Main { + public static void main(String[] args) throws Exception { + ClientConfig clientConfig = new ClientConfig(); + ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig(); + networkConfig.addAddress(""); + networkConfig.getClusterRoutingConfig().setRoutingMode(RoutingMode.SINGLE_MEMBER); + HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); + + System.out.println("Successful connection!"); + System.out.println("Starting to fill the map with random entries."); + + IMap map = client.getMap("map"); + Random random = new Random(); + while (true) { + int randomKey = random.nextInt(100_000); + map.put("key-" + randomKey, "value-" + randomKey); + System.out.println("Current map size: " + map.size()); + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/pom.xml b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/pom.xml new file mode 100755 index 000000000..0055634ba --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast + 5.5.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.Main + + + + + + assemble-all + package + + single + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/src/main/java/com/hazelcast/Main.java b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/src/main/java/com/hazelcast/Main.java new file mode 100644 index 000000000..1614049fe --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/java/src/main/java/com/hazelcast/Main.java @@ -0,0 +1,29 @@ +package com.hazelcast; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.client.properties.ClientProperty; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; + +import java.util.Random; + +public class Main { + public static void main(String[] args) throws Exception { + ClientConfig config = new ClientConfig(); + config.getNetworkConfig().addAddress(""); + config.getProperties().setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.toString(), "true"); + HazelcastInstance client = HazelcastClient.newHazelcastClient(config); + + System.out.println("Successful connection!"); + System.out.println("Starting to fill the map with random entries."); + + IMap map = client.getMap("map"); + Random random = new Random(); + while (true) { + int randomKey = random.nextInt(100_000); + map.put("key-" + randomKey, "value-" + randomKey); + System.out.println("Current map size: " + map.size()); + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/client.js b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/client.js new file mode 100755 index 000000000..1891edc58 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/client.js @@ -0,0 +1,34 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ], + smartRouting: false + } +}; + +(async () => { + try { + const client = await Client.newHazelcastClient(clientConfig); + const map = await client.getMap('map'); + await map.put('key', 'value'); + const res = await map.get('key'); + if (res !== 'value') { + throw new Error('Connection failed, check your configuration.'); + } + console.log('Successful connection!'); + console.log('Starting to fill the map with random entries.'); + while (true) { + const randomKey = Math.floor(Math.random() * 100000); + await map.put('key' + randomKey, 'value' + randomKey); + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package-lock.json b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package-lock.json new file mode 100644 index 000000000..aaaa3d349 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package-lock.json @@ -0,0 +1,58 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "hazelcast", + "version": "1.0.0", + "dependencies": { + "hazelcast-client": "^5.0" + } + }, + "node_modules/@types/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", + "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" + }, + "node_modules/hazelcast-client": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/hazelcast-client/-/hazelcast-client-5.3.0.tgz", + "integrity": "sha512-aCcoUjHBIHcgYFqeOLx0rxB3iGDLkwvkz4Aov9r5EVaAzedZURjT2PZkbYgcSjDSXMl5RAvMuy7Mh0owdcMlog==", + "dependencies": { + "@types/long": "4.0.0", + "long": "4.0.0" + }, + "engines": { + "node": ">=10.4.0" + } + }, + "node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + } + }, + "dependencies": { + "@types/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", + "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" + }, + "hazelcast-client": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/hazelcast-client/-/hazelcast-client-5.3.0.tgz", + "integrity": "sha512-aCcoUjHBIHcgYFqeOLx0rxB3iGDLkwvkz4Aov9r5EVaAzedZURjT2PZkbYgcSjDSXMl5RAvMuy7Mh0owdcMlog==", + "requires": { + "@types/long": "4.0.0", + "long": "4.0.0" + } + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package.json b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package.json new file mode 100755 index 000000000..0319dac80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs-unisocket/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "client.js", + "scripts": { + "start": "node client.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/client.js b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/client.js new file mode 100755 index 000000000..41bf55cf7 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/client.js @@ -0,0 +1,36 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ] + }, + properties: { + ['hazelcast.discovery.public.ip.enabled']: true + } +}; + +(async () => { + try { + const client = await Client.newHazelcastClient(clientConfig); + const map = await client.getMap('map'); + await map.put('key', 'value'); + const res = await map.get('key'); + if (res !== 'value') { + throw new Error('Connection failed, check your configuration.'); + } + console.log('Successful connection!'); + console.log('Starting to fill the map with random entries.'); + while (true) { + const randomKey = Math.floor(Math.random() * 100000); + await map.put('key' + randomKey, 'value' + randomKey); + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package-lock.json b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package-lock.json new file mode 100644 index 000000000..aaaa3d349 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package-lock.json @@ -0,0 +1,58 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "hazelcast", + "version": "1.0.0", + "dependencies": { + "hazelcast-client": "^5.0" + } + }, + "node_modules/@types/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", + "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" + }, + "node_modules/hazelcast-client": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/hazelcast-client/-/hazelcast-client-5.3.0.tgz", + "integrity": "sha512-aCcoUjHBIHcgYFqeOLx0rxB3iGDLkwvkz4Aov9r5EVaAzedZURjT2PZkbYgcSjDSXMl5RAvMuy7Mh0owdcMlog==", + "dependencies": { + "@types/long": "4.0.0", + "long": "4.0.0" + }, + "engines": { + "node": ">=10.4.0" + } + }, + "node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + } + }, + "dependencies": { + "@types/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", + "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" + }, + "hazelcast-client": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/hazelcast-client/-/hazelcast-client-5.3.0.tgz", + "integrity": "sha512-aCcoUjHBIHcgYFqeOLx0rxB3iGDLkwvkz4Aov9r5EVaAzedZURjT2PZkbYgcSjDSXMl5RAvMuy7Mh0owdcMlog==", + "requires": { + "@types/long": "4.0.0", + "long": "4.0.0" + } + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package.json b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package.json new file mode 100755 index 000000000..0319dac80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/nodejs/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "client.js", + "scripts": { + "start": "node client.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/main.py b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/main.py new file mode 100644 index 000000000..7ae33ec66 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/main.py @@ -0,0 +1,21 @@ +import logging +import random + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +client = hazelcast.HazelcastClient( + cluster_members=[""], + smart_routing=False, +) + +print("Successful connection!", flush=True) +print("Starting to fill the map with random entries.", flush=True) + +m = client.get_map("map").blocking() + +while True: + random_number = str(random.randrange(0, 100000)) + m.put("key-" + random_number, "value-" + random_number) + print("Current map size:", m.size()) diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/requirements.txt b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/requirements.txt new file mode 100644 index 000000000..b56934661 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python-unisocket/requirements.txt @@ -0,0 +1 @@ +hazelcast-python-client >= 5.0 diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/main.py b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/main.py new file mode 100644 index 000000000..465fc2bff --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/main.py @@ -0,0 +1,21 @@ +import logging +import random + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +client = hazelcast.HazelcastClient( + cluster_members=[""], + use_public_ip=True, +) + +print("Successful connection!", flush=True) +print("Starting to fill the map with random entries.", flush=True) + +m = client.get_map("map").blocking() + +while True: + random_number = str(random.randrange(0, 100000)) + m.put("key-" + random_number, "value-" + random_number) + print("Current map size:", m.size()) diff --git a/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/requirements.txt b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/requirements.txt new file mode 100644 index 000000000..b56934661 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-expose-externally/docs/modules/ROOT/examples/operator-expose-externally/python/requirements.txt @@ -0,0 +1 @@ +hazelcast-python-client >= 5.0 diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..60758281b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/CONTRIBUTING.adoc @@ -0,0 +1,82 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Append your tutorial repository to the `content.sources` field in the `antora-playbook-local.yml` file at the root of this repository. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: + start_path: docs +``` + +. Install the required dependencies by running `npm i` at the root of this repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/workflows/build-site.yml new file mode 100644 index 000000000..3f54aab6b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [main] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/.gitignore b/platform-operator/hazelcast-platform-operator-external-backup-restore/.gitignore new file mode 100644 index 000000000..862663302 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/.gitignore @@ -0,0 +1,15 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/.vscode/settings.json b/platform-operator/hazelcast-platform-operator-external-backup-restore/.vscode/settings.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/README.adoc b/platform-operator/hazelcast-platform-operator-external-backup-restore/README.adoc new file mode 100644 index 000000000..4f045520d --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-external-backup-restore[Restore a Cluster from Cloud Storage with Hazelcast Platform Operator tutorial]. diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-external-backup-restore/antora-playbook-local.yml new file mode 100644 index 000000000..3c5d0bc46 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/antora-playbook-local.yml @@ -0,0 +1,31 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/create.sh b/platform-operator/hazelcast-platform-operator-external-backup-restore/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/Program.cs b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/Program.cs new file mode 100644 index 000000000..c1e7c01c4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/Program.cs @@ -0,0 +1,67 @@ +using System; +using System.Threading.Tasks; +using Hazelcast; +using Microsoft.Extensions.Logging; + +namespace Client +{ + public class Program + { + static async Task Main(string[] args) + { + if (args.Length != 1) + { + Console.WriteLine("You should pass an argument to run: fill or size"); + return; + } + if (!(args[0] == "fill" || args[0] == "size")) + { + Console.WriteLine("Wrong argument, you should pass: fill or size"); + return; + } + var options = new HazelcastOptionsBuilder() + .With(args) + .With((configuration, options) => + { + options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => + loggingBuilder + .AddConfiguration(configuration.GetSection("logging")) + .AddConsole()); + + options.Networking.Addresses.Add(":5701"); + options.Networking.SmartRouting = false; + + }) + .Build(); + + + await using var client = await HazelcastClientFactory.StartNewClientAsync(options); + + Console.WriteLine("Successful connection!"); + Console.WriteLine("Starting to fill the map with random entries."); + + var map = await client.GetMapAsync("persistent-map"); + var random = new Random(); + + if (args[0] == "fill") + { + Console.WriteLine("Starting to fill the map with random entries."); + while (true) + { + var num = random.Next(100_000); + var key = $"key-{num}"; + var value = $"value-{num}"; + await map.PutAsync(key, value); + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + } + } + else + { + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + await client.DisposeAsync(); + } + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/backup-restore.csproj b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/backup-restore.csproj new file mode 100644 index 000000000..0b2806c1a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/dotnet/backup-restore.csproj @@ -0,0 +1,17 @@ + + + + Exe + net8.0 + enable + enable + kuberentesOut + + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.mod b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.mod new file mode 100644 index 000000000..a43e247ea --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.mod @@ -0,0 +1,15 @@ +module github.com/hazelcast-guides/kubernetes/go + +go 1.23 + +require github.com/hazelcast/hazelcast-go-client v1.4.2 + +require ( + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/shirou/gopsutil/v3 v3.21.10 // indirect + github.com/tklauser/go-sysconf v0.3.9 // indirect + github.com/tklauser/numcpus v0.3.0 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.sum b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.sum new file mode 100644 index 000000000..46aae612c --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/go.sum @@ -0,0 +1,42 @@ +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hazelcast/hazelcast-go-client v1.4.2 h1:5WFTm40Sor7Ku0fbhzlCqAq7UXP3sD8WoG7iln3aCTk= +github.com/hazelcast/hazelcast-go-client v1.4.2/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil/v3 v3.21.10 h1:flTg1DrnV/UVrBqjLgVgDJzx6lf+91rC64/dBHmO2IA= +github.com/shirou/gopsutil/v3 v3.21.10/go.mod h1:t75NhzCZ/dYyPQjyQmrAYP6c8+LCdFANeBMdLPCNnew= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/main.go b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/main.go new file mode 100644 index 000000000..68c798811 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/go/main.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "math/rand" + "os" + + "github.com/hazelcast/hazelcast-go-client" +) + +func main() { + if len(os.Args) != 2 { + fmt.Println("You should pass an argument to run: fill or size") + return + } + if !(os.Args[1] == "fill" || os.Args[1] == "size") { + fmt.Println("Wrong argument, you should pass: fill or size") + return + } + + config := hazelcast.Config{} + cc := &config.Cluster + cc.Network.SetAddresses(":5701") + cc.Unisocket = true + ctx := context.TODO() + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!") + m, err := client.GetMap(ctx, "persistent-map") + if err != nil { + panic(err) + } + if os.Args[1] == "fill" { + fmt.Println("Starting to fill the map with random entries.") + for { + num := rand.Intn(100_000) + key := fmt.Sprintf("key-%d", num) + value := fmt.Sprintf("value-%d", num) + if _, err = m.Put(ctx, key, value); err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + fmt.Println("Current map size:", mapSize) + } + return + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + return + } + fmt.Println("Current map size:", mapSize) + +} diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence-restore.yaml b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence-restore.yaml new file mode 100644 index 000000000..1ec171843 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence-restore.yaml @@ -0,0 +1,16 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: my-hazelcast +spec: + clusterSize: 3 + licenseKeySecretName: hazelcast-license-key + persistence: + pvc: + accessModes: ["ReadWriteOnce"] + requestStorage: 8Gi + restore: + hotBackupResourceName: hot-backup + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence.yaml b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence.yaml new file mode 100644 index 000000000..50e400566 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hazelcast-persistence.yaml @@ -0,0 +1,14 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: my-hazelcast +spec: + clusterSize: 3 + licenseKeySecretName: hazelcast-license-key + persistence: + pvc: + accessModes: ["ReadWriteOnce"] + requestStorage: 8Gi + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hot-backup.yaml b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hot-backup.yaml new file mode 100644 index 000000000..72b1a04fd --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/hot-backup.yaml @@ -0,0 +1,8 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: HotBackup +metadata: + name: hot-backup +spec: + hazelcastResourceName: my-hazelcast + bucketURI: "s3://operator-backup" + secret: "br-secret-s3" \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/pom.xml b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/pom.xml new file mode 100755 index 000000000..0055634ba --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast + 5.5.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.Main + + + + + + assemble-all + package + + single + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/src/main/java/com/hazelcast/Main.java b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/src/main/java/com/hazelcast/Main.java new file mode 100644 index 000000000..664642de8 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/java/src/main/java/com/hazelcast/Main.java @@ -0,0 +1,44 @@ +package com.hazelcast; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.client.config.ClientNetworkConfig; +import com.hazelcast.client.impl.connection.tcp.RoutingMode; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; + +import java.util.Random; + +public class Main { + public static void main(String[] args) throws Exception { + if(args.length == 0) { + System.out.println("You should pass an argument to run: fill or size"); + } else if (!((args[0].equals("fill") || args[0].equals("size")))) { + System.out.println("Wrong argument, you should pass: fill or size"); + } else{ + ClientConfig clientConfig = new ClientConfig(); + ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig(); + networkConfig.addAddress(""); + networkConfig.getClusterRoutingConfig().setRoutingMode(RoutingMode.SINGLE_MEMBER); + HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); + System.out.println("Successful connection!"); + + IMap map = client.getMap("persistent-map"); + + if (args[0].equals("fill")) { + System.out.println("Starting to fill the map with random entries."); + + Random random = new Random(); + while (true) { + int randomKey = random.nextInt(100_000); + map.put("key-" + randomKey, "value-" + randomKey); + System.out.println("Current map size: " + map.size()); + } + } else { + System.out.println("Current map size: " + map.size()); + client.shutdown(); + } + } + + } +} diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/map-persistence.yaml b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/map-persistence.yaml new file mode 100644 index 000000000..7a11ef6ca --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/map-persistence.yaml @@ -0,0 +1,7 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: persistent-map +spec: + hazelcastResourceName: my-hazelcast + persistenceEnabled: true diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/client.js b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/client.js new file mode 100755 index 000000000..41946cd6a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/client.js @@ -0,0 +1,45 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ], + smartRouting: false + } +}; + +(async () => { + try { + if (process.argv.length === 2) { + console.error('You should pass an argument to run: fill or size'); + } else if (!(process.argv[2] === 'fill' || process.argv[2] === 'size')) { + console.error('Wrong argument, you should pass: fill or size'); + } else { + const client = await Client.newHazelcastClient(clientConfig); + const map = await client.getMap('persistent-map'); + await map.put('key', 'value'); + const res = await map.get('key'); + if (res !== 'value') { + throw new Error('Connection failed, check your configuration.'); + } + console.log('Successful connection!'); + if (process.argv[2] === 'fill'){ + console.log('Starting to fill the map with random entries.'); + while (true) { + const randomKey = Math.floor(Math.random() * 100000); + await map.put('key' + randomKey, 'value' + randomKey); + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } else { + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/package.json b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/package.json new file mode 100755 index 000000000..0319dac80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/nodejs/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "client.js", + "scripts": { + "start": "node client.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/python/main.py b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/python/main.py new file mode 100644 index 000000000..972f1d964 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/docs/modules/ROOT/examples/operator-external-backup/python/main.py @@ -0,0 +1,28 @@ +import logging +import random +import sys + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +if len(sys.argv) != 2: + print("You should pass an argument to run: fill or size") +elif not (sys.argv[1] == "fill" or sys.argv[1] == "size"): + print("Wrong argument, you should pass: fill or size") +else: + client = hazelcast.HazelcastClient( + cluster_members=[""], + smart_routing=False, + ) + print("Successful connection!", flush=True) + m = client.get_map("persistent-map").blocking() + + if sys.argv[1] == "fill": + print("Starting to fill the map with random entries.", flush=True) + while True: + random_number = str(random.randrange(0, 100000)) + m.put("key-" + random_number, "value-" + random_number) + print("Current map size:", m.size()) + else: + print("Current map size:", m.size()) diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-external-backup-restore/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-external-backup-restore/package.json b/platform-operator/hazelcast-platform-operator-external-backup-restore/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-external-backup-restore/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..5a54c936a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-jet-job-snapshot + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.gitignore b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.gitignore new file mode 100644 index 000000000..6a94623d2 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/.gitignore @@ -0,0 +1,17 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json + +.vscode diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/README.adoc b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/README.adoc new file mode 100644 index 000000000..2b038a496 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-jet-job-snapshot[Saving the State of Jet Job with Hazelcast Platform Operator tutorial]. diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/antora-playbook-local.yml new file mode 100644 index 000000000..85dc25971 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/antora-playbook-local.yml @@ -0,0 +1,34 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: master + start_paths: docs + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/create.sh b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/hz.yaml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/hz.yaml new file mode 100644 index 000000000..a2dc85990 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/hz.yaml @@ -0,0 +1,10 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast +spec: + clusterSize: 3 + licenseKeySecretName: hazelcast-license-key + jet: + enabled: true + resourceUploadEnabled: true diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/pom.xml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/pom.xml new file mode 100644 index 000000000..0043050a8 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + org.examples.jet.snapshot + jet-pipelines + 1.0-SNAPSHOT + + jet-pipelines + + + UTF-8 + 17 + 17 + 5.4.0 + 5.8.2 + 3.0.0-M7 + + + + + com.hazelcast + hazelcast + ${hazelcast-version} + provided + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api-version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin-version} + + + + + diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV1.java b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV1.java new file mode 100644 index 000000000..9c1314f14 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV1.java @@ -0,0 +1,32 @@ +package org.examples.jet.snapshot; + +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.jet.pipeline.JournalInitialPosition; +import com.hazelcast.jet.pipeline.Pipeline; +import com.hazelcast.jet.pipeline.Sinks; +import com.hazelcast.jet.pipeline.Sources; + +public class JobV1 { + + public static void main(String[] args) { + var p = Pipeline.create(); + var transactionSource = Sources.mapJournal("transaction", JournalInitialPosition.START_FROM_OLDEST); + var loggerSink = Sinks.logger(); + p.readFrom(transactionSource) + .withIngestionTimestamps() + .setName("Emit Transactions") + .map(e -> { + System.out.printf("The transaction '%s' is being executed in 'job-v1'\n", e.getKey()); + // execute the transaction + return String.format("[Job V1] transaction:'%s' payload:'%s'", e.getKey(), e.getValue()); + }) + .setName("Apply Transactions") + .writeTo(loggerSink) + .setName("Log Transactions"); + + HazelcastInstance hz = Hazelcast.bootstrappedInstance(); + hz.getJet().newJob(p); + } + +} diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV2.java b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV2.java new file mode 100644 index 000000000..6a4e69231 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/jet-pipelines/src/main/java/org/examples/jet/snapshot/JobV2.java @@ -0,0 +1,32 @@ +package org.examples.jet.snapshot; + +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.jet.pipeline.JournalInitialPosition; +import com.hazelcast.jet.pipeline.Pipeline; +import com.hazelcast.jet.pipeline.Sinks; +import com.hazelcast.jet.pipeline.Sources; + +public class JobV2 { + + public static void main(String[] args) { + var p = Pipeline.create(); + var transactionSource = Sources.mapJournal("transaction", JournalInitialPosition.START_FROM_OLDEST); + var loggerSink = Sinks.logger(); + p.readFrom(transactionSource) + .withIngestionTimestamps() + .setName("Emit Transactions") + .map(e -> { + System.out.printf("The transaction '%s' is being executed in 'job-v2'\n", e.getKey()); + // execute the transaction + return String.format("[Job V2] transaction:'%s' payload:'%s'", e.getKey(), e.getValue()); + }) + .setName("Apply Transactions") + .writeTo(loggerSink) + .setName("Log Transactions"); + + HazelcastInstance hz = Hazelcast.bootstrappedInstance(); + hz.getJet().newJob(p); + } + +} diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v1.yaml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v1.yaml new file mode 100644 index 000000000..d966aac1c --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v1.yaml @@ -0,0 +1,12 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: JetJob +metadata: + name: transaction-v1 +spec: + hazelcastResourceName: hazelcast + state: Running + jarName: jet-pipelines-1.0-SNAPSHOT.jar + mainClass: org.examples.jet.snapshot.JobV1 + bucketConfig: + bucketURI: '' + secretName: '' diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v2.yaml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v2.yaml new file mode 100644 index 000000000..c1b01ee65 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/job-v2.yaml @@ -0,0 +1,13 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: JetJob +metadata: + name: transaction-v2 +spec: + hazelcastResourceName: hazelcast + state: Running + jarName: jet-pipelines-1.0-SNAPSHOT.jar + mainClass: org.examples.jet.snapshot.JobV2 + initialSnapshotResourceName: snapshot-transaction + bucketConfig: + bucketURI: '' + secretName: '' diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/map.yaml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/map.yaml new file mode 100644 index 000000000..5b3474cfd --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/map.yaml @@ -0,0 +1,8 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: transaction +spec: + hazelcastResourceName: hazelcast + eventJournal: + capacity: 9000 diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/snapshot.yaml b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/snapshot.yaml new file mode 100644 index 000000000..666a9e2ad --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/docs/modules/ROOT/examples/operator-jet-job-snapshot/snapshot.yaml @@ -0,0 +1,7 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: JetJobSnapshot +metadata: + name: snapshot-transaction +spec: + jetJobResourceName: transaction-v1 + cancelJob: true diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-jet-job-snapshot/package.json b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet-job-snapshot/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-jet/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-jet/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..97d693eb4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-jet/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-jet/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-jet/.gitignore b/platform-operator/hazelcast-platform-operator-jet/.gitignore new file mode 100644 index 000000000..9fc24999f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/.gitignore @@ -0,0 +1,16 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json +.vscode diff --git a/platform-operator/hazelcast-platform-operator-jet/README.adoc b/platform-operator/hazelcast-platform-operator-jet/README.adoc new file mode 100644 index 000000000..2972505bc --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-jet[Run Data Pipeline using Jet with Hazelcast Platform Operator tutorial]. diff --git a/platform-operator/hazelcast-platform-operator-jet/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-jet/antora-playbook-local.yml new file mode 100644 index 000000000..85dc25971 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/antora-playbook-local.yml @@ -0,0 +1,34 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: master + start_paths: docs + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-jet/create.sh b/platform-operator/hazelcast-platform-operator-jet/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/hazelcast-jet.yaml b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/hazelcast-jet.yaml new file mode 100644 index 000000000..373ba3684 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/hazelcast-jet.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: my-hazelcast +spec: + licenseKeySecretName: hazelcast-license-key + clusterSize: 3 + jet: + resourceUploadEnabled: true diff --git a/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-canceled.yaml b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-canceled.yaml new file mode 100644 index 000000000..0b97e6561 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-canceled.yaml @@ -0,0 +1,11 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: JetJob +metadata: + name: my-jet-job +spec: + hazelcastResourceName: my-hazelcast + state: Canceled + jarName: jet-pipeline-run-1.0.0.jar + bucketConfig: + bucketURI: "" + secretName: diff --git a/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-running.yaml b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-running.yaml new file mode 100644 index 000000000..4d6a82891 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/docs/modules/ROOT/examples/jet-running.yaml @@ -0,0 +1,11 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: JetJob +metadata: + name: my-jet-job +spec: + hazelcastResourceName: my-hazelcast + state: Running + jarName: jet-pipeline-run-1.0.0.jar + bucketConfig: + bucketURI: "" + secretName: diff --git a/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/pom.xml b/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/pom.xml new file mode 100644 index 000000000..3485352f6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + + org.example + jet-pipeline-run + 1.0.0 + jar + + jet-pipeline + http://maven.apache.org + + + UTF-8 + + + + + + com.hazelcast + hazelcast + 5.4.0 + + + + + junit + junit + 3.8.1 + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + + org.example.run.App + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + + + + + diff --git a/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/src/main/java/org/example/run/App.java b/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/src/main/java/org/example/run/App.java new file mode 100644 index 000000000..c69e55f2b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/jet-pipeline/src/main/java/org/example/run/App.java @@ -0,0 +1,19 @@ +package org.example.run; + +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.jet.pipeline.Pipeline; +import com.hazelcast.jet.pipeline.Sinks; +import com.hazelcast.jet.pipeline.test.TestSources; + +public class App { + public static void main(String[] args) { + Pipeline p = Pipeline.create(); + p.readFrom(TestSources.itemStream(1)) + .withoutTimestamps() + .writeTo(Sinks.logger()); + + HazelcastInstance hz = Hazelcast.bootstrappedInstance(); + hz.getJet().newJob(p); + } +} diff --git a/platform-operator/hazelcast-platform-operator-jet/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-jet/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-jet/package.json b/platform-operator/hazelcast-platform-operator-jet/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-jet/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-map-store/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-map-store/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..97d693eb4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-map-store/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-map-store/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-map-store/.gitignore b/platform-operator/hazelcast-platform-operator-map-store/.gitignore new file mode 100644 index 000000000..862663302 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/.gitignore @@ -0,0 +1,15 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-map-store/README.adoc b/platform-operator/hazelcast-platform-operator-map-store/README.adoc new file mode 100644 index 000000000..9dbf7ed7b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-map-store-mongodb-atlas[Configure MongoDb Atlas as an External Data Store for the Cluster with Hazelcast Platform Operator]. diff --git a/platform-operator/hazelcast-platform-operator-map-store/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-map-store/antora-playbook-local.yml new file mode 100644 index 000000000..3c5d0bc46 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/antora-playbook-local.yml @@ -0,0 +1,31 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-map-store/create.sh b/platform-operator/hazelcast-platform-operator-map-store/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-network-access.png b/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-network-access.png new file mode 100644 index 000000000..410a018f2 Binary files /dev/null and b/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-network-access.png differ diff --git a/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-supplements.png b/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-supplements.png new file mode 100644 index 000000000..8e127d440 Binary files /dev/null and b/platform-operator/hazelcast-platform-operator-map-store/docs/modules/ROOT/images/mongo-atlas-supplements.png differ diff --git a/platform-operator/hazelcast-platform-operator-map-store/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-map-store/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-map-store/mapstore/dependency-reduced-pom.xml b/platform-operator/hazelcast-platform-operator-map-store/mapstore/dependency-reduced-pom.xml new file mode 100644 index 000000000..c2fa3ac85 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/mapstore/dependency-reduced-pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + com.hazelcast.operator.mongodb + mapstore-mongodb + 1.0-SNAPSHOT + + + + maven-shade-plugin + 3.3.0 + + + package + + shade + + + + + *:* + + com/hazelcast/** + hazelcast-* + META-INF/maven/com.hazelcast/** + META-INF/services/com.hazelcast* + + + + + + + + + + + + client + + + + maven-shade-plugin + 3.3.0 + + + package + + shade + + + + + *:* + + com/mongodb/** + org/bson/** + + + + + + + + + + + + + 11 + 11 + + diff --git a/platform-operator/hazelcast-platform-operator-map-store/mapstore/pom.xml b/platform-operator/hazelcast-platform-operator-map-store/mapstore/pom.xml new file mode 100644 index 000000000..ee58a42d2 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/mapstore/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.hazelcast.operator.mongodb + mapstore-mongodb + 1.0-SNAPSHOT + jar + + + com.hazelcast.samples + operator-samples + 0.1-SNAPSHOT + ../../pom.xml + + + + + org.mongodb + mongodb-driver-sync + 4.7.1 + + + com.hazelcast + hazelcast + ${hazelcast.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.3.0 + + + package + + shade + + + + + *:* + + com/hazelcast/** + hazelcast-* + META-INF/maven/com.hazelcast/** + META-INF/services/com.hazelcast* + + + + + + + + + + + + + client + + + + org.apache.maven.plugins + maven-shade-plugin + 3.3.0 + + + package + + shade + + + + + *:* + + com/mongodb/** + org/bson/** + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/hazelcast/tutorial/Client.java b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/hazelcast/tutorial/Client.java new file mode 100644 index 000000000..ad4398397 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/hazelcast/tutorial/Client.java @@ -0,0 +1,35 @@ +package com.hazelcast.tutorial; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; +import com.operator.tutorial.mongodb.Supplement; + +public class Client { + public static void main(String[] args) { + ClientConfig config = new ClientConfig(); + config.getNetworkConfig().addAddress("") + .setSmartRouting(false); + + HazelcastInstance client = HazelcastClient.newHazelcastClient(config); + IMap supplements = client.getMap("supplements"); + supplements.set("1", new Supplement("bcaa", 10)); + supplements.set("2", new Supplement("protein", 100)); + supplements.set("3", new Supplement("glucosamine", 200)); + + System.out.println("Initial map size:"); + System.out.println(supplements.size()); + + supplements.evictAll(); + + System.out.println("Map size after eviction:"); + System.out.println(supplements.size()); + + supplements.loadAll(true); + + System.out.println("Loading entries form the Database..."); + System.out.println("Map size:"); + System.out.println(supplements.size()); + } +} diff --git a/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/MongoMapStore.java b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/MongoMapStore.java new file mode 100644 index 000000000..d32131f53 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/MongoMapStore.java @@ -0,0 +1,120 @@ +package com.operator.tutorial.mongodb; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.MapLoaderLifecycleSupport; +import com.hazelcast.map.MapStore; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.ServerApi; +import com.mongodb.ServerApiVersion; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import com.mongodb.client.FindIterable; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.model.BulkWriteOptions; +import com.mongodb.client.model.InsertOneModel; +import com.mongodb.client.model.Projections; +import org.bson.Document; + +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import static com.mongodb.client.model.Filters.eq; +import static com.mongodb.client.model.Filters.in; + +public class MongoMapStore implements MapStore, MapLoaderLifecycleSupport { + + private MongoClient mongoClient; + private MongoCollection collection; + + public MongoMapStore() { + } + + @Override + public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) { + String mongoUrl = (String) properties.get("mongo.url"); + String dbName = (String) properties.get("mongo.db"); + String collectionName = (String) properties.get("mongo.collection"); + ConnectionString connectionString = new ConnectionString(mongoUrl); + MongoClientSettings settings = MongoClientSettings.builder() + .applyConnectionString(connectionString) + .serverApi(ServerApi.builder() + .version(ServerApiVersion.V1) + .build()) + .build(); + this.mongoClient = MongoClients.create(settings); + this.collection = mongoClient.getDatabase(dbName).getCollection(collectionName); + } + + @Override + public void destroy() { + mongoClient.close(); + } + + @Override + public Supplement load(String key) { + System.out.println("Load " + key); + Document document = (Document) collection.find(eq("_id", key)).first(); + String name = (String) document.get("name"); + Integer price = document.getInteger("price"); + return new Supplement(name, price); + } + + @Override + public Map loadAll(Collection keys) { + System.out.println("LoadAll " + keys); + HashMap result = new HashMap<>(); + + FindIterable id = collection.find(in("_id", keys)); + for (Document document : id) { + String name = (String) document.get("name"); + Integer price = document.getInteger("price"); + result.put(document.get("_id").toString(), new Supplement(name, price)); + } + return result; + } + + @Override + public Iterable loadAllKeys() { + System.out.println("LoadAllKeys"); + List keys = new LinkedList<>(); + FindIterable ids = collection.find().projection(Projections.include("_id")); + for (Document document : ids) { + keys.add(document.get("_id").toString()); + } + return keys; + } + + @Override + public void store(String key, Supplement value) { + Document doc = new Document("name", value.getName()).append("price", value.getPrice()).append("_id", key); + this.collection.insertOne(doc); + } + + @Override + public void storeAll(Map map) { + List batch = new LinkedList<>(); + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + Supplement value = entry.getValue(); + batch.add(new InsertOneModel( + new Document("name", value.getName()).append("price", value.getPrice()) + .append("_id", key))); + } + this.collection.bulkWrite(batch, new BulkWriteOptions().ordered(false)); + } + + @Override + public void delete(String key) { + this.collection.deleteOne(eq("_id", key)); + } + + @Override + public void deleteAll(Collection keys) { + this.collection.deleteMany(in("_id", keys)); + } +} \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/Supplement.java b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/Supplement.java new file mode 100644 index 000000000..f9206d099 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/mapstore/src/main/java/com/operator/tutorial/mongodb/Supplement.java @@ -0,0 +1,22 @@ +package com.operator.tutorial.mongodb; + +import java.io.Serializable; + +public class Supplement implements Serializable { + + private final String name; + private final Integer price; + + public Supplement(String name, Integer price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public Integer getPrice() { + return price; + } +} \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-map-store/package.json b/platform-operator/hazelcast-platform-operator-map-store/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-map-store/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-tls/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-tls/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..97d693eb4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-tls/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-tls/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-tls/.gitignore b/platform-operator/hazelcast-platform-operator-tls/.gitignore new file mode 100644 index 000000000..862663302 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/.gitignore @@ -0,0 +1,15 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-tls/README.adoc b/platform-operator/hazelcast-platform-operator-tls/README.adoc new file mode 100644 index 000000000..e40edeff3 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-tls[Configure TLS with Hazelcast Platform Operator tutorial]. diff --git a/platform-operator/hazelcast-platform-operator-tls/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-tls/antora-playbook-local.yml new file mode 100644 index 000000000..85dc25971 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/antora-playbook-local.yml @@ -0,0 +1,34 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: master + start_paths: docs + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-tls/create.sh b/platform-operator/hazelcast-platform-operator-tls/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/example.go b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/example.go new file mode 100644 index 000000000..ed92320a3 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/example.go @@ -0,0 +1,26 @@ +package main + +import ( + "context" + "crypto/tls" + "fmt" + + "github.com/hazelcast/hazelcast-go-client" + "github.com/hazelcast/hazelcast-go-client/cluster" +) + +func main() { + var clusterConfig cluster.Config + clusterConfig.Network.SetAddresses("") + clusterConfig.Discovery.UsePublicIP = true + clusterConfig.Network.SSL.Enabled = true + clusterConfig.Network.SSL.SetTLSConfig(&tls.Config{InsecureSkipVerify: true}) + + ctx := context.Background() + config := hazelcast.Config{Cluster: clusterConfig} + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!", client) +} diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.mod b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.mod new file mode 100644 index 000000000..604fb2852 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.mod @@ -0,0 +1,14 @@ +module hazelcast/hazelcast-platform-operator-tls/go + +go 1.23 + +require github.com/hazelcast/hazelcast-go-client v1.4.2 + +require ( + github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect + github.com/go-ole/go-ole v1.2.4 // indirect + github.com/shirou/gopsutil/v3 v3.21.5 // indirect + github.com/tklauser/go-sysconf v0.3.4 // indirect + github.com/tklauser/numcpus v0.2.1 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.sum b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.sum new file mode 100644 index 000000000..0c3afa265 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/go/go.sum @@ -0,0 +1,33 @@ +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= +github.com/hazelcast/hazelcast-go-client v1.4.2 h1:5WFTm40Sor7Ku0fbhzlCqAq7UXP3sD8WoG7iln3aCTk= +github.com/hazelcast/hazelcast-go-client v1.4.2/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil/v3 v3.21.5 h1:YUBf0w/KPLk7w1803AYBnH7BmA+1Z/Q5MEZxpREUaB4= +github.com/shirou/gopsutil/v3 v3.21.5/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M= +github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek= +github.com/tklauser/numcpus v0.2.1 h1:ct88eFm+Q7m2ZfXJdan1xYoXKlmwsfP+k88q05KvlZc= +github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/hazelcast.yaml b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/hazelcast.yaml new file mode 100644 index 000000000..248fe1ff2 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/hazelcast.yaml @@ -0,0 +1,13 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast +spec: + clusterSize: 3 + licenseKeySecretName: hazelcast-license-key + tls: + secretName: example + exposeExternally: + type: Smart + discoveryServiceType: LoadBalancer + memberAccess: LoadBalancer diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/pom.xml b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/pom.xml new file mode 100644 index 000000000..410055e80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast-enterprise + 5.5.0 + + + + + Hazelcast Private Release Repository + https://repository.hazelcast.com/release/ + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.example + + + + + + assemble-all + package + + single + + + + + + + + diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/src/main/java/com/hazelcast/example.java b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/src/main/java/com/hazelcast/example.java new file mode 100644 index 000000000..7fb7f6b77 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/java/src/main/java/com/hazelcast/example.java @@ -0,0 +1,25 @@ +package com.hazelcast; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.config.SSLConfig; +import com.hazelcast.core.HazelcastInstance; + +import java.util.Properties; + +public class example { + public static void main(String[] args) throws Exception { + ClientConfig config = new ClientConfig(); + config.getNetworkConfig().addAddress(""); + + Properties clientSSLProps = new Properties(); + clientSSLProps.setProperty("trustStore", "example.jks"); + clientSSLProps.setProperty("trustStorePassword", "hazelcast"); + config.getNetworkConfig().setSSLConfig(new SSLConfig() + .setEnabled(true) + .setProperties(clientSSLProps)); + + HazelcastInstance client = HazelcastClient.newHazelcastClient(config); + System.out.println("Successful connection!"); + } +} diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/managementcenter.yaml b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/managementcenter.yaml new file mode 100644 index 000000000..2b8624177 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/managementcenter.yaml @@ -0,0 +1,14 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: ManagementCenter +metadata: + name: managementcenter +spec: + repository: 'hazelcast/management-center' + licenseKeySecretName: hazelcast-license-key + externalConnectivity: + type: LoadBalancer + hazelcastClusters: + - address: hazelcast + name: dev + tls: + secretName: example diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/example.js b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/example.js new file mode 100644 index 000000000..4613d6eea --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/example.js @@ -0,0 +1,27 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ], + ssl: { + enabled: true, + sslOptionsFactoryProperties: { + caPath: 'example.crt', + servername: 'example', + } + } + } +}; + +(async () => { + try { + const client = await Client.newHazelcastClient(clientConfig); + console.log('Successful connection!'); + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/package.json b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/package.json new file mode 100644 index 000000000..04549ab0f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/nodejs/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "example.js", + "scripts": { + "start": "node example.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/python/example.py b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/python/example.py new file mode 100644 index 000000000..dfe944923 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/docs/modules/ROOT/examples/python/example.py @@ -0,0 +1,14 @@ +import logging + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +client = hazelcast.HazelcastClient( + cluster_members=[""], + use_public_ip=True, + ssl_enabled=True, + ssl_cafile="example.crt", +) + +print("Successful connection!", flush=True) diff --git a/platform-operator/hazelcast-platform-operator-tls/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-tls/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-tls/package.json b/platform-operator/hazelcast-platform-operator-tls/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-tls/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..97d693eb4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/.gitignore b/platform-operator/hazelcast-platform-operator-user-code-namespace/.gitignore new file mode 100644 index 000000000..9fc24999f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/.gitignore @@ -0,0 +1,16 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json +.vscode diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/README.adoc b/platform-operator/hazelcast-platform-operator-user-code-namespace/README.adoc new file mode 100644 index 000000000..a91fc61cb --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-user-code-namespace[hazelcast-platform-operator-user-code-namespace tutorial]. diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-user-code-namespace/antora-playbook-local.yml new file mode 100644 index 000000000..7a4f1c0ed --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/antora-playbook-local.yml @@ -0,0 +1,31 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: master + start_paths: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/create.sh b/platform-operator/hazelcast-platform-operator-user-code-namespace/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/hazelcast.yaml b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/hazelcast.yaml new file mode 100644 index 000000000..e37d7591d --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/hazelcast.yaml @@ -0,0 +1,10 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast +spec: + clusterSize: 1 + repository: "docker.io/hazelcast/hazelcast-enterprise" + version: "5.4.0" + licenseKeySecretName: hazelcast-license-key + userCodeNamespaces: {} diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/map.yaml b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/map.yaml new file mode 100644 index 000000000..fc7e37904 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/map.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: my-map +spec: + hazelcastResourceName: hazelcast + userCodeNamespace: my-ucn + entryListeners: + - className: com.hazelcast.tutorial.SimpleEntryListener diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/ucn.yaml b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/ucn.yaml new file mode 100644 index 000000000..c70c5640a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/docs/modules/ROOT/examples/operator-user-code-namespace/ucn.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: UserCodeNamespace +metadata: + name: my-ucn +spec: + hazelcastResourceName: hazelcast + bucketConfig: + secretName: + bucketURI: diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-user-code-namespace/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/package.json b/platform-operator/hazelcast-platform-operator-user-code-namespace/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/pom.xml b/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/pom.xml new file mode 100644 index 000000000..5fba08d9a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + + com.hazelcast.tutorial + simple-entry-listener + jar + + 1.0-SNAPSHOT + simple-entry-listener + + + 17 + 17 + + + + + + com.hazelcast + hazelcast + 5.4.0 + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/src/main/java/com/hazelcast/tutorial/SimpleEntryListener.java b/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/src/main/java/com/hazelcast/tutorial/SimpleEntryListener.java new file mode 100644 index 000000000..eec2efd2f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-user-code-namespace/simple-entry-listener/src/main/java/com/hazelcast/tutorial/SimpleEntryListener.java @@ -0,0 +1,28 @@ +package com.hazelcast.tutorial; + +import com.hazelcast.core.EntryEvent; +import com.hazelcast.core.HazelcastJsonValue; +import com.hazelcast.map.listener.EntryAddedListener; +import com.hazelcast.map.listener.EntryRemovedListener; +import com.hazelcast.map.listener.EntryUpdatedListener; + +public class SimpleEntryListener implements EntryAddedListener, + EntryUpdatedListener, + EntryRemovedListener { + + @Override + public void entryAdded(EntryEvent event) { + System.out.println("Entry Added:" + event); + } + + @Override + public void entryRemoved(EntryEvent event) { + System.out.println("Entry Removed:" + event); + } + + @Override + public void entryUpdated(EntryEvent event) { + System.out.println("Entry Updated:" + event); + } + +} diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-wan-replication/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..60758281b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/.github/CONTRIBUTING.adoc @@ -0,0 +1,82 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Append your tutorial repository to the `content.sources` field in the `antora-playbook-local.yml` file at the root of this repository. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: + start_path: docs +``` + +. Install the required dependencies by running `npm i` at the root of this repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-wan-replication/.github/workflows/build-site.yml new file mode 100644 index 000000000..3f54aab6b --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [main] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/.gitignore b/platform-operator/hazelcast-platform-operator-wan-replication/.gitignore new file mode 100644 index 000000000..862663302 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/.gitignore @@ -0,0 +1,15 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/README.adoc b/platform-operator/hazelcast-platform-operator-wan-replication/README.adoc new file mode 100644 index 000000000..8092fabe7 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for this tutorial: link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-wan-replication[Replicate Data between Two Hazelcast Clusters with Hazelcast Platform Operator]. diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-wan-replication/antora-playbook-local.yml new file mode 100644 index 000000000..3c5d0bc46 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/antora-playbook-local.yml @@ -0,0 +1,31 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: HEAD + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/create.sh b/platform-operator/hazelcast-platform-operator-wan-replication/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/Program.cs b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/Program.cs new file mode 100644 index 000000000..13d95bd80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/Program.cs @@ -0,0 +1,70 @@ +using System; +using System.Threading.Tasks; +using Hazelcast; +using Microsoft.Extensions.Logging; + +namespace Client +{ + public class Program + { + static async Task Main(string[] args) + { + if (args.Length != 2) + { + Console.WriteLine("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`."); + return; + } + if (!(args[0] == "fill" || args[0] == "size")) + { + Console.WriteLine("Wrong argument, you should pass: fill or size"); + return; + } + + var mapName = args[1]; + var options = new HazelcastOptionsBuilder() + .With(args) + .With((configuration, options) => + { + options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => + loggingBuilder + .AddConsole()); + + options.Networking.UsePublicAddresses = true; + options.Networking.SmartRouting = false; + options.Networking.Addresses.Add(":5701"); + + }) + .Build(); + + + + await using var client = await HazelcastClientFactory.StartNewClientAsync(options); + + Console.WriteLine("Successful connection!"); + Console.WriteLine("Starting to fill the map with random entries."); + + var map = await client.GetMapAsync(mapName); + var random = new Random(); + + if (args[0] == "fill") + { + Console.WriteLine("Starting to fill the map with random entries."); + while (true) + { + var num = random.Next(100_000); + var key = $"key-{num}"; + var value = $"value-{num}"; + await map.PutAsync(key, value); + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + } + } + else + { + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + await client.DisposeAsync(); + } + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/wan-replica.csproj b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/wan-replica.csproj new file mode 100644 index 000000000..a54904651 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/dotnet/wan-replica.csproj @@ -0,0 +1,18 @@ + + + + Exe + net7.0 + backup_restore + enable + enable + + + + + + + + + + diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.mod b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.mod new file mode 100644 index 000000000..0cccc0878 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.mod @@ -0,0 +1,8 @@ +module github.com/hazelcast-guides/kubernetes/go + +go 1.15 + +require ( + github.com/hazelcast/hazelcast-go-client v1.4.1 + github.com/shirou/gopsutil/v3 v3.21.10 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.sum b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.sum new file mode 100644 index 000000000..6b7b5362d --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/go.sum @@ -0,0 +1,66 @@ +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hazelcast/hazelcast-go-client v1.4.1 h1:BSpJqqjbACI4MugfWXGxk+JdZR3JRELx0n769pa85kA= +github.com/hazelcast/hazelcast-go-client v1.4.1/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil/v3 v3.21.5/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw= +github.com/shirou/gopsutil/v3 v3.21.10 h1:flTg1DrnV/UVrBqjLgVgDJzx6lf+91rC64/dBHmO2IA= +github.com/shirou/gopsutil/v3 v3.21.10/go.mod h1:t75NhzCZ/dYyPQjyQmrAYP6c8+LCdFANeBMdLPCNnew= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek= +github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8= +github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/main.go b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/main.go new file mode 100644 index 000000000..91307020a --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/go/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "context" + "fmt" + "math/rand" + "os" + + "github.com/hazelcast/hazelcast-go-client" +) + +func main() { + if len(os.Args) != 3 { + fmt.Println("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.") + return + } + if os.Args[1] != "fill" && os.Args[1] != "size" { + fmt.Println("Wrong argument, pass `fill` or `size` instead.") + return + } + + config := hazelcast.Config{} + cc := &config.Cluster + cc.Network.SetAddresses(":5701") + cc.Unisocket = true + ctx := context.TODO() + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!") + + mapName := os.Args[2] + m, err := client.GetMap(ctx, mapName) + if err != nil { + panic(err) + } + if os.Args[1] == "fill" { + fmt.Printf("Starting to fill the map (%s) with random entries.\n", mapName) + for { + num := rand.Intn(100_000) + key := fmt.Sprintf("key-%d", num) + value := fmt.Sprintf("value-%d", num) + if _, err = m.Put(ctx, key, value); err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + fmt.Println("Current map size:", mapSize) + } + return + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + return + } + fmt.Printf("The map (%s) size: %v", mapName, mapSize) + +} diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-first.yaml b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-first.yaml new file mode 100644 index 000000000..774976a51 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-first.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast-first +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-second.yaml b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-second.yaml new file mode 100644 index 000000000..eda66a8d9 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/hazelcast-second.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast-second +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/pom.xml b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/pom.xml new file mode 100755 index 000000000..9670ee855 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast + 5.4.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.Main + + + + + + assemble-all + package + + single + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/src/main/java/com/hazelcast/Main.java b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/src/main/java/com/hazelcast/Main.java new file mode 100644 index 000000000..e94ecf53c --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/java/src/main/java/com/hazelcast/Main.java @@ -0,0 +1,42 @@ +package com.hazelcast; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; + +import java.util.Random; + +public class Main { + public static void main(String[] args) throws Exception { + if(args.length != 2) { + System.out.println("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`."); + } else if (!((args[0].equals("fill") || args[0].equals("size")))) { + System.out.println("Wrong argument, you should pass: fill or size"); + } else{ + ClientConfig config = new ClientConfig(); + config.getNetworkConfig().addAddress(""); + + HazelcastInstance client = HazelcastClient.newHazelcastClient(config); + System.out.println("Successful connection!"); + + String mapName = args[1]; + IMap map = client.getMap(mapName); + + if (args[0].equals("fill")) { + System.out.printf("Starting to fill the map (%s) with random entries.\n", mapName); + + Random random = new Random(); + while (true) { + int randomKey = random.nextInt(100_000); + map.put("key-" + randomKey, "value-" + randomKey); + System.out.println("Current map size: " + map.size()); + } + } else { + System.out.printf("The map (%s) size: (%d)\n\n", mapName, map.size()); + client.shutdown(); + } + } + + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/map.yaml b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/map.yaml new file mode 100644 index 000000000..a7036f541 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/map.yaml @@ -0,0 +1,13 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: map-1 +spec: + hazelcastResourceName: hazelcast-first +--- +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: map-2 +spec: + hazelcastResourceName: hazelcast-first \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/client.js b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/client.js new file mode 100755 index 000000000..0514a42dc --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/client.js @@ -0,0 +1,45 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ] + } +}; + +(async () => { + try { + if (process.argv.length !== 4) { + console.error('You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.'); + } else if (!(process.argv[2] === 'fill' || process.argv[2] === 'size')) { + console.error('Wrong argument, you should pass: fill or size'); + } else { + const client = await Client.newHazelcastClient(clientConfig); + const mapName = process.argv[3] + const map = await client.getMap(mapName); + await map.put('key', 'value'); + const res = await map.get('key'); + if (res !== 'value') { + throw new Error('Connection failed, check your configuration.'); + } + console.log('Successful connection!'); + if (process.argv[2] === 'fill'){ + console.log(`Starting to fill the map (${mapName}) with random entries.`); + while (true) { + const randomKey = Math.floor(Math.random() * 100000); + await map.put('key' + randomKey, 'value' + randomKey); + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } else { + const size = await map.size(); + console.log(`The map (${mapName}) size: ${size}`); + } + } + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/package.json b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/package.json new file mode 100755 index 000000000..0319dac80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/nodejs/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "client.js", + "scripts": { + "start": "node client.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/python/main.py b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/python/main.py new file mode 100644 index 000000000..04f656ee1 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/python/main.py @@ -0,0 +1,30 @@ +import logging +import random +import sys + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +if len(sys.argv) != 3: + print("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.") +elif not (sys.argv[1] == "fill" or sys.argv[1] == "size"): + print("Wrong argument, you should pass: fill or size") +else: + client = hazelcast.HazelcastClient( + cluster_members=[""], + use_public_ip=True, + ) + print("Successful connection!", flush=True) + + mapName = sys.argv[2] + m = client.get_map(mapName).blocking() + + if sys.argv[1] == "fill": + print(f'Starting to fill the map ({mapName}) with random entries.', flush=True) + while True: + random_number = str(random.randrange(0, 100000)) + m.put("key-" + random_number, "value-" + random_number) + print("Current map size:", m.size()) + else: + print(f'The map ({mapName}) size: {m.size()}') diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/wanreplication.yaml b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/wanreplication.yaml new file mode 100644 index 000000000..fd8b73a43 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/docs/modules/ROOT/examples/operator-wan/wanreplication.yaml @@ -0,0 +1,10 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: WanReplication +metadata: + name: wan-replication +spec: + resources: + - name: hazelcast-first + kind: Hazelcast + targetClusterName: dev + endpoints: "" \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-wan-replication/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-wan-replication/package.json b/platform-operator/hazelcast-platform-operator-wan-replication/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-replication/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/.github/CONTRIBUTING.adoc b/platform-operator/hazelcast-platform-operator-wan-sync/.github/CONTRIBUTING.adoc new file mode 100644 index 000000000..97d693eb4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/.github/CONTRIBUTING.adoc @@ -0,0 +1,70 @@ += Contributing to Hazelcast Tutorials + +This guide covers how to use this template to contribute to Hazelcast tutorials. + +== Repository Structure + +All tutorials follow the same structure: + +- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged. +- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure]. +- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed. +- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally. +- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally. +- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files. + +== Adding a New Tutorial + +. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template]. ++ +TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published. + +. Rename the file in `docs/modules/ROOT/pages` to the name of your repository. + +. Add the filename to the template in the README. + +. Write your tutorial by following the instructions in the file. + +. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files. ++ +For example: ++ +```yaml +content: + sources: + - url: https://github.com/hazelcast-guides/ + branches: main + start_path: docs +``` ++ +After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes. + +== Previewing a Tutorial + +To preview your content in a local version of the tutorials subsite, do the following: + +. Install the required dependencies by running `npm i` at the root of your repository. + +. Build the site. ++ +```bash +npm run-script build-local +``` ++ +You should see the following: ++ +`Site generation complete!` + +. Serve the site locally. ++ +```bash +npm run-script serve +``` ++ +This script automatically copies the local URL to your clipboard. + +. In a web browser, paste the URL into the address bar. + +You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/. + +NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com. diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/.github/workflows/build-site.yml b/platform-operator/hazelcast-platform-operator-wan-sync/.github/workflows/build-site.yml new file mode 100644 index 000000000..cb9a0ce6f --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/.github/workflows/build-site.yml @@ -0,0 +1,13 @@ +# This workflow takes the contents of the branches/tags and builds the production documentation site +name: Build production site + +on: + push: + branches: [master] + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger build + run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8 diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/.gitignore b/platform-operator/hazelcast-platform-operator-wan-sync/.gitignore new file mode 100644 index 000000000..862663302 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/.gitignore @@ -0,0 +1,15 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt +node_modules/ +local-docs/ +package-lock.json \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/README.adoc b/platform-operator/hazelcast-platform-operator-wan-sync/README.adoc new file mode 100644 index 000000000..b20971448 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/README.adoc @@ -0,0 +1 @@ +This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-wan-sync[Syncronizing WAN replicated data between Two Hazelcast Clusters with Hazelcast Platform Operator]. \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/antora-playbook-local.yml b/platform-operator/hazelcast-platform-operator-wan-sync/antora-playbook-local.yml new file mode 100644 index 000000000..7a4f1c0ed --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/antora-playbook-local.yml @@ -0,0 +1,31 @@ +site: + title: Documentation + start_page: tutorials::index.adoc + url: http:localhost:3000 + keys: + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' +content: + sources: + - url: https://github.com/hazelcast/hazelcast-docs + branches: main + start_paths: [tutorials, home] + - url: https://github.com/hazelcast-guides/adoc-templates.git + branches: antora-doc + - url: . + branches: master + start_paths: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true +asciidoc: + attributes: + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + idprefix: '' + idseparator: '-' + extensions: + - ./lib/tabs-block.js diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/create.sh b/platform-operator/hazelcast-platform-operator-wan-sync/create.sh new file mode 100755 index 000000000..0a9c146a5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-map.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-map.yaml new file mode 100644 index 000000000..dd7681eee --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-map.yaml @@ -0,0 +1,8 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: map-sync +spec: + hazelcastResourceName: hazelcast-first + merkleTree: + depth: 10 diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-wanreplication.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-wanreplication.yaml new file mode 100644 index 000000000..b516c0e52 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/delta-sync-wanreplication.yaml @@ -0,0 +1,11 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: WanReplication +metadata: + name: wan-replication +spec: + resources: + - name: hazelcast-first + kind: Hazelcast + targetClusterName: dev + syncConsistencyCheckStrategy: "MERKLE_TREES" + endpoints: "" diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/Program.cs b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/Program.cs new file mode 100644 index 000000000..be5c50a95 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/Program.cs @@ -0,0 +1,70 @@ +using System; +using System.Threading.Tasks; +using Hazelcast; +using Microsoft.Extensions.Logging; + +namespace Client +{ + public class Program + { + static async Task Main(string[] args) + { + if (args.Length != 2) + { + Console.WriteLine("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`."); + return; + } + if (!(args[0] == "fill" || args[0] == "size")) + { + Console.WriteLine("Wrong argument, you should pass: fill or size"); + return; + } + + var mapName = args[1]; + var options = new HazelcastOptionsBuilder() + .With(args) + .With((configuration, options) => + { + options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => + loggingBuilder + .AddConsole()); + + options.Networking.UsePublicAddresses = true; + options.Networking.SmartRouting = false; + options.Networking.Addresses.Add(":5701"); + + }) + .Build(); + + + + await using var client = await HazelcastClientFactory.StartNewClientAsync(options); + + Console.WriteLine("Successful connection!"); + Console.WriteLine("Starting to fill the map with random entries."); + + var map = await client.GetMapAsync(mapName); + var random = new Random(); + + if (args[0] == "fill") + { + Console.WriteLine("Starting to fill the map with random entries."); + while (true) + { + var num = random.Next(100); + var key = $"key-{num}"; + var value = $"value-{num}"; + await map.PutAsync(key, value); + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + } + } + else + { + var mapSize = await map.GetSizeAsync(); + Console.WriteLine($"Current map size: {mapSize}"); + await client.DisposeAsync(); + } + } + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/wan-replica.csproj b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/wan-replica.csproj new file mode 100644 index 000000000..9e56c0845 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/dotnet/wan-replica.csproj @@ -0,0 +1,14 @@ + + + Exe + net7.0 + Client + enable + enable + + + + + + + diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-map.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-map.yaml new file mode 100644 index 000000000..0082a699e --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-map.yaml @@ -0,0 +1,6 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Map +metadata: + name: map-sync +spec: + hazelcastResourceName: hazelcast-first diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-wanreplication.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-wanreplication.yaml new file mode 100644 index 000000000..fd8b73a43 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/full-sync-wanreplication.yaml @@ -0,0 +1,10 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: WanReplication +metadata: + name: wan-replication +spec: + resources: + - name: hazelcast-first + kind: Hazelcast + targetClusterName: dev + endpoints: "" \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.mod b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.mod new file mode 100644 index 000000000..19f1307ce --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.mod @@ -0,0 +1,16 @@ +module github.com/hazelcast-guides/kubernetes/go + +go 1.21 + +require github.com/hazelcast/hazelcast-go-client v1.4.1 + +require ( + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/shirou/gopsutil/v3 v3.22.10 // indirect + github.com/tklauser/go-sysconf v0.3.10 // indirect + github.com/tklauser/numcpus v0.4.0 // indirect + github.com/yusufpapurcu/wmi v1.2.2 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.sum b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.sum new file mode 100644 index 000000000..fa9419754 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/go.sum @@ -0,0 +1,50 @@ +github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s= +github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hazelcast/hazelcast-go-client v1.4.1 h1:BSpJqqjbACI4MugfWXGxk+JdZR3JRELx0n769pa85kA= +github.com/hazelcast/hazelcast-go-client v1.4.1/go.mod h1:PJ38lqXJ18S0YpkrRznPDlUH8GnnMAQCx3jpQtBPZ6Q= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/shirou/gopsutil/v3 v3.22.10 h1:4KMHdfBRYXGF9skjDWiL4RA2N+E8dRdodU/bOZpPoVg= +github.com/shirou/gopsutil/v3 v3.22.10/go.mod h1:QNza6r4YQoydyCfo6rH0blGfKahgibh4dQmV5xdFkQk= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/main.go b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/main.go new file mode 100644 index 000000000..51b1a7ed5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/go/main.go @@ -0,0 +1,63 @@ +package main + +import ( + "context" + "fmt" + "math/rand" + "os" + + "github.com/hazelcast/hazelcast-go-client" +) + +func main() { + if len(os.Args) != 3 { + fmt.Println("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.") + return + } + if os.Args[1] != "fill" && os.Args[1] != "size" { + fmt.Println("Wrong argument, pass `fill` or `size` instead.") + return + } + + config := hazelcast.Config{} + cc := &config.Cluster + cc.Network.SetAddresses("a5fec28eae167431eb081eba49fc7e57-1903362080.us-east-1.elb.amazonaws.com:5701") + cc.Unisocket = true + ctx := context.TODO() + client, err := hazelcast.StartNewClientWithConfig(ctx, config) + if err != nil { + panic(err) + } + fmt.Println("Successful connection!") + + mapName := os.Args[2] + m, err := client.GetMap(ctx, mapName) + if err != nil { + panic(err) + } + if os.Args[1] == "fill" { + fmt.Printf("Starting to fill the map (%s) with random entries.\n", mapName) + for { + num := rand.Intn(100) + key := fmt.Sprintf("key-%d", num) + value := fmt.Sprintf("value-%d", num) + if _, err = m.Put(ctx, key, value); err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + continue + } + fmt.Println("Current map size:", mapSize) + } + return + } + mapSize, err := m.Size(ctx) + if err != nil { + fmt.Println("ERR:", err.Error()) + return + } + fmt.Printf("The map (%s) size: %v", mapName, mapSize) +} diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-first.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-first.yaml new file mode 100644 index 000000000..774976a51 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-first.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast-first +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-second.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-second.yaml new file mode 100644 index 000000000..eda66a8d9 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/hazelcast-second.yaml @@ -0,0 +1,9 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: Hazelcast +metadata: + name: hazelcast-second +spec: + licenseKeySecretName: hazelcast-license-key + exposeExternally: + type: Unisocket + discoveryServiceType: LoadBalancer \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/pom.xml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/pom.xml new file mode 100755 index 000000000..9670ee855 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.hazelcast + java-sample-client + 1.0-SNAPSHOT + + + 17 + 17 + + + + + com.hazelcast + hazelcast + 5.4.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + com.hazelcast.Main + + + + + + assemble-all + package + + single + + + + + + + + \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/src/main/java/com/hazelcast/Main.java b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/src/main/java/com/hazelcast/Main.java new file mode 100644 index 000000000..22114cd39 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/java/src/main/java/com/hazelcast/Main.java @@ -0,0 +1,42 @@ +package com.hazelcast; + +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.client.config.ClientConfig; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.map.IMap; + +import java.util.Random; + +public class Main { + public static void main(String[] args) throws Exception { + if(args.length != 2) { + System.out.println("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`."); + } else if (!((args[0].equals("fill") || args[0].equals("size")))) { + System.out.println("Wrong argument, you should pass: fill or size"); + } else{ + ClientConfig config = new ClientConfig(); + config.getNetworkConfig().addAddress(""); + + HazelcastInstance client = HazelcastClient.newHazelcastClient(config); + System.out.println("Successful connection!"); + + String mapName = args[1]; + IMap map = client.getMap(mapName); + + if (args[0].equals("fill")) { + System.out.printf("Starting to fill the map (%s) with random entries.\n", mapName); + + Random random = new Random(); + while (true) { + int randomKey = random.nextInt(100); + map.put("key-" + randomKey, "value-" + randomKey); + System.out.println("Current map size: " + map.size()); + } + } else { + System.out.printf("The map (%s) size: (%d)\n\n", mapName, map.size()); + client.shutdown(); + } + } + + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/client.js b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/client.js new file mode 100755 index 000000000..8d02a1488 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/client.js @@ -0,0 +1,45 @@ +'use strict'; + +const { Client } = require('hazelcast-client'); + +const clientConfig = { + network: { + clusterMembers: [ + '' + ] + } +}; + +(async () => { + try { + if (process.argv.length !== 4) { + console.error('You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.'); + } else if (!(process.argv[2] === 'fill' || process.argv[2] === 'size')) { + console.error('Wrong argument, you should pass: fill or size'); + } else { + const client = await Client.newHazelcastClient(clientConfig); + const mapName = process.argv[3] + const map = await client.getMap(mapName); + await map.put('key', 'value'); + const res = await map.get('key'); + if (res !== 'value') { + throw new Error('Connection failed, check your configuration.'); + } + console.log('Successful connection!'); + if (process.argv[2] === 'fill'){ + console.log(`Starting to fill the map (${mapName}) with random entries.`); + while (true) { + const randomKey = Math.floor(Math.random() * 100); + await map.put('key' + randomKey, 'value' + randomKey); + const size = await map.size(); + console.log(`Current map size: ${size}`); + } + } else { + const size = await map.size(); + console.log(`The map (${mapName}) size: ${size}`); + } + } + } catch (err) { + console.error('Error occurred:', err); + } +})(); diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/package.json b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/package.json new file mode 100755 index 000000000..0319dac80 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/nodejs/package.json @@ -0,0 +1,13 @@ +{ + "name": "hazelcast", + "version": "1.0.0", + "description": "", + "main": "client.js", + "scripts": { + "start": "node client.js" + }, + "author": "", + "dependencies": { + "hazelcast-client": "^5.0" + } +} diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/python/main.py b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/python/main.py new file mode 100644 index 000000000..04f656ee1 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/python/main.py @@ -0,0 +1,30 @@ +import logging +import random +import sys + +import hazelcast + +logging.basicConfig(level=logging.INFO) + +if len(sys.argv) != 3: + print("You need to pass two arguments. The first argument must be `fill` or `size`. The second argument must be `mapName`.") +elif not (sys.argv[1] == "fill" or sys.argv[1] == "size"): + print("Wrong argument, you should pass: fill or size") +else: + client = hazelcast.HazelcastClient( + cluster_members=[""], + use_public_ip=True, + ) + print("Successful connection!", flush=True) + + mapName = sys.argv[2] + m = client.get_map(mapName).blocking() + + if sys.argv[1] == "fill": + print(f'Starting to fill the map ({mapName}) with random entries.', flush=True) + while True: + random_number = str(random.randrange(0, 100000)) + m.put("key-" + random_number, "value-" + random_number) + print("Current map size:", m.size()) + else: + print(f'The map ({mapName}) size: {m.size()}') diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/wansync.yaml b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/wansync.yaml new file mode 100644 index 000000000..fc66ac07d --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/docs/modules/ROOT/examples/operator-wan-sync/wansync.yaml @@ -0,0 +1,6 @@ +apiVersion: hazelcast.com/v1alpha1 +kind: WanSync +metadata: + name: wan-sync +spec: + wanReplicationResourceName: wan-replication \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/lib/tabs-block.js b/platform-operator/hazelcast-platform-operator-wan-sync/lib/tabs-block.js new file mode 100644 index 000000000..ae47e18d5 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/lib/tabs-block.js @@ -0,0 +1,80 @@ +/* Copyright (c) 2018 OpenDevise, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Extends the AsciiDoc syntax to support a tabset. The tabset is created from + * a dlist enclosed in an example block that is marked with the tabs style. + * + * Usage: + * + * [tabs] + * ==== + * Tab A:: + * + + * -- + * Contents of tab A. + * -- + * Tab B:: + * + + * -- + * Contents of tab B. + * -- + * ==== + * + * @author Dan Allen + */ +const IdSeparatorCh = '-' +const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g +const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g +const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') +const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') + +const generateId = (str, idx) => + `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` + +function tabsBlock () { + this.onContext('example') + this.process((parent, reader, attrs) => { + const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) + const tabsetIdx = parent.getDocument().counter('idx-tabset') + const nodes = [] + nodes.push(createHtmlFragment('
')) + const container = this.parseContent(this.createBlock(parent, 'open'), reader) + const sourceTabs = container.getBlocks()[0] + if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return + const tabs = List.$new(parent, 'ulist') + tabs.addRole('tabs') + const panes = {} + sourceTabs.getItems().forEach(([[title], details]) => { + const tab = ListItem.$new(tabs) + tabs.$append(tab) + const id = generateId(title.getText(), tabsetIdx) + tab.text = `[[${id}]]${title.text}` + let blocks = details.getBlocks() + const numBlocks = blocks.length + if (numBlocks) { + if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() + panes[id] = blocks.map((block) => (block.parent = parent) && block) + } + }) + nodes.push(tabs) + nodes.push(createHtmlFragment('
')) + Object.entries(panes).forEach(([id, blocks]) => { + nodes.push(createHtmlFragment(`
`)) + nodes.push(...blocks) + nodes.push(createHtmlFragment('
')) + }) + nodes.push(createHtmlFragment('
')) + nodes.push(createHtmlFragment('
')) + parent.blocks.push(...nodes) + }) +} + +function register (registry) { + registry.block('tabs', tabsBlock) +} + +module.exports.register = register diff --git a/platform-operator/hazelcast-platform-operator-wan-sync/package.json b/platform-operator/hazelcast-platform-operator-wan-sync/package.json new file mode 100644 index 000000000..0fec44fc6 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator-wan-sync/package.json @@ -0,0 +1,22 @@ +{ + "name": "hazelcast-docs-playbook", + "version": "1.0.0", + "description": "Script for working with Hazelcast tutorials locally", + "author": "Jake Cahill", + "license": "ISC", + "scripts": { + "build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml", + "check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml", + "serve": "serve local-docs", + "expose": "ngrok http 5000" + }, + "devDependencies": { + "@antora/cli": "^3.0.0", + "@antora/site-generator-default": "^3.0.0", + "@antora/xref-validator": "gitlab:antora/xref-validator", + "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", + "asciidoctor-kroki": "^0.10.0", + "ngrok": "^4.2.2", + "serve": "^13.0.2" + } +} diff --git a/platform-operator/hazelcast-platform-operator/.github/workflows/guide-website-update.yml b/platform-operator/hazelcast-platform-operator/.github/workflows/guide-website-update.yml new file mode 100644 index 000000000..594da1ae7 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator/.github/workflows/guide-website-update.yml @@ -0,0 +1,37 @@ +name: Guide Web Site Deploy + +on: + push: + branches: master + paths: + - 'doc/**' + +jobs: + antora: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2.3.1 + with: + repository: hazelcast-guides/guides-site + ref: master + token: ${{ secrets.SECRET_TOKEN }} + + - name: Install Antora + run: | + sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates + curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - + sudo apt -y install nodejs + sudo npm i -g @antora/cli@2.3 @antora/site-generator-default@2.3 + - name: Build website artifacts + run: | + sh create.sh + - name: Commit artifacts changes + run: | + git config --global user.name 'devOpsHazelcast' + git config --global user.email 'devops@hazelcast.com' + export GUIDE_REPO=$(cut -d/ -f2 <<<"${GITHUB_REPOSITORY}") + export COMMIT_ID=$(git rev-parse --short "$GITHUB_SHA") + git add docs + git commit -m "${GUIDE_REPO}-${COMMIT_ID} guide update" + - name: Push artifacts to guides-site repo + run: git push diff --git a/platform-operator/hazelcast-platform-operator/.github/workflows/integration-tests.yml b/platform-operator/hazelcast-platform-operator/.github/workflows/integration-tests.yml new file mode 100644 index 000000000..f6e5bdcf2 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator/.github/workflows/integration-tests.yml @@ -0,0 +1,101 @@ +name: Integration tests +on: push + +jobs: + run-tests: + name: Integration tests + runs-on: ubuntu-latest + steps: + - uses: engineerd/setup-kind@v0.5.0 + with: + version: "v0.11.1" + + - name: Deploy Hazelcast Platform Operator + run: | + kubectl apply -f https://repository.hazelcast.com/operator/bundle.yaml + kubectl wait --for=condition=available --timeout=600s deployment/hazelcast-platform-controller-manager + + - name: Create Hazelcast Platform Enterprise cluster + run: | + kubectl create secret generic hazelcast-license-key --from-literal license-key=${{ secrets.LICENSE }} + cat < { + phase += data.toString(); + }, + stderr: (data) => { + } + }; + const readyMembersOptions = {}; + readyMembersOptions.listeners = { + stdout: (data) => { + readyMembers += data.toString(); + }, + stderr: (data) => { + } + }; + await exec.exec('kubectl', ['get', 'hazelcast', 'my-hazelcast', '-o=jsonpath={.status.phase}'], phaseOptions); + await exec.exec('kubectl', ['get', 'hazelcast', 'my-hazelcast', '-o=jsonpath={.status.hazelcastClusterStatus.readyMembers}'], readyMembersOptions); + if (phase !== "Running") { + core.setFailed(`Unexpected phase: ${phase}`) + } + if (readyMembers !== "3/3") { + core.setFailed(`Unexpected ready members: ${readyMembers}`) + } + + - name: Create ManagementCenter + run: | + cat < { + phase += data.toString(); + }, + stderr: (data) => { + } + }; + await exec.exec('kubectl', ['get', 'managementcenter', 'my-managementcenter', '-o=jsonpath={.status.phase}'], phaseOptions); + if (phase !== "Running") { + core.setFailed(`Unexpected phase: ${phase}`) + } + diff --git a/platform-operator/hazelcast-platform-operator/.gitignore b/platform-operator/hazelcast-platform-operator/.gitignore new file mode 100644 index 000000000..7a6d929ea --- /dev/null +++ b/platform-operator/hazelcast-platform-operator/.gitignore @@ -0,0 +1,12 @@ +target/ +.idea/ +.settings/ +.classpath +.directory +.project +.surefire-* +.DS_Store +*.iml +*.ipr +*.iws +*.txt \ No newline at end of file diff --git a/platform-operator/hazelcast-platform-operator/README.md b/platform-operator/hazelcast-platform-operator/README.md new file mode 100644 index 000000000..a50866cb7 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator/README.md @@ -0,0 +1 @@ +See the guide [here](https://guides.hazelcast.org/hazelcast-platform-operator/). diff --git a/platform-operator/hazelcast-platform-operator/create.sh b/platform-operator/hazelcast-platform-operator/create.sh new file mode 100755 index 000000000..1dbd1e9e4 --- /dev/null +++ b/platform-operator/hazelcast-platform-operator/create.sh @@ -0,0 +1,2 @@ +asciidoctor -D . -a allow-uri-read doc/modules/ROOT/pages/*.adoc; +asciidoctor-pdf -D . -a allow-uri-read doc/modules/ROOT/pages/*.adoc; diff --git a/platform-operator/pom.xml b/platform-operator/pom.xml new file mode 100644 index 000000000..229c4d95f --- /dev/null +++ b/platform-operator/pom.xml @@ -0,0 +1,28 @@ + + + + + 4.0.0 + pom + + operator-samples + + + com.hazelcast.samples + code-samples + 0.1-SNAPSHOT + ../pom.xml + + + + hazelcast-platform-operator-map-store/mapstore + + + + + ${project.parent.basedir} + + + diff --git a/pom.xml b/pom.xml index 2a7333f85..95fe3f3b7 100644 --- a/pom.xml +++ b/pom.xml @@ -77,6 +77,7 @@ osgi partition pipeline + platform-operator replicated-map querying serialization