9e5903c4028fda4fe14ec7e95c93f2f7db53e994 galt Thu Apr 1 16:33:04 2021 -0700 Making blatServersCheck support dynamic servers diff --git src/hg/utils/blatServersCheck/blatServersCheck.c src/hg/utils/blatServersCheck/blatServersCheck.c index dab0a4f..0dbc7c1 100644 --- src/hg/utils/blatServersCheck/blatServersCheck.c +++ src/hg/utils/blatServersCheck/blatServersCheck.c @@ -61,53 +61,56 @@ if (!value) errAbort("setting %s not found!",temp); return value; } void setSocketTimeout(int sockfd, int delayInSeconds) // put socket read timeout so it will not take forever to timeout during a read { struct timeval tv; tv.tv_sec = delayInSeconds; tv.tv_usec = 0; setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv); setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof tv); } -int statusServer(char *hostName, char *portName, boolean isTrans, struct hash *versionHash) +int statusServer(char *hostName, char *portName, boolean isTrans, boolean isDynamic, char *db, struct hash *versionHash) /* Send status message to server arnd report result. * Returns -1 for connection error. * Returns -2 for error reading string. * Returns -3 for type mismatch. * Returns -4 for host mismatch. * Returns -5 for port mismatch. */ { char buf[256]; int sd = 0; int ret = 0; /* Put together command. */ sd = netConnectWithTimeout(hostName, atoi(portName), timeout * 1000); // 10 seconds connect timeout if (sd == -1) { warn("Error connecting to %s:%s", hostName, portName); return -1; } setSocketTimeout(sd, timeout); +if (isDynamic) + sprintf(buf, "%s%s %s %s", gfSignature(), isTrans ? "transInfo" : "untransInfo", db, db); +else sprintf(buf, "%sstatus", gfSignature()); mustWriteFd(sd, buf, strlen(buf)); for (;;) { if (netGetString(sd, buf) == NULL) { warn("Error reading status information from %s:%s", hostName, portName); ret = -2; // error reading response break; } if (sameString(buf, "end")) { break; } @@ -288,62 +291,65 @@ verbose(1, "Reading table %s\n", blatServersTableName); totalRows = sqlTableSize(conn, blatServersTableName); verbose(1,"totalRows=%d\n", totalRows); verbose(1,"\n"); if (totalRows==0) { errAbort("table %s is empty!", blatServersTableName); } int errCount = 0; -sqlSafef(query,sizeof(query), "select db, host, port, isTrans from %s order by db,port", blatServersTableName); +sqlSafef(query,sizeof(query), "select db, host, port, isTrans, dynamic from %s order by db,port", blatServersTableName); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { char *db = row[0]; char *host = row[1]; char *portStr = row[2]; unsigned int port = sqlUnsigned(portStr); unsigned int trans = sqlUnsigned(row[3]); + unsigned int dynamic = sqlUnsigned(row[4]); boolean isTrans = (trans == 1); + boolean isDynamic = (dynamic == 1); if (hostFilter && !sameString(hostFilter, host)) continue; // skip - int res = statusServer(host, portStr, isTrans, versionHash); + int res = statusServer(host, portStr, isTrans, isDynamic, db, versionHash); int res2 = 0; if (res != -1) // if not a connection error, proceed. { res2 = getFileList(host, portStr, db, targetDbHash); } safef(hashKey, sizeof hashKey, "%s:%s", host, portStr); struct hashEl *hel = hashLookup(hash, hashKey); if (hel == NULL) { hashAdd(hash, hashKey, NULL); } else { + if (!isDynamic) warn("duplicate host:port %s found", hashKey); } - if ((res != 0) || (res2 != 0) || (hel != NULL)) + if ((res != 0) || (res2 != 0) || ((hel != NULL) && !isDynamic)) { ++errCount; verbose(1, "db=%s host=%s port=%d isTrans=%d res=%d res2=%d\n\n", db, host, port, trans, res, res2); } else { verbose(2, "db=%s host=%s port=%d isTrans=%d res=%d res2=%d\n\n", db, host, port, trans, res, res2); } } sqlFreeResult(&sr); sqlDisconnect(&conn); // Show a count of how many servers were of each gfServer version