Commit 121704ce authored by Andrew Mitchell's avatar Andrew Mitchell
Browse files

Added example of writing and deleting data efficiently using the new persist mode configurability

parent 447c5903
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 "9e8ea1af7f3c3e748c03286549c445683d4d7b22"
        GIT_TAG "b076890c17fc917580889ca5ce1a29446a554a20"
        BUILD_IN_SOURCE 1
        INSTALL_COMMAND ""
    )
+8 −2
Original line number Diff line number Diff line
@@ -75,7 +75,11 @@ int main(int argc, char* argv[]) {

        sprintf(key_buffer, "%s-%10" PRId64, kinetic_key, i);
        std::string key(key_buffer);
        if (blocking_connection->Delete(key, "", kinetic::WriteMode::IGNORE_VERSION).ok()) {

        // Use the Write Back persist mode for the data deletes, and then use Flush for the
        // metadata below to ensure everything is persisted by the time we exit.
        if (blocking_connection->Delete(key, "",
                kinetic::WriteMode::IGNORE_VERSION, kinetic::PersistMode::WRITE_BACK).ok()) {
            printf(".");
        } else {
            printf("X");
@@ -83,7 +87,9 @@ int main(int argc, char* argv[]) {
        fflush(stdout);
    }

    if (!blocking_connection->Delete(kinetic_key, "", kinetic::WriteMode::IGNORE_VERSION).ok()) {
    // Use the Flush persist mode to make sure all previous deletes are persisted
    if (!blocking_connection->Delete(kinetic_key, "",
            kinetic::WriteMode::IGNORE_VERSION, kinetic::PersistMode::FLUSH).ok()) {
        printf("Unable to delete metadata\n");
    }

+7 −2
Original line number Diff line number Diff line
@@ -103,11 +103,16 @@ int main(int argc, char* argv[]) {
        sprintf(key_buffer, "%s-%10" PRId64, kinetic_key, i);
        remaining++;
        std::string key(key_buffer);
        nonblocking_connection->Delete(key, "", kinetic::WriteMode::IGNORE_VERSION, callback);
        // Use the Write Back persist mode for the data deletes, and then use Flush for the
        // metadata below to ensure everything is persisted by the time we exit.
        nonblocking_connection->Delete(key, "", kinetic::WriteMode::IGNORE_VERSION,
                callback, kinetic::PersistMode::WRITE_BACK);
    }

    remaining++;
    nonblocking_connection->Delete(kinetic_key, "", kinetic::WriteMode::IGNORE_VERSION, callback);
    // Use the Flush persist mode to make sure all previous deletes are persisted
    nonblocking_connection->Delete(kinetic_key, "", kinetic::WriteMode::IGNORE_VERSION,
                callback, kinetic::PersistMode::FLUSH);


    fd_set read_fds, write_fds;
+7 −2
Original line number Diff line number Diff line
@@ -65,11 +65,14 @@ int example_main(

        std::string key(key_buffer);
        std::string value(inputfile_data + i, value_size);
        // Use the Write Back persist mode for the data puts, and then use Flush for the metadata
        // below to ensure everything is persisted by the time we exit.
        if(!blocking_connection->Put(
                key,
                "",
                kinetic::WriteMode::IGNORE_VERSION,
                KineticRecord(value, "", "", Message_Algorithm_SHA1)).ok()) {
                KineticRecord(value, "", "", Message_Algorithm_SHA1),
                kinetic::PersistMode::WRITE_BACK).ok()) {
            printf("Unable to write a chunk\n");
            return 1;
        }
@@ -79,11 +82,13 @@ int example_main(
    printf("\n");


    // Use the Flush persist mode to make sure all previous writes are persisted
    if (!blocking_connection->Put(
            FLAGS_kinetic_key,
            "",
            kinetic::WriteMode::IGNORE_VERSION,
            KineticRecord(to_string(inputfile_stat.st_size), "", "", Message_Algorithm_SHA1)).ok()) {
            KineticRecord(to_string(inputfile_stat.st_size), "", "", Message_Algorithm_SHA1),
            kinetic::PersistMode::FLUSH).ok()) {
        printf("Unable to write metadata\n");
        return 1;
    }
+7 −2
Original line number Diff line number Diff line
@@ -111,11 +111,13 @@ int main(int argc, char* argv[]) {

    printf("All threads joined\n");

    // Use the Flush persist mode to make sure all previous writes are persisted
    if (!blocking_connection->Put(
            kinetic_key,
            "",
            kinetic::WriteMode::IGNORE_VERSION,
            KineticRecord(std::to_string(inputfile_stat.st_size), "", "", Message_Algorithm_SHA1)).ok()) {
            KineticRecord(std::to_string(inputfile_stat.st_size), "", "", Message_Algorithm_SHA1),
            kinetic::PersistMode::FLUSH).ok()) {
        printf("Unable to write metadata\n");
        return 1;
    }
@@ -148,11 +150,14 @@ void put_range(int64_t start, int64_t end, int64_t total_size, const char* kinet

        std::string key(key_buffer);
        std::string value(inputfile_data + i, value_size);
        // Use the Write Back persist mode for the data puts, and then use Flush for the metadata
        // below to ensure everything is persisted by the time we exit.
        KineticStatus status = blocking_connection->Put(
                    key,
                    "",
                    kinetic::WriteMode::IGNORE_VERSION,
                    KineticRecord(value, "", "", Message_Algorithm_SHA1));
                    KineticRecord(value, "", "", Message_Algorithm_SHA1),
                    kinetic::PersistMode::WRITE_BACK);
        if(!status.ok()) {
            printf("Unable to write chunk: %d %s\n", static_cast<int>(status.statusCode()),
                status.message().c_str());
Loading