96c969825f39b33ddb5697c9eb7c36ad622fc160
galt
  Mon Oct 1 16:28:44 2012 -0700
adding flushResults to para and parasol clients
diff --git src/parasol/paraHub/paraHub.c src/parasol/paraHub/paraHub.c
index e947d64..3ad22c6 100644
--- src/parasol/paraHub/paraHub.c
+++ src/parasol/paraHub/paraHub.c
@@ -2094,30 +2094,72 @@
     return -2;
 return freeBatch(userName, batchName);
 }
 
 void freeBatchAcknowledge(char *line, struct paraMessage *pm)
 /* Free batch resources.  Line format is <user> <dir>
 * Returns 0 if success or some err # if a problem.  Sends result back to client. */
 {
 int result = freeBatchFromMessage(line);
 pmClear(pm);
 pmPrintf(pm, "%d",result);
 pmSend(pm, rudpOut);
 }
 
 
+int flushResultsByRequest(char *userName, char *batchName)
+/* Flush results file. Return 0 if nothing running and queue empty. */
+{
+struct user *user = findUser(userName);
+if (user == NULL) return -3;
+struct hashEl *hel = hashLookup(stringHash, batchName);
+if (hel == NULL) return -2;
+char *name = hel->name;
+struct batch *batch = findBatchInList(user->curBatches, name);
+if (batch == NULL)
+    batch = findBatchInList(user->oldBatches, name);
+if (batch == NULL) return -2;
+flushResults(batch->name);
+logDebug("paraHub: User %s flushed results batch %s", userName, batchName);
+/* return 0 if nothing running and queue empty */
+if (batch->runningCount > 0) return -1;
+if (!dlEnd(batch->jobQueue->head)) return -1;
+return 0;
+}
+
+int flushResultsFromMessage(char *line)
+/* Parse out flushResults message and flush the results file. */
+{
+char *userName, *batchName;
+if ((userName = nextWord(&line)) == NULL)
+    return -2;
+if ((batchName = nextWord(&line)) == NULL)
+    return -2;
+return flushResultsByRequest(userName, batchName);
+}
+
+void flushResultsAcknowledge(char *line, struct paraMessage *pm)
+/* Flush results file.  Line format is <user> <dir>
+ * Returns 0 if success or some err # if a problem.  Sends result back to client. */
+{
+int result = flushResultsFromMessage(line);
+pmClear(pm);
+pmPrintf(pm, "%d",result);
+pmSend(pm, rudpOut);
+}
+
+
 int clearSickNodes(char *userName, char *dir)
 /* Clear sick nodes for batch */
 {
 struct user *user = findUser(userName);
 struct batch *batch = findBatch(user, dir, TRUE);
 if (user == NULL) return -2;
 if (batch == NULL) return -2;
 hashFree(&batch->sickNodes);
 batch->sickNodes = newHashExt(6, FALSE);
 batch->continuousCrashCount = 0;  /* reset so user can retry */
 needsPlanning = TRUE;
 updateUserSickNodes(user);
 logDebug("paraHub: User %s cleared sick nodes for batch %s", userName, dir);
 return 0;
 }
@@ -3273,30 +3315,32 @@
     command = nextWord(&line);
     if (sameWord(command, "jobDone"))
 	 jobDone(line);
     else if (sameWord(command, "recycleSpoke"))
 	 recycleSpoke(line);
     else if (sameWord(command, "heartbeat"))
 	 processHeartbeat();
     else if (sameWord(command, "setPriority"))
 	 setPriorityAcknowledge(line, pm);
     else if (sameWord(command, "setMaxJob"))
 	 setMaxJobAcknowledge(line, pm);
     else if (sameWord(command, "resetCounts"))
          resetCountsAcknowledge(line, pm);
     else if (sameWord(command, "freeBatch"))
          freeBatchAcknowledge(line, pm);
+    else if (sameWord(command, "flushResults"))
+         flushResultsAcknowledge(line, pm);
     else if (sameWord(command, "showSickNodes"))
 	 showSickNodesAcknowledge(line, pm);
     else if (sameWord(command, "clearSickNodes"))
 	 clearSickNodesAcknowledge(line, pm);
     else if (sameWord(command, "addJob"))
 	 addJobAcknowledge(line, pm, 1);
     else if (sameWord(command, "addJob2"))
 	 addJobAcknowledge(line, pm, 2);
     else if (sameWord(command, "nodeDown"))
 	 nodeDown(line);
     else if (sameWord(command, "alive"))
 	 nodeAlive(line);
     else if (sameWord(command, "checkIn"))
 	 nodeCheckIn(line);
     else if (sameWord(command, "checkDeadNodesASAP"))