static void _get_nodes(void) { time_t now = time(NULL); char out_msg[128]; /* Dump all data */ snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=%s", (uint32_t) now, "CMD=GETNODES ARG=0:ALL"); if (_xmit(out_msg)) exit(1); /* Dump volatile data */ snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=GETNODES ARG=%u:ALL", (uint32_t) now, (uint32_t) 1); if (_xmit(out_msg)) exit(1); /* Dump state only */ snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=GETNODES ARG=%u:ALL", (uint32_t) now, (uint32_t) (now+2)); if (_xmit(out_msg)) exit(1); }
static void _suspend_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=SUSPENDJOB ARG=%ld", (uint32_t) now, my_job_id); _xmit(out_msg); }
static void _cancel_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=CANCELJOB ARG=%ld TYPE=ADMIN", (uint32_t) now, my_job_id); _xmit(out_msg); }
static void _initialize(void) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=INITIALIZE ARG=USEHOSTEXP=N EPORT=%u", (uint32_t) now, e_port); if (_xmit(out_msg)) exit(1); }
static void _job_requeue(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=REQUEUEJOB ARG=%ld", (uint32_t) now, my_job_id); if (_xmit(out_msg)) exit(1); }
static void _signal_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=SIGNALJOB ARG=%ld VALUE=URG", (uint32_t) now, my_job_id); if (_xmit(out_msg)) exit(1); }
static void _start_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=STARTJOB ARG=%ld TASKLIST=", /* Empty TASKLIST means we don't care */ (uint32_t) now, my_job_id); _xmit(out_msg); }
static void _get_nodes(void) { time_t now = time(NULL); char out_msg[128]; /* Dump all data */ snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=%s", (uint32_t) now, "CMD=GETNODES ARG=0:ALL"); _xmit(out_msg); }
static void _job_will_run(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=JOBWILLRUN ARG=JOBID=%ld,%s", (uint32_t) now, my_job_id, ""); /* put available node list here */ if (_xmit(out_msg)) exit(1); }
static void _notify_job(long my_job_id) { time_t now = time(NULL); char out_msg[256]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=NOTIFYJOB ARG=%ld " "MSG=this_is_a_test", (uint32_t) now, my_job_id); if (_xmit(out_msg)) exit(1); }
static void _single_msg(void) { time_t now = time(NULL); char out_msg[1024]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=%s", (uint32_t) now, "JOBWILLRUN ARG=JOBID=65537,bgl[000x733] " "JOBID=65539,bgl[000x733] JOBID=65538,bgl[000x733]"); if (_xmit(out_msg)) exit(1); }
static void _cancel_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=CANCELJOB ARG=%ld " "TYPE=ADMIN " "COMMENT=\"cancel comment\" ", (uint32_t) now, my_job_id); if (_xmit(out_msg)) exit(1); }
static void _modify_job(long my_job_id) { time_t now = time(NULL); char out_msg[256]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=MODIFYJOB ARG=%ld " /* "PARTITION=pdebug " */ /* "NODES=2 " */ /* "DEPEND=afterany:3 " */ /* "INVALID=123 " */ "TIMELIMIT=10 BANK=test_bank", (uint32_t) now, my_job_id); _xmit(out_msg); }
static void _modify_job(long my_job_id) { time_t now = time(NULL); char out_msg[256]; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=MODIFYJOB ARG=%ld " /* "MINSTARTTIME=55555 " */ /* "JOBNAME=foo " */ /* "RFEATURES=big " */ /* "PARTITION=pdebug " */ /* "NODES=2 " */ /* "DEPEND=afterany:3 " */ /* "INVALID=123 " */ /* "GRES=gpu " */ /* "WCKEY=my_key " */ "COMMENT=test123 " "VARIABLELIST=TEST_ENV1=test_val1,TEST_ENV2=test_val2 " "TIMELIMIT=10 BANK=test_bank", (uint32_t) now, my_job_id); if (_xmit(out_msg)) exit(1); }
static void _start_job(long my_job_id) { time_t now = time(NULL); char out_msg[128]; int i, rc; snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=STARTJOB ARG=%ld " "COMMENT=\'start comment\' " "TASKLIST=", /* Empty TASKLIST means we don't care */ (uint32_t) now, my_job_id); for (i=0; i<10; i++) { if (i) sleep(10); rc = _xmit(out_msg); if (rc == 0) break; /* Still completing after requeue */ } if (rc != 0) exit(1); }
//GroveStreams state machine ethernetStatus_t GroveStreams::run(void) { ethernetStatus_t ret = NO_STATUS; const char httpOKText[] = "HTTP/1.1 200 OK"; static char statusBuf[sizeof(httpOKText)]; if ( nError >= MAX_ERROR ) { Serial << millis() << F(" too many network errors\n"); mcuReset(); } switch (GS_STATE) { case GS_WAIT: //wait for next send break; case GS_SEND: if ( _xmit() == PUT_COMPLETE ) { _msLastPacket = millis(); //initialize receive timeout GS_STATE = GS_RECV; ret = PUT_COMPLETE; } else { GS_STATE = GS_WAIT; ++connFail; ++nError; ret = CONNECT_FAILED; } break; case GS_RECV: { boolean haveStatus = false; if(client.connected()) { uint16_t nChar = client.available(); if (nChar > 0) { _msLastPacket = millis(); Serial << _msLastPacket << F(" received packet, len=") << nChar << endl; char* b = statusBuf; for (uint16_t i = 0; i < nChar; i++) { char ch = client.read(); Serial << _BYTE(ch); if ( !haveStatus && i < sizeof(statusBuf) ) { if ( ch == '\r' || i == sizeof(statusBuf) - 1 ) { haveStatus = true; *b++ = 0; if (strncmp(statusBuf, httpOKText, sizeof(httpOKText)) == 0) { ++httpOK; nError = 0; ret = HTTP_OK; } else { ++httpOther; ++nError; ret = HTTP_OTHER; Serial << endl << endl << millis() << F(" HTTP STATUS: ") << statusBuf << endl; } } else { *b++ = ch; } } } } //if too much time has elapsed since the last packet, time out and close the connection from this end else if (millis() - _msLastPacket >= RECEIVE_TIMEOUT) { _msLastPacket = millis(); Serial << endl << _msLastPacket << F(" Recv timeout\n"); client.stop(); if (_ledPin >= 0) digitalWrite(_ledPin, LOW); GS_STATE = GS_DISCONNECT; ++recvTimeout; ++nError; ret = TIMEOUT; } } else { GS_STATE = GS_DISCONNECT; ret = DISCONNECTING; } break; } case GS_DISCONNECT: // close client end _msDisconnecting = millis(); Serial << _msDisconnecting << F(" disconnecting\n"); client.stop(); if (_ledPin >= 0) digitalWrite(_ledPin, LOW); _msDisconnected = millis(); respTime = _msLastPacket - _msPutComplete; discTime = _msDisconnected - _msDisconnecting; Serial << _msDisconnected << F(" disconnected\n\n"); GS_STATE = GS_WAIT; ret = DISCONNECTED; break; } if (ret != NO_STATUS) lastStatus = ret; return ret; }