00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 # include <dtn-config.h>
00019 #endif
00020
00021 #include "StorageCommand.h"
00022 #include "bundling/BundlePayload.h"
00023 #include "storage/BundleStore.h"
00024 #include "storage/DTNStorageConfig.h"
00025
00026 namespace dtn {
00027
00028 StorageCommand::StorageCommand(DTNStorageConfig* cfg)
00029 : TclCommand(cfg->cmd_.c_str())
00030 {
00031 inited_ = false;
00032
00033 bind_var(new oasys::StringOpt("type", &cfg->type_,
00034 "type", "What storage system to use."));
00035 bind_var(new oasys::StringOpt("dbname", &cfg->dbname_,
00036 "name", "The database name."));
00037 bind_var(new oasys::StringOpt("dbdir", &cfg->dbdir_,
00038 "dir", "The database directory."));
00039
00040 bind_var(new oasys::BoolOpt("init_db", &cfg->init_,
00041 "Same as the --init-db argument to dtnd."));
00042 bind_var(new oasys::BoolOpt("tidy", &cfg->tidy_,
00043 "Same as the --tidy argument to dtnd."));
00044 bind_var(new oasys::IntOpt("tidy_wait", &cfg->tidy_wait_,
00045 "time",
00046 "How long to wait before really doing "
00047 "the tidy operation."));
00048
00049 bind_var(new oasys::IntOpt("fs_fd_cache_size", &cfg->fs_fd_cache_size_,
00050 "num", "number of open fds to cache"));
00051
00052 bind_var(new oasys::BoolOpt("db_mpool", &cfg->db_mpool_,
00053 "use mpool in Berkeley DB"));
00054 bind_var(new oasys::BoolOpt("db_log", &cfg->db_log_,
00055 "use logging in Berkeley DB"));
00056 bind_var(new oasys::BoolOpt("db_txn", &cfg->db_txn_,
00057 "use transactions in Berkeley DB"));
00058 bind_var(new oasys::BoolOpt("db_sharefile", &cfg->db_sharefile_,
00059 "use shared database file"));
00060 bind_var(new oasys::IntOpt("db_max_tx", &cfg->db_max_tx_,
00061 "num", "max # of active transactions in Berkeley DB"));
00062 bind_var(new oasys::IntOpt("db_max_locks", &cfg->db_max_locks_,
00063 "num", "max # of active locks in Berkeley DB"));
00064 bind_var(new oasys::IntOpt("db_max_lockers", &cfg->db_max_lockers_,
00065 "num", "max # of active locking threads in Berkeley DB"));
00066 bind_var(new oasys::IntOpt("db_max_lockedobjs", &cfg->db_max_lockedobjs_,
00067 "num", "max # of active locked objects in Berkeley DB"));
00068 bind_var(new oasys::IntOpt("db_lockdetect", &cfg->db_lockdetect_,
00069 "freq", "frequency to check for Berkeley DB deadlocks "
00070 "(zero disables locking)"));
00071
00072 bind_var(new oasys::StringOpt("payloaddir", &cfg->payload_dir_, "dir",
00073 "directory for payloads while in transit"));
00074
00075 bind_var(new oasys::UInt64Opt("payload_quota",
00076 &cfg->payload_quota_, "bytes",
00077 "storage quota for bundle payloads "
00078 "(0 is unlimited)"));
00079
00080 bind_var(new oasys::UIntOpt("payload_fd_cache_size",
00081 &cfg->payload_fd_cache_size_, "num",
00082 "number of payload file descriptors to keep "
00083 "open in a cache"));
00084
00085 bind_var(new oasys::UInt16Opt("server_port",
00086 &cfg->server_port_,
00087 "port number",
00088 "TCP port for IPC to external data store"));
00089
00090 bind_var(new oasys::StringOpt("schema", &cfg->schema_, "pathname",
00091 "File containing the XML schema for the "
00092 "external data store interface"));
00093
00094 add_to_help("usage", "print the current storage usage");
00095 }
00096
00097
00098 int
00099 StorageCommand::exec(int argc, const char** argv, Tcl_Interp* interp)
00100 {
00101 (void)interp;
00102
00103 if (argc < 2) {
00104 resultf("need a storage subcommand");
00105 return TCL_ERROR;
00106 }
00107
00108 const char* cmd = argv[1];
00109
00110 if (!strcmp(cmd, "usage")) {
00111
00112 resultf("bundles %llu", U64FMT(BundleStore::instance()->total_size()));
00113 return TCL_OK;
00114 }
00115
00116 resultf("unknown storage subcommand %s", cmd);
00117 return TCL_ERROR;
00118 }
00119
00120 }