diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp index f38ba4a..d0a5aa9 100644 --- a/mythtv/programs/mythbackend/mainserver.cpp +++ b/mythtv/programs/mythbackend/mainserver.cpp @@ -4465,8 +4465,10 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, { // If we don't have any dirs of our own, fallback to list of Default // dirs since that is what StorageGroup::Init() does. + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Checking Storage group directories")); if (!query.size()) { + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP This host does not have any specific directories")); query.prepare("SELECT MIN(id),dirname " "FROM storagegroup " "WHERE groupname = :GROUP " @@ -4482,12 +4484,15 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, int bSize; while (query.next()) { + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Start Query")); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Query start size %1").arg(strlist.size())); dirID = query.value(0).toString(); /* The storagegroup.dirname column uses utf8_bin collation, so Qt * uses QString::fromAscii() for toString(). Explicitly convert the * value using QString::fromUtf8() to prevent corruption. */ currentDir = QString::fromUtf8(query.value(1) .toByteArray().constData()); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Directory %1").arg(currentDir)); if (currentDir.right(1) == "/") currentDir.remove(currentDir.length() - 1, 1); @@ -4496,6 +4501,7 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, { if (checkDir.exists()) { + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Directory exists")); QByteArray cdir = currentDir.toAscii(); getDiskSpace(cdir.constData(), totalKB, usedKB); memset(&statbuf, 0, sizeof(statbuf)); @@ -4532,8 +4538,12 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, foundDirs[currentDir] = true; } else + { + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Directory doesn't exist")); foundDirs[currentDir] = false; + } } + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Leaving Query")); } } @@ -4567,7 +4577,9 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, for (list::iterator p = localPlaybackList.begin() ; p != localPlaybackList.end() ; ++p) { + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP start size %1").arg(strlist.size())); (*p)->GetDiskSpace(strlist); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP end size %1").arg(strlist.size())); (*p)->DecrRef(); } } @@ -4578,21 +4590,82 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated, FileSystemInfo fsInfo; QList fsInfos; - QStringList::const_iterator it = strlist.begin(); - while (it != strlist.end()) - { - fsInfo.setHostname(*(it++)); - fsInfo.setPath(*(it++)); - fsInfo.setLocal((*(it++)).toInt() > 0); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, "In trigger"); + QStringList::const_iterator it = strlist.constBegin(); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP Received %1").arg(strlist.size())); + int size=strlist.size(); + int counter=0; + while((size-counter)>7){ + + fsInfo.setHostname((strlist.value(counter))); + counter++; + fsInfo.setPath((strlist.value(counter))); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPFilesystem %1").arg(fsInfo.getPath())); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPHostname %1").arg(fsInfo.getHostname())); + counter++; + fsInfo.setLocal(((strlist.value(counter))).toInt() > 0); + counter++; + fsInfo.setFSysID(-1); + counter++; + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPLocal %1").arg(fsInfo.isLocal())); + //LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPFSID %1").arg(fsInfo.getFSysID())); + fsInfo.setGroupID(((strlist.value(counter))).toInt()); + counter++; + fsInfo.setBlockSize(((strlist.value(counter))).toInt()); + counter++; + fsInfo.setTotalSpace(((strlist.value(counter))).toLongLong()); + counter++; + fsInfo.setUsedSpace(((strlist.value(counter))).toLongLong()); + counter++; + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPGID %1").arg(fsInfo.getGroupID())); + fsInfos.push_back(fsInfo); + } + +/* while (it != strlist.constEnd()) + { + fsInfo.setHostname(*(it++)); + fsInfo.setPath(*(it++)); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPFilesystem %1").arg(fsInfo.getPath())); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPHostname %1").arg(fsInfo.getHostname())); + fsInfo.setLocal((*(it++)).toInt() > 0); fsInfo.setFSysID(-1); ++it; // Without this, the strlist gets out of whack - fsInfo.setGroupID((*(it++)).toInt()); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPLocal %1").arg(fsInfo.isLocal())); + //LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPFSID %1").arg(fsInfo.getFSysID())); + fsInfo.setGroupID((*(it++)).toInt()); fsInfo.setBlockSize((*(it++)).toInt()); fsInfo.setTotalSpace((*(it++)).toLongLong()); fsInfo.setUsedSpace((*(it++)).toLongLong()); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CPGID %1").arg(fsInfo.getGroupID())); +// fsInfo.setBlockSize((*(it)).toInt()); +// fsInfo.setTotalSpace((*(it)).toLongLong()); +// fsInfo.setUsedSpace((*(it)).toLongLong()); + fsInfos.push_back(fsInfo); +// ++it; + } +*/ +/* { + fsInfo.setHostname(*(it++)); + fsInfo.setPath(*(it++)); + LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPFilesystem %1").arg(fsInfo.getPath())); + LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPHostname %1").arg(fsInfo.getHostname())); + //LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPLocal %1").arg((*it))); + fsInfo.setLocal((*(it++)).toInt() > 0); +it++; + LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPLocal %1").arg(fsInfo.isLocal())); + fsInfo.setFSysID((*(it++)).toInt()); + LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPFSID %1").arg(fsInfo.getFSysID())); + fsInfo.setGroupID((*(it++)).toInt()); + LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, QString("CPGID %1").arg(fsInfo.getGroupID())); + fsInfo.setBlockSize((*(it)).toInt()); + fsInfo.setTotalSpace((*(it)).toLongLong()); + fsInfo.setUsedSpace((*(it)).toLongLong()); fsInfos.push_back(fsInfo); + ++it; } +*/ strlist.clear(); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, "Out trigger"); // Consolidate hosts sharing storage int64_t maxWriteFiveSec = GetCurrentMaxBitrate()/12 /*5 seconds*/; @@ -4673,14 +4746,46 @@ void MainServer::GetFilesystemInfos(QList &fsInfos) BackendQueryDiskSpace(strlist, false, true); - QStringList::const_iterator it = strlist.begin(); - while (it != strlist.end()) + QStringList::const_iterator it = strlist.constBegin(); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2 Received %1").arg(strlist.size())); + + int size=strlist.size(); + int counter=0; + while ((size-counter)>7) + { + fsInfo.setHostname((strlist.value(counter))); + counter++; + fsInfo.setPath((strlist.value(counter))); + counter++; + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Filesystem %1").arg(fsInfo.getPath())); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Hostname %1").arg(fsInfo.getHostname())); + fsInfo.setLocal(((strlist.value(counter))).toInt() > 0); + counter++; + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Local %1").arg(fsInfo.isLocal())); + fsInfo.setFSysID(-1); + //it++; + counter++; + fsInfo.setGroupID(((strlist.value(counter))).toInt()); + counter++; + fsInfo.setBlockSize(((strlist.value(counter))).toInt()); + counter++; + fsInfo.setTotalSpace(((strlist.value(counter))).toLongLong()); + counter++; + fsInfo.setUsedSpace(((strlist.value(counter))).toLongLong()); + counter++; + fsInfo.setWeight(0); + fsInfos.push_back(fsInfo); + } +/* while (it != strlist.constEnd()) { fsInfo.setHostname(*(it++)); fsInfo.setPath(*(it++)); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Filesystem %1").arg(fsInfo.getPath())); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Hostname %1").arg(fsInfo.getHostname())); fsInfo.setLocal((*(it++)).toInt() > 0); + LOG(VB_SCHEDULE | VB_FILE, LOG_INFO, QString("CP2Local %1").arg(fsInfo.isLocal())); fsInfo.setFSysID(-1); - ++it; + it++; fsInfo.setGroupID((*(it++)).toInt()); fsInfo.setBlockSize((*(it++)).toInt()); fsInfo.setTotalSpace((*(it++)).toLongLong()); @@ -4688,7 +4793,7 @@ void MainServer::GetFilesystemInfos(QList &fsInfos) fsInfo.setWeight(0); fsInfos.push_back(fsInfo); } - +*/ LOG(VB_SCHEDULE | VB_FILE, LOG_DEBUG, "Determining unique filesystems"); size_t maxWriteFiveSec = GetCurrentMaxBitrate()/12 /*5 seconds*/; // safety for NFS mounted dirs