Commit d6b97a64 authored by Manuel Wudka-Robles's avatar Manuel Wudka-Robles
Browse files

Examples don't use glog

parent cfd953c8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,3 +16,4 @@ write_file_blocking
CMakeScripts/
kinetic_cpp_client_examples.build/
kinetic_cpp_client_examples.xcodeproj/
.idea
+5 −9
Original line number Diff line number Diff line
@@ -3,14 +3,10 @@
#include <fcntl.h>
#include <sys/select.h>

#include "glog/logging.h"
#include "protobufutil/message_stream.h"

#include "hmac_provider.h"
#include "kinetic.pb.h"
#include "kinetic_connection_factory.h"
#include "nonblocking_kinetic_connection.h"
#include "nonblocking_message_service.h"
#include "socket_wrapper.h"
#include "value_factory.h"

@@ -27,14 +23,11 @@ using palominolabs::protobufutil::MessageStreamFactory;
class TestCallback : public GetCallbackInterface {
    public:
    void Call(const std::string &value, const std::string &version, const std::string &tag) {
        LOG(INFO) << "The callback got called!";
        printf("The callback got called!");
    }
};

int main(int argc, char* argv[]) {
    google::InitGoogleLogging(argv[0]);
    FLAGS_logtostderr = 1;

    ConnectionOptions options = {
        .host = "localhost",
        .port = 8123,
@@ -50,7 +43,10 @@ int main(int argc, char* argv[]) {
            message_stream_factory);

    kinetic::NonblockingKineticConnection *connection;
    CHECK(kinetic_connection_factory.NewNonblockingConnection(options, &connection).ok());
    if(!kinetic_connection_factory.NewNonblockingConnection(options, &connection).ok()) {
        printf("Unable to connect");
        return 1;
    }

    TestCallback *callback = new TestCallback;
    connection->Get("key", callback);
+16 −14
Original line number Diff line number Diff line
// This is a minimal blocking get/blocking put example

#include <stdio.h>
#include <glog/logging.h>

#include "glog/logging.h"
#include "protobufutil/message_stream.h"

#include "connection_options.h"
#include "hmac_provider.h"
#include "kinetic_connection_factory.h"
#include "kinetic_connection.h"
#include "kinetic_record.h"
#include "value_factory.h"

using com::seagate::kinetic::HmacProvider;
@@ -26,10 +24,7 @@ using palominolabs::protobufutil::MessageStreamFactory;
int main(int argc, char* argv[]) {
    (void) argc;

    google::InitGoogleLogging(argv[0]);
    FLAGS_logtostderr = 1;

    LOG(INFO)<< "Hello Kinetic Client!";
    printf("Hello Kinetic Client!\n");

    kinetic::ConnectionOptions options;
    options.host = std::string("localhost");
@@ -44,16 +39,23 @@ int main(int argc, char* argv[]) {
            message_stream_factory);

    kinetic::KineticConnection* kinetic_connection;
    CHECK(
            kinetic_connection_factory.NewConnection(options, &kinetic_connection).ok());
    if(!kinetic_connection_factory.NewConnection(options, &kinetic_connection).ok()) {
        printf("Unable to connect\n");
        return 1;
    }

    std::string key = "key";
    std::string value, version, tag;
    CHECK(
            kinetic_connection->Put(key, "",
                    KineticRecord("the value", "", "", Message_Algorithm_SHA1)).ok());
    CHECK(kinetic_connection->Get(key, &value, &version, &tag).ok());
    LOG(INFO)<< "Value for " << key << " is <" << value << ">";
    if(!kinetic_connection->Put(key, "",
                    KineticRecord("the value", "", "", Message_Algorithm_SHA1)).ok()) {
        printf("Unable to PUT\n");
        return 1;
    }
    if(!kinetic_connection->Get(key, &value, &version, &tag).ok()) {
        printf("Unable to GET\n");
        return 1;
    }
    printf("Value for %s is <%s>\n", key.c_str(), value.c_str());

    return 0;
}
+0 −2
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@
#include "connection_options.h"
#include "hmac_provider.h"
#include "kinetic_connection_factory.h"
#include "kinetic_connection.h"
#include "kinetic_record.h"
#include "value_factory.h"

using com::seagate::kinetic::HmacProvider;
+12 −8
Original line number Diff line number Diff line
@@ -4,13 +4,9 @@
#include <inttypes.h>
#include <stdio.h>

#include "glog/logging.h"

#include "connection_options.h"
#include "hmac_provider.h"
#include "kinetic_connection_factory.h"
#include "kinetic_connection.h"
#include "kinetic_record.h"
#include "value_factory.h"

using com::seagate::kinetic::HmacProvider;
@@ -52,13 +48,18 @@ int main(int argc, char* argv[]) {
            message_stream_factory);

    kinetic::KineticConnection* kinetic_connection;
    CHECK(
            kinetic_connection_factory.NewConnection(options, &kinetic_connection).ok());
    if(!kinetic_connection_factory.NewConnection(options, &kinetic_connection).ok()) {
        printf("Unable to connect\n");
        return 1;
    }

    if (argc == 2) {
        // User just specified host so dump everything
        DriveLog drive_log;
        CHECK(kinetic_connection->GetLog(&drive_log).ok());
        if(!kinetic_connection->GetLog(&drive_log).ok()) {
            printf("Unable to get log\n");
            return 1;
        }

        dump_all_information(drive_log);
    } else {
@@ -69,7 +70,10 @@ int main(int argc, char* argv[]) {
        int report_number = 0;
        while (true) {
            DriveLog drive_log;
            CHECK(kinetic_connection->GetLog(&drive_log).ok());
            if(!kinetic_connection->GetLog(&drive_log).ok()) {
                printf("Unable to get log\n");
                return 1;
            }

            bool print_headers = report_number % 5 == 0;

Loading