Commit acb94b35 authored by Marshall Pierce's avatar Marshall Pierce
Browse files

Merge pull request #28 from Seagate/features/asokvad185_cluster_version_reporting

setclusterversion reports expected version
parents 0af418b0 69a2c82c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 ""
    )
+2 −2
Original line number Diff line number Diff line
@@ -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`)
--------
+3 −1
Original line number Diff line number Diff line
@@ -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,
@@ -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;
}
+12 −7
Original line number Diff line number Diff line
@@ -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;
    }

@@ -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;