void checkVersions( const string& ns ) { vector<Shard> all; Shard::getAllShards( all ); // Don't report exceptions here as errors in GetLastError LastError::Disabled ignoreForGLE(lastError.get(false)); // Now only check top-level shard connections for ( unsigned i=0; i<all.size(); i++ ) { Shard& shard = all[i]; try { string sconnString = shard.getConnString(); Status* s = _getStatus( sconnString ); if( ! s->avail ) { s->avail = shardConnectionPool.get( sconnString ); s->created++; // After, so failed creation doesn't get counted } versionManager.checkShardVersionCB( s->avail, ns, false, 1 ); } catch ( const DBException& ex ) { warning() << "problem while initially checking shard versions on" << " " << shard.getName() << causedBy( ex ) << endl; // NOTE: This is only a heuristic, to avoid multiple stale version retries // across multiple shards, and does not affect correctness. } } }
string CRedisClient::bgsave() { Command cmd( "BGSAVE" ); string str; _getStatus(cmd,str); return str; }
void checkVersions( const string& ns ) { vector<Shard> all; Shard::getAllShards( all ); // Now only check top-level shard connections for ( unsigned i=0; i<all.size(); i++ ) { Shard& shard = all[i]; try { string sconnString = shard.getConnString(); Status* s = _getStatus( sconnString ); if( ! s->avail ) { s->avail = shardConnectionPool.get( sconnString ); s->created++; // After, so failed creation doesn't get counted } versionManager.checkShardVersionCB( s->avail, ns, false, 1 ); } catch ( const std::exception& e ) { warning() << "problem while initially checking shard versions on" << " " << shard.getName() << causedBy(e) << endl; throw; } } }
string CRedisClient::shutdown() { Command cmd( "SHUTDOWN" ); string status; _getStatus( cmd, status ); return status; }
string CRedisClient::bgrewriteaof() { Command cmd( "BGREWRITEAOF" ); string str; _getStatus(cmd,str); return str; }
bool RedisClient::type( const string& key , string& type ) { BuildCommand cmd("TYPE"); cmd << key; return _getStatus(cmd, type); }
bool CRedisClient::save() { Command cmd( "SAVE" ); string status; _getStatus( cmd, status ); return ("OK"==status? true : false ); }
void CRedisClient::flushdb() { Command cmd( "FLUSHDB" ); string status; _getStatus( cmd, status ); if ( "OK"!=status) throw ProtocolErr( "FLUSHDB: data recved is not OK" ); }
bool CRedisClient::configRewrite() { Command cmd( "CONFIG" ); cmd<<"REWRITE"; string status; _getStatus( cmd, status ); return ("OK"==status? true : false ); }
bool RedisClient::rename( const string& key , const string& newKey ) { BuildCommand cmd("RENAME"); string status; cmd << key << newKey; return _getStatus(cmd, status); }
bool RedisClient::restore( const string& key , const string& buf , const int& ttl ) { BuildCommand cmd("RESTORE"); string status; cmd << key << ttl << buf; return _getStatus(cmd, status); }
void CRedisClient::configResetstat() { Command cmd( "CONFIG" ); cmd<<"RESETSTAT"; string status; _getStatus( cmd, status ); if ( "OK"!=status) throw ProtocolErr( "CONFIG RESETSTAT: data recved is not OK" ); }
bool CRedisClient::configSet(const string& parameter,const string& value) { Command cmd( "CONFIG" ); cmd<<"SET"; cmd<<parameter<<value; string status; _getStatus( cmd, status ); return ("OK"==status? true : false ); }
// Standard AVIcap window message // "capGetStatus" macro wrapper BOOL CAviCap::GetCapStatus(CAPSTATUS *status) { CHECKWIN(); CHECKCNCT(); if(status) return FALSE; _getStatus(); memcpy (status, &_capStatus, sizeof CAPSTATUS); return TRUE; }
void CRedisClient::slaveof(const string& host,const UInt16 port) { Command cmd( "SLAVEOF" ); cmd<<host<<port; string status; _getStatus( cmd, status ); std::cout<<status<<std::endl; if (('O'==status[0])&&('K'==status[1])) return; throw ProtocolErr( "SLAVEOF: data recved is not OK" ); }
bool CRedisClient::clientSetname (const string& connectionName) { Command cmd( "CLIENT" ); cmd<<"SETNAME"; cmd<<connectionName; string status; _getStatus( cmd, status ); return ("OK"==status? true : false ); }
bool CRedisClient::clientKill(const string& ip,const UInt16 port) { Command cmd( "CLIENT" ); cmd<<"KILL"; std::stringstream ss; ss << ip<<":"<< port; cmd<<ss.str(); string status; _getStatus( cmd, status ); return ("OK"==status? true : false ); }
bool RedisClient::scriptKill() { BuildCommand cmd("SCRIPT"); cmd << "KILL"; string retStr; if ( _getStatus(cmd, retStr) ) { return true; } return false; }
void CRedisClient::hmset(const string &key, const CRedisClient::MapString &pairs) { Command cmd( "HMSET" ); cmd << key; MapString::const_iterator it = pairs.begin(); MapString::const_iterator end = pairs.end(); for ( ; it !=end ; ++it ) { cmd << it->first; cmd << it->second; } string status; _getStatus( cmd, status ); }
bool RedisClient::scriptFlush( void ) { BuildCommand cmd("SCRIPT"); string status; cmd << "FLUSH"; if ( _getStatus(cmd, status) ) { if ( status.find("OK") < 10 || status.find("ok") < 10 ) { return true; } } return false; }
//no comments:) BOOL CAviCap::SetBitResolution(UINT bits) { CHECKWIN(); CHECKCNCT(); if(!IsSupportedBitsResolution(bits)) return FALSE; if(!_getStatus()) return FALSE; LPBITMAPINFO bi= _mk_LPBITMAPINFO(bits, (int)_capStatus.uiImageWidth, (int)_capStatus.uiImageHeight); BOOL ret=SetFormat(bi); if(bi) delete bi; return ret; }
DBClientBase * get( const string& addr , const string& ns ) { _check( ns ); Status* s = _getStatus( addr ); auto_ptr<DBClientBase> c; // Handles cleanup if there's an exception thrown if ( s->avail ) { c.reset( s->avail ); s->avail = 0; shardConnectionPool.onHandedOut( c.get() ); // May throw an exception } else { c.reset( shardConnectionPool.get( addr ) ); s->created++; // After, so failed creation doesn't get counted } return c.release(); }
//no comments:) BOOL CAviCap::SetFrameSize(int cx, int cy) { CHECKWIN(); CHECKCNCT(); if( ((LPBITMAPINFOHEADER)_bmpInfo)->biWidth == cx && ((LPBITMAPINFOHEADER)_bmpInfo)->biHeight == cy) return TRUE; LPBITMAPINFO bi = _mk_LPBITMAPINFO( 0 /*Do not change bits resolution*/, cx, cy /*just set a new image size*/ ); BOOL ret=SetFormat(bi); if(bi) delete bi; _getStatus(); _autoSize(); return ret; }
//General connection method BOOL CAviCap::_connect2Driver(int indx) { CHECKWIN(); if(indx<0||indx>_totalDrv()) { TRACE("CAviCap Window connection failed: illegal driver index\n"); iLastError=CAP_ILLEGAL_DRIVERID; return FALSE; } AfxGetApp( )-> DoWaitCursor( 1 ); //connect via VFW BOOL ret=capDriverConnect(GetSafeHwnd(), indx); checkQuit(); if(ret) { //starts gathering of driver information _curDriver=indx; if(!_getCaps()|| !_getSetup()|| !_getStatus()|| !_getFormat()) { iLastError=CAP_INIT_FAILED; ret=FALSE; } else { //try to make window unvisible befor testing BOOL vsbl=IsWindowVisible(); if(vsbl) ShowWindow(SW_HIDE); //Slow or fast connection? if(!m_DoQuickConnection) { //OK. We have enough time to test driver :-) UP_THR(); #ifdef ON_CONNECT_TEST_BIBITSCOUNT _testBiBitsCount(); #endif checkQuit(); #ifdef ON_CONNECT_CHECK_VALIDFORMATS _testValidFormats(); #endif checkQuit(); #ifdef DEFAULT_FORCE_SINGLE_FRAME _testInternalBuffers(); #endif checkQuit(); DN_THR(); } //else skip testing // Setup default capture parameters // OPTIONAL #ifdef DEFAULT_FORCE_SINGLE_FRAME capSetCallbackOnFrame(GetSafeHwnd(),(LPVOID)_1FrameCallbackProc); _1FrameCallBackInstalled = TRUE; #else capSetCallbackOnFrame(GetSafeHwnd(), _defaultFrameCallbackProc); capPreviewRate(GetSafeHwnd(), _previewRate); #endif #ifdef DEFAULT_USED_DOSMEMORY _captureParms.wNumVideoRequested=1; _captureParms.fUsingDOSMemory=TRUE; #endif #ifdef DEFAULT_STEP_CAPTUREAT2X _captureParms.fStepCaptureAt2x=TRUE; _captureParms.wStepCaptureAverageFrames=3; #endif _captureParms.dwRequestMicroSecPerFrame=20000; _captureParms.fYield = TRUE; capCaptureSetSetup (GetSafeHwnd(), &_captureParms, sizeof CAPTUREPARMS); capCaptureGetSetup (GetSafeHwnd(), &_captureParms, sizeof CAPTUREPARMS); if(vsbl) ShowWindow(SW_SHOW); //restore }//end else } else { AfxGetApp( )-> DoWaitCursor( 0 ); TRACE("Connection to Capure Driver Failed\n"); iLastError=CAP_CONNECTION_FAILED; return FALSE; } if(ret) TRACE("Connected to <%s: %s>\n",GetDriverName(),GetDriverVer()); else TRACE("Connection (phase 2) to Capure Driver Failed\n"); if(!ret) Disconnect(); return ret; }