Skip to content

Commit

Permalink
Merge pull request #28 from Seagate/features/asokvad185_cluster_versi…
Browse files Browse the repository at this point in the history
…on_reporting

setclusterversion reports expected version
  • Loading branch information
Marshall Pierce committed Jun 27, 2014
2 parents 0af418b + 69a2c82 commit acb94b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else(USE_LOCAL_KINETIC_CLIENT)
kinetic_cpp_client
PREFIX "vendor"
GIT_REPOSITORY "https://github.com/Seagate/kinetic-cpp-client.git"
GIT_TAG "0.0.6"
GIT_TAG "29ab1eafa95daca535b7eb23cd5253dbdef31f4c"
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Toy example demonstrating how to change the ACLs. It always sets a hard-coded se
-------------------
Changes the cluster version and verifies that requests with the old cluster version get rejected. Example usage:

./setclusterversion -host 127.1 -port 8123 -new_cluster_version 99
./setclusterversion -host 127.1 -port 8123 -cluster_version 0 -new_cluster_version 99

`setpin` (see `src/setpin.cc`)
--------
Expand Down Expand Up @@ -98,4 +98,4 @@ Finally, if you reconsider the preciousness of the data you can obliterate it by
./delete_file_blocking localhost object_store
./delete_file_nonblocking localhost object_store

Similarly to their read counterparts, those examples are implemented by `src/delete_file_blocking.cc` and `src/delete_file_nonblocking.cc`.
Similarly to their read counterparts, those examples are implemented by `src/delete_file_blocking.cc` and `src/delete_file_nonblocking.cc`.
4 changes: 3 additions & 1 deletion src/command_line_flags.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* kinetic-cpp-examples
* Copyright (C) 2014 Seagate Technology.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
Expand Down Expand Up @@ -30,6 +30,7 @@ DEFINE_uint64(port, 8123, "Kinetic Port");
DEFINE_uint64(timeout, 30, "Timeout");
DEFINE_uint64(user_id, 1, "Kinetic User ID");
DEFINE_string(hmac_key, "asdfasdf", "Kinetic User HMAC key");
DEFINE_int64(cluster_version, 0, "Kinetic Cluster Version");

bool parse_flags(int *argc,
char*** argv,
Expand All @@ -50,6 +51,7 @@ bool parse_flags(int *argc,
return false;
}
blocking_connection = std::make_shared<kinetic::BlockingKineticConnection>(nonblocking_connection, FLAGS_timeout);
blocking_connection->SetClientClusterVersion(FLAGS_cluster_version);

return true;
}
Expand Down
19 changes: 12 additions & 7 deletions src/setclusterversion.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* kinetic-cpp-examples
* Copyright (C) 2014 Seagate Technology.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
Expand Down Expand Up @@ -39,8 +39,13 @@ int example_main(
char** argv) {
printf("Setting cluster version to %" PRId64 "\n", FLAGS_new_cluster_version);

if (!(blocking_connection->SetClusterVersion(FLAGS_new_cluster_version).ok())) {
printf("Unable to set cluster version\n");
kinetic::KineticStatus status = blocking_connection->SetClusterVersion(FLAGS_new_cluster_version);
if (!status.ok()) {
printf("Unable to set cluster version");
if (status.statusCode() == kinetic::StatusCode::REMOTE_CLUSTER_VERSION_MISMATCH) {
printf(". Incorrect cluster version; should be %" PRId64, status.expected_cluster_version());
}
printf("\n");
return 1;
}

Expand All @@ -50,12 +55,12 @@ int example_main(
blocking_connection->SetClientClusterVersion(FLAGS_new_cluster_version + 1);

unique_ptr<KineticRecord> result = unique_ptr<KineticRecord>();
kinetic::StatusCode code = blocking_connection->Get("foo", result).statusCode();
if (code != kinetic::StatusCode::REMOTE_CLUSTER_VERSION_MISMATCH) {
printf("Unexpectedly got %d\n", static_cast<int>(code));
status = blocking_connection->Get("foo", result);
if (status.statusCode() != kinetic::StatusCode::REMOTE_CLUSTER_VERSION_MISMATCH) {
printf("Unexpectedly got %d\n", static_cast<int>(status.statusCode()));
return 1;
} else {
printf("Correctly rejected a GET with incorrect cluster version\n");
printf("Correctly rejected a GET with incorrect cluster version; should have sent %" PRId64 "\n", status.expected_cluster_version());
}

return 0;
Expand Down

0 comments on commit acb94b3

Please sign in to comment.