void DataLoader::on_finished(int, QProcess::ExitStatus) { isProcExited = true; if (parsing && guiUpdateTimer.isActive()) dbs("ASSERT in DataLoader: timer active while parsing"); if (parsing == guiUpdateTimer.isActive() && !canceling) dbs("ASSERT in DataLoader: inconsistent timer"); if (guiUpdateTimer.isActive()) // no need to wait anymore guiUpdateTimer.start(1); }
void BitKey::ReAllocate(uint32_t i_len) { if(i_len > iv_Capacity) // never shrink { bool wasDirect = IsDirect(); uint32_t oldSize = iv_Capacity; uint32_t * oldPtr = DataPtr(); uint32_t wordsize = getWordSize(i_len); iv_Capacity = 32*wordsize; bool isDirect = IsDirect(); if(!isDirect) // to indirect { uint32_t * newBuffer = new uint32_t[wordsize]; BitString dbs(iv_Capacity,newBuffer); dbs.Pattern(0x00000000); BitString sbs(oldSize,oldPtr); dbs.SetBits(sbs); iv_storage1 = 0; if(!wasDirect) // from indirect { delete [] iv_rep.buffer; } iv_rep.buffer = newBuffer; } } }
int main( int argc, char *argv[]) { pwr_tStatus sts; //dbs_sEnv env; //dbs_sEnv *ep; wb_erep *erep = new wb_erep(); if (argc <= 2) exit(0); // ep = dbs_Map(&sts, &env, argv[1]); wb_vrepdbs *vdbs = new wb_vrepdbs(erep, argv[1]); vdbs->load(); wb_dbs dbs(vdbs); dbs.setFileName("lasse.dbs"); dbs.importVolume(*vdbs); //wb_orepdbs *op = (wb_orepdbs *)vdbs->object(&sts); wb_db db(vdbs->vid()); db.create(vdbs->vid(), vdbs->cid(), vdbs->name(), argv[2]); db.importVolume(*vdbs); db.close(); wb_vrepdb vdb(erep, argv[2]); wb_dbs adbs(vdbs); adbs.setFileName("alasse.dbs"); adbs.importVolume(vdb); }
void DataLoader::on_timeout() { if (canceling) { deleteLater(); return; // we leave with guiUpdateTimer not active } parsing = true; // process could exit while we are processing so save the flag now bool lastBuffer = isProcExited; loadedBytes += readNewData(lastBuffer); emit newDataReady(fh); // inserting in list view is about 3% of total time if (lastBuffer) { emit loaded(fh, loadedBytes, loadTime.elapsed(), true, "", ""); deleteLater(); } else if (isProcExited) { // exited while parsing dbs("Exited while parsing!!!!"); guiUpdateTimer.start(1); } else guiUpdateTimer.start(GUI_UPDATE_INTERVAL); parsing = false; }
void CIRexxApp::titleOfScript(Int16 index, CString & title) { ScriptRecord sr; CDBStream dbs(m_scriptIndexDB->QueryRecord(index)); dbs >> sr.m_title; title += sr.m_title; return; }
void MyProcess::on_readyReadStandardError() { if (canceling) return; if (receiver) emit procDataReady(readAllStandardError()); // redirect to stdout else dbs("ASSERT in myReadFromStderr: NULL receiver"); }
void CIRexxApp::dbIndicatorOfScript(Int16 index, CString & dbi) { ScriptRecord sr; CDBStream dbs(m_scriptIndexDB->QueryRecord(index)); dbs >> sr.m_title; dbs >> sr.m_dbi; dbi += sr.m_dbi; return; }
void DataLoader::addSplittedChunks(const QByteArray* hc) { if (hc->at(hc->size() - 1) != 0) { dbs("ASSERT in DataLoader, bad half chunk"); return; } // do not assume we have only one chunk in hc int ofs = 0; while (ofs != -1 && ofs != (int)hc->size()) ofs = git->addChunk(fh, *hc, ofs); }
void MyProcess::on_readyReadStandardError() { if (canceling) return; if (receiver) { QByteArray err = readAllStandardError(); accError += err; emit procDataReady(err); // redirect to stdout } else dbs("ASSERT in myReadFromStderr: NULL receiver"); }
BitKey & BitKey::operator=(const BitString & bit_string) { if(iv_Capacity) { BitString bs(iv_Capacity,DataPtr()); bs.Pattern(0x00000000); } ReAllocate(bit_string.GetLength()); BitString dbs(iv_Capacity,DataPtr()); dbs.SetBits(bit_string); return(*this); }
const QStringList MyProcess::splitArgList(SCRef cmd) { // return argument list handling quotes and double quotes // substring, as example from: // cmd some_arg "some thing" v='some value' // to (comma separated fields) // sl = <cmd,some_arg,some thing,v='some value'> // early exit the common case if (!( cmd.contains(QGit::QUOTE_CHAR) || cmd.contains("\"") || cmd.contains("\'"))) return cmd.split(' ', QString::SkipEmptyParts); // we have some work to do... // first find a possible separator const QString sepList("#%&!?"); // separator candidates int i = 0; while (cmd.contains(sepList[i]) && i < sepList.length()) i++; if (i == sepList.length()) { dbs("ASSERT no unique separator found."); return QStringList(); } const QChar& sepChar(sepList[i]); // remove all spaces QString newCmd(cmd); newCmd.replace(QChar(' '), sepChar); // re-add spaces in quoted sections restoreSpaces(newCmd, sepChar); // QUOTE_CHAR is used internally to delimit arguments // with quoted text wholly inside as // arg1 = <[patch] cool patch on "cool feature"> // and should be removed before to feed QProcess newCmd.remove(QGit::QUOTE_CHAR); // QProcess::setArguments doesn't want quote // delimited arguments, so remove trailing quotes QStringList sl(newCmd.split(sepChar, QString::SkipEmptyParts)); QStringList::iterator it(sl.begin()); for ( ; it != sl.end(); ++it) { if (((*it).left(1) == "\"" && (*it).right(1) == "\"") || ((*it).left(1) == "\'" && (*it).right(1) == "\'")) *it = (*it).mid(1, (*it).length() - 2); } return sl; }
bool DataLoader::createTemporaryFile() { // redirect 'git log' output to a temporary file dataFile = new UnbufferedTemporaryFile(this); #ifndef Q_OS_WIN32 /* For performance reasons we would like to use a tmpfs filesystem if available, this is normally mounted under '/tmp' in Linux. According to Qt docs, a temporary file is placed in QDir::tempPath(), that should be system's temporary directory. On Unix/Linux systems this is usually /tmp; on Windows this is usually the path in the TEMP or TMP environment variable. But due to a bug in Qt 4.2 QDir::tempPath() is instead set to $HOME/tmp under Unix/Linux, that is not a tmpfs filesystem. So try to manually set the best directory for our temporary file. */ QDir dir("/tmp"); bool foundTmpDir = (dir.exists() && dir.isReadable()); if (foundTmpDir && dir.absolutePath() != QDir::tempPath()) { dataFile->setFileTemplate(dir.absolutePath() + "/qt_temp"); if (!dataFile->open()) { // test for write access delete dataFile; dataFile = new UnbufferedTemporaryFile(this); dbs("WARNING: directory '/tmp' is not writable, " "fallback on Qt default one, there could " "be a performance penalty."); } else dataFile->close(); } #endif if (!dataFile->open()) // to read the file name return false; setStandardOutputFile(dataFile->fileName()); dataFile->close(); return true; }
/*-------------------------------------CIRexxApp::copyScriptFromIndexDatabase-+ | | +----------------------------------------------------------------------------*/ void CIRexxApp::copyScriptFromIndexDatabase(Int16 index) { Int16 count; UInt32 dbptr; ScriptRecord sr; CDBStream dbs(m_scriptIndexDB->QueryRecord(index)); dbs >> sr.m_title; dbs >> sr.m_dbi; dbs >> dbptr; sr.m_db = (CDatabase *)dbptr; dbs >> count; sr.m_indexes.EnsureSize(count); sr.m_segments.EnsureSize(count); for (int i = 0; i < count; ++i) { Int16 value1, value2; dbs >> value1 >> value2; sr.m_indexes.Insert(i, value1); sr.m_segments.Insert(i, value2); } emptyScript(); bool isSegmented = count > 1; for (Int16 i = 0; i < count; ++i) { MemHandle hMem = sr.m_db->QueryRecord(sr.m_indexes[i]); char * script = (char *)MemHandleLock(hMem); UInt32 size = MemHandleSize(hMem); if (isSegmented) { char * realScript = strstr( script, "!DO NOT TOUCH THIS LINE OR ABOVE!" ); if (realScript) { realScript += 34; size -= (realScript - script); script = realScript; } } if (script[size - 1] == '\0') { --size; } appendScript(script, size); MemHandleUnlock(hMem); } return; }
bool DataLoader::start(SCList args, SCRef wd, SCRef buf) { if (!isProcExited) { dbs("ASSERT in DataLoader::start(), called while processing"); return false; } isProcExited = false; setWorkingDirectory(wd); connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(on_finished(int, QProcess::ExitStatus))); if (!createTemporaryFile() || !QGit::startProcess(this, args, buf)) { deleteLater(); return false; } loadTime.start(); guiUpdateTimer.start(GUI_UPDATE_INTERVAL); return true; }
void first4server::readConfiguration() { QDomDocument dbs("databases"); QFile file ( "/etc/first4server/databases.conf" ); if (file.open(QIODevice::ReadOnly)) { dbs.setContent(file.readAll()); file.close(); } else qDebug() << "Can't read database file"; QDomElement db = dbs.documentElement(); QDomNodeList nlist = db.elementsByTagName("Database"); if(nlist.size() > 0) { QDomElement e = nlist.at(0).toElement(); if(!e.isNull()) connectToDatabase(e.attribute("Host"), e.attribute("Port").toInt(), e.attribute("DBName"), e.attribute("User"), e.attribute("Password")); } }
void FileList::mouseMoveEvent(QMouseEvent* e) { if (d->isReadyToDrag()) { if (!d->setDragging(true)) return; if (dragFileName.isEmpty()) dbs("ASSERT in FileList::mouseMoveEvent() empty drag name"); QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; mimeData->setText(dragFileName); drag->setMimeData(mimeData); dragFileName = ""; drag->start(); // blocking until drop event d->setDragging(false); } QListWidget::mouseMoveEvent(e); }
void frmMain::StoreServers() { wxLogInfo(wxT("Storing listed servers for later...")); // Store the currently listed servers for later retrieval. pgServer *server; int numServers = 0; // Get the hostname for later... char buf[255]; gethostname(buf, 255); wxString hostname = wxString(buf, wxConvUTF8); wxTreeItemIdValue foldercookie; wxTreeItemId folderitem = browser->GetFirstChild(browser->GetRootItem(), foldercookie); while (folderitem) { if (browser->ItemHasChildren(folderitem)) { wxTreeItemIdValue servercookie; wxTreeItemId serveritem = browser->GetFirstChild(folderitem, servercookie); while (serveritem) { server = (pgServer*)browser->GetItemData(serveritem); if (server->IsCreatedBy(serverFactory)) { wxString key; ++numServers; key.Printf(wxT("Servers/%d/"), numServers); settings->Write(key + wxT("Server"), server->GetName()); settings->Write(key + wxT("Description"), server->GetDescription()); settings->Write(key + wxT("ServiceID"), server->GetServiceID()); settings->Write(key + wxT("DiscoveryID"), server->GetDiscoveryID()); settings->Write(key + wxT("Port"), server->GetPort()); settings->Write(key + wxT("StorePwd"), server->GetStorePwd()); settings->Write(key + wxT("Rolename"), server->GetRolename()); settings->Write(key + wxT("Restore"), server->GetRestore()); settings->Write(key + wxT("Database"), server->GetDatabaseName()); settings->Write(key + wxT("Username"), server->GetUsername()); settings->Write(key + wxT("LastDatabase"), server->GetLastDatabase()); settings->Write(key + wxT("LastSchema"), server->GetLastSchema()); settings->Write(key + wxT("DbRestriction"), server->GetDbRestriction()); settings->Write(key + wxT("Colour"), server->GetColour()); settings->Write(key + wxT("SSL"), server->GetSSL()); settings->Write(key + wxT("Group"), server->GetGroup()); pgCollection *coll=browser->FindCollection(databaseFactory, server->GetId()); if (coll) { treeObjectIterator dbs(browser, coll); pgDatabase *db; while ((db=(pgDatabase*)dbs.GetNextObject()) != 0) settings->Write(key + wxT("Databases/") + db->GetName() + wxT("/SchemaRestriction"), db->GetSchemaRestriction()); } } serveritem = browser->GetNextChild(folderitem, servercookie); } } folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); } // Write the server count settings->Write(wxT("Servers/Count"), numServers); wxLogInfo(wxT("Stored %d servers."), numServers); }
static void dbsCallFunc(const iocshArgBuf *args) { dbs(args[0].sval);}
bool run(const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool) { string target = cmdObj.firstElement().valuestrsafe(); Shard s = Shard::make( target ); if ( ! grid.knowAboutShard( s.getConnString() ) ) { errmsg = "unknown shard"; return false; } ScopedDbConnection conn( configServer.getPrimary() ); if (conn->count("config.shards", BSON("_id" << NE << s.getName() << ShardFields::draining(true)))){ conn.done(); errmsg = "Can't have more than one draining shard at a time"; return false; } if (conn->count("config.shards", BSON("_id" << NE << s.getName())) == 0){ conn.done(); errmsg = "Can't remove last shard"; return false; } BSONObj primaryDoc = BSON( "_id" << NE << "local" << "primary" << s.getName() ); BSONObj dbInfo; // appended at end of result on success { boost::scoped_ptr<DBClientCursor> cursor (conn->query("config.databases", primaryDoc)); if (cursor->more()) { // skip block and allocations if empty BSONObjBuilder dbInfoBuilder; dbInfoBuilder.append("note", "you need to drop or movePrimary these databases"); BSONArrayBuilder dbs(dbInfoBuilder.subarrayStart("dbsToMove")); while (cursor->more()){ BSONObj db = cursor->nextSafe(); dbs.append(db["_id"]); } dbs.doneFast(); dbInfo = dbInfoBuilder.obj(); } } // If the server is not yet draining chunks, put it in draining mode. BSONObj searchDoc = BSON( "_id" << s.getName() ); BSONObj drainingDoc = BSON( "_id" << s.getName() << ShardFields::draining(true) ); BSONObj shardDoc = conn->findOne( "config.shards", drainingDoc ); if ( shardDoc.isEmpty() ) { // TODO prevent move chunks to this shard. log() << "going to start draining shard: " << s.getName() << endl; BSONObj newStatus = BSON( "$set" << BSON( ShardFields::draining(true) ) ); conn->update( "config.shards" , searchDoc , newStatus, false /* do no upsert */); errmsg = conn->getLastError(); if ( errmsg.size() ) { log() << "error starting remove shard: " << s.getName() << " err: " << errmsg << endl; return false; } BSONObj primaryLocalDoc = BSON("_id" << "local" << "primary" << s.getName() ); PRINT(primaryLocalDoc); if (conn->count("config.databases", primaryLocalDoc)) { log() << "This shard is listed as primary of local db. Removing entry." << endl; conn->remove("config.databases", BSON("_id" << "local")); errmsg = conn->getLastError(); if ( errmsg.size() ) { log() << "error removing local db: " << errmsg << endl; return false; } } Shard::reloadShardInfo(); result.append( "msg" , "draining started successfully" ); result.append( "state" , "started" ); result.append( "shard" , s.getName() ); result.appendElements(dbInfo); conn.done(); return true; } // If the server has been completely drained, remove it from the ConfigDB. // Check not only for chunks but also databases. BSONObj shardIDDoc = BSON( "shard" << shardDoc[ "_id" ].str() ); long long chunkCount = conn->count( "config.chunks" , shardIDDoc ); long long dbCount = conn->count( "config.databases" , primaryDoc ); if ( ( chunkCount == 0 ) && ( dbCount == 0 ) ) { log() << "going to remove shard: " << s.getName() << endl; conn->remove( "config.shards" , searchDoc ); errmsg = conn->getLastError(); if ( errmsg.size() ) { log() << "error concluding remove shard: " << s.getName() << " err: " << errmsg << endl; return false; } Shard::removeShard( shardDoc[ "_id" ].str() ); Shard::reloadShardInfo(); result.append( "msg" , "removeshard completed successfully" ); result.append( "state" , "completed" ); result.append( "shard" , s.getName() ); conn.done(); return true; } // If the server is already in draining mode, just report on its progress. // Report on databases (not just chunks) that are left too. result.append( "msg" , "draining ongoing" ); result.append( "state" , "ongoing" ); BSONObjBuilder inner; inner.append( "chunks" , chunkCount ); inner.append( "dbs" , dbCount ); result.append( "remaining" , inner.obj() ); result.appendElements(dbInfo); conn.done(); return true; }
void frmMain::StoreServers() { wxLogInfo(wxT("Storing listed servers for later...")); // Store the currently listed servers for later retrieval. pgServer *server; int numServers = 0; // Get the hostname for later... char buf[255]; gethostname(buf, 255); wxString hostname = wxString(buf, wxConvUTF8); wxTreeItemIdValue foldercookie; wxTreeItemId folderitem = browser->GetFirstChild(browser->GetRootItem(), foldercookie); while (folderitem) { if (browser->ItemHasChildren(folderitem)) { wxTreeItemIdValue servercookie; wxTreeItemId serveritem = browser->GetFirstChild(folderitem, servercookie); while (serveritem) { server = (pgServer *)browser->GetItemData(serveritem); if (server != NULL && server->IsCreatedBy(serverFactory)) { wxString key; ++numServers; key.Printf(wxT("Servers/%d/"), numServers); settings->Write(key + wxT("Server"), server->GetName()); settings->Write(key + wxT("HostAddr"), server->GetHostAddr()); settings->Write(key + wxT("Description"), server->GetDescription()); settings->Write(key + wxT("Service"), server->GetService()); settings->Write(key + wxT("ServiceID"), server->GetServiceID()); settings->Write(key + wxT("DiscoveryID"), server->GetDiscoveryID()); settings->WriteInt(key + wxT("Port"), server->GetPort()); settings->WriteBool(key + wxT("StorePwd"), server->GetStorePwd()); settings->Write(key + wxT("Rolename"), server->GetRolename()); settings->WriteBool(key + wxT("Restore"), server->GetRestore()); settings->Write(key + wxT("Database"), server->GetDatabaseName()); settings->Write(key + wxT("Username"), server->GetUsername()); settings->Write(key + wxT("LastDatabase"), server->GetLastDatabase()); settings->Write(key + wxT("LastSchema"), server->GetLastSchema()); settings->Write(key + wxT("DbRestriction"), server->GetDbRestriction()); settings->Write(key + wxT("Colour"), server->GetColour()); settings->WriteInt(key + wxT("SSL"), server->GetSSL()); settings->Write(key + wxT("Group"), server->GetGroup()); settings->Write(key + wxT("SSLCert"), server->GetSSLCert()); settings->Write(key + wxT("SSLKey"), server->GetSSLKey()); settings->Write(key + wxT("SSLRootCert"), server->GetSSLRootCert()); settings->Write(key + wxT("SSLCrl"), server->GetSSLCrl()); settings->WriteBool(key + wxT("SSLCompression"), server->GetSSLCompression()); #if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT) settings->WriteBool(key + wxT("SSHTunnel"), server->GetSSHTunnel()); settings->Write(key + wxT("TunnelHost"), server->GetTunnelHost()); settings->Write(key + wxT("TunnelUserName"), server->GetTunnelUserName()); settings->WriteBool(key + wxT("TunnelModePwd"), server->GetAuthModePwd()); settings->Write(key + wxT("PublicKeyFile"), server->GetPublicKeyFile()); settings->Write(key + wxT("IdentityFile"), server->GetIdentityFile()); settings->WriteInt(key + wxT("TunnelPort"), server->GetTunnelPort()); #endif pgCollection *coll = browser->FindCollection(databaseFactory, server->GetId()); if (coll) { treeObjectIterator dbs(browser, coll); pgDatabase *db; while ((db = (pgDatabase *)dbs.GetNextObject()) != 0) settings->Write(key + wxT("Databases/") + db->GetName() + wxT("/SchemaRestriction"), db->GetSchemaRestriction()); } } serveritem = browser->GetNextChild(folderitem, servercookie); } } folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); } // Write the server count settings->WriteInt(wxT("Servers/Count"), numServers); wxLogInfo(wxT("Stored %d servers."), numServers); }