Permalink
Browse files

Merge branch 'release/0.3.1'

  • Loading branch information...
kuenishi committed Jul 20, 2012
2 parents e2a2397 + 78058d2 commit 9b24016db90ec67627371720e62a05824d8b044b
Showing with 1,386 additions and 1,033 deletions.
  1. +11 −0 README.rst
  2. +6 −0 src/classifier/wscript
  3. +13 −6 src/common/exception.hpp
  4. +14 −38 src/common/exception_info.hpp
  5. +50 −24 src/common/exception_test.cpp
  6. +238 −41 src/common/mprpc/async_client.cpp
  7. +114 −37 src/common/mprpc/async_client.hpp
  8. +65 −0 src/common/mprpc/exception.hpp
  9. +37 −159 src/common/mprpc/rpc_client.cpp
  10. +202 −103 src/common/mprpc/rpc_client.hpp
  11. +203 −45 src/common/mprpc/rpc_client_test.cpp
  12. +1 −1 src/common/mprpc/wscript
  13. +34 −0 src/common/util.cpp
  14. +3 −0 src/common/util.hpp
  15. +20 −12 src/common/zk.cpp
  16. +26 −21 src/framework/jubatus_serv.cpp
  17. +3 −1 src/framework/keeper.cpp
  18. +6 −11 src/framework/keeper.hpp
  19. +45 −36 src/framework/mixer.cpp
  20. +8 −8 src/framework/mixer.hpp
  21. +15 −25 src/framework/server_util.cpp
  22. +16 −10 src/framework/server_util.hpp
  23. +1 −1 src/framework/wscript
  24. +12 −7 src/jubavisor/jubavisor.cpp
  25. +1 −0 src/jubavisor/jubavisor.hpp
  26. +3 −1 src/jubavisor/main.cpp
  27. +1 −30 src/server/classifier.idl
  28. +6 −6 src/server/classifier_impl.cpp
  29. +5 −7 src/server/classifier_serv.cpp
  30. +30 −26 src/server/classifier_test.cpp
  31. +1 −50 src/server/classifier_types.hpp
  32. +13 −18 src/server/graph.idl
  33. +14 −14 src/server/graph_client.hpp
  34. +9 −9 src/server/graph_impl.cpp
  35. +6 −6 src/server/graph_keeper.cpp
  36. +9 −6 src/server/graph_serv.cpp
  37. +4 −0 src/server/graph_serv.hpp
  38. +7 −7 src/server/graph_server.hpp
  39. +8 −0 src/server/graph_test.cpp
  40. +6 −12 src/server/graph_types.hpp
  41. +3 −34 src/server/recommender.idl
  42. +12 −12 src/server/recommender_impl.cpp
  43. +2 −4 src/server/recommender_serv.cpp
  44. +11 −4 src/server/recommender_test.cpp
  45. +1 −52 src/server/recommender_types.hpp
  46. +1 −30 src/server/regression.idl
  47. +6 −6 src/server/regression_impl.cpp
  48. +4 −7 src/server/regression_serv.cpp
  49. +12 −8 src/server/regression_test.cpp
  50. +1 −50 src/server/regression_types.hpp
  51. +18 −18 src/server/stat.idl
  52. +13 −13 src/server/stat_impl.cpp
  53. +7 −7 src/server/stat_keeper.cpp
  54. +9 −0 src/server/test_util.hpp
  55. +8 −0 src/server/wscript
  56. +1 −1 src/stat/mixable_stat_test.cpp
  57. +1 −0 src/stat/stat.hpp
  58. +6 −2 src/storage/wscript
  59. +1 −4 tools/generator/OMakefile
  60. +2 −2 tools/generator/generator.ml
  61. +1 −1 wscript
