Skip to content

Commit

Permalink
Import nouveau (#4291)
Browse files Browse the repository at this point in the history
Nouveau - a new (experimental) full-text indexing feature for Apache CouchDB, using Lucene 9. Requires Java 11 or higher (19 is preferred).
  • Loading branch information
rnewson committed Apr 22, 2023
1 parent c1195e4 commit a28b75a
Show file tree
Hide file tree
Showing 118 changed files with 9,387 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.rebar/
.eunit/
cover/
core
/core
debian/
log
apache-couchdb-*/
Expand Down Expand Up @@ -133,3 +133,5 @@ test/javascript/junit.xml

.idea
*.lock

.tool-versions
43 changes: 42 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TEST_OPTS="-c 'startup_jitter=0' -c 'default_security=admin_local'"

.PHONY: all
# target: all - Build everything
all: couch fauxton docs escriptize
all: couch fauxton docs escriptize nouveau


.PHONY: help
Expand Down Expand Up @@ -152,10 +152,12 @@ escriptize: couch
.PHONY: check
# target: check - Test everything
check: all
@$(MAKE) exunit
@$(MAKE) eunit
@$(MAKE) mango-test
@$(MAKE) elixir-suite
@$(MAKE) weatherreport-test
@$(MAKE) nouveau-test

ifdef apps
subdirs = $(apps)
Expand Down Expand Up @@ -425,6 +427,12 @@ else
endif
endif

ifeq ($(with_nouveau), 1)
@mkdir -p rel/couchdb/nouveau/
@cp nouveau/target/server-*-dist.jar rel/couchdb/nouveau/
@cp nouveau/nouveau.yaml rel/couchdb/nouveau/
endif

@echo "... done"
@echo
@echo " You can now copy the rel/couchdb directory anywhere on your system."
Expand Down Expand Up @@ -465,6 +473,9 @@ clean:
@rm -f src/couch/priv/couch_js/config.h
@rm -f dev/*.beam dev/devnode.* dev/pbkdf2.pyc log/crash.log
@rm -f dev/erlserver.pem dev/couch_ssl_dist.conf
ifeq ($(with_nouveau), 1)
@cd nouveau && mvn clean
endif


.PHONY: distclean
Expand Down Expand Up @@ -525,3 +536,33 @@ derived:
@echo "ON_TAG: $(ON_TAG)"
@echo "REL_TAG: $(REL_TAG)"
@echo "SUB_VSN: $(SUB_VSN)"

################################################################################
# Nouveau
################################################################################

.PHONY: nouveau
# Build nouveau
nouveau:
ifeq ($(with_nouveau), 1)
@cd nouveau && mvn -D maven.test.skip=true
endif

.PHONY: nouveau-test
nouveau-test: nouveau-test-maven nouveau-test-elixir

.PHONY: nouveau-test-maven
nouveau-test-maven: couch nouveau
ifeq ($(with_nouveau), 1)
@cd nouveau && mvn test -P allTests
endif

.PHONY: nouveau-test-elixir
nouveau-test-elixir: export MIX_ENV=integration
nouveau-test-elixir: elixir-init devclean
nouveau-test-elixir: couch nouveau
ifeq ($(with_nouveau), 1)
@dev/run -n 1 -q -a adm:pass --with-nouveau \
--locald-config test/config/test-config.ini \
--no-eval 'mix test --trace --include test/elixir/test/config/nouveau.elixir'
endif
10 changes: 10 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ REBAR3_BRANCH="main"
WITH_PROPER="true"
WITH_FAUXTON=1
WITH_DOCS=1
WITH_NOUVEAU=0
ERLANG_MD5="false"
SKIP_DEPS=0

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

--enable-nouveau)
WITH_NOUVEAU=1
shift
continue
;;

--erlang-md5)
ERLANG_MD5="true"
shift
Expand All @@ -121,6 +129,7 @@ parse_opts() {
--dev)
WITH_DOCS=0
WITH_FAUXTON=0
WITH_NOUVEAU=1
shift
continue
;;
Expand Down Expand Up @@ -302,6 +311,7 @@ package_author_name = $PACKAGE_AUTHOR_NAME
with_fauxton = $WITH_FAUXTON
with_docs = $WITH_DOCS
with_nouveau = $WITH_NOUVEAU
user = $COUCHDB_USER
spidermonkey_version = $SM_VSN
Expand Down
48 changes: 47 additions & 1 deletion dev/run
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import optparse
import os
import posixpath
import re
import signal
import socket
import subprocess as sp
import sys
Expand Down Expand Up @@ -226,6 +227,13 @@ def get_args_parser():
default=[],
help="Path to config to place in 'local.d'. Can be repeated",
)
parser.add_option(
"--with-nouveau",
dest="with_nouveau",
default=False,
action="store_true",
help="Start Nouveau server",
)
return parser


Expand Down Expand Up @@ -255,6 +263,7 @@ def setup_context(opts, args):
"procs": [],
"auto_ports": opts.auto_ports,
"locald_configs": opts.locald_configs,
"with_nouveau": opts.with_nouveau,
}


Expand Down Expand Up @@ -304,9 +313,11 @@ def setup_configs(ctx):
),
"node_name": "-name %s@127.0.0.1" % node,
"cluster_port": cluster_port,
"clouseau_name": "clouseau%d@127.0.0.1" % (idx + 1),
"backend_port": backend_port,
"prometheus_port": prometheus_port,
"uuid": "fake_uuid_for_dev",
"with_nouveau": str(ctx["with_nouveau"]).lower(),
"_default": "",
}
write_config(ctx, node, env)
Expand Down Expand Up @@ -451,6 +462,32 @@ def boot_haproxy(ctx):
)


def boot_nouveau(ctx):
if not ctx["with_nouveau"]:
return

version = "1.0-SNAPSHOT"
cmd = [
"java",
"-server",
"-jar",
"target/server-%s-dist.jar" % version,
"server",
"nouveau.yaml",
]

logfname = os.path.join(ctx["devdir"], "logs", "nouveau.log")
log = open(logfname, "w")
return sp.Popen(
" ".join(cmd),
cwd="nouveau",
shell=True,
stdin=sp.PIPE,
stdout=log,
stderr=sp.STDOUT,
)


def hack_default_ini(ctx, node, contents):
contents = re.sub(
"^\[httpd\]$",
Expand Down Expand Up @@ -509,6 +546,11 @@ def hashify(pwd, salt=COMMON_SALT, iterations=10, keylen=20):


def startup(ctx):
def handler(signalno, frame):
kill_processes(ctx)
sys.exit()

signal.signal(signal.SIGTERM, handler)
atexit.register(kill_processes, ctx)
boot_nodes(ctx)
ensure_all_nodes_alive(ctx)
Expand All @@ -525,7 +567,8 @@ def startup(ctx):
def kill_processes(ctx):
for proc in ctx["procs"]:
if proc and proc.returncode is None:
proc.kill()
proc.terminate()
ctx["procs"] = []


def degrade_cluster(ctx):
Expand All @@ -551,6 +594,9 @@ def boot_nodes(ctx):
haproxy_proc = boot_haproxy(ctx)
if haproxy_proc is not None:
ctx["procs"].append(haproxy_proc)
nouveau_proc = boot_nouveau(ctx)
if nouveau_proc is not None:
ctx["procs"].append(nouveau_proc)


def ensure_all_nodes_alive(ctx):
Expand Down
7 changes: 7 additions & 0 deletions nouveau/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*~
.classpath
.project
.settings/
target/
.vscode/
dependency-reduced-pom.xml

0 comments on commit a28b75a

Please sign in to comment.