You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/05/31 17:16:29 UTC

[1/2] incubator-kudu git commit: Add unique id generation to the client

Repository: incubator-kudu
Updated Branches:
  refs/heads/master 8721f9539 -> cc658cac1


Add unique id generation to the client

This adds unique id generation to the client, which takes the form of
an uuid. The uuid is generated when the client is built, by a static
OidGenerator.

This also adds a test that generates 1000 clients and makes sure that
the generated ids are unique. Since this test will now run all the time
we should get notified if stuff becomes flaky dues to repeated ids.

Change-Id: Ie752ab8337cc76c3be1536958c24a8b6c5794650
Reviewed-on: http://gerrit.cloudera.org:8080/3077
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Reviewed-by: Todd Lipcon <to...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/71420f00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/71420f00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/71420f00

Branch: refs/heads/master
Commit: 71420f00e0de5bec20562681b2b3ef46dc4f069e
Parents: 8721f95
Author: David Alves <da...@cloudera.com>
Authored: Tue May 3 13:20:26 2016 -0700
Committer: David Ribeiro Alves <da...@cloudera.com>
Committed: Mon May 30 23:02:46 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/client-internal.h                |  3 +++
 src/kudu/client/client.cc                        |  3 +++
 src/kudu/client/client.h                         |  2 ++
 src/kudu/integration-tests/client-stress-test.cc | 18 ++++++++++++++++++
 4 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/71420f00/src/kudu/client/client-internal.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-internal.h b/src/kudu/client/client-internal.h
index 9571616..3db9eb1 100644
--- a/src/kudu/client/client-internal.h
+++ b/src/kudu/client/client-internal.h
@@ -186,6 +186,9 @@ class KuduClient::Data {
                                    const ReqClass&, RespClass*,
                                    rpc::RpcController*)>& func);
 
+  // The unique id of this client.
+  std::string client_id_;
+
   std::shared_ptr<rpc::Messenger> messenger_;
   gscoped_ptr<DnsResolver> dns_resolver_;
   scoped_refptr<internal::MetaCache> meta_cache_;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/71420f00/src/kudu/client/client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index 91af4e2..ebb8934 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -55,6 +55,7 @@
 #include "kudu/util/init.h"
 #include "kudu/util/logging.h"
 #include "kudu/util/net/dns_resolver.h"
+#include "kudu/util/oid_generator.h"
 #include "kudu/util/version_info.h"
 
 using kudu::master::AlterTableRequestPB;
@@ -241,6 +242,8 @@ Status KuduClientBuilder::Build(shared_ptr<KuduClient>* client) {
 
 KuduClient::KuduClient()
   : data_(new KuduClient::Data()) {
+  static ObjectIdGenerator oid_generator;
+  data_->client_id_ = oid_generator.Next();
 }
 
 KuduClient::~KuduClient() {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/71420f00/src/kudu/client/client.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.h b/src/kudu/client/client.h
index 29e25ab..99664aa 100644
--- a/src/kudu/client/client.h
+++ b/src/kudu/client/client.h
@@ -48,6 +48,7 @@
 
 namespace kudu {
 
+class ClientStressTest_TestUniqueClientIds_Test;
 class LinkedListTester;
 class PartitionSchema;
 
@@ -286,6 +287,7 @@ class KUDU_EXPORT KuduClient : public sp::enable_shared_from_this<KuduClient> {
   friend class KuduTableAlterer;
   friend class KuduTableCreator;
 
+  FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
   FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
   FRIEND_TEST(ClientTest, TestMasterDown);
   FRIEND_TEST(ClientTest, TestMasterLookupPermits);

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/71420f00/src/kudu/integration-tests/client-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/client-stress-test.cc b/src/kudu/integration-tests/client-stress-test.cc
index 9be5f71..5a1f17b 100644
--- a/src/kudu/integration-tests/client-stress-test.cc
+++ b/src/kudu/integration-tests/client-stress-test.cc
@@ -19,8 +19,10 @@
 #include <memory>
 #include <vector>
 
+#include "kudu/client/client-internal.h"
 #include "kudu/client/client-test-util.h"
 #include "kudu/gutil/mathlimits.h"
+#include "kudu/gutil/strings/join.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/integration-tests/external_mini_cluster.h"
 #include "kudu/integration-tests/test_workload.h"
@@ -279,4 +281,20 @@ TEST_F(ClientStressTest_LowMemory, TestMemoryThrottling) {
   }
 }
 
+// This test just creates a bunch of clients and makes sure that the generated client ids
+// are unique among the created clients.
+TEST_F(ClientStressTest, TestUniqueClientIds) {
+  set<string> client_ids;
+  for (int i = 0; i < 1000; i++) {
+    KuduClientBuilder builder;
+    client::sp::shared_ptr<KuduClient> client;
+    CHECK_OK(cluster_->CreateClient(builder, &client));
+    string client_id = client->data_->client_id_;
+    auto result = client_ids.insert(client_id);
+    EXPECT_TRUE(result.second) << "Unique id generation failed. New client id: " << client_id
+                                   << " had already been used. Generated ids: "
+                                   << JoinStrings(client_ids, ",");
+  }
+}
+
 } // namespace kudu


[2/2] incubator-kudu git commit: KUDU-1470 Exceptions on getting a column value should return the column name not the column number

Posted by da...@apache.org.
KUDU-1470 Exceptions on getting a column value should return the column name not the column number

Change-Id: Ie8bb3db1ed7b4e2027814815776f6252b0f749c5
Reviewed-on: http://gerrit.cloudera.org:8080/3231
Reviewed-by: Dan Burkert <da...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/cc658cac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/cc658cac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/cc658cac

Branch: refs/heads/master
Commit: cc658cac1b8be86a18839ea5c7a89c1a768c8516
Parents: 71420f0
Author: tmalaska <te...@cloudera.com>
Authored: Thu May 26 20:47:08 2016 -0400
Committer: Dan Burkert <da...@cloudera.com>
Committed: Tue May 31 17:16:01 2016 +0000

----------------------------------------------------------------------
 .../src/main/java/org/kududb/client/RowResult.java          | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cc658cac/java/kudu-client/src/main/java/org/kududb/client/RowResult.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/kududb/client/RowResult.java b/java/kudu-client/src/main/java/org/kududb/client/RowResult.java
index e0c09ae..7692c53 100644
--- a/java/kudu-client/src/main/java/org/kududb/client/RowResult.java
+++ b/java/kudu-client/src/main/java/org/kududb/client/RowResult.java
@@ -480,7 +480,9 @@ public class RowResult {
       return;
     }
     if (isNull(columnIndex)) {
-      throw new IllegalArgumentException("The requested column (" + columnIndex + ")  is null");
+      ColumnSchema columnSchema = schema.getColumnByIndex(columnIndex);
+      throw new IllegalArgumentException("The requested column (name: " + columnSchema.getName() +
+          ", index: " + columnIndex + ") is null");
     }
   }
 
@@ -488,8 +490,9 @@ public class RowResult {
     ColumnSchema columnSchema = schema.getColumnByIndex(columnIndex);
     Type columnType = columnSchema.getType();
     if (!columnType.equals(expectedType)) {
-      throw new IllegalArgumentException("Column (" + columnIndex + ") is of type " +
-              columnType.getName() + " but was requested as a type " + expectedType.getName());
+      throw new IllegalArgumentException("Column (name: " + columnSchema.getName() +
+          ", index: " + columnIndex +") is of type " +
+          columnType.getName() + " but was requested as a type " + expectedType.getName());
     }
   }