Skip to content

Commit

Permalink
Dont build proxy client activity by default (#185)
Browse files Browse the repository at this point in the history
* Dont build proxy client activity by default

* Update Makefile to not  build proxy client activity by default

---------

Co-authored-by: Jon Levell <[email protected]>
  • Loading branch information
jonquark and Jon Levell authored Jul 22, 2024
1 parent 5b90141 commit fc92d4b
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 45 deletions.
41 changes: 33 additions & 8 deletions server_proxy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -51,17 +61,20 @@ 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 +=

# ------------------------------------------------
# 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))
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
4 changes: 2 additions & 2 deletions server_proxy/src/iotrest.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <iotrest.h>
#include <selector.h>
#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY
#include <pxactivity.h>
#endif
#include <pxtransport.h>
Expand Down Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions server_proxy/src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
#include <ismutil.h>
#include <ismjson.h>
#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY
#include <pxactivity.h>
#endif
#include <pxtransport.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions server_proxy/src/pxStatsdClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <tenant.h>
#define NO_KAFKA_POBJ
#include <pxkafka.h>
#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY
#include <pxactivity.h>
#endif

Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions server_proxy/src/pxconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <throttle.h>
#include <pxrouting.h>
#include <sys/stat.h>
#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY
#include <pxactivity.h>
#endif

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -188,7 +188,7 @@ int g_licensedUsage = LICENSE_None;
#include "topicrule.c"
#endif

#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY

int pxactEnabled = 0;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*/
Expand Down
14 changes: 7 additions & 7 deletions server_proxy/src/pxmqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <protoex.h>
#include <auth.h>
#include <pxrouting.h>
#ifndef NO_PXACT
#ifdef PX_CLIENTACTIVITY
#include <pxactivity.h>
#endif
#include <byteswap.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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 ;
Expand Down
2 changes: 1 addition & 1 deletion server_proxy/src/pxtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion server_proxy/src/pxtransport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

1 comment on commit fc92d4b

@eclipse-amlen-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built with quay.io/amlen/amlen-builder-almalinux9:main-1.0.0.10

Please sign in to comment.