Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ set(GENERATED_SOURCES_PATH ${kinetic_cpp_client_SOURCE_DIR}/src/main/generated)

include(ExternalProject)

option(USE_LOCAL_KINETIC_CLIENT "Uses the kinetic client at the KINETIC_CLIENT_PATH variable instead of downloading library from Git" off)
option(USE_LOCAL_KINETIC_CLIENT "Uses the kinetic client at the KINETIC_CLIENT_PATH variable instead of downloading library from Git" on)
if(USE_LOCAL_KINETIC_CLIENT)
else(USE_LOCAL_KINETIC_CLIENT)
set(KINETIC_CLIENT_PATH "${CMAKE_BINARY_DIR}/vendor/src/kinetic_cpp_client")
ExternalProject_add(
kinetic_cpp_client
PREFIX "vendor"
GIT_REPOSITORY "https://github.com/Seagate/kinetic-cpp-client.git"
GIT_TAG "0.1.1"
GIT_TAG "develop"
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
)
Expand Down Expand Up @@ -78,3 +78,5 @@ add_example_target(firmware_update false)
add_example_target(write_file_blocking_threads false)
add_example_target(dump_keyspace false)
add_example_target(copydrive false)
add_example_target(media_scan_blocking true)
add_example_target(media_optimize_blocking true)
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ Changes the cluster version and verifies that requests with the old cluster vers
Allows changing a drive's PIN. For instance:

./setpin -host 127.1 -port 8123 -new_pin 1234 -old_pin 5678

`media_scan_blocking` (see `src/media_scan_blocking.cc`)
--------
Performs media scan with the specified range and priority. For instance:

./media_scan_blocking -host 127.1 -port 8123 -start_key key000 -end_key key999 -start_key_inclusive true -end_key_inclusive true

`media_optimize_blocking` (see `src/media_optimize_blocking.cc`)
--------
Performs media optimize with the specified range and priority. For instance:

./media_optimize_blocking -host 127.1 -port 8123 -start_key key000 -end_key key999 -start_key_inclusive true -end_key_inclusive true

Object store examples
---------------------
Expand Down
61 changes: 61 additions & 0 deletions src/media_optimize_blocking.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

// This allows changing a drive's cluster version
#include <stdio.h>

#include "kinetic/kinetic.h"
#include "gflags/gflags.h"

using com::seagate::kinetic::client::proto::Command_Algorithm_SHA1;
using kinetic::Status;
using kinetic::KineticRecord;
using kinetic::MediaScanRequest;
using kinetic::MediaOptimizeRequest;
using kinetic::RequestPriority;

using std::unique_ptr;

DEFINE_string(start_key, "", "MediaOptimize start key");
DEFINE_string(start_key_inclusive, "true", "MediaOptimize start key inclusive");
DEFINE_string(end_key, "", "MediaOptimize end key");
DEFINE_string(end_key_inclusive, "true", "MediaOptimize end key inclusive");

int example_main(
std::shared_ptr<kinetic::NonblockingKineticConnection> nonblocking_connection,
std::shared_ptr<kinetic::BlockingKineticConnection> blocking_connection,
int argc, char** argv) {
//media optimize
MediaOptimizeRequest media_optimize_request;
media_optimize_request.start_key = FLAGS_start_key;
media_optimize_request.end_key = FLAGS_end_key;
media_optimize_request.start_key_inclusive = FLAGS_start_key_inclusive.compare("true") == 0;
media_optimize_request.end_key_inclusive = FLAGS_end_key_inclusive.compare("true") == 0;

RequestPriority priority = RequestPriority::Priority_NORMAL;
kinetic::KineticStatus status = blocking_connection->MediaOptimize(
media_optimize_request, priority);
std::string result = status.ok() ? "success" : "failure";
printf("Media optimize %s ~ %s return %s\n",
media_optimize_request.start_key.c_str(),
media_optimize_request.end_key.c_str(), result.c_str());

return 0;
}
60 changes: 60 additions & 0 deletions src/media_scan_blocking.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

// This allows changing a drive's cluster version
#include <stdio.h>

#include "kinetic/kinetic.h"
#include "gflags/gflags.h"

using com::seagate::kinetic::client::proto::Command_Algorithm_SHA1;
using kinetic::Status;
using kinetic::KineticRecord;
using kinetic::MediaScanRequest;
using kinetic::MediaOptimizeRequest;
using kinetic::RequestPriority;

using std::unique_ptr;

DEFINE_string(start_key, "", "MediaScan start key");
DEFINE_string(start_key_inclusive, "true", "MediaScan start key inclusive");
DEFINE_string(end_key, "", "MediaScan end key");
DEFINE_string(end_key_inclusive, "true", "MediaScan end key inclusive");

int example_main(
std::shared_ptr<kinetic::NonblockingKineticConnection> nonblocking_connection,
std::shared_ptr<kinetic::BlockingKineticConnection> blocking_connection,
int argc, char** argv) {
//media scan
MediaScanRequest media_scan_request;
media_scan_request.start_key = FLAGS_start_key;
media_scan_request.end_key = FLAGS_end_key;
media_scan_request.start_key_inclusive = FLAGS_start_key_inclusive.compare("true") == 0;
media_scan_request.end_key_inclusive = FLAGS_end_key_inclusive.compare("true") == 0;

RequestPriority priority = RequestPriority::Priority_NORMAL;
kinetic::KineticStatus status = blocking_connection->MediaScan(
media_scan_request, priority);
std::string result = status.ok() ? "success" : "failure";
printf("Media scan %s ~ %s return %s\n", media_scan_request.start_key.c_str(),
media_scan_request.end_key.c_str(), result.c_str());

return 0;
}