本文整理汇总了C++中curTimeMicros64函数的典型用法代码示例。如果您正苦于以下问题:C++ curTimeMicros64函数的具体用法?C++ curTimeMicros64怎么用?C++ curTimeMicros64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curTimeMicros64函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: curTimeMicros64
void Stats::rotate() {
unsigned long long now = curTimeMicros64();
unsigned long long dt = now - _lastRotate;
if( dt >= _intervalMicros && _intervalMicros ) {
// rotate
curr->_dtMillis = (unsigned) (dt/1000);
_lastRotate = now;
curr = other();
curr->reset();
}
}
开发者ID:Aaron20141021,项目名称:mongo,代码行数:11,代码来源:dur.cpp
示例2: REMAPPRIVATEVIEW
/** We need to remap the private views periodically. otherwise they would become very large.
Call within write lock.
*/
void REMAPPRIVATEVIEW() {
static unsigned startAt;
static unsigned long long lastRemap;
dbMutex.assertWriteLocked();
dbMutex._remapPrivateViewRequested = false;
assert( !commitJob.hasWritten() );
if( 0 ) {
log() << "TEMP remapprivateview disabled for testing - will eventually run oom in this mode if db bigger than ram" << endl;
return;
}
// we want to remap all private views about every 2 seconds. there could be ~1000 views so
// we do a little each pass; beyond the remap time, more significantly, there will be copy on write
// faults after remapping, so doing a little bit at a time will avoid big load spikes on
// remapping.
unsigned long long now = curTimeMicros64();
double fraction = (now-lastRemap)/20000000.0;
set<MongoFile*>& files = MongoFile::getAllFiles();
unsigned sz = files.size();
if( sz == 0 )
return;
unsigned ntodo = (unsigned) (sz * fraction);
if( ntodo < 1 ) ntodo = 1;
if( ntodo > sz ) ntodo = sz;
const set<MongoFile*>::iterator b = files.begin();
const set<MongoFile*>::iterator e = files.end();
set<MongoFile*>::iterator i = b;
// skip to our starting position
for( unsigned x = 0; x < startAt; x++ ) {
i++;
if( i == e ) i = b;
}
startAt = (startAt + ntodo) % sz; // mark where to start next time
for( unsigned x = 0; x < ntodo; x++ ) {
dassert( i != e );
if( (*i)->isMongoMMF() ) {
MongoMMF *mmf = (MongoMMF*) *i;
assert(mmf);
if( mmf->willNeedRemap() ) {
mmf->willNeedRemap() = false;
mmf->remapThePrivateView();
}
i++;
if( i == e ) i = b;
}
}
}
开发者ID:meganyao,项目名称:mongo,代码行数:56,代码来源:dur.cpp
示例3: curTimeMicros64
void CurOp::ensureStarted() {
if ( _start == 0 ) {
_start = curTimeMicros64();
// If ensureStarted() is invoked after setMaxTimeMicros(), then time limit tracking will
// start here. This is because time limit tracking can only commence after the
// operation is assigned a start time.
if (_maxTimeMicros > 0) {
_maxTimeTracker.setTimeLimit(_start, _maxTimeMicros);
}
}
}
开发者ID:Benguang,项目名称:mongo,代码行数:12,代码来源:curop.cpp
示例4: socket
bool Socket::connect(SockAddr& remote) {
_remote = remote;
_fd = socket(remote.getType(), SOCK_STREAM, 0);
if ( _fd == INVALID_SOCKET ) {
LOG(_logLevel) << "ERROR: connect invalid socket " << errnoWithDescription() << endl;
return false;
}
if ( _timeout > 0 ) {
setTimeout( _timeout );
}
static const unsigned int connectTimeoutMillis = 5000;
ConnectBG bg(_fd, remote);
bg.go();
if ( bg.wait(connectTimeoutMillis) ) {
if ( bg.inError() ) {
warning() << "Failed to connect to "
<< _remote.getAddr() << ":" << _remote.getPort()
<< ", reason: " << bg.getErrnoWithDescription() << endl;
close();
return false;
}
}
else {
// time out the connect
close();
bg.wait(); // so bg stays in scope until bg thread terminates
warning() << "Failed to connect to "
<< _remote.getAddr() << ":" << _remote.getPort()
<< " after " << connectTimeoutMillis << " milliseconds, giving up." << endl;
return false;
}
if (remote.getType() != AF_UNIX)
disableNagle(_fd);
#ifdef SO_NOSIGPIPE
// ignore SIGPIPE signals on osx, to avoid process exit
const int one = 1;
setsockopt( _fd , SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(int));
#endif
_local = getLocalAddrForBoundSocketFd(_fd);
_fdCreationMicroSec = curTimeMicros64();
_awaitingHandshake = false;
return true;
}
开发者ID:byterock,项目名称:mongo,代码行数:52,代码来源:sock.cpp
示例5: socket
bool Socket::connect(SockAddr& remote) {
_remote = remote;
_fd = socket(remote.getType(), SOCK_STREAM, 0);
if ( _fd == INVALID_SOCKET ) {
LOG(_logLevel) << "ERROR: connect invalid socket " << errnoWithDescription() << endl;
return false;
}
if ( _timeout > 0 ) {
setTimeout( _timeout );
}
ConnectBG bg(_fd, remote);
bg.go();
if ( bg.wait(5000) ) {
if ( bg.inError() ) {
close();
return false;
}
}
else {
// time out the connect
close();
bg.wait(); // so bg stays in scope until bg thread terminates
return false;
}
if (remote.getType() != AF_UNIX)
disableNagle(_fd);
#ifdef SO_NOSIGPIPE
// ignore SIGPIPE signals on osx, to avoid process exit
const int one = 1;
setsockopt( _fd , SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(int));
#endif
_local = getLocalAddrForBoundSocketFd(_fd);
_fdCreationMicroSec = curTimeMicros64();
return true;
}
开发者ID:nathanielc,项目名称:mongo,代码行数:42,代码来源:sock.cpp
示例6: dassert
void CurOp::MaxTimeTracker::setTimeLimit(uint64_t startEpochMicros, uint64_t durationMicros) {
dassert(durationMicros != 0);
_enabled = true;
_targetEpochMicros = startEpochMicros + durationMicros;
uint64_t now = curTimeMicros64();
// If our accurate time source thinks time is not up yet, calculate the next target for
// our approximate time source.
if (_targetEpochMicros > now) {
_approxTargetServerMillis = Listener::getElapsedTimeMillis() +
static_cast<int64_t>((_targetEpochMicros - now) / 1000);
}
// Otherwise, set our approximate time source target such that it thinks time is already
// up.
else {
_approxTargetServerMillis = Listener::getElapsedTimeMillis();
}
}
开发者ID:Benguang,项目名称:mongo,代码行数:20,代码来源:curop.cpp
示例7: statsThread
void statsThread() {
/*cout << "TEMP disabled statsthread" << endl;
if( 1 )
return;*/
Client::initThread("stats");
unsigned long long timeLastPass = 0;
while ( 1 ) {
{
/* todo: do we even need readlock here? if so for what? */
readlock lk("");
Top::completeSnapshot();
q = (q+1)%NStats;
Timing timing;
dbMutex.info().getTimingInfo(timing.start, timing.timeLocked);
unsigned long long now = curTimeMicros64();
if ( timeLastPass ) {
unsigned long long dt = now - timeLastPass;
unsigned long long dlocked = timing.timeLocked - tlast.timeLocked;
{
stringstream ss;
ss << dt / 1000 << '\t';
ss << dlocked / 1000 << '\t';
if ( dt )
ss << (dlocked*100)/dt << '%';
string s = ss.str();
if ( cmdLine.cpu )
log() << "cpu: " << s << endl;
lockStats[q] = s;
ClientCursor::idleTimeReport( (unsigned) ((dt - dlocked)/1000) );
}
}
timeLastPass = now;
tlast = timing;
}
sleepsecs(4);
}
}
开发者ID:phildarnowsky,项目名称:mongo,代码行数:37,代码来源:dbwebserver.cpp
示例8: _initAndListen
//.........这里部分代码省略.........
//
// The invariant is *not* a statement that `repairDatabasesAndCheckVersion` must return
// `MustDowngrade`. Instead, it is meant as a guardrail to protect future developers from
// accidentally buying into this behavior. New errors that are returned from the method
// may or may not want to go through a clean shutdown, and they likely won't want the
// program to return an exit code of `EXIT_NEED_DOWNGRADE`.
severe(LogComponent::kControl) << "** IMPORTANT: "
<< swNonLocalDatabases.getStatus().reason();
invariant(swNonLocalDatabases == ErrorCodes::MustDowngrade);
exitCleanly(EXIT_NEED_DOWNGRADE);
}
// Assert that the in-memory featureCompatibilityVersion parameter has been explicitly set. If
// we are part of a replica set and are started up with no data files, we do not set the
// featureCompatibilityVersion until a primary is chosen. For this case, we expect the in-memory
// featureCompatibilityVersion parameter to still be uninitialized until after startup.
if (canCallFCVSetIfCleanStartup &&
(!replSettings.usingReplSets() || swNonLocalDatabases.getValue())) {
invariant(serverGlobalParams.featureCompatibility.isVersionInitialized());
}
if (storageGlobalParams.upgrade) {
log() << "finished checking dbs";
exitCleanly(EXIT_CLEAN);
}
// Start up health log writer thread.
HealthLog::get(startupOpCtx.get()).startup();
auto const globalAuthzManager = AuthorizationManager::get(serviceContext);
uassertStatusOK(globalAuthzManager->initialize(startupOpCtx.get()));
// This is for security on certain platforms (nonce generation)
srand((unsigned)(curTimeMicros64()) ^ (unsigned(uintptr_t(&startupOpCtx))));
if (globalAuthzManager->shouldValidateAuthSchemaOnStartup()) {
Status status = verifySystemIndexes(startupOpCtx.get());
if (!status.isOK()) {
log() << redact(status);
if (status == ErrorCodes::AuthSchemaIncompatible) {
exitCleanly(EXIT_NEED_UPGRADE);
} else if (status == ErrorCodes::NotMaster) {
// Try creating the indexes if we become master. If we do not become master,
// the master will create the indexes and we will replicate them.
} else {
quickExit(EXIT_FAILURE);
}
}
// SERVER-14090: Verify that auth schema version is schemaVersion26Final.
int foundSchemaVersion;
status =
globalAuthzManager->getAuthorizationVersion(startupOpCtx.get(), &foundSchemaVersion);
if (!status.isOK()) {
log() << "Auth schema version is incompatible: "
<< "User and role management commands require auth data to have "
<< "at least schema version " << AuthorizationManager::schemaVersion26Final
<< " but startup could not verify schema version: " << status;
log() << "To manually repair the 'authSchema' document in the admin.system.version "
"collection, start up with --setParameter "
"startupAuthSchemaValidation=false to disable validation.";
exitCleanly(EXIT_NEED_UPGRADE);
}
if (foundSchemaVersion <= AuthorizationManager::schemaVersion26Final) {
log() << "This server is using MONGODB-CR, an authentication mechanism which "
开发者ID:wpjunior,项目名称:mongo,代码行数:67,代码来源:db.cpp
示例9: networkWarnWithDescription
//.........这里部分代码省略.........
if (!setBlock(_fd, false)) {
networkWarnWithDescription(*this, "set socket to non-blocking mode");
return false;
}
const Milliseconds connectTimeoutMillis(static_cast<int64_t>(
_timeout > 0 ? std::min(kMaxConnectTimeoutMS, (_timeout * 1000)) : kMaxConnectTimeoutMS));
const Date_t expiration = Date_t::now() + connectTimeoutMillis;
bool connectSucceeded = ::connect(_fd, _remote.raw(), _remote.addressSize) == 0;
if (!connectSucceeded) {
#ifdef _WIN32
if (WSAGetLastError() != WSAEWOULDBLOCK) {
networkWarnWithDescription(*this, "connect");
return false;
}
#else
if (errno != EINTR && errno != EINPROGRESS) {
networkWarnWithDescription(*this, "connect");
return false;
}
#endif
pollfd pfd;
pfd.fd = _fd;
pfd.events = POLLOUT;
while (true) {
const auto timeout = std::max(Milliseconds(0), expiration - Date_t::now());
int pollReturn = socketPoll(&pfd, 1, timeout.count());
#ifdef _WIN32
if (pollReturn == SOCKET_ERROR) {
networkWarnWithDescription(*this, "poll");
return false;
}
#else
if (pollReturn == -1) {
if (errno != EINTR) {
networkWarnWithDescription(*this, "poll");
return false;
}
// EINTR in poll, try again
continue;
}
#endif
// No activity for the full duration of the timeout.
if (pollReturn == 0) {
warning() << "Failed to connect to " << _remote.getAddr() << ":"
<< _remote.getPort() << " after " << connectTimeoutMillis
<< " milliseconds, giving up.";
return false;
}
// We had a result, see if there's an error on the socket.
int optVal;
socklen_t optLen = sizeof(optVal);
if (::getsockopt(
_fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&optVal), &optLen) == -1) {
networkWarnWithDescription(*this, "getsockopt");
return false;
}
if (optVal != 0) {
networkWarnWithDescription(*this, "checking socket for error after poll", optVal);
return false;
}
// We had activity and we don't have errors on the socket, we're connected.
break;
}
}
if (!setBlock(_fd, true)) {
networkWarnWithDescription(*this, "could not set socket to blocking mode");
return false;
}
if (_timeout > 0) {
setTimeout(_timeout);
}
if (remote.getType() != AF_UNIX)
disableNagle(_fd);
#ifdef SO_NOSIGPIPE
// ignore SIGPIPE signals on osx, to avoid process exit
const int one = 1;
setsockopt(_fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(int));
#endif
_local = getLocalAddrForBoundSocketFd(_fd);
_fdCreationMicroSec = curTimeMicros64();
_awaitingHandshake = false;
return true;
}
开发者ID:ksuarz,项目名称:mongo,代码行数:101,代码来源:sock.cpp
示例10: curTimeMicros64
void CurOp::ensureStarted() {
if ( _start == 0 )
_start = curTimeMicros64();
}
开发者ID:AK-Dominator,项目名称:mongo,代码行数:4,代码来源:curop.cpp
示例11: _initAndListen
//.........这里部分代码省略.........
ss << "repairpath (" << storageGlobalParams.repairpath << ") does not exist";
uassert(12590, ss.str().c_str(), boost::filesystem::exists(storageGlobalParams.repairpath));
}
// TODO: This should go into a MONGO_INITIALIZER once we have figured out the correct
// dependencies.
if (snmpInit) {
snmpInit();
}
if (!storageGlobalParams.readOnly) {
boost::filesystem::remove_all(storageGlobalParams.dbpath + "/_tmp/");
}
if (mmapv1GlobalOptions.journalOptions & MMAPV1Options::JournalRecoverOnly)
return EXIT_NET_ERROR;
if (mongodGlobalParams.scriptingEnabled) {
ScriptEngine::setup();
}
auto startupOpCtx = getGlobalServiceContext()->makeOperationContext(&cc());
repairDatabasesAndCheckVersion(startupOpCtx.get());
if (storageGlobalParams.upgrade) {
log() << "finished checking dbs";
exitCleanly(EXIT_CLEAN);
}
uassertStatusOK(getGlobalAuthorizationManager()->initialize(startupOpCtx.get()));
/* this is for security on certain platforms (nonce generation) */
srand((unsigned)(curTimeMicros64() ^ startupSrandTimer.micros()));
// The snapshot thread provides historical collection level and lock statistics for use
// by the web interface. Only needed when HTTP is enabled.
if (serverGlobalParams.isHttpInterfaceEnabled) {
statsSnapshotThread.go();
invariant(dbWebServer);
stdx::thread web(stdx::bind(&webServerListenThread, dbWebServer));
web.detach();
}
#ifndef _WIN32
mongo::signalForkSuccess();
#endif
AuthorizationManager* globalAuthzManager = getGlobalAuthorizationManager();
if (globalAuthzManager->shouldValidateAuthSchemaOnStartup()) {
Status status = authindex::verifySystemIndexes(startupOpCtx.get());
if (!status.isOK()) {
log() << redact(status);
exitCleanly(EXIT_NEED_UPGRADE);
}
// SERVER-14090: Verify that auth schema version is schemaVersion26Final.
int foundSchemaVersion;
status =
globalAuthzManager->getAuthorizationVersion(startupOpCtx.get(), &foundSchemaVersion);
if (!status.isOK()) {
log() << "Auth schema version is incompatible: "
<< "User and role management commands require auth data to have "
<< "at least schema version " << AuthorizationManager::schemaVersion26Final
<< " but startup could not verify schema version: " << status;
exitCleanly(EXIT_NEED_UPGRADE);
开发者ID:judahschvimer,项目名称:mongo,代码行数:67,代码来源:db.cpp
示例12: run
void run() {
int iterations = 1000*1000;
while(iterations--){
curTimeMicros64();
}
}
开发者ID:DjComandos,项目名称:mongo,代码行数:6,代码来源:perftest.cpp
示例13: run
void run(){
if ( _token.size() == 0 && _name.size() == 0 ){
log(1) << "mms not configured" << endl;
return;
}
if ( _token.size() == 0 ){
log() << "no token for mms - not running" << endl;
return;
}
if ( _name.size() == 0 ){
log() << "no name for mms - not running" << endl;
return;
}
log() << "mms monitor staring... token:" << _token << " name:" << _name << " interval: " << _secsToSleep << endl;
unsigned long long lastTime = 0;
unsigned long long lastLockTime = 0;
while ( ! inShutdown() ){
sleepsecs( _secsToSleep );
stringstream url;
url << _baseurl << _token << "?";
url << "monitor_name=" << _name << "&";
url << "version=" << versionString << "&";
url << "git_hash=" << gitVersion() << "&";
{ //percent_locked
unsigned long long time = curTimeMicros64();
unsigned long long start , lock;
dbMutexInfo.timingInfo( start , lock );
if ( lastTime ){
double timeDiff = (double) (time - lastTime);
double lockDiff = (double) (lock - lastLockTime);
url << "percent_locked=" << (int)ceil( 100 * ( lockDiff / timeDiff ) ) << "&";
}
lastTime = time;
lastLockTime = lock;
}
vector< string > dbNames;
getDatabaseNames( dbNames );
boost::intmax_t totalSize = 0;
for ( vector< string >::iterator i = dbNames.begin(); i != dbNames.end(); ++i ) {
boost::intmax_t size = dbSize( i->c_str() );
totalSize += size;
}
url << "data_size=" << totalSize / ( 1024 * 1024 ) << "&";
/* TODO:
message_operations
update_operations
insert_operations
get_more_operations
delete_operations
kill_cursors_operations
*/
log(1) << "mms url: " << url.str() << endl;
try {
HttpClient c;
map<string,string> headers;
stringstream ss;
int rc = c.get( url.str() , headers , ss );
log(1) << "\t response code: " << rc << endl;
if ( rc != 200 ){
log() << "mms error response code:" << rc << endl;
log(1) << "mms error body:" << ss.str() << endl;
}
}
catch ( std::exception& e ){
log() << "mms get exception: " << e.what() << endl;
}
}
}
开发者ID:fizx,项目名称:mongo,代码行数:82,代码来源:mms.cpp
示例14: durThread
//.........这里部分代码省略.........
// Now that the write intents have been copied to the buffer, the commit job is
// free to be reused. We need to reset the commit job's contents while under
// the S flush lock, because otherwise someone might have done a write and this
// would wipe out their changes without ever being committed.
commitJob.committingReset();
double systemMemoryPressurePercentage =
ProcessInfo::getSystemMemoryPressurePercentage();
// Now that the in-memory modifications have been collected, we can potentially
// release the flush lock if remap is not necessary.
// When we remap due to memory pressure, we look at two criteria
// 1. If the amount of 4k pages touched exceeds 512 MB,
// a reasonable estimate of memory pressure on Linux.
// 2. Check if the amount of free memory on the machine is running low,
// since #1 is underestimates the memory pressure on Windows since
// commits in 64MB chunks.
const bool shouldRemap = (estimatedPrivateMapSize >= UncommittedBytesLimit) ||
(systemMemoryPressurePercentage > 0.0) ||
(commitCounter % NumCommitsBeforeRemap == 0) ||
(mmapv1GlobalOptions.journalOptions & MMAPV1Options::JournalAlwaysRemap);
double remapFraction = 0.0;
if (shouldRemap) {
// We want to remap all private views about every 2 seconds. There could be
// ~1000 views so we do a little each pass. There will be copy on write
// faults after remapping, so doing a little bit at a time will avoid big
// load spikes when the pages are touched.
//
// TODO: Instead of the time-based logic above, consider using ProcessInfo
// and watching for getResidentSize to drop, which is more precise.
remapFraction = (curTimeMicros64() - remapLastTimestamp) / 2000000.0;
if (mmapv1GlobalOptions.journalOptions & MMAPV1Options::JournalAlwaysRemap) {
remapFraction = 1;
} else {
// We don't want to get close to the UncommittedBytesLimit
const double remapMemFraction =
estimatedPrivateMapSize / ((double)UncommittedBytesLimit);
remapFraction = std::max(remapMemFraction, remapFraction);
remapFraction = std::max(systemMemoryPressurePercentage, remapFraction);
}
} else {
LOG(4) << "Early release flush lock";
// We will not be doing a remap so drop the flush lock. That way we will be
// doing the journal I/O outside of lock, so other threads can proceed.
invariant(!shouldRemap);
autoFlushLock.release();
}
buffer->journalListenerToken = getJournalListener()->getToken();
// Request async I/O to the journal. This may block.
journalWriter.writeBuffer(buffer, commitNumber);
// Data has now been written to the shared view. If remap was requested, we
// would still be holding the S flush lock here, so just upgrade it and
// perform the remap.
if (shouldRemap) {
// Need to wait for the previously scheduled journal writes to complete
// before any remap is attempted.
journalWriter.flush();
开发者ID:AshishSanju,项目名称:mongo,代码行数:67,代码来源:dur.cpp
示例15: memset
void Stats::S::reset() {
memset(this, 0, sizeof(*this));
_startTimeMicros = curTimeMicros64();
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:4,代码来源:dur.cpp
示例16: curTimeMicros64
void CurOp::leave( Client::Context * context ) {
unsigned long long now = curTimeMicros64();
Top::global.record( _ns , _op , _lockType , now - _checkpoint , _command );
_checkpoint = now;
}
开发者ID:jfensign,项目名称:mongo,代码行数:5,代码来源:curop.cpp
示例17: setThreadName
void FileAllocator::run( FileAllocator * fa ) {
setThreadName( "FileAllocator" );
{
// initialize unique temporary file name counter
// TODO: SERVER-6055 -- Unify temporary file name selection
SimpleMutex::scoped_lock lk(_uniqueNumberMutex);
_uniqueNumber = curTimeMicros64();
}
while( 1 ) {
{
scoped_lock lk( fa->_pendingMutex );
if ( fa->_pending.size() == 0 )
fa->_pendingUpdated.wait( lk.boost() );
}
while( 1 ) {
string name;
long size = 0;
{
scoped_lock lk( fa->_pendingMutex );
if ( fa->_pending.size() == 0 )
break;
name = fa->_pending.front();
size = fa->_pendingSize[ name ];
}
string tmp;
long fd = 0;
try {
log() << "allocating new datafile " << name << ", filling with zeroes..." << endl;
boost::filesystem::path parent = ensureParentDirCreated(name);
tmp = fa->makeTempFileName( parent );
ensureParentDirCreated(tmp);
#if defined(_WIN32)
fd = _open( tmp.c_str(), _O_RDWR | _O_CREAT | O_NOATIME, _S_IREAD | _S_IWRITE );
#else
fd = open(tmp.c_str(), O_CREAT | O_RDWR | O_NOATIME, S_IRUSR | S_IWUSR);
#endif
if ( fd < 0 ) {
log() << "FileAllocator: couldn't create " << name << " (" << tmp << ") " << errnoWithDescription() << endl;
uasserted(10439, "");
}
#if defined(POSIX_FADV_DONTNEED)
if( posix_fadvise(fd, 0, size, POSIX_FADV_DONTNEED) ) {
log() << "warning: posix_fadvise fails " << name << " (" << tmp << ") " << errnoWithDescription() << endl;
}
#endif
Timer t;
/* make sure the file is the full desired length */
ensureLength( fd , size );
close( fd );
fd = 0;
if( rename(tmp.c_str(), name.c_str()) ) {
const string& errStr = errnoWithDescription();
const string& errMessage = str::stream()
<< "error: couldn't rename " << tmp
<< " to " << name << ' ' << errStr;
msgasserted(13653, errMessage);
}
flushMyDirectory(name);
log() << "done allocating datafile " << name << ", "
<< "size: " << size/1024/1024 << "MB, "
<< " took " << ((double)t.millis())/1000.0 << " secs"
<< endl;
// no longer in a failed state. allow new writers.
fa->_failed = false;
}
catch ( const std::exception& e ) {
log() << "error: failed to allocate new file: " << name
<< " size: " << size << ' ' << e.what()
<< ". will try again in 10 seconds" << endl;
if ( fd > 0 )
close( fd );
try {
if ( ! tmp.empty() )
boost::filesystem::remove( tmp );
boost::filesystem::remove( name );
} catch ( const std::exception& e ) {
log() << "error removing files: " << e.what() << endl;
}
scoped_lock lk( fa->_pendingMutex );
fa->_failed = true;
// not erasing from pending
fa->_pendingUpdated.notify_all();
sleepsecs(10);
continue;
}
{
scoped_lock lk( fa->_pendingMutex );
//.........这里部分代码省略.........
开发者ID:DeathBorn,项目名称:mongo,代码行数:101,代码来源:file_allocator.cpp
示例18: _REMAPPRIVATEVIEW
static void _REMAPPRIVATEVIEW() {
// todo: Consider using ProcessInfo herein and watching for getResidentSize to drop. that could be a way
// to assure very good behavior here.
static unsigned startAt;
static unsigned long long lastRemap;
LOG(4) << "journal REMAPPRIVATEVIEW" << endl;
invariant(!commitJob.hasWritten());
// we want to remap all private views about every 2 seconds. there could be ~1000 views so
// we do a little each pass; beyond the remap time, more significantly, there will be copy on write
// faults after remapping, so doing a little bit at a time will avoid big load spikes on
// remapping.
unsigned long long now = curTimeMicros64();
double fraction = (now-lastRemap)/2000000.0;
if (storageGlobalParams.durOptions & StorageGlobalParams::DurAlwaysRemap)
fraction = 1;
lastRemap = now;
#if defined(_WIN32) || defined(__sunos__)
// Note that this negatively affects performance.
// We must grab the exclusive lock here because remapPrivateView() on Windows and
// Solaris need to grab it as well, due to the lack of an atomic way to remap a
// memory mapped file.
// See SERVER-5723 for performance improvement.
// See SERVER-5680 to see why this code is necessary on Windows.
// See SERVER-8795 to see why this code is necessary on Solaris.
LockMongoFilesExclusive lk;
#else
LockMongoFilesShared lk;
#endif
set<MongoFile*>& files = MongoFile::getAllFiles();
unsigned sz = files.size();
if( sz == 0 )
return;
{
// be careful not to use too much memory if the write rate is
// extremely high
double f = privateMapBytes / ((double)UncommittedBytesLimit);
if( f > fraction ) {
fraction = f;
}
privateMapBytes = 0;
}
unsigned ntodo = (unsigned) (sz * fraction);
if( ntodo < 1 ) ntodo = 1;
if( ntodo > sz ) ntodo = sz;
const set<MongoFile*>::iterator b = files.begin();
const set<MongoFile*>::iterator e = files.end();
set<MongoFile*>::iterator i = b;
// skip to our starting position
for( unsigned x = 0; x < startAt; x++ ) {
i++;
if( i == e ) i = b;
}
unsigned startedAt = startAt;
startAt = (startAt + ntodo) % sz; // mark where to start next time
Timer t;
for( unsigned x = 0; x < ntodo; x++ ) {
dassert( i != e );
if( (*i)->isDurableMappedFile() ) {
DurableMappedFile *mmf = (DurableMappedFile*) *i;
verify(mmf);
if( mmf->willNeedRemap() ) {
mmf->remapThePrivateView();
}
i++;
if( i == e ) i = b;
}
}
LOG(2) << "journal REMAPPRIVATEVIEW done startedAt: " << startedAt << " n:" << ntodo << ' ' << t.millis() << "ms" << endl;
}
开发者ID:Aaron20141021,项目名称:mongo,代码行数:78,代码来源:dur.cpp
示例19: curTimeMicros64
void SnapshotData::takeSnapshot() {
_created = curTimeMicros64();
_globalUsage = Top::global.getGlobalData();
// _totalWriteLockedTime = d.dbMutex.info().getTimeLocked();
Top::global.cloneMap(_usage);
}
开发者ID:Aaron20141021,项目名称:mongo,代码行数:6,代码来源:snapshots.cpp
注:本文中的curTimeMicros64函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论