display fixes.

./gb installgb and ./gb installgb2 now install 'gb'
if 'gb.new' is not present.
This commit is contained in:
Matt Wells 2014-01-11 17:16:20 -08:00
parent 299a208253
commit 6de7abf6ba
4 changed files with 52 additions and 14 deletions

View File

@ -7,6 +7,7 @@
#include "sort.h"
#include "Users.h"
static int defaultSort ( const void *i1, const void *i2 );
static int pingSort1 ( const void *i1, const void *i2 );
static int pingSort2 ( const void *i1, const void *i2 );
static int pingAgeSort ( const void *i1, const void *i2 );
@ -37,8 +38,8 @@ bool sendPageHosts ( TcpSocket *s , HttpRequest *r ) {
SafeBuf sb(buf, 64*1024);
// check for a sort request
long sort = r->getLong ( "sort", -1 );
// sort by ping times by default now, we are usually always doing that
if ( sort == -1 ) sort = 1;
// sort by hostid with dead on top by default
if ( sort == -1 ) sort = 16;
char *coll = r->getString ( "c" );
//char *pwd = r->getString ( "pwd" );
// check for setnote command
@ -292,6 +293,7 @@ skipReplaceHost:
case 13:gbsort ( hostSort, nh, sizeof(long), splitTimeSort ); break;
case 14:gbsort ( hostSort, nh, sizeof(long), pingMaxSort ); break;
case 15:gbsort ( hostSort, nh, sizeof(long), slowDiskSort ); break;
case 16:gbsort ( hostSort, nh, sizeof(long), defaultSort ); break;
}
// we are the only one that uses these flags, so set them now
@ -390,24 +392,26 @@ skipReplaceHost:
// does its hosts.conf file disagree with ours?
if ( h->m_hostsConfCRC &&
h->m_hostsConfCRC != g_hostdb.getCRC() )
fb.safePrintf("<font color=red>H</font>");
fb.safePrintf("<font color=red><b title=\"Hosts.conf "
"in disagreement with ours.\">H</b></font>");
// rebalancing?
if ( h->m_flags & PFLAG_REBALANCING )
fb.safePrintf("<blink>R</blink>");
fb.safePrintf("<b title=\"Current rebalancing\">R</b>");
// has recs that should be in another shard? indicates
// we need to rebalance or there is a bad hosts.conf
if ( h->m_flags & PFLAG_FOREIGNRECS )
fb.safePrintf("<font color=red><blink>F"
"</blink></font");
fb.safePrintf("<font color=red><b title=\"Foreign data "
"detected. Needs rebalance.\">F"
"</b></font");
// if it has spiders going on say "S"
if ( h->m_flags & PFLAG_HASSPIDERS )
fb.safePrintf ( "S");
fb.safePrintf ( "<span title=\"Spidering\">S</span>");
// say "M" if merging
if ( h->m_flags & PFLAG_MERGING )
fb.safePrintf ( "M");
fb.safePrintf ( "<span title=\"Merging\">M</span>");
// say "D" if dumping
if ( h->m_flags & PFLAG_DUMPING )
fb.safePrintf ( "D");
fb.safePrintf ( "<span title=\"Dumping\">D</span>");
// say "y" if doing the daily merge
if ( !(h->m_flags & PFLAG_MERGEMODE0) )
fb.safePrintf ( "y");
@ -980,6 +984,24 @@ long generatePingMsg( Host *h, long long nowms, char *buf ) {
return pingAge;
}
int defaultSort ( const void *i1, const void *i2 ) {
Host *h1 = g_hostdb.getHost ( *(long*)i1 );
Host *h2 = g_hostdb.getHost ( *(long*)i2 );
// float up to the top if the host is reporting kernel errors
// even if the ping is normal
if ( h1->m_kernelErrors > 0 && h2->m_kernelErrors <= 0 ) return -1;
if ( h2->m_kernelErrors > 0 && h1->m_kernelErrors <= 0 ) return 1;
if ( h2->m_kernelErrors > 0 && h1->m_kernelErrors > 0 ) {
if ( h1->m_hostId < h2->m_hostId ) return -1;
return 1;
}
if ( g_hostdb.isDead(h1) && ! g_hostdb.isDead(h2) ) return -1;
if ( g_hostdb.isDead(h2) && ! g_hostdb.isDead(h1) ) return 1;
if ( h1->m_hostId < h2->m_hostId ) return -1;
return 1;
}
int pingSort1 ( const void *i1, const void *i2 ) {
Host *h1 = g_hostdb.getHost ( *(long*)i1 );
Host *h2 = g_hostdb.getHost ( *(long*)i2 );

View File

@ -2048,8 +2048,8 @@ bool Pages::printCollectionNavBar ( SafeBuf *sb ,
while ( b < g_collectiondb.m_numRecs && countb < 16 )
if ( g_collectiondb.m_recs[b++] ) countb++;
char *s = "";
if ( g_collectiondb.m_numRecsUsed == 1 ) s = "s";
char *s = "s";
if ( g_collectiondb.m_numRecsUsed == 1 ) s = "";
sb->safePrintf ( "<center><b>%li Collection%s</b></center><br>\n",
g_collectiondb.m_numRecsUsed , s );

View File

@ -18574,7 +18574,9 @@ bool Parms::updateParm ( char *rec , WaitEntry *we ) {
sb->nullTerm();
//return true;
// sanity
if ( data[dataSize-1] != '\0' ) { char *xx=NULL;*xx=0; }
// we no longer include the \0 in the dataSize... so a dataSize
// of 0 means empty string...
//if ( data[dataSize-1] != '\0' ) { char *xx=NULL;*xx=0; }
}
else {
// and copy the data into collrec or g_conf

View File

@ -4362,11 +4362,18 @@ int install ( install_flag_konst_t installFlag , long hostId , char *dir ,
else if ( installFlag == ifk_installgb ) {
// don't copy to ourselves
//if ( h2->m_hostId == h->m_hostId ) continue;
File f;
char *target = "gb.new";
f.set(h2->m_dir,target);
if ( ! f.doesExist() ) target = "gb";
sprintf(tmp,
"rcp "
"%sgb.new "
"%s%s "
"%s:%s/gb.installed &",
dir,
target,
iptoa(h2->m_ip),
h2->m_dir);
log(LOG_INIT,"admin: %s", tmp);
@ -4767,11 +4774,18 @@ int install ( install_flag_konst_t installFlag , long hostId , char *dir ,
//if ( h2->m_hostId == h->m_hostId ) continue;
char *amp = " &";
if ( i > 0 && (i%5) == 0 ) amp = "";
File f;
char *target = "gb.new";
f.set(h2->m_dir,target);
if ( ! f.doesExist() ) target = "gb";
sprintf(tmp,
"rcp "
"%sgb.new "
"%s%s "
"%s:%s/gb.installed %s",
dir,
target ,
iptoa(h2->m_ipShotgun),
h2->m_dir,
amp);