diff --git a/server_proxy/Makefile b/server_proxy/Makefile index 7982d644..e078ca32 100644 --- a/server_proxy/Makefile +++ b/server_proxy/Makefile @@ -35,13 +35,23 @@ IFLAGS += -I$(ROOTREL)/server_utils/src #(uses the path_parser.py/paths.properties mechanism) PATH_VAR_CFLAGS=$(IMA_SVR_AND_BRIDGE_AND_PROXY_PATH_DEFINES) -# Default the location of the mongo C driver +# Default the location of the mongo C driver - only needed if we include the activity code +ifeq ($(IMA_PROXY_ACTIVITY),TRUE) +MONGOC_LIBS=-lbson-1.0 -lmongoc-1.0 + ifeq ($(MONGOC_HOME),) MONGOC_INCLUDE=-I/opt/mongo-c-driver-1.9.5/include/libbson-1.0 -I/opt/mongo-c-driver-1.9.5/include/libmongoc-1.0 -MONGOC_LIB=-L/opt/mongo-c-driver-1.9.5/lib +MONGOC_LIBPATH=-L/opt/mongo-c-driver-1.9.5/lib else MONGOC_INCLUDE=-I$(MONGOC_HOME)/include/libbson-1.0 -I$(MONGOC_HOME)/include/libmongoc-1.0 -MONGOC_LIB=-L$(MONGOC_HOME)/lib64 +MONGOC_LIBPATH=-L$(MONGOC_HOME)/lib64 +endif + +else +#Don't need mongo +MONGOC_LIBS= +MONGOC_INCLUDE= +MONGOC_LIBPATH= endif @@ -51,8 +61,8 @@ IDFLAGS += IFLAGS += -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(ROOTREL)/build_tools/applications/oracle -I$(ROOTREL)/server_transport/src $(MONGOC_INCLUDE) CFLAGS += -DIMAPROXY -DGAI_SIG CPPFLAGS += -std=c++11 -LDFLAGS += $(MONGOC_LIB) -Wl,-rpath,/opt/ibm/imaproxy/lib64 -LDLIBS += $(IMA_ICU_LIBS) -licuuc -licui18n -licudata -lanl $(SSL_LIB) -lssl -lcrypto -lcurl -ldl -lstatsdclient -lbson-1.0 -lmongoc-1.0 +LDFLAGS += $(MONGOC_LIBPATH) -Wl,-rpath,/opt/ibm/imaproxy/lib64 +LDLIBS += $(IMA_ICU_LIBS) -licuuc -licui18n -licudata -lanl $(SSL_LIB) -lssl -lcrypto -lcurl -ldl -lstatsdclient $(MONGOC_LIBS) XFLAGS += SHARED_FLAGS += @@ -60,8 +70,11 @@ SHARED_FLAGS += # Add project specific make rules # ------------------------------------------------ +ifeq ($(IMA_PROXY_ACTIVITY),TRUE) # Include the activity headers, C and C++ files IFLAGS += -I$(SRCDIR)/activity +CFLAGS += -DPX_CLIENTACTIVITY + $(eval $(call add-search-directory,.c,$(SRCDIR)/activity)) $(eval $(call add-search-directory,.cpp,$(SRCDIR)/activity)) $(eval $(call add-search-directory,.cpp,$(PRJDIR)/test_activity/src)) @@ -70,6 +83,12 @@ libimaproxy-activity-FILES = ActivityBank.cpp ActivityDB.cpp ActivityDBClient.cp libimaproxy-activity-test-FILES = UnitTestMain.cpp CyclicFileLogger.cpp ServerProxyUnitTestInit.cpp \ PXActivityUnitTestTraceInit.cpp ProxyMembershipTest.cpp ActivityUtilsTest.cpp \ ActivityTrackerCAPITest.cpp ActivityTrackerTest.cpp ActivityDBTest.cpp ActivityBankTest.cpp +else +libimaproxy-activity-FILES = +libimaproxy-activity-test-FILES = +#Don't include calls to activity code +CFLAGS += -DNO_PXACT +endif imaproxy-FILES = proxy.c @@ -143,16 +162,23 @@ $(CUNITTESTDIR)/proxy_activity_test$(EXE): $(call objects, $(libimaproxy-activit $(call build-cunit-test) CUNIT_BASIC += proxy_test -CUNIT_ACTIVITY += proxy_activity_test CUNIT_FULL += proxy_test + proxy_test: $(CUNITTESTDIR)/proxy_test$(EXE) $(call run-cunit-test,$<) .PHONY:: transport_test +ifeq ($(IMA_PROXY_ACTIVITY),TRUE) +CUNIT_ACTIVITY += proxy_activity_test + proxy_activity_test: $(CUNITTESTDIR)/proxy_activity_test$(EXE) $(call run-cunit-test,$<) .PHONY:: proxy_activity_test +activitytest: production ${CUNIT_ACTIVITY} +.PHONY:: activitytest +endif + DEBUG_CUNIT_BASIC += debug_proxy_test DEBUG_CUNIT_FULL += debug_proxy_test debug_proxy_test: $(DEBUG_CUNITTESTDIR)/proxy_test$(EXE) @@ -175,11 +201,10 @@ debug: $(COMMON-DIR-TARGETS) $(DEBUG-DIR-TARGETS) $(DEBUG-LIB-TARGETS) $(DEBUG- all: production debug test: production $(CUNIT_BASIC) -activitytest: production ${CUNIT_ACTIVITY} fulltest: production $(CUNIT_BASIC) $(CUNIT_FULL) debugtest: debug $(DEBUG_CUNIT_BASIC) debugfulltest: debug $(DEBUG_CUNIT_BASIC) $(DEBUG_CUNIT_FULL) coveragetest: coverage $(COVERAGE_CUNIT_BASIC) coveragefulltest: coverage $(COVERAGE_CUNIT_BASIC) $(COVERAGE_CUNIT_FULL) -.PHONY:: production debug coverage all test activitytest fulltest coveragetest coveragefulltest debugtest debugfulltest +.PHONY:: production debug coverage all test fulltest coveragetest coveragefulltest debugtest debugfulltest diff --git a/server_proxy/src/iotrest.c b/server_proxy/src/iotrest.c index bcb0c599..c6217ab3 100644 --- a/server_proxy/src/iotrest.c +++ b/server_proxy/src/iotrest.c @@ -24,7 +24,7 @@ #include #include -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY #include #endif #include @@ -271,7 +271,7 @@ static int getBooleanQueryProperty(const char * str, const char * name, int defa static void updateHttpClientActivity(ism_http_t *http, int line) { -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY if (!ism_pxactivity_is_started()) return; diff --git a/server_proxy/src/proxy.c b/server_proxy/src/proxy.c index c39009e4..f38d9bc1 100644 --- a/server_proxy/src/proxy.c +++ b/server_proxy/src/proxy.c @@ -19,7 +19,7 @@ */ #include #include -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY #include #endif #include @@ -97,7 +97,7 @@ static int inpause = 0; static volatile int doterm = 0; static volatile int doUser2 = 0; static ism_threadh_t cmdthread; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY static int pxact=0; void ism_proxy_setClientActivityMonitoring(int enable); #endif @@ -196,7 +196,7 @@ int main (int argc, char * * argv) { ism_common_setProperty(ism_common_getConfigProperties(), "TraceFile", &f); } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY pxact = ism_common_getIntConfig(PXACT_CFG_ENABLE_ACTIVITY_TRACKING, 0); f.type = VT_Integer; f.val.i = pxact; @@ -215,7 +215,7 @@ int main (int argc, char * * argv) { TRACE(2, "platform = %s %s\n", ism_common_getPlatformInfo(), ism_common_getKernelInfo()); TRACE(2, "processor = %s\n", ism_common_getProcessorInfo()); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY TRACE(2, "ActivityMonitoringEnable = %d\n", pxact); ism_proxy_setClientActivityMonitoring(pxact); if (pxact) { @@ -403,7 +403,7 @@ int main (int argc, char * * argv) { if (cRC == CURLE_OK) { curl_global_cleanup(); } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY ism_pxactivity_term(); #endif } @@ -579,7 +579,7 @@ static int process_args(int argc, char * * argv, int pass) { //PXACT /* -a = enable pxActivity */ else if (argp[1] == 'a') { -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY pxact = 1; #endif } diff --git a/server_proxy/src/pxStatsdClient.c b/server_proxy/src/pxStatsdClient.c index 5e1372cc..771cb30e 100644 --- a/server_proxy/src/pxStatsdClient.c +++ b/server_proxy/src/pxStatsdClient.c @@ -25,7 +25,7 @@ #include #define NO_KAFKA_POBJ #include -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY #include #endif @@ -49,7 +49,7 @@ extern int g_useKafkaIMMessaging; static px_kafka_messaging_stat_t kafkaIMMessagingStats[2]; static px_kafka_messaging_stat_t mhubMessagingStats[2]; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY static uint8_t lastPXActStatIndex = 0; //PXACT static double lastPXActUpdateTime = 0.0; #endif @@ -677,7 +677,7 @@ static void updateMHUBMessagingStats(double sampleRate) { //PXACT static void updatePXActStats(void) { -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY char prepBuff[2048]; char sendBuffer[MAX_BUF_SIZE]; double currTime = ism_common_readTSC(); @@ -1077,7 +1077,7 @@ static void updateStats(void) { static int updateStatsTimer(ism_timer_t key, ism_time_t timestamp, void * userdata) { if(lastUpdateTime == 0.0) { lastUpdateTime = ism_common_readTSC(); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY lastPXActUpdateTime = lastUpdateTime; //PXACT #endif return 1; diff --git a/server_proxy/src/pxconfig.c b/server_proxy/src/pxconfig.c index 746f6ae7..b36bacde 100644 --- a/server_proxy/src/pxconfig.c +++ b/server_proxy/src/pxconfig.c @@ -23,7 +23,7 @@ #include #include #include -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY #include #endif @@ -32,7 +32,7 @@ static int notify_fd = 0; static pthread_mutex_t notify_lock; static pthread_mutex_t rulelock = PTHREAD_MUTEX_INITIALIZER; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY static int g_shutdown = 0; static pthread_mutex_t pxactivity_lock = PTHREAD_MUTEX_INITIALIZER; #endif @@ -109,7 +109,7 @@ int ism_transport_getEndpointList(const char * match, ism_json_t * jobj, int jso int ism_proxy_getAuthMask(const char * name); const char * ism_json_getJsonValue(ism_json_entry_t * ent); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY static void replaceString(const char * * oldval, const char * val); #endif @@ -188,7 +188,7 @@ int g_licensedUsage = LICENSE_None; #include "topicrule.c" #endif -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY int pxactEnabled = 0; @@ -604,7 +604,7 @@ void ism_proxy_notify_init(void) { ism_common_setDisableCRLCallback(checkDisableCRL); } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY int ism_proxy_activity_start_thread(ism_timer_t key, ism_time_t timestamp, void * userdata) { int rc = 0; @@ -720,7 +720,7 @@ static int startMessagingTimer(ism_timer_t timer, ism_time_t timestamp, void * u } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY static int init_called=0; static ismPXActivity_ConfigActivityDB_t actDB[1]; @@ -1069,7 +1069,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko int entloc = 1; int needlog = 1; #ifndef HAS_BRIDGE -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY xUNUSED int pxact = 0; #endif #endif @@ -1185,7 +1185,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko break; case JSON_Integer: /* Number with no decimal point */ if (complex == 0) { -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY if (!strcmpi(ent->name, PXACT_CFG_ENABLE_ACTIVITY_TRACKING)) { var.type = VT_Integer; var.val.i = ent->count; @@ -1317,7 +1317,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko ism_common_setProperty(ism_common_getConfigProperties(), "KafkaIMServerShutdownOnErrorTime", &var); ism_kafka_setKafkaIMServerShutdownOnErrorTime(ent->count); #endif -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY } else if (!strcmpi(ent->name, PXACT_CFG_ENABLE_ACTIVITY_TRACKING)) { pxact = 1; var.type = VT_Integer; @@ -1542,7 +1542,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko } } #endif -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY } else if (!strcmp(ent->name, "ActivityMonitoring") || !strcmp(ent->name, "ActivityDB")) { /* TEMP: Allow legacy name */ xrc = ism_proxy_activity_json(parseobj, entloc); @@ -1622,7 +1622,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko } } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY if (pxact && (rc == 0 || keepgoing)) { int pxactState = ism_pxactivity_get_state(); int enabled = ism_common_getIntConfig(PXACT_CFG_ENABLE_ACTIVITY_TRACKING, 0); @@ -1665,7 +1665,7 @@ int ism_proxy_complexConfig(ism_json_parse_t * parseobj, int complex, int checko return rc; } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY /* * Do a strcmp allowing for NULLs */ diff --git a/server_proxy/src/pxmqtt.c b/server_proxy/src/pxmqtt.c index 07385db9..4c00667f 100644 --- a/server_proxy/src/pxmqtt.c +++ b/server_proxy/src/pxmqtt.c @@ -27,7 +27,7 @@ #include #include #include -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY #include #endif #include @@ -1784,7 +1784,7 @@ static int handleConnectRequest(ism_transport_t * transport, mqttMsg_t * mmsg, u return mmsg->rc; } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY // PXACT static int ism_pxact_track_client(ism_transport_t * transport, PXACT_ACTIVITY_TYPE_t type) { if (!transport) { @@ -2257,7 +2257,7 @@ int ism_mqtt_receive(ism_transport_t * transport, char * inbuf, int buflen, int rc = doPublishS2P(transport, &mmsg, bp, buflen, &buf); else { rc = doPublishC2P(transport, &mmsg, bp, buflen, &buf); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY // PXACT if (!rc && ism_pxact_track_client(transport, PXACT_ACTIVITY_TYPE_MQTT_PUBLISH)) { @@ -2473,7 +2473,7 @@ int ism_mqtt_receive(ism_transport_t * transport, char * inbuf, int buflen, int } } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY /* * PXACT - Do activity monitoring */ @@ -2505,7 +2505,7 @@ int ism_mqtt_receive(ism_transport_t * transport, char * inbuf, int buflen, int rc = doUnsubscribe(transport, bp, buflen, &buf, &subcnt); if (subcnt == 0 && rc == 0) sendit = 0; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY // PXACT if (LIKELY(sendit != 0) && ism_pxact_track_client(transport, PXACT_ACTIVITY_TYPE_MQTT_UNSUB)) { @@ -2767,7 +2767,7 @@ int ism_mqtt_receive(ism_transport_t * transport, char * inbuf, int buflen, int break; } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY // PXACT if (ism_pxact_track_client(ctransport, PXACT_ACTIVITY_TYPE_MQTT_CONN)) { @@ -2946,7 +2946,7 @@ int ism_mqtt_receive(ism_transport_t * transport, char * inbuf, int buflen, int __sync_bool_compare_and_swap(&pobj->disconnect_pending, 0, 1); } } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY // PXACT { ctransport = transport->pobj->client_transport ? transport->pobj->client_transport : transport ; diff --git a/server_proxy/src/pxtcp.c b/server_proxy/src/pxtcp.c index fa712aa6..9d3e5026 100644 --- a/server_proxy/src/pxtcp.c +++ b/server_proxy/src/pxtcp.c @@ -1019,7 +1019,7 @@ static int closeConnectionNotify(ism_transport_t * transport, int rc, int clean, #ifndef NO_PROXY char timest [32]; /* Only get the timestamp once */ timest[0] = 0; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY ism_pxact_disconnect(transport, rc); #endif /* If we are monitoring, disconnectMsg will set the timestamp but at millisecond resolution */ diff --git a/server_proxy/src/pxtransport.c b/server_proxy/src/pxtransport.c index 10996e04..d2cc4138 100644 --- a/server_proxy/src/pxtransport.c +++ b/server_proxy/src/pxtransport.c @@ -816,7 +816,7 @@ int ism_transport_startMessaging(void) { TRACE(4, "Start messaging\n"); g_messaging_started = 1; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY if (pxactEnabled) ism_pxactivity_startMessaging(); #endif diff --git a/server_proxy/src/tenant.c b/server_proxy/src/tenant.c index 47da5b97..7c4e650b 100644 --- a/server_proxy/src/tenant.c +++ b/server_proxy/src/tenant.c @@ -1325,7 +1325,7 @@ int ism_tenant_makeTenant(ism_json_parse_t * parseobj, int where, const char * n tenant->rlacAppResourceGroupEnabled = 2; tenant->rlacAppDefaultGroup = 2; tenant->sgEnabled = 2; -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY tenant->pxactEnabled = 2; #endif tenant->disableCRL = 2; @@ -1378,7 +1378,7 @@ int ism_tenant_makeTenant(ism_json_parse_t * parseobj, int where, const char * n ism_common_setErrorData(ISMRC_BadPropertyValue, "%s%s", "SGEnabled", getJsonValue(ent)); rc = ISMRC_BadPropertyValue; } -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY } else if (!strcmpi(ent->name, "ClientActivityEnabled")) { if (ent->objtype != JSON_True && ent->objtype != JSON_False && ent->objtype != JSON_Null) { ism_common_setErrorData(ISMRC_BadPropertyValue, "%s%s", "ClientActivityEnabled", getJsonValue(ent)); @@ -1577,7 +1577,7 @@ int ism_tenant_makeTenant(ism_json_parse_t * parseobj, int where, const char * n tenant->require_secure = tristate(ent); } else if (!strcmpi(ent->name, "SGEnabled")) { tenant->sgEnabled = tristate(ent); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY } else if (!strcmpi(ent->name, "ClientActivityEnabled")) { tenant->pxactEnabled = tristate(ent); #endif @@ -2578,7 +2578,7 @@ int ism_tenant_getTenantJson(ism_tenant_t * tenant, ism_json_t * jobj, const cha ism_json_putBooleanItem(jobj, "DisableCRL", tenant->disableCRL); if (tenant->checkSessionUser != 2) ism_json_putBooleanItem(jobj, "CheckSessionUser", tenant->checkSessionUser); -#ifndef NO_PXACT +#ifdef PX_CLIENTACTIVITY if (tenant->pxactEnabled != 2) ism_json_putBooleanItem(jobj, "ClientActivityEnabled", tenant->pxactEnabled); #endif