Loading CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ else(USE_LOCAL_KINETIC_CLIENT) kinetic_cpp_client PREFIX "vendor" GIT_REPOSITORY "git@github.com:Seagate/Kinetic-C-Client.git" GIT_TAG "7046918130914d97036e1aaf708fffa9f89ddbe0" GIT_TAG "e5a14908ac17652d621997261a51dfac4c141c86" BUILD_IN_SOURCE 1 INSTALL_COMMAND "" ) Loading Loading @@ -67,6 +67,7 @@ add_example_target(write_file_blocking) add_example_target(read_file_blocking) add_example_target(read_file_nonblocking) add_example_target(delete_file_nonblocking) add_example_target(delete_file_blocking) add_example_target(write_file_nonblocking) add_example_target(firmware_update) src/delete_file_blocking.cc 0 → 100644 +88 −0 Original line number Diff line number Diff line // This deletes a file written using write_file_(non)blocking #include <stdio.h> #include "protobufutil/message_stream.h" #include "kinetic/connection_options.h" #include "kinetic/kinetic_connection_factory.h" #include "value_factory.h" #include "socket_wrapper.h" using com::seagate::kinetic::HmacProvider; using com::seagate::kinetic::proto::Message; using com::seagate::kinetic::proto::Message_MessageType_GET; using com::seagate::kinetic::proto::Message_Algorithm_SHA1; using com::seagate::kinetic::ValueFactory; using kinetic::KineticConnectionFactory; using kinetic::KineticRecord; using kinetic::NonblockingError; using kinetic::SimpleCallbackInterface; using kinetic::Status; using palominolabs::protobufutil::MessageStreamFactory; int main(int argc, char* argv[]) { google::InitGoogleLogging(argv[0]); if (argc != 3) { printf("%s: <host> <kinetic key>\n", argv[0]); return 1; } const char* host = argv[1]; const char* kinetic_key = argv[2]; kinetic::ConnectionOptions options; options.host = host; options.port = 8123; options.user_id = 1; options.hmac_key = "asdfasdf"; KineticConnectionFactory kinetic_connection_factory = kinetic::NewKineticConnectionFactory(); kinetic::ConnectionHandle* connection; if(!kinetic_connection_factory.NewConnection(options, &connection).ok()) { printf("Unable to connect\n"); return 1; } KineticRecord* record; if(!connection->blocking().Get(kinetic_key, &record).ok()) { printf("Unable to get metadata\n"); return 1; } long long file_size = std::stoll(record->value()); delete record; printf("Deleting file of size %llu\n", file_size); char key_buffer[100]; for (int64_t i = 0; i < file_size; i += 1024*1024) { unsigned int block_length = 1024*1024; if (i + block_length > file_size) { block_length = file_size - i + 1; } sprintf(key_buffer, "%s-%10" PRId64, kinetic_key, i); std::string key(key_buffer); if (connection->blocking().Delete(key, "", true).ok()) { printf("."); } else { printf("X"); } fflush(stdout); } if (!connection->blocking().Delete(kinetic_key, "", true).ok()) { printf("Unable to delete metadata\n"); } printf("\nDone!\n"); delete connection; google::protobuf::ShutdownProtobufLibrary(); google::ShutdownGoogleLogging(); google::ShutDownCommandLineFlags(); return 0; } Loading
CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ else(USE_LOCAL_KINETIC_CLIENT) kinetic_cpp_client PREFIX "vendor" GIT_REPOSITORY "git@github.com:Seagate/Kinetic-C-Client.git" GIT_TAG "7046918130914d97036e1aaf708fffa9f89ddbe0" GIT_TAG "e5a14908ac17652d621997261a51dfac4c141c86" BUILD_IN_SOURCE 1 INSTALL_COMMAND "" ) Loading Loading @@ -67,6 +67,7 @@ add_example_target(write_file_blocking) add_example_target(read_file_blocking) add_example_target(read_file_nonblocking) add_example_target(delete_file_nonblocking) add_example_target(delete_file_blocking) add_example_target(write_file_nonblocking) add_example_target(firmware_update)
src/delete_file_blocking.cc 0 → 100644 +88 −0 Original line number Diff line number Diff line // This deletes a file written using write_file_(non)blocking #include <stdio.h> #include "protobufutil/message_stream.h" #include "kinetic/connection_options.h" #include "kinetic/kinetic_connection_factory.h" #include "value_factory.h" #include "socket_wrapper.h" using com::seagate::kinetic::HmacProvider; using com::seagate::kinetic::proto::Message; using com::seagate::kinetic::proto::Message_MessageType_GET; using com::seagate::kinetic::proto::Message_Algorithm_SHA1; using com::seagate::kinetic::ValueFactory; using kinetic::KineticConnectionFactory; using kinetic::KineticRecord; using kinetic::NonblockingError; using kinetic::SimpleCallbackInterface; using kinetic::Status; using palominolabs::protobufutil::MessageStreamFactory; int main(int argc, char* argv[]) { google::InitGoogleLogging(argv[0]); if (argc != 3) { printf("%s: <host> <kinetic key>\n", argv[0]); return 1; } const char* host = argv[1]; const char* kinetic_key = argv[2]; kinetic::ConnectionOptions options; options.host = host; options.port = 8123; options.user_id = 1; options.hmac_key = "asdfasdf"; KineticConnectionFactory kinetic_connection_factory = kinetic::NewKineticConnectionFactory(); kinetic::ConnectionHandle* connection; if(!kinetic_connection_factory.NewConnection(options, &connection).ok()) { printf("Unable to connect\n"); return 1; } KineticRecord* record; if(!connection->blocking().Get(kinetic_key, &record).ok()) { printf("Unable to get metadata\n"); return 1; } long long file_size = std::stoll(record->value()); delete record; printf("Deleting file of size %llu\n", file_size); char key_buffer[100]; for (int64_t i = 0; i < file_size; i += 1024*1024) { unsigned int block_length = 1024*1024; if (i + block_length > file_size) { block_length = file_size - i + 1; } sprintf(key_buffer, "%s-%10" PRId64, kinetic_key, i); std::string key(key_buffer); if (connection->blocking().Delete(key, "", true).ok()) { printf("."); } else { printf("X"); } fflush(stdout); } if (!connection->blocking().Delete(kinetic_key, "", true).ok()) { printf("Unable to delete metadata\n"); } printf("\nDone!\n"); delete connection; google::protobuf::ShutdownProtobufLibrary(); google::ShutdownGoogleLogging(); google::ShutDownCommandLineFlags(); return 0; }