Changeset f698804


Ignore:
Timestamp:
09/11/13 14:07:34 (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
b5a7675
Parents:
9599cf7
Message:

Get the new watcher class up to the same (or slightly more) functionality thatn the old implementation. Now to start adding the new checking for mirroring/resilvering and or zpool errors.

Location:
src-qt4/life-preserver
Files:
4 edited

Legend:

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

    r8516ff2 rf698804  
    4141  //Start up the watcher 
    4242  watcher->start(); 
     43  updateTrayIcon(); 
     44  updateToolTip(); 
    4345} 
    4446 
     
    200202*/ 
    201203 
     204void LPTray::updateTrayIcon(){ 
     205  if( watcher->hasError() ){ 
     206    //Errors - show that attention is required 
     207    this->setIcon( QIcon(":/images/tray-icon-failed.png") ); 
     208  }else if( watcher->isRunning() ){ 
     209    //Show the working icon 
     210    this->setIcon( QIcon(":/images/tray-icon-active7.png") ); 
     211  }else{ 
     212    //Show the idle icon 
     213    this->setIcon( QIcon(":/images/tray-icon-idle.png") ); 
     214  } 
     215   
     216} 
     217 
     218void LPTray::updateToolTip(){ 
     219  QStringList info = watcher->getAllCurrentMessages(); 
     220  this->setToolTip( info.join("\n") );   
     221} 
     222 
    202223// =============== 
    203224//     PRIVATE SLOTS 
     
    205226void LPTray::watcherMessage(QString type){ 
    206227  qDebug() << "New Watcher Message:" << type; 
     228  QStringList info; 
     229  if(type=="message"){ 
     230    //Show the message pop-up 
     231    info << "time" << "message"; 
     232    info = watcher->getMessages(type,info); 
     233    if(!info.isEmpty()){ 
     234      this->showMessage( info[0], info[1], QSystemTrayIcon::Information, 5000); 
     235    } 
     236  }else if(type=="replication"){ 
     237    info << "id" << "time" << "message"; 
     238    info = watcher->getMessages(type,info); 
     239    if(info.isEmpty()){ return; } 
     240    if(info[0] == "STARTED"){ 
     241      this->showMessage( info[1], info[2], QSystemTrayIcon::Information, 5000); 
     242    }else if(info[0] == "RUNNING"){ 
     243      //don't show anything here - just let the tooltip update 
     244    }else if(info[0] == "FINISHED"){ 
     245      this->showMessage( info[1], info[2], QSystemTrayIcon::Information, 5000); 
     246    }else if(info[0] == "ERROR"){ 
     247      this->showMessage( info[1], info[2], QSystemTrayIcon::Warning, 5000); 
     248    } 
     249     
     250  }else if(type=="critical"){ 
     251           
     252  }else if(type=="mirror"){ 
     253           
     254  } 
     255  //Update the tray icon 
     256  updateTrayIcon(); 
     257  //Update the tooltip 
     258  updateToolTip(); 
    207259} 
    208260/* 
  • src-qt4/life-preserver/LPTray.h

    r8516ff2 rf698804  
    4040        //double displayToDoubleK(QString); 
    4141 
     42        void updateTrayIcon(); 
     43        void updateToolTip(); 
     44         
    4245private slots: 
    4346        void watcherMessage(QString); 
  • src-qt4/life-preserver/LPWatcher.cpp

    r9ba89ba rf698804  
    66    "replication" status: 20-29 
    77    "critical" status: 30-39 
     8    "mirror" status: 40-49 
    89  Within each set: 
    910    *0 = ID Code (for internal identification as necessary) 
     
    1617  Valid Internal ID's: 
    1718    SNAPCREATED -> new snapshot created 
    18     REPSTARTED    -> Replication task started 
    19     REPFINISHED  -> Replication task finished 
    20     REPERROR       -> Replication task failed 
     19    STARTED     -> Task started 
     20    RUNNING     -> Task running (I.E. status update) 
     21    FINISHED    -> Task finished 
     22    ERROR               -> Task failed 
    2123     
    2224*/ 
     
    8385  unsigned int base; 
    8486  if(type=="message"){base=10;} 
    85   else if(type=="running"){base=20;} 
     87  else if(type=="replicate"){base=20;} 
    8688  else if(type=="critical"){base=30;} 
     89  else if(type=="mirror"){base=40;} 
    8790  else{ return output; } //invalid input type 
    8891  //Now fill the output array based upon requested outputs 
     
    99102  //Return the output list 
    100103  return output; 
     104} 
     105 
     106QStringList LPWatcher::getAllCurrentMessages(){ 
     107  //Useful for quickly displaying all latest messages in a tooltip or summary 
     108  QStringList output; 
     109  if(LOGS.contains(12) && LOGS.contains(14)){ output << LOGS[14]+" -- "+LOGS[12]; } 
     110  if(LOGS.contains(22) && LOGS.contains(24)){ output << LOGS[24]+" -- "+LOGS[22]; } 
     111  if(LOGS.contains(32) && LOGS.contains(34)){ output << LOGS[34]+" -- "+LOGS[32]; } 
     112  if(LOGS.contains(42) && LOGS.contains(44)){ output << LOGS[44]+" -- "+LOGS[42]; } 
     113  return output; 
     114} 
     115 
     116bool LPWatcher::isRunning(){ 
     117  if(LOGS.value(20) == "STARTED" || LOGS.value(20) == "RUNNING"){ return true; } 
     118  else if(LOGS.value(40) == "STARTED" || LOGS.value(40) == "RUNNING"){ return true; } 
     119  else{ return false; } 
     120} 
     121 
     122bool LPWatcher::hasError(){ 
     123  return (LOGS.value(20)=="ERROR" || LOGS.contains(30) || LOGS.value(40)=="ERROR"); 
    101124} 
    102125 
     
    135158      // 23 - Full message set on update ping 
    136159      LOGS.insert(24, timestamp); //full timestamp 
    137       LOGS.insert(25, time); // time only       
    138       //let the first ping of the replication file watcher emit the signal - don't do it now 
     160      LOGS.insert(25, time); // time only 
     161      if(!quiet){ emit MessageAvailable("replication"); } 
    139162    }else if(message.contains("finished replication")){ 
    140163      stopRepFileWatcher(); 
     
    201224      lastSize = cSize; //save the current size for later 
    202225      //Now set the current process status 
     226      LOGS.insert(20,"RUNNING"); 
    203227      LOGS.insert(21,dataset); 
    204228      LOGS.insert(23,txt); 
     
    253277void LPWatcher::checkErrorFile(){ 
    254278  return; 
    255   //Check zpool status and report any errors/processes 
    256279  if(QFile::exists(FILE_ERROR)){ 
    257280    //Read the file to determine the cause of the error 
  • src-qt4/life-preserver/LPWatcher.h

    r8516ff2 rf698804  
    1919 
    2020        QStringList getMessages(QString type, QStringList msgList); 
    21         //Valid types - "critical"/"running"/"message" 
    22         //Valid messages - "dataset","message","summary","id", "timestamp", "time" 
     21        QStringList getAllCurrentMessages(); 
     22        bool isRunning(); 
     23        bool hasError(); 
    2324 
    2425public slots: 
Note: See TracChangeset for help on using the changeset viewer.