1
0
Fork 0

added flag for default journal size

This commit is contained in:
Frank Celler 2012-04-10 15:58:04 +02:00
parent 22db9dd361
commit fbad5735b1
7 changed files with 90 additions and 12 deletions

View File

@ -171,6 +171,7 @@ AvocadoServer::AvocadoServer (int argc, char** argv)
_databasePath("/var/lib/avocado"), _databasePath("/var/lib/avocado"),
_removeOnDrop(true), _removeOnDrop(true),
_removeOnCompacted(true), _removeOnCompacted(true),
_defaultMaximalSize(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE),
_vocbase(0) { _vocbase(0) {
char* p; char* p;
@ -353,6 +354,7 @@ void AvocadoServer::buildApplicationServer () {
additional["DATABASE Options:help-admin"] additional["DATABASE Options:help-admin"]
("database.directory", &_databasePath, "path to the database directory (use this option in configuration files instead of passing it via the command line)") ("database.directory", &_databasePath, "path to the database directory (use this option in configuration files instead of passing it via the command line)")
("database.remove-on-drop", &_removeOnDrop, "wipe a collection from disk after dropping") ("database.remove-on-drop", &_removeOnDrop, "wipe a collection from disk after dropping")
("database.maximal-journal-size", &_defaultMaximalSize, "default maximal journal size, can be overwritten when creating a collection")
; ;
additional["DATABASE Options:help-devel"] additional["DATABASE Options:help-devel"]
@ -811,6 +813,7 @@ void AvocadoServer::openDatabase () {
_vocbase->_removeOnDrop = _removeOnDrop; _vocbase->_removeOnDrop = _removeOnDrop;
_vocbase->_removeOnCompacted = _removeOnCompacted; _vocbase->_removeOnCompacted = _removeOnCompacted;
_vocbase->_defaultMaximalSize = _defaultMaximalSize;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -333,6 +333,8 @@ namespace triagens {
/// collection directory will be renamed to @LIT{deleted-...}, but remains on /// collection directory will be renamed to @LIT{deleted-...}, but remains on
/// hard disk. To restore such a dropped collection, you can simple rename to /// hard disk. To restore such a dropped collection, you can simple rename to
/// the directory to @LIT{collection-...}. /// the directory to @LIT{collection-...}.
///
/// The default is @LIT{true}.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool _removeOnDrop; bool _removeOnDrop;
@ -345,10 +347,26 @@ namespace triagens {
/// Normally the garbage collection will removed compacted datafile. For debug /// Normally the garbage collection will removed compacted datafile. For debug
/// purposes you can use this option to keep the old datafiles. You should /// purposes you can use this option to keep the old datafiles. You should
/// never set it to @LIT{false} on a live system. /// never set it to @LIT{false} on a live system.
///
/// The default is @LIT{true}.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool _removeOnCompacted; bool _removeOnCompacted;
////////////////////////////////////////////////////////////////////////////////
/// @brief default journal size
///
/// @CMDOPT{--database.maximal-journal-size @CA{size}}
///
/// Maximal size of journal in bytes. Can be overwritten when creating a new
/// collection. Note that this also limits the maximal size of a single
/// document.
///
/// The default is @LIT{32MB}.
////////////////////////////////////////////////////////////////////////////////
uint64_t _defaultMaximalSize;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief unit tests /// @brief unit tests
/// ///

View File

@ -142,6 +142,8 @@
/// ///
/// <ol> /// <ol>
/// <li>database.directory</li> /// <li>database.directory</li>
/// <li>database.remove-on-drop</li>
/// <li>database.maximal-journal-size</li>
/// <li>server.admin-port</li> /// <li>server.admin-port</li>
/// <li>server.http-port</li> /// <li>server.http-port</li>
/// </ol> /// </ol>
@ -156,6 +158,10 @@
/// ///
/// @copydetails triagens::avocado::AvocadoServer::_databasePath /// @copydetails triagens::avocado::AvocadoServer::_databasePath
/// ///
/// @copydetails triagens::avocado::AvocadoServer::_removeOnDrop
///
/// @copydetails triagens::avocado::AvocadoServer::_defaultMaximalSize
///
/// @copydetails triagens::avocado::AvocadoServer::_adminPort /// @copydetails triagens::avocado::AvocadoServer::_adminPort
/// ///
/// @copydetails triagens::avocado::AvocadoServer::_httpPort /// @copydetails triagens::avocado::AvocadoServer::_httpPort

View File

@ -4988,20 +4988,55 @@ static v8::Handle<v8::Value> JS_CreateVocBase (v8::Arguments const& argv) {
TRI_vocbase_t* vocbase = UnwrapClass<TRI_vocbase_t>(argv.Holder(), WRP_VOCBASE_TYPE); TRI_vocbase_t* vocbase = UnwrapClass<TRI_vocbase_t>(argv.Holder(), WRP_VOCBASE_TYPE);
if (vocbase == 0) { if (vocbase == 0) {
return scope.Close(v8::ThrowException(v8::String::New("corrupted vocbase"))); return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_INTERNAL, "corrupted vocbase")));
} }
// expecting two arguments // expecting at least one arguments
if (argv.Length() != 2) { if (argv.Length() < 1) {
return scope.Close(v8::ThrowException(v8::String::New("usage: _create(<name>, <wait-for-sync>)"))); return scope.Close(v8::ThrowException(
CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
"usage: _create(<name>, <parameters>)")));
} }
// extract the name
string name = TRI_ObjectToString(argv[0]); string name = TRI_ObjectToString(argv[0]);
// extract the parameter
TRI_col_parameter_t parameter; TRI_col_parameter_t parameter;
TRI_InitParameterCollection(&parameter, name.c_str(), DEFAULT_MAXIMAL_SIZE); if (2 <= argv.Length()) {
parameter._waitForSync = TRI_ObjectToBoolean(argv[1]); if (! argv[1]->IsObject()) {
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_BAD_PARAMETER, "<parameters> must be an object")));
}
v8::Handle<v8::Object> p = argv[1]->ToObject();
v8::Handle<v8::String> waitForSyncKey = v8::String::New("waitForSync");
v8::Handle<v8::String> journalSizeKey = v8::String::New("journalSize");
if (p->Has(journalSizeKey)) {
double s = TRI_ObjectToDouble(p->Get(journalSizeKey));
if (s < TRI_JOURNAL_MINIMAL_SIZE) {
return scope.Close(v8::ThrowException(
CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
"<parameters>.journalSize too small")));
}
TRI_InitParameterCollection(&parameter, name.c_str(), (TRI_voc_size_t) s);
}
else {
TRI_InitParameterCollection(&parameter, name.c_str(), vocbase->_defaultMaximalSize);
}
if (p->Has(waitForSyncKey)) {
parameter._waitForSync = TRI_ObjectToBoolean(p->Get(waitForSyncKey));
}
}
else {
TRI_InitParameterCollection(&parameter, name.c_str(), vocbase->_defaultMaximalSize);
}
TRI_vocbase_col_t const* collection = TRI_CreateCollectionVocBase(vocbase, &parameter); TRI_vocbase_col_t const* collection = TRI_CreateCollectionVocBase(vocbase, &parameter);

