diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-25 01:49:19 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-25 01:49:19 +0000 |
commit | dc15dc32bb3348c760ba3643c083af7e0c8e43fe (patch) | |
tree | 2823b9165d5c3a8a1bc96b3d071f86101bb995b4 /sandbox/sebastien/cpp/apr-2/components/log | |
parent | 088b2e47386078c79781a448e0b6e458ddaae23c (diff) |
Create a sandbox branch to experiment with latest APR.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1052740 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/sebastien/cpp/apr-2/components/log')
23 files changed, 1342 insertions, 0 deletions
diff --git a/sandbox/sebastien/cpp/apr-2/components/log/Makefile.am b/sandbox/sebastien/cpp/apr-2/components/log/Makefile.am new file mode 100644 index 0000000000..c53230b23f --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/Makefile.am @@ -0,0 +1,76 @@ +# 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. + +if WANT_LOG + +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-tail-start scribe-tail-stop +compdir=$(prefix)/components/log + +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 log.componentType logger.componentType *.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 + ${THRIFT_PREFIX}/bin/thrift -r --gen cpp scribe.thrift + +CLEANFILES = gen-cpp/* + +comp_LTLIBRARIES = liblog.la liblogger.la +noinst_DATA = liblog.so liblogger.so + +CXXFLAGS = ${DEFAULT_CXXFLAGS} -Wno-unused-parameter -Wno-conversion + +nodist_liblog_la_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 +liblog_la_CXXFLAGS = -Wno-unused-parameter -Wno-conversion +liblog_la_SOURCES = log.cpp +liblog_la_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -R${FB303_LIB} -lfb303 -L${SCRIBE_LIB} -R${SCRIBE_LIB} -lscribe +liblog.so: + ln -s .libs/liblog.so + +nodist_liblogger_la_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 +liblogger_la_CXXFLAGS = -Wno-unused-parameter -Wno-conversion +liblogger_la_SOURCES = logger.cpp +liblogger_la_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -R${FB303_LIB} -lfb303 -L${SCRIBE_LIB} -R${SCRIBE_LIB} -lscribe +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 -Wno-conversion +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 + +dist_noinst_SCRIPTS = scribe-test server-test +noinst_PROGRAMS = client-test +TESTS = scribe-test server-test + +endif diff --git a/sandbox/sebastien/cpp/apr-2/components/log/adder-test.scm b/sandbox/sebastien/cpp/apr-2/components/log/adder-test.scm new file mode 100644 index 0000000000..ccd5bc555f --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/adder-test.scm @@ -0,0 +1,20 @@ +; 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. + +; Logger test case + +(define (add a b) (+ a b)) diff --git a/sandbox/sebastien/cpp/apr-2/components/log/client-test.cpp b/sandbox/sebastien/cpp/apr-2/components/log/client-test.cpp new file mode 100644 index 0000000000..5f13f64ac1 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/client-test.cpp @@ -0,0 +1,107 @@ +/* + * 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$ */ + +/** + * Test log component. + */ + +#include <assert.h> +#include "stream.hpp" +#include "string.hpp" + +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "perf.hpp" +#include "../../modules/http/http.hpp" + +namespace tuscany { +namespace log { + +const string uri("http://localhost:8090/log"); + +bool testLog() { + http::CURLSession cs("", "", ""); + + const list<value> i = list<value>() + + (list<value>() + "name" + string("Apple")) + + (list<value>() + "price" + string("$2.99")); + const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); + + const failable<value> id = http::post(a, uri, cs); + assert(hasContent(id)); + + return true; +} + +struct logLoop { + const value a; + const string uri; + http::CURLSession cs; + logLoop(const value& a, const string& uri, http::CURLSession cs) : a(a), uri(uri), cs(cs) { + } + const bool operator()() const { + const failable<value> id = http::post(a, uri, cs); + assert(hasContent(id)); + return true; + } +}; + +bool testLogPerf() { + const list<value> i = list<value>() + + (list<value>() + "name" + string("Apple")) + + (list<value>() + "price" + string("$2.99")); + const value a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); + + http::CURLSession cs("", "", ""); + const failable<value> id = http::post(a, uri, cs); + assert(hasContent(id)); + + const lambda<bool()> ll = logLoop(a, uri, cs); + cout << "Log test " << time(ll, 5, 200) << " ms" << endl; + + return true; +} + +bool testLogger() { + http::CURLSession cs("", "", ""); + + const failable<value> res = http::evalExpr(mklist<value>(string("sum"), 33, 22), string("http://localhost:8090/client"), cs); + assert(hasContent(res)); + assert((int)content(res) == 55); + + return true; +} + +} +} + +int main() { + tuscany::cout << "Testing..." << tuscany::endl; + + tuscany::log::testLog(); + tuscany::log::testLogPerf(); + tuscany::log::testLogger(); + + tuscany::cout << "OK" << tuscany::endl; + + return 0; +} diff --git a/sandbox/sebastien/cpp/apr-2/components/log/client-test.scm b/sandbox/sebastien/cpp/apr-2/components/log/client-test.scm new file mode 100644 index 0000000000..1da6ca3564 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/client-test.scm @@ -0,0 +1,20 @@ +; 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. + +; Logger test case + +(define (sum a b adder) (adder "add" a b)) diff --git a/sandbox/sebastien/cpp/apr-2/components/log/fb303.thrift b/sandbox/sebastien/cpp/apr-2/components/log/fb303.thrift new file mode 100644 index 0000000000..66c8315274 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/fb303.thrift @@ -0,0 +1,112 @@ +/* + * 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. + */ + +/** + * fb303.thrift + */ + +namespace java com.facebook.fb303 +namespace cpp facebook.fb303 +namespace perl Facebook.FB303 + +/** + * Common status reporting mechanism across all services + */ +enum fb_status { + DEAD = 0, + STARTING = 1, + ALIVE = 2, + STOPPING = 3, + STOPPED = 4, + WARNING = 5, +} + +/** + * Standard base service + */ +service FacebookService { + + /** + * Returns a descriptive name of the service + */ + string getName(), + + /** + * Returns the version of the service + */ + string getVersion(), + + /** + * Gets the status of this service + */ + fb_status getStatus(), + + /** + * User friendly description of status, such as why the service is in + * the dead or warning state, or what is being started or stopped. + */ + string getStatusDetails(), + + /** + * Gets the counters for this service + */ + map<string, i64> getCounters(), + + /** + * Gets the value of a single counter + */ + i64 getCounter(1: string key), + + /** + * Sets an option + */ + void setOption(1: string key, 2: string value), + + /** + * Gets an option + */ + string getOption(1: string key), + + /** + * Gets all options + */ + map<string, string> getOptions(), + + /** + * Returns a CPU profile over the given time interval (client and server + * must agree on the profile format). + */ + string getCpuProfile(1: i32 profileDurationInSec), + + /** + * Returns the unix time that the server has been running since + */ + i64 aliveSince(), + + /** + * Tell the server to reload its configuration, reopen log files, etc + */ + oneway void reinitialize(), + + /** + * Suggest a shutdown to the server + */ + oneway void shutdown(), + +} diff --git a/sandbox/sebastien/cpp/apr-2/components/log/log.componentType b/sandbox/sebastien/cpp/apr-2/components/log/log.componentType new file mode 100644 index 0000000000..e661f568f1 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/log.componentType @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components"> + + <service name="log"/> + <property name="category" type="xsd:string">default</property> + +</composite> diff --git a/sandbox/sebastien/cpp/apr-2/components/log/log.composite b/sandbox/sebastien/cpp/apr-2/components/log/log.composite new file mode 100644 index 0000000000..3e13c410fa --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/log.composite @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components" + name="log"> + + <component name="log"> + <implementation.cpp path="." library="liblog"/> + <property name="category">default</property> + <service name="log"> + <t:binding.http uri="log"/> + </service> + </component> + + <component name="client"> + <implementation.scheme script="client-test.scm"/> + <service name="client"> + <t:binding.http uri="client"/> + </service> + <reference name="adder" target="logger"/> + </component> + + <component name="logger"> + <implementation.cpp path="." library="liblogger"/> + <property name="category">default</property> + <service name="logger"> + <t:binding.http uri="logger"/> + </service> + <reference name="relay" target="adder"/> + </component> + + <component name="adder"> + <implementation.scheme script="adder-test.scm"/> + <service name="adder"> + <t:binding.http uri="adder"/> + </service> + </component> + +</composite> diff --git a/sandbox/sebastien/cpp/apr-2/components/log/log.cpp b/sandbox/sebastien/cpp/apr-2/components/log/log.cpp new file mode 100644 index 0000000000..24a5844c45 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/log.cpp @@ -0,0 +1,94 @@ +/* + * 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$ */ + +/** + * Scribe-based log component implementation. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "scribe.hpp" + +namespace tuscany { +namespace log { + +/** + * Post an item to the Scribe log. + */ +const failable<value> post(const list<value>& params, const value& category, scribe::Scribe& sc) { + debug(cadr(params), "log::post::value"); + const failable<bool> val = scribe::log(cadr(params), category, sc); + if (!hasContent(val)) + return mkfailure<value>(reason(val)); + return value(mklist<value>(true)); +} + +/** + * Component implementation lambda function. + */ +class applyLog { +public: + applyLog(const value& category, scribe::Scribe& sc) : category(category), sc(sc) { + } + + const value operator()(const list<value>& params) const { + const value func(car(params)); + if (func == "post") + return post(cdr(params), category, sc); + return tuscany::mkfailure<tuscany::value>(); + } + +private: + const value category; + scribe::Scribe& sc; +}; + +/** + * Start the component. + */ +const failable<value> start(unused const list<value>& params) { + // Connect to Scribe + scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464)); + + // Extract the configured category + const value category = ((lambda<value(list<value>)>)car(params))(list<value>()); + debug(category, "log::start::category"); + + // Return the component implementation lambda function + return value(lambda<value(const list<value>&)>(applyLog(category, sc))); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list<tuscany::value>& params) { + const tuscany::value func(car(params)); + if (func == "start") + return tuscany::log::start(cdr(params)); + return tuscany::mkfailure<tuscany::value>(); +} + +} diff --git a/sandbox/sebastien/cpp/apr-2/components/log/logger.componentType b/sandbox/sebastien/cpp/apr-2/components/log/logger.componentType new file mode 100644 index 0000000000..1c9546e685 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/logger.componentType @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components"> + + <service name="logger"/> + <reference name="relay"/> + <property name="category" type="xsd:string">default</property> + +</composite> diff --git a/sandbox/sebastien/cpp/apr-2/components/log/logger.cpp b/sandbox/sebastien/cpp/apr-2/components/log/logger.cpp new file mode 100644 index 0000000000..e1f4712d61 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/logger.cpp @@ -0,0 +1,92 @@ +/* + * 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$ */ + +/** + * Scribe-based logger component implementation, used to intercept + * and log service invocations. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "scribe.hpp" + +namespace tuscany { +namespace logger { + +/** + * Component implementation lambda function. + */ +class applyLog { +public: + applyLog(const lambda<value(const list<value>&)>& relay, const value& category, scribe::Scribe& sc) : relay(relay), category(category), sc(sc) { + } + + const value operator()(const list<value>& params) const { + // Log the function params + debug(params, "logger::apply::params"); + scribe::log(params, category, sc); + + // Relay the function + const failable<value> res = relay(params); + + // Log the result + scribe::log(res, category, sc); + return res; + } + +private: + const lambda<value(const list<value>&)> relay; + const value category; + scribe::Scribe& sc; +}; + +/** + * Start the component. + */ +const failable<value> start(unused const list<value>& params) { + // Connect to Scribe + scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464)); + + // Extract the configured relay service and category + const value rel = car(params); + const value category = ((lambda<value(list<value>)>)cadr(params))(list<value>()); + debug(category, "logger::start::category"); + + // Return the component implementation lambda function + return value(lambda<value(const list<value>&)>(applyLog(rel, category, sc))); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list<tuscany::value>& params) { + const tuscany::value func(car(params)); + if (func == "start") + return tuscany::logger::start(cdr(params)); + return tuscany::mkfailure<tuscany::value>(); +} + +} diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribe-cat.cpp b/sandbox/sebastien/cpp/apr-2/components/log/scribe-cat.cpp new file mode 100644 index 0000000000..f3c5e898cd --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/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/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-start b/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-start new file mode 100755 index 0000000000..0044f1620d --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-start @@ -0,0 +1,44 @@ +#!/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 +# 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. + +# Tail a file and pipe into scribe-cat +here=`readlink -f $0`; here=`dirname $here` + +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 + +mkdir -p `dirname $file` +touch $file +file=`readlink -f $file` + +tail -f -n 0 $file | $here/scribe-cat $category $type & + diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-stop b/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-stop new file mode 100755 index 0000000000..e1b74fc0c6 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribe-tail-stop @@ -0,0 +1,42 @@ +#!/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 +# 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. + +# Stop tailing a file +here=`readlink -f $0`; here=`dirname $here` + +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` + +cmd="tail -f -n 0 $file" +kill `ps -ef | grep -v grep | grep "${cmd}" | awk '{ print $2 }'` + diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribe-test b/sandbox/sebastien/cpp/apr-2/components/log/scribe-test new file mode 100755 index 0000000000..a355026dd0 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribe-test @@ -0,0 +1,43 @@ +#!/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 +# 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. + +echo "Testing..." + +# Setup +rm -rf tmp +./scribed-central-conf tmp +./scribed-client-conf tmp localhost +./scribed-central-start tmp +./scribed-client-start tmp +sleep 1 + +# Test logging a message +echo test | ./scribe-cat >/dev/null +sleep 4 +grep test tmp/scribe/logs/central/default/default_current >/dev/null +rc=$? + +# Cleanup +./scribed-client-stop tmp +./scribed-central-stop tmp +sleep 1 +if [ "$rc" = "0" ]; then + echo "OK" +fi +return $rc diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribe.hpp b/sandbox/sebastien/cpp/apr-2/components/log/scribe.hpp new file mode 100644 index 0000000000..5237bd0183 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribe.hpp @@ -0,0 +1,147 @@ +/* + * 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$ */ + +#ifndef tuscany_scribe_hpp +#define tuscany_scribe_hpp + +/** + * Scribe logging functions. + */ + +// Work around redundant defines in Scribe headers +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef VERSION + +// Ignore integer conversion issues in Thrift and Scribe headers +#ifdef WANT_MAINTAINER_MODE +#pragma GCC diagnostic ignored "-Wconversion" +#endif + +#include <protocol/TBinaryProtocol.h> +#include <transport/TSocket.h> +#include <transport/TTransportUtils.h> + +#include "gen-cpp/scribe.h" + +#ifdef WANT_MAINTAINER_MODE +#pragma GCC diagnostic warning "-Wconversion" +#endif + +#include "string.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "../../modules/scheme/eval.hpp" + +namespace tuscany { +namespace scribe { + +/** + * Represents a Scribe connection. + */ +class Scribe { +public: + Scribe() : owner(false) { + } + + Scribe(const string host, const int port) : owner(true) { + init(host, port); + } + + Scribe(const Scribe& c) : owner(false) { + client = c.client; + transport = c.transport; + } + + ~Scribe() { + if (!owner) + return; + try { + transport->close(); + delete client; + } catch (const std::exception& e) { + mkfailure<bool>(e.what()); + } + } + +private: + bool owner; + ::scribe::thrift::scribeClient* client; + boost::shared_ptr<apache::thrift::transport::TTransport> transport; + + friend const failable<bool> log(const value& val, const value& category, const Scribe& sc); + + /** + * Initialize the Scribe connection. + */ + const failable<bool> init(const string& host, const int port) { + try { + boost::shared_ptr<apache::thrift::transport::TTransport> sock(new apache::thrift::transport::TSocket(c_str(host), port)); + boost::shared_ptr<apache::thrift::transport::TFramedTransport> framedSock(new apache::thrift::transport::TFramedTransport(sock)); + transport = framedSock; + boost::shared_ptr<apache::thrift::protocol::TProtocol> proto(new apache::thrift::protocol::TBinaryProtocol(transport)); + client = new ::scribe::thrift::scribeClient(proto); + transport->open(); + return true; + } catch (const std::exception& e) { + return mkfailure<bool>(e.what()); + } + } +}; + +/** + * Log an item. + */ +const failable<bool> log(const value& val, const value& category, const Scribe& sc) { + debug(val, "scribe::log::value"); + debug(category, "scribe::log::category"); + + const value cat = isString(category)? value(c_str(category)):category; + const string cs(scheme::writeValue(cat)); + const string vs(scheme::writeValue(val)); + + try { + ::scribe::thrift::LogEntry entry; + entry.category = c_str(cs); + entry.message = c_str(vs); + std::vector< ::scribe::thrift::LogEntry> msgs; + msgs.push_back(entry); + + int result = sc.client->Log(msgs); + if (result != ::scribe::thrift::OK) + return mkfailure<bool>("Could not log value, retry later"); + } catch (const std::exception& e) { + return mkfailure<bool>(e.what()); + } + + debug(true, "scribe::log::result"); + return true; +} + +} +} + +#endif /* tuscany_scribe_hpp */ diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribe.thrift b/sandbox/sebastien/cpp/apr-2/components/log/scribe.thrift new file mode 100644 index 0000000000..592e8b630e --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribe.thrift @@ -0,0 +1,39 @@ +#!/usr/local/bin/thrift --cpp --php + +## Copyright (c) 2007-2008 Facebook +## +## Licensed 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. +## +## See accompanying file LICENSE or visit the Scribe site at: +## http://developers.facebook.com/scribe/ + +include "fb303.thrift" + +namespace cpp scribe.thrift + +enum ResultCode +{ + OK, + TRY_LATER +} + +struct LogEntry +{ + 1: string category, + 2: string message +} + +service scribe extends fb303.FacebookService +{ + ResultCode Log(1: list<LogEntry> messages); +} diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-conf b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-conf new file mode 100755 index 0000000000..b23646c24f --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-conf @@ -0,0 +1,73 @@ +#!/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 +# 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. + +# Generate a Scribe central conf +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 + +cat >$root/scribe/conf/scribe-central.conf <<EOF +# Generated by: scribed-central-conf $* +# Scribe central configuration +port=$port +max_msg_per_second=2000000 +check_interval=3 + +# Log store configuration +<store> +category=default +type=buffer + +target_write_size=20480 +max_write_interval=1 +buffer_send_rate=2 +retry_interval=30 +retry_interval_range=10 + +<primary> +type=file +fs_type=std +file_path=$root/scribe/logs/central +base_filename=central +max_size=1000000 +add_newlines=1 +rotate_period=daily +rotate_hour=0 +rotate_minute=10 +</primary> + +<secondary> +type=file +fs_type=std +file_path=$root/scribe/logs/central-secondary +base_filename=central +max_size=3000000 +</secondary> + +</store> +EOF diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-start b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-start new file mode 100755 index 0000000000..c2035037de --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-start @@ -0,0 +1,27 @@ +#!/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 +# 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. + +# Start central scribed +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +scribe_prefix=`cat $here/scribe.prefix` +thrift_prefix=`cat $here/thrift.prefix` +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${thrift_prefix}/lib:${thrift_prefix}/contrib/fb303/lib:${scribe_prefix}/lib +$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-central.conf 1>$root/scribe/logs/central.log 2>&1 & diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-stop b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-stop new file mode 100755 index 0000000000..95a976813f --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-central-stop @@ -0,0 +1,28 @@ +#!/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 +# 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. + +# Stop central scribed +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +scribe_prefix=`cat $here/scribe.prefix` +thrift_prefix=`cat $here/thrift.prefix` +scribed="$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-central.conf" + +kill `ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'` diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-conf b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-conf new file mode 100755 index 0000000000..87c8749c2e --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-conf @@ -0,0 +1,67 @@ +#!/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 +# 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. + +# Generate a Scribe client conf +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 + +cat >$root/scribe/conf/scribe-client.conf <<EOF +# Generated by: scribed-client-conf $* +# Scribe client configuration +port=1464 +max_msg_per_second=2000000 +check_interval=3 + +# Forward all messages to central Scribe on port 1463 +# Save them locally as well +<store> +category=default +type=buffer + +target_write_size=20480 +max_write_interval=1 +buffer_send_rate=1 +retry_interval=30 +retry_interval_range=10 + +<primary> +type=network +remote_host=$central +remote_port=$cport +</primary> + +<secondary> +type=file +fs_type=std +file_path=$root/scribe/logs/client-secondary +base_filename=client +max_size=3000000 +</secondary> +</store> +EOF diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-start b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-start new file mode 100755 index 0000000000..ed8636d7f2 --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-start @@ -0,0 +1,27 @@ +#!/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 +# 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. + +# Start client scribed +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +scribe_prefix=`cat $here/scribe.prefix` +thrift_prefix=`cat $here/thrift.prefix` +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${thrift_prefix}/lib:${thrift_prefix}/contrib/fb303/lib:${scribe_prefix}/lib +$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-client.conf 1>$root/scribe/logs/client.log 2>&1 & diff --git a/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-stop b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-stop new file mode 100755 index 0000000000..2e8959fbfc --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/scribed-client-stop @@ -0,0 +1,28 @@ +#!/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 +# 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. + +# Stop client scribed +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +scribe_prefix=`cat $here/scribe.prefix` +thrift_prefix=`cat $here/thrift.prefix` +scribed="$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-client.conf" + +kill `ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'` diff --git a/sandbox/sebastien/cpp/apr-2/components/log/server-test b/sandbox/sebastien/cpp/apr-2/components/log/server-test new file mode 100755 index 0000000000..631487c77a --- /dev/null +++ b/sandbox/sebastien/cpp/apr-2/components/log/server-test @@ -0,0 +1,65 @@ +#!/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 +# 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. + +# Setup +../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs +../../modules/server/server-conf tmp +../../modules/server/scheme-conf tmp +cat >>tmp/conf/httpd.conf <<EOF +SCAContribution `pwd`/ +SCAComposite log.composite +EOF + +rm -rf tmp/scribe +./scribed-central-conf tmp +./scribed-client-conf tmp localhost +./scribed-central-start tmp +./scribed-client-start tmp +sleep 1 +../../modules/http/httpd-start tmp +sleep 2 + +# Test +./client-test 2>/dev/null +rc=$? +if [ "$rc" = "0" ]; then + echo "Testing..." + sleep 4 + grep "Apple" tmp/scribe/logs/central/default/default_current >/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + grep "(add 33 22)" tmp/scribe/logs/central/default/default_current >/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + grep "55" tmp/scribe/logs/central/default/default_current >/dev/null + rc=$? +fi + +# Cleanup +../../modules/http/httpd-stop tmp +sleep 1 +./scribed-client-stop tmp +./scribed-central-stop tmp +sleep 1 +if [ "$rc" = "0" ]; then + echo "OK" +fi +return $rc |