Commit a3d1bc25 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: workers emit MQ client ID to syslog

parent 5dd49a6b
......@@ -101,6 +101,13 @@ AMQ_Worker::getVersion() {
return md->getCMSProviderName() + " " + md->getProviderVersion();
}
std::string
AMQ_Worker::getClientID() {
if (connection == NULL)
throw cms::IllegalStateException("Connection uninitialized");
return connection->getClientID();
}
const char *
AMQ_GlobalInit(void)
{
......@@ -149,6 +156,16 @@ AMQ_Version(AMQ_Worker *worker, char *version)
CATCHALL
}
const char *
AMQ_ClientID(AMQ_Worker *worker, char *clientID)
{
try {
strcpy(clientID, worker->getClientID().c_str());
return NULL;
}
CATCHALL
}
const char *
AMQ_WorkerShutdown(AMQ_Worker **worker)
{
......
......@@ -62,6 +62,7 @@ public:
virtual ~AMQ_Worker();
void send(std::string& text);
std::string getVersion();
std::string getClientID();
};
#else
typedef struct AMQ_Worker AMQ_Worker;
......@@ -76,6 +77,7 @@ extern "C" {
char *qName);
const char *AMQ_Send(AMQ_Worker *worker, const char *data, unsigned len);
const char *AMQ_Version(AMQ_Worker *worker, char *version);
const char *AMQ_ClientID(AMQ_Worker *worker, char *clientID);
const char *AMQ_WorkerShutdown(AMQ_Worker **worker);
const char *AMQ_GlobalShutdown(void);
......
......@@ -96,6 +96,12 @@ MQ_Version(void *priv, char *version)
return AMQ_Version((AMQ_Worker *) priv, version);
}
const char *
MQ_ClientID(void *priv, char *clientID)
{
return AMQ_ClientID((AMQ_Worker *) priv, clientID);
}
const char *
MQ_WorkerShutdown(void **priv)
{
......
......@@ -118,6 +118,23 @@ static const char
return NULL;
}
static const char
*test_clientID(void)
{
const char *err;
char clientID[BUFSIZ];
printf("... testing client ID info\n");
mu_assert("MQ_ClientID: worker is NULL before call", worker != NULL);
err = MQ_ClientID(worker, clientID);
sprintf(errmsg, "MQ_Version: %s", err);
mu_assert(errmsg, err == NULL);
mu_assert("MQ_Version: client ID is empty", clientID[0] != '\0');
return NULL;
}
static const char
*test_send(void)
{
......@@ -173,6 +190,7 @@ static const char
mu_run_test(test_init_connection);
mu_run_test(test_worker_init);
mu_run_test(test_version);
mu_run_test(test_clientID);
mu_run_test(test_send);
mu_run_test(test_worker_shutdown);
mu_run_test(test_global_shutdown);
......
......@@ -152,6 +152,7 @@ const char *MQ_InitConnections(void);
const char *MQ_WorkerInit(void **priv);
const char *MQ_Send(void *priv, const char *data, unsigned len);
const char *MQ_Version(void *priv, char *version);
const char *MQ_ClientID(void *priv, char *clientID);
const char *MQ_WorkerShutdown(void **priv);
const char *MQ_GlobalShutdown(void);
......
......@@ -40,6 +40,7 @@
#include "miniobj.h"
#define VERSION_LEN 64
#define CLIENT_ID_LEN 80
static int running = 0;
......@@ -137,7 +138,7 @@ static void
void *amq_worker;
dataentry *entry;
const char *err;
char version[VERSION_LEN];
char version[VERSION_LEN], clientID[CLIENT_ID_LEN];
LOG_Log(LOG_INFO, "Worker %d: starting", wrk->id);
CHECK_OBJ_NOTNULL(wrk, WORKER_DATA_MAGIC);
......@@ -158,6 +159,12 @@ static void
version[0] = '\0';
}
err = MQ_ClientID(amq_worker, clientID);
if (err != NULL) {
LOG_Log(LOG_ERR, "Worker %d: Failed to get MQ client ID", wrk->id, err);
clientID[0] = '\0';
}
VSTAILQ_INIT(&wrk->wrk_freelist);
wrk->wrk_nfree = 0;
......@@ -166,7 +173,8 @@ static void
running++;
AZ(pthread_mutex_unlock(&running_lock));
LOG_Log(LOG_INFO, "Worker %d: running (%s)", wrk->id, version);
LOG_Log(LOG_INFO, "Worker %d: running (%s, id = %s)", wrk->id, version,
clientID);
while (run) {
entry = (dataentry *) SPMCQ_Deq();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment