Skip to content

Commit a28b75a

Browse files
authored
Import nouveau (#4291)
Nouveau - a new (experimental) full-text indexing feature for Apache CouchDB, using Lucene 9. Requires Java 11 or higher (19 is preferred).
1 parent c1195e4 commit a28b75a

File tree

118 files changed

+9387
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+9387
-40
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.rebar/
1919
.eunit/
2020
cover/
21-
core
21+
/core
2222
debian/
2323
log
2424
apache-couchdb-*/
@@ -133,3 +133,5 @@ test/javascript/junit.xml
133133

134134
.idea
135135
*.lock
136+
137+
.tool-versions

Makefile

+42-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TEST_OPTS="-c 'startup_jitter=0' -c 'default_security=admin_local'"
100100

101101
.PHONY: all
102102
# target: all - Build everything
103-
all: couch fauxton docs escriptize
103+
all: couch fauxton docs escriptize nouveau
104104

105105

106106
.PHONY: help
@@ -152,10 +152,12 @@ escriptize: couch
152152
.PHONY: check
153153
# target: check - Test everything
154154
check: all
155+
@$(MAKE) exunit
155156
@$(MAKE) eunit
156157
@$(MAKE) mango-test
157158
@$(MAKE) elixir-suite
158159
@$(MAKE) weatherreport-test
160+
@$(MAKE) nouveau-test
159161

160162
ifdef apps
161163
subdirs = $(apps)
@@ -425,6 +427,12 @@ else
425427
endif
426428
endif
427429

430+
ifeq ($(with_nouveau), 1)
431+
@mkdir -p rel/couchdb/nouveau/
432+
@cp nouveau/target/server-*-dist.jar rel/couchdb/nouveau/
433+
@cp nouveau/nouveau.yaml rel/couchdb/nouveau/
434+
endif
435+
428436
@echo "... done"
429437
@echo
430438
@echo " You can now copy the rel/couchdb directory anywhere on your system."
@@ -465,6 +473,9 @@ clean:
465473
@rm -f src/couch/priv/couch_js/config.h
466474
@rm -f dev/*.beam dev/devnode.* dev/pbkdf2.pyc log/crash.log
467475
@rm -f dev/erlserver.pem dev/couch_ssl_dist.conf
476+
ifeq ($(with_nouveau), 1)
477+
@cd nouveau && mvn clean
478+
endif
468479

469480

470481
.PHONY: distclean
@@ -525,3 +536,33 @@ derived:
525536
@echo "ON_TAG: $(ON_TAG)"
526537
@echo "REL_TAG: $(REL_TAG)"
527538
@echo "SUB_VSN: $(SUB_VSN)"
539+
540+
################################################################################
541+
# Nouveau
542+
################################################################################
543+
544+
.PHONY: nouveau
545+
# Build nouveau
546+
nouveau:
547+
ifeq ($(with_nouveau), 1)
548+
@cd nouveau && mvn -D maven.test.skip=true
549+
endif
550+
551+
.PHONY: nouveau-test
552+
nouveau-test: nouveau-test-maven nouveau-test-elixir
553+
554+
.PHONY: nouveau-test-maven
555+
nouveau-test-maven: couch nouveau
556+
ifeq ($(with_nouveau), 1)
557+
@cd nouveau && mvn test -P allTests
558+
endif
559+
560+
.PHONY: nouveau-test-elixir
561+
nouveau-test-elixir: export MIX_ENV=integration
562+
nouveau-test-elixir: elixir-init devclean
563+
nouveau-test-elixir: couch nouveau
564+
ifeq ($(with_nouveau), 1)
565+
@dev/run -n 1 -q -a adm:pass --with-nouveau \
566+
--locald-config test/config/test-config.ini \
567+
--no-eval 'mix test --trace --include test/elixir/test/config/nouveau.elixir'
568+
endif

configure

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ REBAR3_BRANCH="main"
2727
WITH_PROPER="true"
2828
WITH_FAUXTON=1
2929
WITH_DOCS=1
30+
WITH_NOUVEAU=0
3031
ERLANG_MD5="false"
3132
SKIP_DEPS=0
3233

@@ -56,6 +57,7 @@ Options:
5657
-u | --user USER set the username to run as (defaults to $COUCHDB_USER)
5758
--disable-fauxton do not build Fauxton
5859
--disable-docs do not build any documentation or manpages
60+
--enable-nouveau enable the new experimental search module
5961
--erlang-md5 use erlang for md5 hash operations
6062
--dev alias for --disable-docs --disable-fauxton
6163
--spidermonkey-version VSN specify the version of SpiderMonkey to use (defaults to $SM_VSN)
@@ -112,6 +114,12 @@ parse_opts() {
112114
continue
113115
;;
114116

117+
--enable-nouveau)
118+
WITH_NOUVEAU=1
119+
shift
120+
continue
121+
;;
122+
115123
--erlang-md5)
116124
ERLANG_MD5="true"
117125
shift
@@ -121,6 +129,7 @@ parse_opts() {
121129
--dev)
122130
WITH_DOCS=0
123131
WITH_FAUXTON=0
132+
WITH_NOUVEAU=1
124133
shift
125134
continue
126135
;;
@@ -302,6 +311,7 @@ package_author_name = $PACKAGE_AUTHOR_NAME
302311
303312
with_fauxton = $WITH_FAUXTON
304313
with_docs = $WITH_DOCS
314+
with_nouveau = $WITH_NOUVEAU
305315
306316
user = $COUCHDB_USER
307317
spidermonkey_version = $SM_VSN

dev/run

+47-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import optparse
2424
import os
2525
import posixpath
2626
import re
27+
import signal
2728
import socket
2829
import subprocess as sp
2930
import sys
@@ -226,6 +227,13 @@ def get_args_parser():
226227
default=[],
227228
help="Path to config to place in 'local.d'. Can be repeated",
228229
)
230+
parser.add_option(
231+
"--with-nouveau",
232+
dest="with_nouveau",
233+
default=False,
234+
action="store_true",
235+
help="Start Nouveau server",
236+
)
229237
return parser
230238

231239

@@ -255,6 +263,7 @@ def setup_context(opts, args):
255263
"procs": [],
256264
"auto_ports": opts.auto_ports,
257265
"locald_configs": opts.locald_configs,
266+
"with_nouveau": opts.with_nouveau,
258267
}
259268

260269

@@ -304,9 +313,11 @@ def setup_configs(ctx):
304313
),
305314
"node_name": "-name %[email protected]" % node,
306315
"cluster_port": cluster_port,
316+
"clouseau_name": "clouseau%[email protected]" % (idx + 1),
307317
"backend_port": backend_port,
308318
"prometheus_port": prometheus_port,
309319
"uuid": "fake_uuid_for_dev",
320+
"with_nouveau": str(ctx["with_nouveau"]).lower(),
310321
"_default": "",
311322
}
312323
write_config(ctx, node, env)
@@ -451,6 +462,32 @@ def boot_haproxy(ctx):
451462
)
452463

453464

465+
def boot_nouveau(ctx):
466+
if not ctx["with_nouveau"]:
467+
return
468+
469+
version = "1.0-SNAPSHOT"
470+
cmd = [
471+
"java",
472+
"-server",
473+
"-jar",
474+
"target/server-%s-dist.jar" % version,
475+
"server",
476+
"nouveau.yaml",
477+
]
478+
479+
logfname = os.path.join(ctx["devdir"], "logs", "nouveau.log")
480+
log = open(logfname, "w")
481+
return sp.Popen(
482+
" ".join(cmd),
483+
cwd="nouveau",
484+
shell=True,
485+
stdin=sp.PIPE,
486+
stdout=log,
487+
stderr=sp.STDOUT,
488+
)
489+
490+
454491
def hack_default_ini(ctx, node, contents):
455492
contents = re.sub(
456493
"^\[httpd\]$",
@@ -509,6 +546,11 @@ def hashify(pwd, salt=COMMON_SALT, iterations=10, keylen=20):
509546

510547

511548
def startup(ctx):
549+
def handler(signalno, frame):
550+
kill_processes(ctx)
551+
sys.exit()
552+
553+
signal.signal(signal.SIGTERM, handler)
512554
atexit.register(kill_processes, ctx)
513555
boot_nodes(ctx)
514556
ensure_all_nodes_alive(ctx)
@@ -525,7 +567,8 @@ def startup(ctx):
525567
def kill_processes(ctx):
526568
for proc in ctx["procs"]:
527569
if proc and proc.returncode is None:
528-
proc.kill()
570+
proc.terminate()
571+
ctx["procs"] = []
529572

530573

531574
def degrade_cluster(ctx):
@@ -551,6 +594,9 @@ def boot_nodes(ctx):
551594
haproxy_proc = boot_haproxy(ctx)
552595
if haproxy_proc is not None:
553596
ctx["procs"].append(haproxy_proc)
597+
nouveau_proc = boot_nouveau(ctx)
598+
if nouveau_proc is not None:
599+
ctx["procs"].append(nouveau_proc)
554600

555601

556602
def ensure_all_nodes_alive(ctx):

nouveau/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*~
2+
.classpath
3+
.project
4+
.settings/
5+
target/
6+
.vscode/
7+
dependency-reduced-pom.xml

0 commit comments

Comments
 (0)