View
@@ -31,6 +31,17 @@ LGPL 2.1
Update history
--------------
+0.3.1 2012/7/20
+~~~~~~~~~~~~~~~
+
+Improvements
+ - RPC enhances to many exceptions and provide new error handling interface (#49)
+ - JSON interface for set_config APIs (#44)
+ - jubavisor close zk connection correctly (#74)
+
+Bugfix
+ - #73, #69, #66, #65
+
Release 0.3.0 2012/6/29
~~~~~~~~~~~~~~~~~~~~~~~
View
@@ -29,3 +29,9 @@ def build(bld):
target = "classifier_test",
includes = '.',
use = 'jubatus_classifier jubastorage')
+
+ bld.install_files('${PREFIX}/include/jubatus/classifier', [
+ 'classifier_base.hpp',
+ 'classifier_factory.hpp',
+ 'classifier_type.hpp',
+ ])
View
@@ -38,6 +38,13 @@ typedef error_info<struct error_at_file_, char const *> error_at_file;
typedef error_info<struct error_at_func_, char const *> error_at_func;
typedef error_info<struct error_at_line_, int> error_at_line;
typedef error_info<struct error_errno_, int> error_errno;
+inline std::string to_string(const error_errno& info)
+{
+ std::string msg(strerror(info.value()));
+ msg += " (" + pfi::lang::lexical_cast<std::string>(info.value()) + ")";
+ return msg;
+}
+
typedef error_info<struct error_file_name_, std::string> error_file_name;
typedef error_info<struct error_api_func_, std::string> error_api_func;
typedef error_info<struct error_message_, std::string> error_message;
@@ -70,7 +77,7 @@ class jubatus_exception : public std::exception {
virtual exception_thrower_ptr thrower() const = 0;
template <class Exception>
- friend Exception const & add_info(Exception const & e, pfi::lang::shared_ptr<error_info_base> info);
+ friend const Exception& add_info(const Exception& e, pfi::lang::shared_ptr<error_info_base> info);
std::string name() const throw()
{
@@ -96,20 +103,20 @@ class jubatus_exception : public std::exception {
};
template <class Exception>
-inline Exception const & add_info(Exception const & e, pfi::lang::shared_ptr<error_info_base> info)
+inline const Exception& add_info(const Exception& e, pfi::lang::shared_ptr<error_info_base> info)
{
e.info_list_.push_back(info);
return e;
}
template <class Exception, class Tag, class V>
-inline Exception const & operator <<(Exception const & e, error_info<Tag, V> const & info)
+inline const Exception& operator <<(const Exception& e, const error_info<Tag, V>& info)
{
return add_info(e, pfi::lang::shared_ptr<error_info_base>(new error_info<Tag, V>(info)));
}
template <class Exception>
-inline Exception const & operator <<(Exception const & e, pfi::lang::shared_ptr<error_info_base> info)
+inline const Exception& operator <<(const Exception& e, pfi::lang::shared_ptr<error_info_base> info)
{
return add_info(e, info);
}
@@ -174,7 +181,7 @@ class jubaexception : public jubatus_exception {
};
template <class Exception>
-inline Exception const & operator <<(Exception const & e, exception_thrower_binder_type const &)
+inline const Exception& operator <<(const Exception& e, const exception_thrower_binder_type&)
{
e.bind_thrower(exception_thrower_ptr(new exception_thrower_impl<Exception>(e)));
return e;
@@ -205,7 +212,7 @@ class runtime_error : public jubaexception<runtime_error> {
namespace detail {
template <class Exception>
-exception_thrower_ptr current_std_exception(Exception const & e)
+exception_thrower_ptr current_std_exception(const Exception& e)
{
return exception_thrower_ptr(new exception_thrower_impl<Exception>(e));
}
@@ -15,6 +15,8 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#pragma once
+
#include <cstring>
#include <typeinfo>
#include <pficommon/lang/shared_ptr.h>
@@ -29,7 +31,11 @@ std::string demangle_symbol(const char *symbol);
class error_info_base {
public:
- virtual bool splitter() const = 0;
+ virtual bool splitter() const
+ {
+ return false;
+ }
+
virtual std::string tag_typeid_name() const = 0;
virtual std::string as_string() const = 0;
@@ -40,6 +46,12 @@ class error_info_base {
template <class Tag, class V>
class error_info;
+template <class Tag, class V>
+inline std::string to_string(const error_info<Tag, V>& info)
+{
+ return pfi::lang::lexical_cast<std::string, V>(info.value());
+}
+
template<>
class error_info<struct error_splitter_, void> : public error_info_base {
public:
@@ -60,42 +72,13 @@ class error_info<struct error_splitter_, void> : public error_info_base {
}
};
-template<>
-class error_info<struct error_errno_, int> : public error_info_base {
-public:
- error_info(int err)
- : value_(err)
- {
- }
-
- bool splitter() const
- {
- return false;
- }
-
- std::string tag_typeid_name() const
- {
- return jubatus::exception::detail::demangle_symbol(typeid(struct error_errno_*).name());
- }
-
- std::string as_string() const
- {
- std::string msg(strerror(value_));
- msg += " (" + pfi::lang::lexical_cast<std::string>(value_) + ")";
- return msg;
- }
-private:
- int value_;
-};
-
template <class Tag, class V>
class error_info : public error_info_base {
public:
typedef V value_type;
error_info(value_type v);
~error_info() throw();
- bool splitter() const;
std::string tag_typeid_name() const;
std::string as_string() const;
@@ -119,12 +102,6 @@ inline error_info<Tag, V>::~error_info() throw()
{
}
-template <class Tag, class V>
-inline bool error_info<Tag, V>::splitter() const
-{
- return false;
-}
-
template <class Tag, class V>
inline std::string error_info<Tag, V>::tag_typeid_name() const
{
@@ -134,8 +111,7 @@ inline std::string error_info<Tag, V>::tag_typeid_name() const
template <class Tag, class V>
inline std::string error_info<Tag, V>::as_string() const
{
- // TODO: implement generic and user defined converter to std::string
- return pfi::lang::lexical_cast<std::string>(value_);
+ return to_string(*this);
}
} // exception
@@ -31,6 +31,33 @@ using jubatus::exception::error_info_list_t;
using jubatus::exception::exception_thrower_ptr;
using jubatus::exception::jubaexception;
+namespace jubatus {
+namespace exception {
+typedef error_info<struct test_my_tag_, int> test_my_tag;
+inline string to_string(const test_my_tag& info)
+{
+ return pfi::lang::lexical_cast<string>(info.value() * 2);
+}
+} // exception
+} // jubatus
+
+TEST(error_info, defined_tag)
+{
+ jubatus::exception::test_my_tag tag(1);
+
+ EXPECT_FALSE(tag.splitter());
+ EXPECT_EQ(1, tag.value());
+}
+
+TEST(error_info, error_info_base)
+{
+ jubatus::exception::test_my_tag tag(1);
+ const jubatus::exception::error_info_base& base = tag;
+
+ EXPECT_FALSE(base.splitter());
+ EXPECT_EQ("2", base.as_string());
+}
+
namespace test_exception {
class ore_exception : public jubaexception<ore_exception> {
public:
@@ -56,7 +83,7 @@ class derived_exception : public jubatus::exception::runtime_error {
// multi-derived exception cannot get as it thrower
// because thrower() returns exception_thrower_impl<runtime_error>
};
-}
+} // test_exception
TEST(exception, custom_exception)
{
@@ -145,10 +172,10 @@ TEST(exception, exception_info_macro)
} catch (const jubatus_exception& e) {
error_info_list_t info_list = e.error_info();
EXPECT_EQ(4, info_list.size());
- EXPECT_EQ(false, info_list[0]->splitter());
- EXPECT_EQ(false, info_list[1]->splitter());
- EXPECT_EQ(false, info_list[2]->splitter());
- EXPECT_EQ(true, info_list[3]->splitter());
+ EXPECT_FALSE(info_list[0]->splitter());
+ EXPECT_FALSE(info_list[1]->splitter());
+ EXPECT_FALSE(info_list[2]->splitter());
+ EXPECT_TRUE(info_list[3]->splitter());
}
}
@@ -161,12 +188,12 @@ TEST(exception, exception_info_macro_additional)
} catch (const jubatus_exception& e) {
error_info_list_t info_list = e.error_info();
EXPECT_EQ(5, info_list.size());
- EXPECT_EQ(false, info_list[0]->splitter());
+ EXPECT_FALSE(info_list[0]->splitter());
EXPECT_EQ(string("message"), info_list[0]->as_string());
- EXPECT_EQ(false, info_list[1]->splitter());
- EXPECT_EQ(false, info_list[2]->splitter());
- EXPECT_EQ(false, info_list[3]->splitter());
- EXPECT_EQ(true, info_list[4]->splitter());
+ EXPECT_FALSE(info_list[1]->splitter());
+ EXPECT_FALSE(info_list[2]->splitter());
+ EXPECT_FALSE(info_list[3]->splitter());
+ EXPECT_TRUE(info_list[4]->splitter());
}
}
@@ -191,10 +218,10 @@ TEST(exception, exception_custom_error_info)
} catch (const jubatus_exception& e) {
error_info_list_t info_list = e.error_info();
EXPECT_EQ(4, info_list.size());
- EXPECT_EQ(false, info_list[0]->splitter());
- EXPECT_EQ(false, info_list[1]->splitter());
- EXPECT_EQ(false, info_list[2]->splitter());
- EXPECT_EQ(true, info_list[3]->splitter());
+ EXPECT_FALSE(info_list[0]->splitter());
+ EXPECT_FALSE(info_list[1]->splitter());
+ EXPECT_FALSE(info_list[2]->splitter());
+ EXPECT_TRUE(info_list[3]->splitter());
}
}
@@ -217,16 +244,16 @@ TEST(exception, exception_info_add_macro)
caught = true;
error_info_list_t info_list = e.error_info();
EXPECT_EQ(9, info_list.size());
- EXPECT_EQ(false, info_list[0]->splitter());
- EXPECT_EQ(false, info_list[1]->splitter());
- EXPECT_EQ(false, info_list[2]->splitter());
- EXPECT_EQ(true, info_list[3]->splitter());
- EXPECT_EQ(false, info_list[4]->splitter());
+ EXPECT_FALSE(info_list[0]->splitter());
+ EXPECT_FALSE(info_list[1]->splitter());
+ EXPECT_FALSE(info_list[2]->splitter());
+ EXPECT_TRUE(info_list[3]->splitter());
+ EXPECT_FALSE(info_list[4]->splitter());
EXPECT_EQ(string("added"), info_list[4]->as_string());
- EXPECT_EQ(false, info_list[5]->splitter());
- EXPECT_EQ(false, info_list[6]->splitter());
- EXPECT_EQ(false, info_list[7]->splitter());
- EXPECT_EQ(true, info_list[8]->splitter());
+ EXPECT_FALSE(info_list[5]->splitter());
+ EXPECT_FALSE(info_list[6]->splitter());
+ EXPECT_FALSE(info_list[7]->splitter());
+ EXPECT_TRUE(info_list[8]->splitter());
}
EXPECT_TRUE(caught);
@@ -288,4 +315,3 @@ TEST(exception, exception_class_name)
}
#endif
-
Oops, something went wrong.

0 comments on commit 9b24016

Please sign in to comment.