mirror of https://gitee.com/bigwinds/arangodb
added flag for default journal size
This commit is contained in:
parent
22db9dd361
commit
fbad5735b1
|
@ -171,6 +171,7 @@ AvocadoServer::AvocadoServer (int argc, char** argv)
|
|||
_databasePath("/var/lib/avocado"),
|
||||
_removeOnDrop(true),
|
||||
_removeOnCompacted(true),
|
||||
_defaultMaximalSize(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE),
|
||||
_vocbase(0) {
|
||||
char* p;
|
||||
|
||||
|
@ -353,6 +354,7 @@ void AvocadoServer::buildApplicationServer () {
|
|||
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.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"]
|
||||
|
@ -811,6 +813,7 @@ void AvocadoServer::openDatabase () {
|
|||
|
||||
_vocbase->_removeOnDrop = _removeOnDrop;
|
||||
_vocbase->_removeOnCompacted = _removeOnCompacted;
|
||||
_vocbase->_defaultMaximalSize = _defaultMaximalSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -333,6 +333,8 @@ namespace triagens {
|
|||
/// collection directory will be renamed to @LIT{deleted-...}, but remains on
|
||||
/// hard disk. To restore such a dropped collection, you can simple rename to
|
||||
/// the directory to @LIT{collection-...}.
|
||||
///
|
||||
/// The default is @LIT{true}.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _removeOnDrop;
|
||||
|
@ -345,10 +347,26 @@ namespace triagens {
|
|||
/// Normally the garbage collection will removed compacted datafile. For debug
|
||||
/// purposes you can use this option to keep the old datafiles. You should
|
||||
/// never set it to @LIT{false} on a live system.
|
||||
///
|
||||
/// The default is @LIT{true}.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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
|
||||
///
|
||||
|
|
|
@ -142,6 +142,8 @@
|
|||
///
|
||||
/// <ol>
|
||||
/// <li>database.directory</li>
|
||||
/// <li>database.remove-on-drop</li>
|
||||
/// <li>database.maximal-journal-size</li>
|
||||
/// <li>server.admin-port</li>
|
||||
/// <li>server.http-port</li>
|
||||
/// </ol>
|
||||
|
@ -156,6 +158,10 @@
|
|||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_databasePath
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_removeOnDrop
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_defaultMaximalSize
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_adminPort
|
||||
///
|
||||
/// @copydetails triagens::avocado::AvocadoServer::_httpPort
|
||||
|
|
|
@ -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);
|
||||
|
||||
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
|
||||
if (argv.Length() != 2) {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("usage: _create(<name>, <wait-for-sync>)")));
|
||||
// expecting at least one arguments
|
||||
if (argv.Length() < 1) {
|
||||
return scope.Close(v8::ThrowException(
|
||||
CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: _create(<name>, <parameters>)")));
|
||||
}
|
||||
|
||||
// extract the name
|
||||
string name = TRI_ObjectToString(argv[0]);
|
||||
|
||||
// extract the parameter
|
||||
TRI_col_parameter_t parameter;
|
||||
|
||||
TRI_InitParameterCollection(¶meter, name.c_str(), DEFAULT_MAXIMAL_SIZE);
|
||||
parameter._waitForSync = TRI_ObjectToBoolean(argv[1]);
|
||||
if (2 <= argv.Length()) {
|
||||
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(¶meter, name.c_str(), (TRI_voc_size_t) s);
|
||||
}
|
||||
else {
|
||||
TRI_InitParameterCollection(¶meter, name.c_str(), vocbase->_defaultMaximalSize);
|
||||
}
|
||||
|
||||
if (p->Has(waitForSyncKey)) {
|
||||
parameter._waitForSync = TRI_ObjectToBoolean(p->Get(waitForSyncKey));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
TRI_InitParameterCollection(¶meter, name.c_str(), vocbase->_defaultMaximalSize);
|
||||
}
|
||||
|
||||
|
||||
TRI_vocbase_col_t const* collection = TRI_CreateCollectionVocBase(vocbase, ¶meter);
|
||||
|
||||
|
|
|
@ -668,7 +668,7 @@ static int ManifestCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t*
|
|||
TRI_sim_collection_t* sim;
|
||||
TRI_col_parameter_t parameter;
|
||||
|
||||
TRI_InitParameterCollection(¶meter, collection->_name, DEFAULT_MAXIMAL_SIZE);
|
||||
TRI_InitParameterCollection(¶meter, collection->_name, TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE);
|
||||
|
||||
parameter._type = type;
|
||||
parameter._waitForSync = false;
|
||||
|
@ -1048,9 +1048,10 @@ TRI_vocbase_t* TRI_OpenVocBase (char const* path) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// defaults for remove
|
||||
// defaults
|
||||
vocbase->_removeOnDrop = true;
|
||||
vocbase->_removeOnCompacted = true;
|
||||
vocbase->_defaultMaximalSize = TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE;
|
||||
|
||||
// vocbase is now active
|
||||
vocbase->_active = 1;
|
||||
|
|
|
@ -142,7 +142,13 @@ extern size_t PageSize;
|
|||
/// @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
|
||||
|
@ -270,6 +276,7 @@ typedef struct TRI_vocbase_s {
|
|||
|
||||
bool _removeOnDrop; // wipe collection from disk after dropping
|
||||
bool _removeOnCompacted; // wipe datafile from disk after compaction
|
||||
TRI_voc_size_t _defaultMaximalSize;
|
||||
|
||||
TRI_read_write_lock_t _lock;
|
||||
|
||||
|
|
|
@ -110,6 +110,10 @@ function CollectionRepresentation (collection, showProperties, showCount, showFi
|
|||
/// is synchronised to disk before returning from a create or update of an
|
||||
/// 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
|
||||
///
|
||||
/// @verbinclude api-collection-create-collection
|
||||
|
@ -133,14 +137,18 @@ function POST_api_collection (req, res) {
|
|||
}
|
||||
|
||||
var name = body.name;
|
||||
var waitForSync = false;
|
||||
var parameter = { waitForSync : false };
|
||||
|
||||
if (body.hasOwnProperty("waitForSync")) {
|
||||
waitForSync = body.waitForSync;
|
||||
parameter.waitForSync = body.waitForSync;
|
||||
}
|
||||
|
||||
if (body.hasOwnProperty("journalSize")) {
|
||||
parameter.waitForSync = body.journalSize;
|
||||
}
|
||||
|
||||
try {
|
||||
var collection = db._create(name, waitForSync);
|
||||
var collection = db._create(name, parameter);
|
||||
|
||||
var result = {};
|
||||
var headers = {};
|
||||
|
|
Loading…
Reference in New Issue