To build the examples you need `cmake`, `git` and a working build system. Once you've acquired those items you can build all the examples by running:
Overview
========
This repository contains a number of examples showing how to use the Kinetic C++ client in different way. Each example is fairly simple but includes error handling and they cover threaded and non-blocking IO.
Building
========
The examples live in the `src` directory . To build them examples you need `cmake`, `git` and a working build system. Once you've acquired those items you can build all the examples by running:
cmake .
make
Binaries will appear in the working directory. The first build takes several minutes because all the dependencies are downloaded and compiled.
Examples
========
`CMakeLists.txt` provides a starting point for including the Kinetic C++ client in CMake-based projects.
All the examples have shared boilerplate code for command line argument parsing, logging setup, etc. This common code is extracted out into `src/command_line_flags.h` and `src/example_main.cc`.
`copydrive` (see `src/copydrive.cc`)
-----------
This example uses the P2P push functionality to copy an entire keyspace from one drive to one or more other drives. For example, to run a pipeline that
looks like A -> B -> C you could call it like so:
./copydrive A 8123 B 8123 C 4444
`dump_keyspace` (see `src/dump_keyspace.cc`)
---------------
This example uses the C++ client iterator (which uses GetKeyRange internally) to print the entire keyspace of the given drive. You can expose it like so:
./dump_keyspace 127.0.0.1 8123
`firmware_update` (see `src/firmware_update.cc`)
-----------------
The Kinetic API allows supplying new firmware images. This example shows how to do this. To invoke it run:
This example shows how to use the ISE functionality to immediately wipe a drive. To try it out run:
./ise -host 127.1 -port 8123
`kineticstat` (see `src/kineticstat.cc`)
-------------
The Kinetic API exposes rich management detail available via the GetLog command. The `kineticstat` example shows how to present this information in different ways. Some fun things to try:
* Dump all available info: `./kineticstat -host 127.1 -port 8123 -type all`
The remaining examples form a more complex app that allows storing, retrieveing and deleting large files in a Kinetic implementation. They break up the file into 1MB chunks and store each chunk in its own keys. During
retrieval the individual chunks are re-assembled. For instance, suppose you create a file called `my_precious_data` by doing something like this:
Those example programs are implemented in `src/write_file_blocking.cc`, `src/write_file_blocking_threads.cc`, and `src/write_file_nonblocking.cc`. They all do the same thing but use non-blocking IO, blocking IO, or multi-threaded blocking IO to demonstrate different styles.