DVS Features
Part of Dynamic Visualization Store
Description of various features of the DVS API.
Description of various features of the DVS API.
Was this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
#include <string>
#include <chrono>
#include <thread>
#include "dvs_client_interface.h"
#include "dvs_server_interface.h"
#include "dynamic_visualization_store_enums.h"
static void logging_function(void* user_data, const char* message)
{
fprintf(stderr, message);
}
int main(int argc, char** argv)
{
std::string server_uri = "grpc://localhost:12345/";
DVS::IServer* server = DVS::CREATE_SERVER_INSTANCE(server_uri.c_str());
if (!server) {
//Error creating server
return -1;
}
std::string cache_uri = "hdf5://localhost/D:/my/cache/location";
//Set a cache uri location if saving/caching data
server->set_option("CACHE_URI", cache_uri.c_str());
uint32_t server_number = 0; //Zero based server number
uint32_t local_ranks = 1; //Number of local ranks for this specific server
server->startup(server_number, local_ranks);
//Turn on blocking for server and client side deduplication
dvs_client_flags client_flags = dvs_client_flags::BLOCK_FOR_SERVER | dvs_client_flags::DEDUP;
std::string shared_secret = ""; // Can use a shared secret to authenticate clients with server
DVS::IClient* client = DVS::CREATE_CLIENT_INSTANCE(server, client_flags, shared_secret.c_str());
if (!client) {
//Error creating client
return -2;
}
dvs_log_flags log_flags = dvs_log_flags::LOG_ALL; //Turn on all logging for debugging
client->set_logger(new DVS::Logger(nullptr, log_flags, logging_function));
std::string dataset_name = "my_dataset";
uint32_t my_rank = 0; //Zero based rank number;
uint32_t num_global_ranks = 1; //Number of global ranks across all servers
uint32_t num_chunks = 1; //Number of chunks this rank is using, 1 if not using chunking
//Initialize dataset
client->begin_init(dataset_name.c_str(), my_rank, num_global_ranks, num_chunks);
client->set_unit_system("SI");
{
//Add a part
dvs_part_info part_info;
part_info._id = 1;
part_info._name = "Part 1";
part_info._structured = 0;
part_info._chunking = 0;
part_info._metadata_num_pairs = 0;
part_info._metadata_keys = nullptr;
part_info._metadata_vals = nullptr;
client->add_part_info(&part_info, 1);
}
{
//Add a var
dvs_var_info var_info;
var_info._id = 1;
var_info._name = "Var 1";
var_info._type = dvs_var_type::SCALAR;
var_info._location = dvs_var_location::NODE;
var_info._unit = "";
var_info._unit_label = "";
var_info._metadata_num_pairs = 0;
var_info._metadata_keys = nullptr;
var_info._metadata_vals = nullptr;
client->add_var_info(&var_info, 1);
}
client->end_init();
//Delete all timesteps after 5.5 seconds
//See the DVS Cache URI section on Query Stanza's for more information on filtering.
//The delete item API only supports timestep.time objects currently.
client->delete_item(my_rank, "/timestep.time/gte/5.5");
DVS::DESTROY_CLIENT_INSTANCE(client);
uint32_t num_pending = 1;
uint32_t num_complete = 0;
//Wait until the server finished before shutting it down or the write operations may not complete
while (num_pending > 0) {
dvs_ret error = server->get_timestep_count(num_pending, num_complete);
if (error != DVS_NONE) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
DVS::DESTROY_SERVER_INSTANCE(server);
}
Was this page helpful?