summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-19 04:10:43 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-19 04:10:43 +0000
commit768a1e33e56c579edbcab1d4ea73d06b85cdd06c (patch)
tree5ea1f2c67ad34a17155c221711df7eff010034d2 /sca-cpp/trunk/components
parentd4184f1ab86fd589126f3de2ed9fa433cf1b54b2 (diff)
Script fixes to get database working with the HTTPS-enabled store-cluster sample configuration. Also some logging improvements and aggregation of the sample logs using scribe.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@987012 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/components')
-rw-r--r--sca-cpp/trunk/components/log/Makefile.am13
-rw-r--r--sca-cpp/trunk/components/log/scribe-cat.cpp77
-rwxr-xr-xsca-cpp/trunk/components/log/scribe-tail-start (renamed from sca-cpp/trunk/components/log/scribe-cat)30
-rwxr-xr-x[-rw-r--r--]sca-cpp/trunk/components/log/scribe-tail-stop (renamed from sca-cpp/trunk/components/log/scribecat.py)46
-rwxr-xr-xsca-cpp/trunk/components/log/scribe-test2
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-central-conf7
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-client-conf9
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-standby-conf24
-rwxr-xr-xsca-cpp/trunk/components/sqldb/standby-test2
9 files changed, 157 insertions, 53 deletions
diff --git a/sca-cpp/trunk/components/log/Makefile.am b/sca-cpp/trunk/components/log/Makefile.am
index 0408607b59..614a13bcc5 100644
--- a/sca-cpp/trunk/components/log/Makefile.am
+++ b/sca-cpp/trunk/components/log/Makefile.am
@@ -22,17 +22,17 @@ INCLUDES = -I${THRIFT_INCLUDE} -I${FB303_INCLUDE}
incl_HEADERS = *.hpp
incldir = $(prefix)/include/components/log
-dist_comp_SCRIPTS = scribed-central-conf scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-cat
+dist_comp_SCRIPTS = scribed-central-conf scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-tail-start scribe-tail-stop
compdir=$(prefix)/components/log
-comp_DATA = scribe.prefix thrift.prefix scribecat.py
+comp_DATA = scribe.prefix thrift.prefix
scribe.prefix: $(top_builddir)/config.status
echo ${SCRIBE_PREFIX} >scribe.prefix
thrift.prefix: $(top_builddir)/config.status
echo ${THRIFT_PREFIX} >thrift.prefix
-EXTRA_DIST = log.composite *.py *.scm *.thrift
+EXTRA_DIST = log.composite *.scm *.thrift
BUILT_SOURCES=gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h
gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h: scribe.thrift
@@ -57,6 +57,13 @@ liblogger_la_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -
liblogger.so:
ln -s .libs/liblogger.so
+comp_PROGRAMS = scribe-cat
+
+nodist_scribe_cat_SOURCES = gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h
+scribe_cat_CXXFLAGS = -Wno-unused-parameter
+scribe_cat_SOURCES = scribe-cat.cpp
+scribe_cat_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -R${FB303_LIB} -lfb303 -L${SCRIBE_LIB} -R${SCRIBE_LIB} -lscribe
+
client_test_SOURCES = client-test.cpp
client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
diff --git a/sca-cpp/trunk/components/log/scribe-cat.cpp b/sca-cpp/trunk/components/log/scribe-cat.cpp
new file mode 100644
index 0000000000..f3c5e898cd
--- /dev/null
+++ b/sca-cpp/trunk/components/log/scribe-cat.cpp
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * A utility that logs stdin into a scribe log.
+ */
+
+#include "string.hpp"
+#include "function.hpp"
+#include "list.hpp"
+#include "value.hpp"
+#include "monad.hpp"
+
+#undef debug
+#define debug(...)
+#include "scribe.hpp"
+
+namespace tuscany {
+namespace scribecat {
+
+int cat(const string& category, const string& type) {
+ // Connect to Scribe
+ scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
+
+ // Read lines from stdin and log them
+ char buf[8192];
+ for (;;) {
+ const char* s = fgets(buf, 8192, stdin);
+ if (s == NULL)
+ return 0;
+ const int l = strlen(s);
+ if (l < 2)
+ return 0;
+ buf[l - 1] = '\0';
+
+ // Log each line as is
+ if (length(type) == 0) {
+ const failable<bool> val = scribe::log(buf, category, sc);
+ if (!hasContent(val))
+ return 1;
+ continue;
+ }
+
+ // Log each line prefixed with time and a type tag
+ ostringstream os;
+ os << "[" << logTime() << "] [" << type << "] " << buf;
+ const failable<bool> val = scribe::log(c_str(str(os)), category, sc);
+ if (!hasContent(val))
+ return 1;
+ }
+}
+
+}
+}
+
+int main(const int argc, const char** argv) {
+ return tuscany::scribecat::cat(argc < 2? "default" : argv[1], argc < 3? "" : argv[2]);
+}
+
diff --git a/sca-cpp/trunk/components/log/scribe-cat b/sca-cpp/trunk/components/log/scribe-tail-start
index 812e7e7a54..0044f1620d 100755
--- a/sca-cpp/trunk/components/log/scribe-cat
+++ b/sca-cpp/trunk/components/log/scribe-tail-start
@@ -17,16 +17,28 @@
# specific language governing permissions and limitations
# under the License.
-# Write messages to Scribe
+# Tail a file and pipe into scribe-cat
here=`readlink -f $0`; here=`dirname $here`
-category=$1
-if [ "$category" = "" ]; then
- category="default"
+
+category=""
+type=""
+file=""
+if [ "$3" != "" ]; then
+ category=$1
+ type=$2
+ file=$3
+else
+ if [ "$2" != "" ]; then
+ category=$1
+ file=$2
+ else
+ file=$1
+ fi
fi
-python_prefix=`cat $here/../../modules/python/python.prefix`
-scribe_prefix=`cat $here/scribe.prefix`
-thrift_prefix=`cat $here/thrift.prefix`
-export PYTHONPATH=$PYTHONPATH:${thrift_prefix}/lib/python2.6/site-packages:${thrift_prefix}/contrib/fb303/lib/python2.6/site-packages:${scribe_prefix}/lib/python2.6/site-packages
-$python_prefix/bin/python $here/scribecat.py $category
+mkdir -p `dirname $file`
+touch $file
+file=`readlink -f $file`
+
+tail -f -n 0 $file | $here/scribe-cat $category $type &
diff --git a/sca-cpp/trunk/components/log/scribecat.py b/sca-cpp/trunk/components/log/scribe-tail-stop
index b0fef42fbf..e1b74fc0c6 100644..100755
--- a/sca-cpp/trunk/components/log/scribecat.py
+++ b/sca-cpp/trunk/components/log/scribe-tail-stop
@@ -1,3 +1,5 @@
+#!/bin/sh
+
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -15,30 +17,26 @@
# specific language governing permissions and limitations
# under the License.
-# Write messages to Scribe
-
-import sys
-from scribe import scribe
-from thrift.transport import TTransport, TSocket
-from thrift.protocol import TBinaryProtocol
-
-category = sys.argv[1]
-host = 'localhost'
-port = 1464
+# Stop tailing a file
+here=`readlink -f $0`; here=`dirname $here`
-entry = scribe.LogEntry(category=category, message=sys.stdin.read())
-socket = TSocket.TSocket(host=host, port=port)
-transport = TTransport.TFramedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False)
-client = scribe.Client(iprot=protocol, oprot=protocol)
-transport.open()
-result = client.Log(messages=[entry])
-transport.close()
+category=""
+type=""
+file=""
+if [ "$3" != "" ]; then
+ category=$1
+ type=$2
+ file=$3
+else
+ if [ "$2" != "" ]; then
+ category=$1
+ file=$2
+ else
+ file=$1
+ fi
+fi
+file=`readlink -f $file`
-if result == scribe.ResultCode.OK:
- sys.exit()
-if result == scribe.ResultCode.TRY_LATER:
- print >> sys.stderr, "Try later"
- sys.exit(84)
-sys.exit(result)
+cmd="tail -f -n 0 $file"
+kill `ps -ef | grep -v grep | grep "${cmd}" | awk '{ print $2 }'`
diff --git a/sca-cpp/trunk/components/log/scribe-test b/sca-cpp/trunk/components/log/scribe-test
index 1c76b2eb58..a355026dd0 100755
--- a/sca-cpp/trunk/components/log/scribe-test
+++ b/sca-cpp/trunk/components/log/scribe-test
@@ -28,7 +28,7 @@ rm -rf tmp
sleep 1
# Test logging a message
-echo test | ./scribe-cat
+echo test | ./scribe-cat >/dev/null
sleep 4
grep test tmp/scribe/logs/central/default/default_current >/dev/null
rc=$?
diff --git a/sca-cpp/trunk/components/log/scribed-central-conf b/sca-cpp/trunk/components/log/scribed-central-conf
index 3bb9c29c85..b23646c24f 100755
--- a/sca-cpp/trunk/components/log/scribed-central-conf
+++ b/sca-cpp/trunk/components/log/scribed-central-conf
@@ -22,6 +22,11 @@ here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
+port=$2
+if [ "$port" = "" ]; then
+ port="1463"
+fi
+
mkdir -p $root/scribe/conf
mkdir -p $root/scribe/logs/central
mkdir -p $root/scribe/logs/central-secondary
@@ -29,7 +34,7 @@ mkdir -p $root/scribe/logs/central-secondary
cat >$root/scribe/conf/scribe-central.conf <<EOF
# Generated by: scribed-central-conf $*
# Scribe central configuration
-port=1463
+port=$port
max_msg_per_second=2000000
check_interval=3
diff --git a/sca-cpp/trunk/components/log/scribed-client-conf b/sca-cpp/trunk/components/log/scribed-client-conf
index 3300e4e5ec..87c8749c2e 100755
--- a/sca-cpp/trunk/components/log/scribed-client-conf
+++ b/sca-cpp/trunk/components/log/scribed-client-conf
@@ -21,7 +21,12 @@
here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
+
central=$2
+cport=$3
+if [ "$cport" = "" ]; then
+ cport="1463"
+fi
mkdir -p $root/scribe/conf
mkdir -p $root/scribe/logs/client-secondary
@@ -47,8 +52,8 @@ retry_interval_range=10
<primary>
type=network
-remote_host=$2
-remote_port=1463
+remote_host=$central
+remote_port=$cport
</primary>
<secondary>
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
index 3b4aa6dff5..cbfd90b48c 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
+++ b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
@@ -22,19 +22,8 @@ here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
-# Master server address
-if [ "$2" = "" ]; then
- mhost="localhost"
- mport="5432"
- mhttpport="80"
-else
- mhost="$2"
- mport="$3"
- mhttpport="$4"
-fi
-
# Server address
-addr=$5
+addr=$2
if [ "$addr" = "" ]; then
ip="*"
port="5432"
@@ -46,6 +35,17 @@ else
port=`$here/../../modules/http/httpd-addr port $addr`
fi
+# Master server address
+if [ "$3" = "" ]; then
+ mhost="localhost"
+ mport="5432"
+ mhttpport="80"
+else
+ mhost="$3"
+ mport="$4"
+ mhttpport="$5"
+fi
+
pgsql_prefix=`cat $here/pgsql.prefix`
mkdir -p $root/sqldb/data
chmod 700 $root/sqldb/data
diff --git a/sca-cpp/trunk/components/sqldb/standby-test b/sca-cpp/trunk/components/sqldb/standby-test
index e572de6fe2..9e56bfc039 100755
--- a/sca-cpp/trunk/components/sqldb/standby-test
+++ b/sca-cpp/trunk/components/sqldb/standby-test
@@ -25,7 +25,7 @@
./pgsql localhost 5432 "create table test(key text, value text);" 1>/dev/null 2>&1
../../modules/http/httpd-start tmp/master
sleep 2
-./pgsql-standby-conf tmp/standby localhost 5432 8090 5433
+./pgsql-standby-conf tmp/standby 5433 localhost 5432 8090
./pgsql-start tmp/standby
# Test