Copilot commented on code in PR #3041:
URL: https://github.com/apache/hugegraph/pull/3041#discussion_r3338744059
##########
docker/hbase/README.md:
##########
@@ -1,422 +1,301 @@
-# HBase Backend Testing with Docker
+# HugeGraph + HBase Backend
-This guide explains how to start HBase locally with Docker, verify it is
working, and validate HugeGraph API operations.
+This guide covers running HugeGraph with HBase backend.
-> **All commands in this guide should be run from the repository root** unless
otherwise noted.
-> **Security note**: The HBase Docker build enforces SHA512 verification by
default and fails when checksum download/parsing/validation fails. Only use
`--build-arg ALLOW_UNVERIFIED_DOWNLOAD=true` for trusted test environments with
restricted networks.
+> All commands below run from the repository root (this project folder).
----
-
-## Quick Start
+Use this once at the start of your terminal session:
-### 0. (Optional) Build the HBase Docker Image
```bash
-docker compose -f docker/hbase/docker-compose.hbase.yml build --no-cache hbase
+ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
+cd "$ROOT_DIR"
```
-### 1. Start HBase with Docker
-
-```bash
-docker compose -f docker/hbase/docker-compose.hbase.yml up -d
-```
+---
-### 2. Wait for HBase to be Ready (~2 minutes)
+## Quick Start Paths (Choose One)
-```bash
-# Check ZooKeeper connectivity
-nc -z localhost 2181 && echo "Ready" || echo "Not ready"
+<details>
+<summary><b>Option 1: Standalone HugeGraph (using
start-hugegraph.sh)</b></summary>
-# Or watch the logs
-docker compose -f docker/hbase/docker-compose.hbase.yml logs
+Prerequisite: build local artifact first.
+mvn clean package -DskipTests
```
-
-### 3. (Optional) Clean Up Leftover HBase Tables
-
-For reruns, drop any leftover HugeGraph tables after the container is up:
-
-```bash
-docker exec hg-hbase-test bash -c '
- for t in $(echo "list" | hbase shell -n 2>/dev/null | grep
"^default_hugegraph"); do
- echo "disable '"'"'$t'"'"'; drop '"'"'$t'"'"'"
- done | hbase shell
-'
+cd "$ROOT_DIR"
```
-Verify tables are gone before proceeding:
-
```bash
-docker exec hg-hbase-test bash -lc "echo 'list' | hbase shell -n"
-# Expected: TABLE (empty), 0 row(s)
+# 1) Start HBase
+docker compose -p hg-hbase -f docker/hbase/docker-compose.hbase.yml down -v
+docker compose -p hg-hbase -f docker/hbase/docker-compose.hbase.yml build
--no-cache hbase
+HBASE_MASTER_HOSTNAME=localhost HBASE_REGIONSERVER_HOSTNAME=localhost \
+docker compose -p hg-hbase -f docker/hbase/docker-compose.hbase.yml up -d
+until docker exec hg-hbase-test nc -z localhost 2181 >/dev/null 2>&1; do sleep
2; done
+echo "HBase ZooKeeper is reachable on 2181"
+# Optional troubleshooting stream:
+# docker compose -p hg-hbase -f docker/hbase/docker-compose.hbase.yml logs -f
hbase
```
-
-
-### 4. Configure and Init the HugeGraph Server (required for API tests)
-
-> This step is only needed for HugeGraph API sanity checks.
-
-> **Prerequisite**: Run `mvn clean package -DskipTests` from the repository
root to generate the distribution. This creates an
`apache-hugegraph-<version>/` directory with all necessary binaries and configs.
-
-Set backend to HBase in the server config:
-
```bash
-SERVER_DIR="$(find . -maxdepth 3 -type d -path
'./apache-hugegraph-*/apache-hugegraph-server-*' | head -n 1)"
-SERVER_DIR="${SERVER_DIR#./}"
-[ -n "$SERVER_DIR" ] || { echo "HugeGraph server runtime not found. Run mvn
clean package -DskipTests first."; exit 1; }
+# 2) Configure HugeGraph (standalone runtime)
+SERVER_DIR="$(find . -maxdepth 4 -type d -path
'./hugegraph-server/apache-hugegraph-server-*' | head -n 1)"
+[ -n "$SERVER_DIR" ] || { echo "Build artifact not found"; exit 1; }
CONF="$SERVER_DIR/conf/graphs/hugegraph.properties"
-# Switch backend to hbase
-perl -pi -e 's/^backend=.*/backend=hbase/' "$CONF"
+perl -pi -e 's/^backend=.*/backend=hbase/' "$CONF"
perl -pi -e 's/^serializer=.*/serializer=hbase/' "$CONF"
-
-# Uncomment HBase connection settings
-perl -pi -e 's/^#(hbase\.hosts=.*)/$1/' "$CONF"
-perl -pi -e 's/^#(hbase\.port=.*)/$1/' "$CONF"
+perl -pi -e 's/^#(hbase\.hosts=.*)/$1/' "$CONF"
+perl -pi -e 's/^#(hbase\.port=.*)/$1/' "$CONF"
perl -pi -e 's/^#(hbase\.znode_parent=.*)/$1/' "$CONF"
-```
-
-Initialize HBase tables and start the server:
+perl -pi -e 's/^hbase\.hosts=.*/hbase.hosts=localhost/' "$CONF"
+perl -pi -e 's/^hbase\.port=.*/hbase.port=2181/' "$CONF"
+perl -pi -e 's|^hbase\.znode_parent=.*|hbase.znode_parent=/hbase|' "$CONF"
-```bash
-printf 'pa\npa\n' | "$SERVER_DIR/bin/init-store.sh"
-"$SERVER_DIR/bin/start-hugegraph.sh" -t 60
+grep -E '^(backend|serializer|hbase\.)' "$CONF"
```
-After `init-store.sh`, you can verify the tables were created:
-
```bash
-docker exec hg-hbase-test bash -lc "echo 'list' | hbase shell -n"
-```
+# 3) Init and start server
+cd "$SERVER_DIR"
+printf 'pa\npa\n' | ./bin/init-store.sh
+./bin/start-hugegraph.sh -t 60
----
-
-## Docker Compose Services
-
-### HBase Container
-
-- **Image**: `hugegraph/hbase:2.6.5`
-- **Container Name**: `hg-hbase-test`
-- **Hostname**: `hbase`
-- **Ports**:
- - `2181` - ZooKeeper (embedded)
- - `16000` - HBase Master RPC
- - `16010` - HBase Master Web UI (http://localhost:16010)
- - `16020` - HBase RegionServer RPC
- - `16030` - HBase RegionServer Web UI (http://localhost:16030)
-- **Health Check**: ZooKeeper connectivity on port 2181
-- **Startup Time**: ~90-120 seconds
+# 4) Verify backend logs mention hbase
+grep -Eai 'hbase|rocksdb|hstore' "$SERVER_DIR"/logs/*.log | tail -n 30
+```
----
+</details>
-## Manual Verification
+<details>
+<summary><b>Option 2: Docker HugeGraph (fully containerized)</b></summary>
-### 1. Check Container is Healthy
+```bash
+cd "$ROOT_DIR"
+````
Review Comment:
The Option 2 snippet has an invalid code fence terminator (it currently
closes with four backticks), which breaks Markdown rendering.
##########
docker/hbase/entrypoint.sh:
##########
@@ -17,7 +17,39 @@
#
set -e
+HBASE_HOSTNAME="${HBASE_HOSTNAME:-hbase}"
+HBASE_MASTER_HOSTNAME="${HBASE_MASTER_HOSTNAME:-${HBASE_HOSTNAME}}"
+HBASE_REGIONSERVER_HOSTNAME="${HBASE_REGIONSERVER_HOSTNAME:-${HBASE_HOSTNAME}}"
+HBASE_SITE_XML="${HBASE_HOME}/conf/hbase-site.xml"
+
+escape_sed_replacement() {
+ printf '%s' "$1" | sed -e 's/[&|]/\\&/g'
+}
+
+set_xml_property_value() {
+ local property_name="$1"
+ local property_value
+ property_value=$(escape_sed_replacement "$2")
+
+ # The in-place replacement below expects the standard HBase layout where
+ # <name>...</name> is followed by <value>...</value> on the next line.
+ # Fail loudly if the property entry is missing to avoid silent misconfig.
+ if ! grep -q "<name>${property_name}</name>" "${HBASE_SITE_XML}"; then
+ echo "Missing required property '${property_name}' in
${HBASE_SITE_XML}" >&2
+ exit 1
+ fi
Review Comment:
The presence check uses `grep` with a regex pattern, so `.` in the property
name is treated as “any character”. This can yield false positives (and make
the subsequent `sed` edit fail silently in some edge cases). Use `grep -F`
(fixed-string) for an exact match on the `<name>...</name>` line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]