Brian Aker 13 лет назад
Родитель
Сommit
3d0d3be056
10 измененных файлов с 111 добавлено и 27 удалено
  1. 1 1
      bin/function.h
  2. 2 1
      bin/include.am
  3. 1 0
      configure.ac
  4. 1 0
      libtest/include.am
  5. 29 0
      m4/drizzled.m4
  6. 1 1
      tests/drizzle_test.cc
  7. 1 0
      util/instance.cc
  8. 1 0
      util/instance.hpp
  9. 72 0
      util/operation.cc
  10. 2 24
      util/operation.hpp

+ 1 - 1
bin/function.h

@@ -37,7 +37,7 @@
 
 #pragma once
 
-#include <iostream>
+#include <iosfwd>
 #include <vector>
 
 #include <libgearman/gearman.h>

+ 2 - 1
bin/include.am

@@ -25,7 +25,8 @@ bin_PROGRAMS+= \
 
 bin_gearadmin_SOURCES= \
 		       bin/gearadmin.cc \
-		       util/instance.cc
+		       util/instance.cc \
+		       util/operation.cc
 bin_gearadmin_CPPFLAGS= \
 			$(AM_CPPFLAGS) \
 			$(BOOST_CPPFLAGS)

+ 1 - 0
configure.ac

@@ -42,6 +42,7 @@ AM_CONDITIONAL(HAVE_LIBGEARMAN, true)
 WITH_LIBMEMCACHED
 WITH_MEMCACHED
 WITH_LIBDRIZZLE
+WITH_DRIZZLED
 
 PANDORA_REQUIRE_PTHREAD
 PANDORA_REQUIRE_LIBEVENT

+ 1 - 0
libtest/include.am

@@ -89,6 +89,7 @@ LIBTEST_LDADD+= libgearman/libgearman.la
 libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc
 libtest_libtest_la_SOURCES+= libtest/gearmand.cc
 libtest_libtest_la_SOURCES+= util/instance.cc
+libtest_libtest_la_SOURCES+= util/operation.cc
 endif
 
 libtest_tmp_dir: tests/var/log tests/var/tmp tests/var/run clearn-var

+ 29 - 0
m4/drizzled.m4

@@ -0,0 +1,29 @@
+AC_DEFUN([WITH_DRIZZLED],
+  [AC_ARG_WITH([drizzled],
+    [AS_HELP_STRING([--with-drizzled],
+      [Drizzled binary to use for make test])],
+    [ac_cv_with_drizzled="$withval"],
+    [ac_cv_with_drizzled=drizzled])
+
+  # Disable if --without-drizzled
+  # only used by make test
+  AS_IF([test "x$withval" = "xno"],
+    [
+      ac_cv_with_drizzled=
+      DRIZZLED_BINARY=
+    ],
+    [
+       AS_IF([test -f "$withval"],
+         [
+           ac_cv_with_drizzled=$withval
+           DRIZZLED_BINARY=$withval
+           AC_DEFINE_UNQUOTED([DRIZZLED_BINARY], "$DRIZZLED_BINARY", [Name of the drizzled binary used in make test])
+         ],
+         [
+           ac_cv_with_drizzled=
+           DRIZZLED_BINARY=
+         ])
+    ])
+  AM_CONDITIONAL(HAVE_DRIZZLED, test -n ${ac_cv_with_drizzled})
+  AC_SUBST(DRIZZLED_BINARY)
+])

+ 1 - 1
tests/drizzle_test.cc

@@ -32,7 +32,7 @@ using namespace libtest;
 
 static test_return_t test_for_HAVE_LIBDRIZZLE(void *)
 {
-#ifdef HAVE_LIBDRIZZLE
+#if defined HAVE_LIBDRIZZLE && defined HAVE_DRIZZLED
   return TEST_SUCCESS;
 #else
   return TEST_SKIPPED;

+ 1 - 0
util/instance.cc

@@ -42,6 +42,7 @@
 
 #include <cstdio>
 #include <sstream>
+#include <iostream>
 #include <netdb.h>
 #include <poll.h>
 #include <sys/socket.h>

+ 1 - 0
util/instance.hpp

@@ -43,6 +43,7 @@
 #include <cassert>
 #include <cstddef>
 #include <sys/socket.h>
+#include <string>
 
 #include "util/operation.hpp"
 

+ 72 - 0
util/operation.cc

@@ -0,0 +1,72 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  DataDifferential Utility Library
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <config.h>
+
+#include "util/operation.hpp"
+#include <string>
+
+namespace datadifferential {
+namespace util {
+
+bool Operation::response(std::string &arg)
+{
+  if (_response.empty())
+    return false;
+
+  if (not memcmp("OK\r\n", &_response[0], 3))
+  { }
+  else if (not memcmp("OK ", &_response[0], 3))
+  {
+    arg.append(&_response[3], _response.size() -3);
+  }
+  else if (not memcmp("ERR ", &_response[0], 4))
+  {
+    arg.append(&_response[4], _response.size() -4);
+    return false;
+  }
+  else 
+  {
+    arg.append(&_response[0], _response.size());
+  }
+
+  return true;
+}
+
+} /* namespace util */
+} /* namespace datadifferential */

+ 2 - 24
util/operation.hpp

@@ -39,7 +39,7 @@
 
 
 #include <cstring>
-#include <iostream>
+#include <iosfwd>
 #include <vector>
 
 namespace datadifferential {
@@ -86,29 +86,7 @@ public:
   }
 
   // Return false on error
-  bool response(std::string &arg)
-  {
-    if (_response.empty())
-      return false;
-
-    if (not memcmp("OK\r\n", &_response[0], 3))
-    { }
-    else if (not memcmp("OK ", &_response[0], 3))
-    {
-      arg.append(&_response[3], _response.size() -3);
-    }
-    else if (not memcmp("ERR ", &_response[0], 4))
-    {
-      arg.append(&_response[4], _response.size() -4);
-      return false;
-    }
-    else 
-    {
-      arg.append(&_response[0], _response.size());
-    }
-
-    return true;
-  }
+  bool response(std::string &);
 
   bool reconnect() const
   {