StorageCommand.cc

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #include "StorageCommand.h"
00018 #include "bundling/BundlePayload.h"
00019 #include "storage/BundleStore.h"
00020 #include "storage/DTNStorageConfig.h"
00021 
00022 namespace dtn {
00023 
00024 StorageCommand::StorageCommand(DTNStorageConfig* cfg)
00025     : TclCommand(cfg->cmd_.c_str())
00026 {
00027     inited_ = false;
00028     
00029     bind_var(new oasys::StringOpt("type", &cfg->type_,
00030                                   "type", "What storage system to use."));
00031     bind_var(new oasys::StringOpt("dbname", &cfg->dbname_,
00032                                   "name", "The database name."));
00033     bind_var(new oasys::StringOpt("dbdir", &cfg->dbdir_,
00034                                   "dir", "The database directory."));
00035 
00036     bind_var(new oasys::BoolOpt("init_db", &cfg->init_,
00037                                 "Same as the --init-db argument to dtnd."));
00038     bind_var(new oasys::BoolOpt("tidy", &cfg->tidy_,
00039                                 "Same as the --tidy argument to dtnd."));
00040     bind_var(new oasys::IntOpt("tidy_wait", &cfg->tidy_wait_,
00041                                "time",
00042                                "How long to wait before really doing "
00043                                "the tidy operation."));
00044 
00045     bind_var(new oasys::IntOpt("fs_fd_cache_size", &cfg->fs_fd_cache_size_, 
00046                                "num", "number of open fds to cache"));
00047 
00048     bind_var(new oasys::BoolOpt("db_mpool", &cfg->db_mpool_,
00049                                 "use mpool in Berkeley DB"));
00050     bind_var(new oasys::BoolOpt("db_log", &cfg->db_log_,
00051                                 "use logging in Berkeley DB"));
00052     bind_var(new oasys::BoolOpt("db_txn", &cfg->db_txn_,
00053                                 "use transactions in Berkeley DB"));
00054     bind_var(new oasys::BoolOpt("db_sharefile", &cfg->db_sharefile_,
00055                                 "use shared database file"));
00056     bind_var(new oasys::IntOpt("db_max_tx", &cfg->db_max_tx_,
00057                                "num", "max # of active transactions in Berkeley DB"));
00058     bind_var(new oasys::IntOpt("db_max_locks", &cfg->db_max_locks_,
00059                                "num", "max # of active locks in Berkeley DB"));
00060     bind_var(new oasys::IntOpt("db_max_lockers", &cfg->db_max_lockers_,
00061                                "num", "max # of active locking threads in Berkeley DB"));
00062     bind_var(new oasys::IntOpt("db_max_lockedobjs", &cfg->db_max_lockedobjs_,
00063                                "num", "max # of active locked objects in Berkeley DB"));
00064     bind_var(new oasys::IntOpt("db_lockdetect", &cfg->db_lockdetect_,
00065                                "freq", "frequency to check for Berkeley DB deadlocks "
00066                                "(zero disables locking)"));
00067 
00068     bind_var(new oasys::StringOpt("payloaddir", &cfg->payload_dir_, "dir",
00069                                   "directory for payloads while in transit"));
00070     
00071     bind_var(new oasys::UInt64Opt("payload_quota",
00072                                   &cfg->payload_quota_, "bytes",
00073                                   "storage quota for bundle payloads "
00074                                   "(0 is unlimited)"));
00075     
00076     bind_var(new oasys::UIntOpt("payload_fd_cache_size",
00077                                 &cfg->payload_fd_cache_size_, "num",
00078                                 "number of payload file descriptors to keep "
00079                                 "open in a cache"));
00080 
00081     add_to_help("usage", "print the current storage usage");
00082 }
00083 
00084 //----------------------------------------------------------------------
00085 int
00086 StorageCommand::exec(int argc, const char** argv, Tcl_Interp* interp)
00087 {
00088     (void)interp;
00089     
00090     if (argc < 2) {
00091         resultf("need a storage subcommand");
00092         return TCL_ERROR;
00093     }
00094 
00095     const char* cmd = argv[1];
00096 
00097     if (!strcmp(cmd, "usage")) {
00098         // storage usage
00099         resultf("bundles %llu", U64FMT(BundleStore::instance()->total_size()));
00100         return TCL_OK;
00101     }
00102 
00103     resultf("unknown storage subcommand %s", cmd);
00104     return TCL_ERROR;
00105 }
00106 
00107 } // namespace dtn

Generated on Thu Jun 7 16:56:52 2007 for DTN Reference Implementation by  doxygen 1.5.1