Skip to content

Commit

Permalink
Support proxy to cassandra (#19)
Browse files Browse the repository at this point in the history
* Add prometheus metrics to gobeansproxy (#15)

* Add cassandra support (#17)
  • Loading branch information
dispensable committed Feb 2, 2024
1 parent f425dd9 commit 1bed777
Show file tree
Hide file tree
Showing 57 changed files with 5,367 additions and 338 deletions.
27 changes: 27 additions & 0 deletions .doubanpde/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
SHELL := /bin/bash
PROJECT_DIR := /home/project

env:
dpi -y -D "-y"
mkdir -p /tmp/gobeansproxy_prefix/proxy/

build:
go build -o gobeansproxy_bin

start-proxy: build
./gobeansproxy_bin -confdir .doubanpde/scripts/bdb/gobeansproxy/prefix-switch-cfg/conf/

start-riven-proxy: build
./gobeansproxy_bin -confdir .doubanpde/scripts/bdb/rivenbeansproxy/conf/

start-proxy-gc-trace: build
GODEBUG=gctrace=1 ./gobeansproxy_bin -confdir .doubanpde/scripts/bdb/gobeansproxy/prefix-switch-cfg/conf/

start-proxy-valgrind: build
G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --error-limit=no --log-file=valgrind.log ./gobeansproxy_bin -confdir .doubanpde/scripts/bdb/gobeansproxy/prefix-switch-cfg/conf/

tail-log:
tail -f /tmp/gobeansproxy_prefix/proxy/*.log

cqlsh:
cqlsh -u cassandra -p cassandra
126 changes: 126 additions & 0 deletions .doubanpde/pde.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
apiVersion: v1
kind: Pod
metadata:
labels:
app: "gobeansproxy"
createId: "{{ uuid }}"
createdBy: pdectl
createdByUser: wangqiang
runByUser: '{{ .CliArgs.String "username" }}'
runByPdectlVersion: "{{ .CliArgs.App.Version }}"
runnerAddress: "{{ .RunnerAddress }}"
createdTime: "{{ .CreatedTime }}"
pdeVersion: "v0.1.4"
useWebEditor: "false"
webEditorPort: 0
webEditorType: ""
name: "gobeansproxy"
annotations:
pdectl.douban.com/cfg/exec-cmd: '{{ .CliArgs.String "exec-default-cmd" }}'
spec:
containers:
- name: "main"
env:
- name: HOSTNAME
value: "gobeansproxy-main"
- name: SCRIBE_HOST
value: 10.0.2.2
image: "docker.douban/sa/pde-go-cli:latest-1.20-v2"
ports:
volumeMounts:
# mount go path src to container go path
- mountPath: /go/src/
name: go-path-src
# mount code folder
- mountPath: /home/project/
name: code
- mountPath: /root/
name: userhome
- mountPath: '/home/{{ .CliArgs.String "username" }}'
name: userhome
- mountPath: /fuse:rslave
name: fuse
- mountPath: /etc/douban/
name: etc-douban
readOnly: true
- mountPath: /etc/localtime
name: etc-localtime
readOnly: true
- mountPath: /var/run/nscd/
name: var-run-nscd
readOnly: true
workingDir: /home/project
# - name: mc
# image: docker.douban/memcached:latest
# workingDir: /
{{- range (mkSlice 57980 57981 57982 57983) }}
- name: beansdb-{{ . }}
image: docker.douban/platform/gobeansdb:latest
workingDir: /data/
volumeMounts:
- mountPath: /data
name: beansdb-{{ . }}-data-dir
- mountPath: /gobeansdb/default_beansdb_cfg/
name: beansdb-{{ . }}-cfg-dir
{{- end }}
- name: cassandra
image: docker.douban/dba/cassandra:4.1.2
workingDir: /
volumeMounts:
- mountPath: /var/lib/cassandra/
name: cassandra-data-dir
# - mountPath: /tmp/cassandra/
# name: cassandra-cfg
# command:
# - "/bin/bash"
# args:
# - "-c"
# - >
# cp -rfv /tmp/cassandra/cassandra.yaml /etc/cassandra/ &&
# /usr/local/bin/docker-entrypoint.sh cassandra -f
restartPolicy: Never
volumes:
- hostPath:
path: '{{ expandEnvVar "$GOPATH/src" }}'
type: Directory
name: go-path-src
{{- $env := . }}
{{- range (mkSlice 57980 57981 57982 57983) }}
- hostPath:
path: '{{ $env.CliArgs.String "project-dir" }}/.doubanpde/data/beansdb-{{ . }}/'
type: DirectoryOrCreate
name: beansdb-{{ . }}-data-dir
- hostPath:
path: '{{ $env.CliArgs.String "project-dir" }}/.doubanpde/scripts/bdb/gobeansproxy/{{ . }}/conf/'
type: Directory
name: beansdb-{{ . }}-cfg-dir
{{- end }}
- hostPath:
path: '{{ .CliArgs.String "project-dir" }}/.doubanpde/data/cassandra/'
type: DirectoryOrCreate
name: cassandra-data-dir
- hostPath:
path: '{{ .CliArgs.String "project-dir" }}/.doubanpde/scripts/cassandra/'
name: cassandra-cfg
- hostPath:
path: '{{ .CliArgs.String "project-dir" }}'
type: Directory
name: code
- hostPath:
path: '{{ expandEnvVar "$HOME/" }}'
type: Directory
name: userhome
- hostPath:
path: /fuse
type: Directory
name: fuse
- hostPath:
path: /etc/douban/
name: etc-douban
- hostPath:
path: /etc/localtime
name: etc-localtime
- hostPath:
path: /var/run/nscd/
name: var-run-nscd

32 changes: 32 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57980/conf/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
hstore:
data:
check_vhash: true
datafile_max_str: 4000M
flush_interval: 60
flush_wake_str: 10M
no_gc_days: 7
hint:
hint_index_interval_str: 32K
hint_merge_interval: 5
hint_no_merged: true
hint_split_cap_str: 1M
htree:
tree_height: 3
local:
home: /data
mc:
body_big_str: 5M
body_c_str: 0K
body_max_str: 50M
flush_max_str: 100M
max_key_len: 250
max_req: 16
server:
accesslog: /tmp/access.log
errorlog: /tmp/error.log
hostname: 127.0.0.1
listen: 0.0.0.0
port: 57980
threads: 4
webport: 57990
zk: 'NO'
26 changes: 26 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57980/conf/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
backup:
- 127.0.0.1:57983
main:
- addr: 127.0.0.1:57980
buckets: &id001
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- a
- b
- c
- d
- e
- f
- addr: 127.0.0.1:57981
buckets: *id001
- addr: 127.0.0.1:57982
buckets: *id001
numbucket: 16
32 changes: 32 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57981/conf/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
hstore:
data:
check_vhash: true
datafile_max_str: 4000M
flush_interval: 60
flush_wake_str: 10M
no_gc_days: 7
hint:
hint_index_interval_str: 32K
hint_merge_interval: 5
hint_no_merged: true
hint_split_cap_str: 1M
htree:
tree_height: 3
local:
home: /data
mc:
body_big_str: 5M
body_c_str: 0K
body_max_str: 50M
flush_max_str: 100M
max_key_len: 250
max_req: 16
server:
accesslog: /tmp/access.log
errorlog: /tmp/error.log
hostname: 127.0.0.1
listen: 0.0.0.0
port: 57981
threads: 4
webport: 57991
zk: 'NO'
26 changes: 26 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57981/conf/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
backup:
- 127.0.0.1:57983
main:
- addr: 127.0.0.1:57980
buckets: &id001
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- a
- b
- c
- d
- e
- f
- addr: 127.0.0.1:57981
buckets: *id001
- addr: 127.0.0.1:57982
buckets: *id001
numbucket: 16
32 changes: 32 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57982/conf/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
hstore:
data:
check_vhash: true
datafile_max_str: 4000M
flush_interval: 60
flush_wake_str: 10M
no_gc_days: 7
hint:
hint_index_interval_str: 32K
hint_merge_interval: 5
hint_no_merged: true
hint_split_cap_str: 1M
htree:
tree_height: 3
local:
home: /data
mc:
body_big_str: 5M
body_c_str: 0K
body_max_str: 50M
flush_max_str: 100M
max_key_len: 250
max_req: 16
server:
accesslog: /tmp/access.log
errorlog: /tmp/error.log
hostname: 127.0.0.1
listen: 0.0.0.0
port: 57982
threads: 4
webport: 57992
zk: 'NO'
26 changes: 26 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57982/conf/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
backup:
- 127.0.0.1:57983
main:
- addr: 127.0.0.1:57980
buckets: &id001
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- a
- b
- c
- d
- e
- f
- addr: 127.0.0.1:57981
buckets: *id001
- addr: 127.0.0.1:57982
buckets: *id001
numbucket: 16
32 changes: 32 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57983/conf/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
hstore:
data:
check_vhash: true
datafile_max_str: 4000M
flush_interval: 60
flush_wake_str: 10M
no_gc_days: 7
hint:
hint_index_interval_str: 32K
hint_merge_interval: 5
hint_no_merged: true
hint_split_cap_str: 1M
htree:
tree_height: 3
local:
home: /data
mc:
body_big_str: 5M
body_c_str: 0K
body_max_str: 50M
flush_max_str: 100M
max_key_len: 250
max_req: 16
server:
accesslog: /tmp/access.log
errorlog: /tmp/error.log
hostname: 127.0.0.1
listen: 0.0.0.0
port: 57983
threads: 4
webport: 57993
zk: 'NO'
26 changes: 26 additions & 0 deletions .doubanpde/scripts/bdb/gobeansproxy/57983/conf/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
backup:
- 127.0.0.1:57983
main:
- addr: 127.0.0.1:57980
buckets: &id001
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- a
- b
- c
- d
- e
- f
- addr: 127.0.0.1:57981
buckets: *id001
- addr: 127.0.0.1:57982
buckets: *id001
numbucket: 16
Loading

0 comments on commit 1bed777

Please sign in to comment.