Ignore:
Timestamp:
09/26/13 13:41:56 (12 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
30e1ce9
Parents:
cec4c86b
Message:

Completely finish cleaning up the replication functionality in the tray watcher it works great now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/LPWatcher.cpp

    r108626c r8c6a630  
    8686  unsigned int base; 
    8787  if(type=="message"){base=10;} 
    88   else if(type=="replicate"){base=20;} 
     88  else if(type=="replication"){base=20;} 
    8989  else if(type=="critical"){base=30;} 
    9090  else if(type=="mirror"){base=40;} 
     
    158158      //Setup the file watcher for this new log file 
    159159      FILE_REPLICATION = dev; 
     160      dev = message.section(" ",5,5,QString::SectionSkipEmpty); 
    160161      startRepFileWatcher(); 
    161162      //Set the appropriate status variables 
    162       LOGS.insert(20,"REPSTARTED"); 
    163       // 21 - dataset set on update ping 
    164       LOGS.insert(22, tr("Replication Started") ); //summary 
    165       // 23 - Full message set on update ping 
     163      LOGS.insert(20,"STARTED"); 
     164      LOGS.insert(21, dev); //zpool 
     165      LOGS.insert(22, tr("Replication Starting") ); //summary 
     166      LOGS.insert(23, QString(tr("Starting replication for %1")).arg(dev) ); //Full message 
    166167      LOGS.insert(24, timestamp); //full timestamp 
    167168      LOGS.insert(25, time); // time only 
     
    171172      dev = message.section(" ",-1).simplified(); 
    172173      //Now set the status of the process 
    173       LOGS.insert(20,"REPFINISHED"); 
     174      LOGS.insert(20,"FINISHED"); 
    174175      LOGS.insert(21,dev); //dataset 
    175176      LOGS.insert(22, tr("Finished Replication") ); //summary 
     
    178179      LOGS.insert(25, time); // time only       
    179180      if(!quiet){ emit MessageAvailable("replication"); } 
    180     }else if( message.contains("FAILED replication") ){ 
     181    }else if( message.contains("failed replication") ){ 
    181182      stopRepFileWatcher(); 
    182183      //Now set the status of the process 
     
    184185      QString file = log.section("LOGFILE:",1,1).simplified(); 
    185186      QString tt = QString(tr("Replication Failed for %1")).arg(dev) +"\n"+ QString(tr("Logfile available at: %1")).arg(file); 
    186       LOGS.insert(20,"REPERROR"); 
     187      LOGS.insert(20,"ERROR"); 
    187188      LOGS.insert(21,dev); //dataset 
    188189      LOGS.insert(22, tr("Replication Failed") ); //summary 
     
    196197} 
    197198 
    198 void LPWatcher::readReplicationFile(bool quiet){ 
     199void LPWatcher::readReplicationFile(){ 
    199200  QString stat; 
    200201  while( !RFSTREAM->atEnd() ){  
     
    203204    else if(line.startsWith("send from ")){} 
    204205    else if(line.startsWith("TIME ")){} 
     206    else if(line.startsWith("warning: ")){} //start of an error 
    205207    else{ stat = line; } //only save the relevant/latest status line 
    206208  } 
    207   if(stat.isEmpty()){ 
    208     qDebug() << "New Status Message:" << stat; 
     209  if(!stat.isEmpty()){ 
     210    //qDebug() << "New Status Message:" << stat;             
    209211    //Divide up the status message into sections 
    210212    stat.replace("\t"," "); 
     
    233235      LOGS.insert(20,"RUNNING"); 
    234236      LOGS.insert(21,dataset); 
     237      LOGS.insert(22,txt); 
    235238      LOGS.insert(23,txt); 
    236       if(!quiet){ emit MessageAvailable("replication"); } 
     239      emit MessageAvailable(""); 
    237240    } 
    238241  } 
     
    240243 
    241244void LPWatcher::startRepFileWatcher(){ 
     245  //qDebug() << "Start Rep File Watcher:" << FILE_REPLICATION; 
    242246  if(FILE_REPLICATION.isEmpty()){ return; } 
     247 
     248  if(watcher->files().contains(FILE_REPLICATION)){ return; } //duplicate - file already opened 
     249  else if(!watcher->files().isEmpty()){  
     250    //Check that the file watcher is not already operating on a file 
     251    // only one can be running at a time, so always cancel the previous instance (it is stale) 
     252    QString tmp = FILE_REPLICATION; 
     253    stopRepFileWatcher(); 
     254    FILE_REPLICATION = tmp; 
     255  } 
     256  //Check to make sure that lpreserver actually has a process running before starting this 
     257  //if(!QFile::exists("/var/run/<something.pid>"){ FILE_REPLICATION.clear(); return; } 
     258  //Check for the existance of the file to watch and create it as necessary   
    243259  if(!QFile::exists(FILE_REPLICATION)){ system( QString("touch "+FILE_REPLICATION).toUtf8() ); } 
     260  //Now open the file and start watching it for changes 
    244261  repfile->setFileName(FILE_REPLICATION); 
    245262  repfile->open(QIODevice::ReadOnly | QIODevice::Text); 
    246263  RFSTREAM = new QTextStream(repfile); 
    247264  watcher->addPath(FILE_REPLICATION); 
     265  //qDebug() << "Finished starting rep file watcher"; 
    248266} 
    249267 
    250268void LPWatcher::stopRepFileWatcher(){ 
     269  //qDebug() << "Stop Rep File Watcher:" << FILE_REPLICATION; 
    251270  if(FILE_REPLICATION.isEmpty()){ return; } 
    252271  watcher->removePath(FILE_REPLICATION); 
     
    256275  repTotK.clear(); 
    257276  lastSize.clear(); 
     277  //qDebug() << "Finished stopping rep file watcher"; 
    258278} 
    259279 
Note: See TracChangeset for help on using the changeset viewer.