View File

@ -668,7 +668,7 @@ static int ManifestCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t*
TRI_sim_collection_t* sim; TRI_sim_collection_t* sim;
TRI_col_parameter_t parameter; TRI_col_parameter_t parameter;
TRI_InitParameterCollection(&parameter, collection->_name, DEFAULT_MAXIMAL_SIZE); TRI_InitParameterCollection(&parameter, collection->_name, TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE);
parameter._type = type; parameter._type = type;
parameter._waitForSync = false; parameter._waitForSync = false;
@ -1048,9 +1048,10 @@ TRI_vocbase_t* TRI_OpenVocBase (char const* path) {
return NULL; return NULL;
} }
// defaults for remove // defaults
vocbase->_removeOnDrop = true; vocbase->_removeOnDrop = true;
vocbase->_removeOnCompacted = true; vocbase->_removeOnCompacted = true;
vocbase->_defaultMaximalSize = TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE;
// vocbase is now active // vocbase is now active
vocbase->_active = 1; vocbase->_active = 1;

View File

@ -142,7 +142,13 @@ extern size_t PageSize;
/// @brief default maximal collection journal size /// @brief default maximal collection journal size
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define DEFAULT_MAXIMAL_SIZE (1024 * 1024 * 128) #define TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE (1024 * 1024 * 32)
////////////////////////////////////////////////////////////////////////////////
/// @brief minimal collection journal size
////////////////////////////////////////////////////////////////////////////////
#define TRI_JOURNAL_MINIMAL_SIZE (1024 * 1024 * 128)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief document handle separator as character /// @brief document handle separator as character
@ -270,6 +276,7 @@ typedef struct TRI_vocbase_s {
bool _removeOnDrop; // wipe collection from disk after dropping bool _removeOnDrop; // wipe collection from disk after dropping
bool _removeOnCompacted; // wipe datafile from disk after compaction bool _removeOnCompacted; // wipe datafile from disk after compaction
TRI_voc_size_t _defaultMaximalSize;
TRI_read_write_lock_t _lock; TRI_read_write_lock_t _lock;

View File

@ -110,6 +110,10 @@ function CollectionRepresentation (collection, showProperties, showCount, showFi
/// is synchronised to disk before returning from a create or update of an /// is synchronised to disk before returning from a create or update of an
/// document. /// document.
/// ///
/// @LIT{journalSize} (optional, default 32MB): The maximal size of a
/// journal or datafile. Note that this also limits the maximal size
/// of a single object. Must be at least 1MB.
///
/// @EXAMPLES /// @EXAMPLES
/// ///
/// @verbinclude api-collection-create-collection /// @verbinclude api-collection-create-collection
@ -133,14 +137,18 @@ function POST_api_collection (req, res) {
} }
var name = body.name; var name = body.name;
var waitForSync = false; var parameter = { waitForSync : false };
if (body.hasOwnProperty("waitForSync")) { if (body.hasOwnProperty("waitForSync")) {
waitForSync = body.waitForSync; parameter.waitForSync = body.waitForSync;
}
if (body.hasOwnProperty("journalSize")) {
parameter.waitForSync = body.journalSize;
} }
try { try {
var collection = db._create(name, waitForSync); var collection = db._create(name, parameter);
var result = {}; var result = {};
var headers = {}; var headers = {};