Changeset: 98253c4a5d11 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=98253c4a5d11
Modified Files:
configure.ag
tools/merovingian/ChangeLog
tools/merovingian/client/monetdb.c
tools/merovingian/daemon/.merovingian_properties.in
tools/merovingian/daemon/Makefile.ag
tools/merovingian/daemon/argvcmds.c
tools/merovingian/daemon/argvcmds.h
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/discoveryrunner.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/handlers.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/merovingian.h
tools/merovingian/daemon/monetdbd.1.in
tools/merovingian/daemon/peering.c
tools/merovingian/utils/properties.c
tools/merovingian/utils/properties.h
tools/merovingian/utils/utils.c
tools/merovingian/utils/utils.h
Branch: default
Log Message:
merovingian: implement dbfarm oriented mode of operation
Too many changes to list precisely, a combination of cleanup, refinement
and making merovingian work with its own properties that can be set
using merovingian itself. This is all but completed yet, but this is
already an improvement over the current situation which is more broken
than the state of affairs of this patch.
This patch has some repercussions on other pieces of code, in particular
mapi and the monetdb client tool.
- extend confkeyval with an int version of the value for easy use with
numbers, add convenience wrappers for retrieving values for a key
- properly disable discoveryservice, as advertised in the manpage
- .merovingian_properties files are only used by merovingian these days,
a template that ensures backwards compatability for systemwide
installs is installed
- removed replacePrefix function as it is no longer necessary
- unix sockets are now placed in /tmp by default, and named
.s.monetdb.<tcpport> for mapi connections and .s.merovingian.<tcpport>
for control connections
- monetdbd now understands actions (like monetdb) 'create', 'start',
'stop', 'get' and 'set' that operate on a dbfarm directory
- logfile capabilities have been reduced, now only a single logfile can
be used, and logging to stdout/stderr is no longer possible
diffs (truncated from 2317 to 300 lines):
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2974,6 +2974,7 @@
QElocalstatedir="`echo "$Elocalstatedir" | sed 's/\\\\/\\\\\\\\/g'`"
AC_SUBST(Qlocalstatedir)
AC_SUBST(Xlocalstatedir)
+AC_SUBST(Elocalstatedir)
AC_SUBST(QXlocalstatedir)
Qlibdir="$libdir"
Xlibdir="`$translatepath "$libdir"`"
@@ -2990,7 +2991,8 @@
Qbindir="$bindir"
Xbindir="`$translatepath "$bindir"`"
QXbindir="`echo "$Xbindir" | sed 's/\\\\/\\\\\\\\/g'`"
-eval "Ebindir=${Xbindir}"
+Ebindir="`echo "$Xbindir" | sed 's/{exec_prefix}/{prefix}/'`"
+eval "Ebindir=${Ebindir}"
QEbindir="`echo "$Ebindir" | sed 's/\\\\/\\\\\\\\/g'`"
AC_SUBST(Qbindir)
AC_SUBST(Xbindir)
@@ -3049,8 +3051,6 @@
AC_SUBST(QXSOURCE)
AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$QElocalstatedir",[modifiable single-machine
data])
AC_DEFINE_UNQUOTED(BINDIR,"$QEbindir",[location where binaries are installed])
-AC_SUBST([MERO_LOG], [${Elocalstatedir}/log/monetdb/merovingian.log])
-AC_DEFINE_UNQUOTED([MERO_LOG],
["${Elocalstatedir}/log/monetdb/merovingian.log"], [where Merovingian will
store its logs by default])
dnl On Solaris, libxml2 enables threading only when _REENTRANT, __MT__
dnl or _POSIX_C_SOURCE >= 199506L is defined. The latter is only
diff --git a/tools/merovingian/ChangeLog b/tools/merovingian/ChangeLog
--- a/tools/merovingian/ChangeLog
+++ b/tools/merovingian/ChangeLog
@@ -1,3 +1,17 @@
# ChangeLog file for sql/src/backends/monet5/merovingian
# This file is updated with mchangelog
+* Tue Feb 15 2011 Fabian Groffen <[email protected]>
+- monetdbd can no longer log error and normal messages to separate
+ logfiles, logging to stdout and stderr is no longer possible either.
+- The .merovingian_pass file is no longer in use, and replaced by the
+ .merovingian_properties file. Use monetdbd (get|set) passphrase to
+ view/edit the control passphrase. Existing .merovingian_pass files
+ will automatically be migrated upon startup of monetdbd.
+- monetdbd now understands commands that allow to create, start, stop,
+ get and set properties on a given dbfarm. This behaviour is intended
+ as primary way to start a MonetDB Database Server, on a given location
+ of choice. monetdbd get and set are the replacement of editing the
+ monetdb5.conf file (which is no longer in use as of the Apr2011
+ release). See monetdbd(1).
+
diff --git a/tools/merovingian/client/monetdb.c
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -983,7 +983,6 @@
char property[24] = "";
int i;
int state = 0;
- confkeyval *props = getDefaultProps();
char *res;
char *out;
sabdb *orig = NULL;
@@ -1077,7 +1076,6 @@
free(res);
msab_freeStatus(&orig);
- free(props);
exit(state);
}
@@ -1097,7 +1095,6 @@
}
msab_freeStatus(&orig);
- free(props);
exit(state);
}
@@ -1153,9 +1150,7 @@
argv[i] = NULL;
if (strcmp(property, "all") == 0) {
size_t off = 0;
- /* die hard leak (can't use constant, strtok
modifies
- * (and hence crashes)) */
- property = malloc(sizeof(char) * 512);
+ property = alloca(sizeof(char) * 512);
kv = defprops;
off += snprintf(property, 512, "name");
while (kv->key != NULL) {
@@ -1359,12 +1354,12 @@
int i;
int fd;
confkeyval ckv[] = {
- {"gdk_dbfarm", strdup(LOCALSTATEDIR
"/monetdb5/dbfarm"), STR},
- {"gdk_nr_threads", NULL, INT},
- {"mero_doproxy", strdup("yes"), BOOL},
- {"mero_discoveryport", NULL, INT},
- {"#master", strdup("no"), BOOL},
- { NULL, NULL, INVALID}
+ {"gdk_dbfarm", strdup(LOCALSTATEDIR
"/monetdb5/dbfarm"), 0, STR},
+ {"gdk_nr_threads", NULL, 0, INT},
+ {"mero_doproxy", strdup("yes"), 1, BOOL},
+ {"mero_discoveryport", NULL, 0, INT},
+ {"#master", strdup("no"), 0, BOOL},
+ { NULL, NULL, 0, INVALID}
};
confkeyval *kv;
#ifdef TIOCGWINSZ
@@ -1392,7 +1387,7 @@
prefix = kv->val;
kv = findConfKey(ckv, "gdk_dbfarm");
- dbfarm = replacePrefix(kv->val, prefix);
+ dbfarm = kv->val;
if (dbfarm == NULL) {
fprintf(stderr, "%s: cannot find gdk_dbfarm in config file\n",
argv[0]);
exit(2);
diff --git a/tools/merovingian/daemon/.merovingian_properties.in
b/tools/merovingian/daemon/.merovingian_properties.in
new file mode 100644
--- /dev/null
+++ b/tools/merovingian/daemon/.merovingian_properties.in
@@ -0,0 +1,28 @@
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+# Copyright August 2008-2011 MonetDB B.V.
+# All Rights Reserved.
+
+
+# DO NOT EDIT THIS FILE - use monetdbd(1) to set these properties
+
+# This file is used by monetdbd and contains defaults for a system-wide
+# installation of the MonetDB Database Server. This file is a mere
+# template, and will get overwritten as soon as monetdbd is started. It
+# is, however, crucial that the file locations in this file are present.
+
+
+logfile=@Elocalstatedir@@DIRSEP@log@DIRSEP@monetdb@[email protected]
+pidfile=@Elocalstatedir@@DIRSEP@run@DIRSEP@monetdb@[email protected]
diff --git a/tools/merovingian/daemon/Makefile.ag
b/tools/merovingian/daemon/Makefile.ag
--- a/tools/merovingian/daemon/Makefile.ag
+++ b/tools/merovingian/daemon/Makefile.ag
@@ -22,7 +22,7 @@
monetdb_var_rundir = $(localstatedir)/run/monetdb
monetdb_var_run_DATA =
monetdb_var_dbfarmdir = $(localstatedir)/monetdb5/dbfarm
-monetdb_var_dbfarm_DATA =
+monetdb_var_dbfarm_DATA = .merovingian_properties
# MONETDB5: Sabaoth
INCLUDES = .. \
@@ -31,8 +31,9 @@
../../../common/utils \
../../../clients/mapilib
-EXTRA_DIST = $(man_MANS) \
+EXTRA_DIST = $(man_MANS) .merovingian_properties \
merovingian.h \
+ argvcmds.h \
client.h \
connections.h \
controlrunner.h \
@@ -44,9 +45,11 @@
proxy.h
bin_monetdbd = {
- # hack: include merovingian.1.in here to get it expanded
- SOURCES = monetdbd.1.in \
+ # hack: include monetdbd.1.in and .merovingian_properties.in here to
+ # get them expanded
+ SOURCES = monetdbd.1.in .merovingian_properties.in \
merovingian.c \
+ argvcmds.c \
client.c \
connections.c \
controlrunner.c \
diff --git a/tools/merovingian/daemon/argvcmds.c
b/tools/merovingian/daemon/argvcmds.c
new file mode 100644
--- /dev/null
+++ b/tools/merovingian/daemon/argvcmds.c
@@ -0,0 +1,354 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#include "monetdb_config.h"
+#include <stdio.h>
+#include <unistd.h> /* chdir */
+#include <string.h> /* strerror */
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h> /* kill */
+
+#include <utils/utils.h>
+#include <utils/properties.h>
+
+#include "merovingian.h"
+
+int
+command_help(int argc, char *argv[])
+{
+ int exitcode = 0;
+
+ if (argc < 2) {
+ printf("usage: monetdbd [ command [ command-options ] ]\n");
+ printf(" where command is one of:\n");
+ printf(" create, start, stop, get, set, version or help\n");
+ printf(" use the help command to get help for a particular
command\n");
+ printf(" For backwards compatability, when monetdbd is ran
without\n");
+ printf(" options, it will start the daemon in the default
dbfarm\n");
+ printf(" location (%s).\n", LOCALSTATEDIR "/monetdb5/dbfarm");
+ } else if (strcmp(argv[1], "create") == 0) {
+ printf("usage: monetdbd create <dbfarm>\n");
+ printf(" Initialises a new dbfarm for a MonetDB Server.
dbfarm\n");
+ printf(" must be a path in the filesystem where a directory
can be\n");
+ printf(" created, or a directory that is writable that already
exists.\n");
+ } else if (strcmp(argv[1], "start") == 0) {
+ printf("usage: monetdbd start [dbfarm]\n");
+ printf(" Starts the monetdbd deamon. When no dbfarm given, it
starts\n");
+ printf(" in the default dbfarm (%s).\n", LOCALSTATEDIR
"/monetdb5/dbfarm");
+ } else if (strcmp(argv[1], "stop") == 0) {
+ printf("usage: monetdbd stop [dbfarm]\n");
+ printf(" Stops a running monetdbd deamon for the given dbfarm,
or\n");
+ printf(" when none given, the default one (%s).\n",
LOCALSTATEDIR "/monetdb5/dbfarm");
+ } else if (strcmp(argv[1], "set") == 0) {
+ printf("usage: monetdbd set property=value [dbfarm]\n");
+ printf(" Sets property to value for the given dbfarm, or
when\n");
+ printf(" absent, the default (%s).\n", LOCALSTATEDIR
"/monetdb5/dbfarm");
+ printf(" For a list of properties, use `monetdbd get all`\n");
+ } else if (strcmp(argv[1], "get") == 0) {
+ printf("usage: monetdbd get <\"all\" | property,...>
[dbfarm]\n");
+ printf(" Gets value for property for the given dbfarm, or\n");
+ printf(" retrieves all properties for the given dbfarm\n");
+ } else {
+ printf("help: unknown command: %s\n", argv[1]);
+ exitcode = 1;
+ }
+
+ return(exitcode);
+}
+
+int
+command_version(void)
+{
+ printf("MonetDB Database Server v%s (%s)\n",
+ MERO_VERSION, MONETDB_RELEASE);
+ return(0);
+}
+
+int
+command_create(int argc, char *argv[])
+{
+ char path[2048];
+ char buf[48];
+ char *p;
+ char *dbfarm;
+ struct stat sb;
+ confkeyval phrase[2];
+
+ if (argc != 2) {
+ command_help(2, &argv[-1]);
+ return(1);
+ }
+
+ dbfarm = argv[1];
+
+ /* check if dbfarm actually exists */
+ if (stat(dbfarm, &sb) == -1) {
+ strncpy(path, dbfarm, sizeof(path) - 1);
+ path[sizeof(path) - 1] = '\0';
+ p = path;
+ /* try to create the dbfarm */
+ while ((p = strchr(p + 1, '/')) != NULL) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list