mama_status mamaDQPublisherManager_create ( mamaDQPublisherManager manager, mamaTransport transport, mamaQueue queue, const mamaDQPublisherManagerCallbacks* callback, const char* sourcename, const char* root, void * closure) { char* topic; int length = 0; mamaDQPublisherManagerImpl* impl = (mamaDQPublisherManagerImpl*) manager; static mamaMsgCallbacks basicSubscCbs = { dqPublisherImplCreateCb, dqPublisherImplErrorCb, dqPublisherImplMsgCb, NULL }; impl->mUserCallbacks = *callback; impl->mTransport = transport; impl->mQueue = queue; impl->mClosure = closure; length = strlen(root) + 1 + (strlen(sourcename) + 1); topic = calloc(length, sizeof(char)); strcpy(topic, root); impl->mNameSpace = strdup(sourcename); strcat(topic, "."); strcat(topic, sourcename); impl->mPublisherMap = wtable_create (topic, NUM_BUCKETS); mamaSubscription_allocate (&impl->mSubscription); mamaPublisher_create (&impl->mPublisher, transport, MAMA_CM_TOPIC, NULL, NULL); mamaSubscription_createBasic (impl->mSubscription, transport, queue, &basicSubscCbs, topic, impl); free(topic); return MAMA_STATUS_OK; }
void MamaSource::addSubscription (const char* symbol, MamaSubscription* sub) { if (!mySubs) { mySubs = wtable_create ("MamaSource::mySubs", 100); } MamaSubscription* foundSub = (MamaSubscription*) wtable_lookup (mySubs, symbol); if (foundSub) { return; } wtable_insert (mySubs, symbol, sub); }
int createStatisticsCache(statsCache** sCache,int numMsgCategories, FILE* outfile,int header) { int mysCacheStatus; struct timeval sTime; /*create statsCache struct*/ statsCache* mysCache = (statsCache*)calloc(1,sizeof(statsCache)); if(!mysCache) { mysCacheStatus = STATS_NO_MEMORY; } mysCache->mNumMsg = numMsgCategories; mysCache->mHeader = header; mysCache->mOutfile = outfile; mysCache->mNumMessages = 0; mysCache->mNumBytes = 0; (void)gettimeofday(&sTime,NULL); mysCache->mLastUpdateTime = ( (double) sTime.tv_sec ) + ( (double)sTime.tv_usec / 1000000 ); /* mysCache->mNumMsg flags wether calculating stats on per symbol * basis or general stats on all symbols, if > 0 then a table is needed * to store data on all symbols */ if(mysCache->mNumMsg>0) { /*Per symbol/category*/ mysCache->mSymbolTable = wtable_create("mSymbolTable",mysCache->mNumMsg); if (!mysCache->mSymbolTable) { printf ("Error: wtable_create() failed.\n"); } else { if(mysCache->mHeader == 1 && mysCache->mOutfile == stdout) { fprintf(mysCache->mOutfile,opHeaderPeriod); mysCache->mHeader=0; } *sCache = mysCache; } } else { /* Global statistics */ const char* dummySymbol = "Global"; mysCache->mPData =(perfData*)calloc(1,sizeof(perfData)); if(!mysCache) { return STATS_NO_MEMORY; } initPerfData(mysCache->mPData, outfile, dummySymbol); if(mysCache->mPData) { if(mysCache->mHeader == 1 && mysCache->mOutfile == stdout) { fprintf(mysCache->mOutfile,opHeaderPeriod); mysCache->mHeader=0; } *sCache = mysCache; } } return STATS_OK; }