#include "os.h"
#include "common.h"
{
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *sessionProps[50];
int propIndex;
int loop;
char binMsg[1024];
solClient_uint32_t deliveryMode;
char gdWindowStr[32];
long long startTime;
long long targetTime;
long long currentTime;
long long timeDiff;
long long elapsedTime;
long double usPerMsg;
char positionalParms[] = "\t[mode] Delivery Mode (persistentQ, non-persistentQ, persistentT,\n"\
"\t non-persistentT - default persistentQ.)\n";
printf ( "\nperfADPub.c (Copyright 2007-2024 Solace Corporation. All rights reserved.)\n" );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK |
DEST_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
NUM_MSGS_MASK |
MSG_RATE_MASK |
WINDOW_SIZE_MASK |
LOG_LEVEL_MASK |
USE_GSS_MASK |
ZIP_LEVEL_MASK));
if ( common_parseCommandOptions ( argc, argv, &commandOpts, positionalParms ) == 0 ) {
exit(1);
}
destination.
dest = commandOpts.destinationName;
if (optind < argc ) {
if ( strcmp ( "persistentQ", argv[optind] ) == 0 ) {
} else if ( strcmp ( "non-persistentQ", argv[optind] ) == 0 ) {
} else if ( strcmp ( "persistentT", argv[optind] ) == 0 ) {
} else if ( strcmp ( "non-persistentT", argv[optind] ) == 0 ) {
} else {
printf ( "Invalid mode parameter '%s' - must be one of 'persistentQ', 'non-persistentQ', 'persistentT', 'non-persistentT'\n",
argv[optind]);
exit(1);
}
} else {
}
common_handleError ( rc, "solClient_initialize()" );
goto notInitialized;
}
common_printCCSMPversion ( );
&context_p, &contextFuncInfo,
sizeof ( contextFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_context_create()" );
goto cleanup;
}
propIndex = 0;
sessionProps[propIndex++] = commandOpts.username;
sessionProps[propIndex++] = commandOpts.password;
if ( commandOpts.targetHost[0] != (char) 0 ) {
sessionProps[propIndex++] = commandOpts.targetHost;
}
sessionProps[propIndex++] = ( commandOpts.enableCompression ) ? "9" : "0";
if ( commandOpts.gdWindow != 0 ) {
snprintf ( gdWindowStr, sizeof ( gdWindowStr ), "%d", commandOpts.gdWindow );
sessionProps[propIndex++] = gdWindowStr;
}
if ( commandOpts.vpn[0] ) {
sessionProps[propIndex++] = commandOpts.vpn;
}
if ( commandOpts.useGSS ) {
}
sessionProps[propIndex++] = NULL;
context_p, &session_p, &sessionFuncInfo, sizeof ( sessionFuncInfo ) ) )
common_handleError ( rc, "solClient_session_create()" );
goto cleanup;
}
common_handleError ( rc, "solClient_session_connect()" );
goto cleanup;
}
common_handleError ( rc, "solClient_msg_alloc()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto sessionConnected;
}
memset ( ( void * ) binMsg, 0xab, sizeof ( binMsg ) );
common_handleError ( rc, "solClient_msg_setBinaryAttachmentPtr()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_setDestination()" );
goto sessionConnected;
}
usPerMsg = ( long double ) 1000000.0 / ( long double ) commandOpts.msgRate;
startTime = getTimeInUs ( );
targetTime = startTime + ( long long ) usPerMsg;
for ( loop = 0; loop < commandOpts.numMsgsToSend; loop++ ) {
common_handleError ( rc, "solClient_session_send" );
break;
}
currentTime = getTimeInUs ( );
timeDiff = targetTime - currentTime;
if ( timeDiff > 0 ) {
sleepInUs ( ( int ) ( timeDiff ) );
}
targetTime += ( long long ) usPerMsg;
}
elapsedTime = getTimeInUs ( ) - startTime;
printf ( "Sent %d msgs in %lld usec, rate of %Lf msgs/sec\n",
commandOpts.numMsgsToSend, elapsedTime,
( long double ) commandOpts.numMsgsToSend / ( ( long double ) elapsedTime / ( long double ) 1000000.0 ) );
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
goto notInitialized;
notInitialized:
return 0;
}