示例#1
0
c_char*
cmx_writerNew(
    const c_char* publisher,
    const c_char* name,
    const c_char* topic,
    const c_char* qos)
{
    u_publisher pub;
    u_topic top;
    u_writer wri;
    c_char* result;
    cmx_entityArg arg;
    u_result ur;
    cmx_entityKernelArg kernelArg;
    v_writerQos wQos;
    
    result = NULL;
    pub = u_publisher(cmx_entityUserEntity(publisher));
    
    if(pub != NULL){
        top = u_topic(cmx_entityUserEntity(topic));
        
        if(top != NULL){
            kernelArg = cmx_entityKernelArg(os_malloc(C_SIZEOF(cmx_entityKernelArg)));
            u_entityAction(u_entity(pub), cmx_entityKernelAction, (c_voidp)kernelArg);
            
            if(qos != NULL){
                wQos = v_writerQos(cmx_qosKernelQosFromKind(qos, K_WRITER, c_getBase(c_object(kernelArg->kernel))));
                
                if(wQos == NULL){
                    wQos = v_writerQosNew(kernelArg->kernel, NULL);
                    wQos->reliability.kind = V_RELIABILITY_RELIABLE;
                }
            } else {
                wQos = v_writerQosNew(kernelArg->kernel, NULL);
                wQos->reliability.kind = V_RELIABILITY_RELIABLE;
            }
            wri = u_writerNew(pub, name, top, NULL, wQos, TRUE);
            os_free(kernelArg);
            c_free(wQos);
            
            if(wri != NULL){
                cmx_registerEntity(u_entity(wri));
                arg = cmx_entityArg(os_malloc(C_SIZEOF(cmx_entityArg)));
                arg->entity = u_entity(wri);
                arg->create = FALSE;
                arg->participant = NULL;
                arg->result = NULL;
                ur = u_entityAction(u_entity(wri), cmx_entityNewFromAction, (c_voidp)(arg));
                
                if(ur == U_RESULT_OK){
                    result = arg->result;
                    os_free(arg);
                }
            }
        }
    }
    return result;
}
示例#2
0
c_char*
cmx_publisherNew(
    const c_char* participant,
    const c_char* name,
    const c_char* qos)
{
    u_participant par;
    u_publisher pub;
    c_char* result;
    cmx_entityArg arg;
    u_result ur;
    v_publisherQos pqos;
    cmx_entityKernelArg kernelArg;

    result = NULL;    
    par = u_participant(cmx_entityUserEntity(participant));
    
    if(par != NULL){
        kernelArg = cmx_entityKernelArg(os_malloc(C_SIZEOF(cmx_entityKernelArg)));
        u_entityAction(u_entity(par), cmx_entityKernelAction, (c_voidp)kernelArg);
        
        if(qos != NULL){
            pqos = v_publisherQos(cmx_qosKernelQosFromKind(qos, K_PUBLISHER, c_getBase(c_object(kernelArg->kernel))));
            
            if(pqos == NULL){
                pqos = v_publisherQosNew(kernelArg->kernel, NULL);
            }
        } else {
            pqos = v_publisherQosNew(kernelArg->kernel, NULL);
        } 
        pub = u_publisherNew(par, name, pqos, TRUE);
        os_free(kernelArg);
        c_free(pqos);
        
        if(pub != NULL){
            cmx_registerEntity(u_entity(pub));
            arg = cmx_entityArg(os_malloc(C_SIZEOF(cmx_entityArg)));
            arg->entity = u_entity(pub);
            arg->create = FALSE;
            arg->participant = NULL;
            arg->result = NULL;
            ur = u_entityAction(u_entity(pub), cmx_entityNewFromAction, (c_voidp)(arg));
            
            if(ur == U_RESULT_OK){
                result = arg->result;
                os_free(arg);
            }
        }
    }
    return result;
}
示例#3
0
c_char*
cmx_serviceGetState(
    const c_char* service)
{
    u_entity uservice;
    u_result actionSuccess;
    cmx_entityArg arg;
    c_char* result;
    
    result = NULL;
    uservice = cmx_entityUserEntity(service);
    
    if(uservice != NULL){
        arg = cmx_entityArg(os_malloc(C_SIZEOF(cmx_entityArg)));
        arg->participant = u_entityParticipant(uservice);
        arg->create = FALSE;
        arg->result = NULL;
        arg->entity = NULL;
        
        actionSuccess = u_entityAction(uservice, cmx_serviceAction, arg);
        
        if(actionSuccess == U_RESULT_OK){
            result = arg->result;
            os_free(arg);
        }
    }
    return result;
}
示例#4
0
c_char*
cmx_readerSnapshotNew(
    const c_char* reader)
{
    u_entity e;
    c_char* result;
    struct cmx_readerSnapshotArg arg;
    os_mutex m;
    
    arg.success = FALSE;
    result = NULL;
    e = cmx_entityUserEntity(reader);
    
    if(e != NULL){    
        u_entityAction(e, cmx_readerSnapshotNewAction, &arg);
        
        if(arg.success == TRUE){
            m = cmx_getReaderSnapshotMutex();
            os_mutexLock(&m);
            readerSnapshots = c_iterInsert(readerSnapshots, arg.snapshot);
            os_mutexUnlock(&m);
            
            result = (c_char*)(os_malloc(60));
            os_sprintf(result, "<readerSnapshot><id>"PA_ADDRFMT"</id></readerSnapshot>", (c_address)(arg.snapshot));
        }
    }
    return result;
}
示例#5
0
/**This function only works if the topic already exists.
 * In the future this must be extended.
 */
jni_topic
jni_createTopic(
    jni_participant p,
    const char* name,
    const char* typeName,
    v_topicQos qos)
{
    jni_topic topic;
    u_result result;
    struct jni_topicArg arg;
    
    topic = NULL;
    
    if((p != NULL) && (jni_lookupTopic(p, name) == NULL)){
        arg.topicName = name;
        arg.keyExpr = NULL;
        arg.result = U_RESULT_ILL_PARAM;
        result = u_entityAction(u_entity(p->uparticipant), jni_getTopicKeyExpression, &arg);       
                
        if((result == U_RESULT_OK) && (arg.result == U_RESULT_OK)){
            topic = jni_topicNew(p, name, typeName, arg.keyExpr, qos);
            
            if(arg.keyExpr != NULL){
                os_free(arg.keyExpr);
            }
            
            if(topic != NULL){
                p->topics = c_iterInsert(p->topics, topic);
            }
        }
       
    }
    return topic;
}
示例#6
0
static void*
cms_soapThreadRun(
    void *thr)
{
    cms_soapThread thread;
    struct soap* soap;
    c_char* result;

    thread = cms_soapThread(thr);
    os_mutexLock(&thread->soapMutex);

    while(cms_thread(thread)->terminate == FALSE){

        if(thread->soap != NULL){
            soap = thread->soap;
            thread->soap = NULL;

            cms_thread(thread)->results = NULL;
            soap->user = thr;
            soap_serve(soap);
            soap_destroy(soap);
            soap_end(soap);
            soap_done(soap);
            free(soap);
            u_entityAction( u_entity(thread->client->service->uservice),
                            cms_soapThreadStatisticsRequestHandledAdd,
                            thread->client->service);

            if(cms_thread(thread)->results != NULL){
                result = (c_char*)(c_iterTakeFirst(cms_thread(thread)->results));

                while(result){
                    os_free(result);
                    result = (c_char*)(c_iterTakeFirst(cms_thread(thread)->results));
                }
                c_iterFree(cms_thread(thread)->results);
                cms_thread(thread)->results = NULL;
            }
        }

        if(cms_thread(thread)->terminate == FALSE){
            cms_thread(thread)->ready = TRUE;

            if(thread->client->service->configuration->verbosity >= 7){
                OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' ready.", cms_thread(thread)->name);
            }
            os_condWait(&thread->condition, &thread->soapMutex);

            if(thread->client->service->configuration->verbosity >= 7){
                OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' condition triggered.", cms_thread(thread)->name);
            }
        }
    }
    os_mutexUnlock(&thread->soapMutex);

    if(thread->client->service->configuration->verbosity >= 6){
        OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' ends.", cms_thread(thread)->name);
    }
    return NULL;
}
示例#7
0
jni_writer
jni_writerNew(
    jni_publisher pub,
    jni_topic top,
    v_writerQos qos)
{
    jni_writer wri;
    u_writer uw;
    u_result ur;
    struct jni_writerTypeArg arg;
    
    wri = NULL;
    
    if((pub != NULL) && (top != NULL)){    
        ur = u_entityAction(u_entity(top->utopic), jni_writerTypeAction, &arg);
        
        if ((ur == U_RESULT_OK) && (arg.type != NULL)){
            uw = u_writerNew(pub->upublisher, NULL, top->utopic, jni_writerCopy, qos, TRUE);
    
            if(uw != NULL){
                wri = jni_writer(os_malloc((size_t)(C_SIZEOF(jni_writer))));
                wri->publisher = pub;
                wri->topic = top;
                wri->uwriter = uw;
                wri->deserializer = sd_serializerXMLNewTyped(arg.type);
            }
        }
    }
    return wri;
}
示例#8
0
static void
cms_serviceUpdateStatistics(
    cms_service service)
{
    if(service != NULL) {
        u_entityAction(u_entity(service->uservice), cms_serviceStatisticsAction, service);
    }
}
示例#9
0
c_base
kernelGetBase(u_entity e)
{
    c_base base = NULL;

    u_entityAction(u_entity(e), retrieveBase, &base);

    return base;
}
示例#10
0
static v_gid
kernelEntityGid (
    u_entity entity)
{
    v_gid gid;

    u_entityAction(entity, getEntityGid, &gid);

    return gid;
}
示例#11
0
v_kernel
kernelGetKernelId (
    u_entity e)
{
    v_kernel kernel = NULL;

    u_entityAction(e, getKernelId, &kernel);

    return kernel;
}
示例#12
0
gapi_char *
kernelTopicGetKeys (
    u_topic topic)
{
    gapi_char *keys = NULL;

    u_entityAction(u_entity(topic), topicGetKeys, &keys);

    return keys;
}
示例#13
0
c_base
d_findBase(
    d_durability durability)
{
    u_service service;
    struct baseFind data;

    service = d_durabilityGetService(durability);
    u_entityAction(u_entity(service), d_findBaseAction, &data);

    return data.base;
}
示例#14
0
c_long
kernelStatusGet (
    u_entity e)
{
    c_long mask;
    u_result result;
    result = u_entityAction(e, getStatusMask, &mask);
    if (result != U_RESULT_OK) {
        mask = 0;
    }
    return mask;
}
示例#15
0
gapi_boolean
kernelCheckTopicKeyList (
    u_topic topic,
    const gapi_char *keyList)
{
    checkTopicKeyListArg argument;

    argument.keyList = keyList;
    argument.equal   = FALSE;

    u_entityAction(u_entity(topic), checkTopicKeyList, &argument);

    return argument.equal;
}
示例#16
0
static os_result
u__serviceExceptionCallbackWrapper(void)
{
    os_result result = os_resultSuccess;

    /* do not detach when using single process as this does not function correctly for single process*/
    if(!os_serviceGetSingleProcess()) {
        OS_REPORT(OS_ERROR, "u__serviceExceptionCallbackWrapper", 0,
                "Exception occurred, will detach service from domain.");
        /* calling the kernel service free directly because only the kernel administration needs to be removed */
        if (u_entityAction(u_entity(callbackService),freeKernelServiceObject,NULL) != U_RESULT_OK)
            result = os_resultFail;
    }
    return result;
}
示例#17
0
static void *
nw_channelWriterMainFunc(
    nw_runnable runnable,
    c_voidp arg)
{
    u_result result;
    nw_channelWriter channelWriter = (nw_channelWriter)runnable;

    nw_runnableSetRunState(runnable, rsRunning);
    result = u_entityAction(u_entity(((nw_channelUser)channelWriter)->reader),
                            nw_channelWriterMain,channelWriter);
    nw_runnableSetRunState(runnable, rsTerminated);

    return NULL;
}
示例#18
0
c_char*
cmx_readerDataType(
    const c_char* reader)
{
    u_entity entity;
    struct cmx_readerArg arg;

    entity = cmx_entityUserEntity(reader);
    arg.result = NULL;

    if(entity != NULL){
        u_entityAction(entity, cmx_readerDataTypeAction, &arg);
    }
    return arg.result;
}
示例#19
0
c_char*
cmx_writerDataType(
    const c_char* writer)
{
    u_entity entity;
    c_bool result;
    c_char* type;
    struct cmx_writerTypeArg arg;
    
    type = NULL;
    entity = cmx_entityUserEntity(writer);
    arg.result = NULL;
    
    if(entity != NULL){
        result = u_entityAction(entity, cmx_writerDataTypeAction, &arg);
    }
    return arg.result;
}
示例#20
0
const c_char*
cmx_writerUnregister(
    const c_char* writer, 
    const c_char* data)
{
    u_entity entity;
    c_bool result;
    c_char* type;
    struct cmx_writerArg arg;
    
    type = NULL;
    entity = cmx_entityUserEntity(writer);
    arg.result = data;

    if(entity != NULL){
        result = u_entityAction(entity, cmx_writerUnregisterCopy, &arg);
    }
    return arg.success;
}
示例#21
0
c_char*
cmx_queryNew(
    const c_char* reader,
    const c_char* name,
    const c_char* expression)
{
    u_reader rea;
    u_query que;
    q_expr qexpr;
    c_char* result;
    cmx_entityArg arg;
    u_result ur;

    result = NULL;    
    rea = u_reader(cmx_entityUserEntity(reader));
    
    if(rea != NULL){
        qexpr = q_parse(expression);
        
        if(qexpr != NULL){
            que = u_queryNew(rea, name, qexpr, NULL);
            q_dispose(qexpr);
        
            if(que != NULL){
                cmx_registerEntity(u_entity(que));
                arg = cmx_entityArg(os_malloc(C_SIZEOF(cmx_entityArg)));
                arg->entity = u_entity(que);
                arg->create = FALSE;
                arg->participant = NULL;
                arg->result = NULL;
                ur = u_entityAction(u_entity(que),
                                    cmx_entityNewFromAction,
                                    (c_voidp)(arg));
                
                if(ur == U_RESULT_OK){
                    result = arg->result;
                    os_free(arg);
                }
            }
        }
    }
    return result;
}
示例#22
0
d_storeResult
d_topicInfoInject(
    d_topicInfo _this,
    d_store store,
    u_participant participant)
{
    d_storeResult result;
    c_type type;
    struct baseFind f;
    u_topic utopic;

    u_entityAction(u_entity(participant), d_storeGetBase, &f);

    type = cloneType(c_getBase(_this), f.base, _this->dataType);

    if(type){
        utopic = u_topicNew(participant, _this->name, _this->typeName,
                _this->keyExpr, _this->qos);

        if(utopic) {
           d_storeReport(store, D_LEVEL_FINE, "Topic %s created.\n", _this->name);
           u_topicFree(utopic);
           result = D_STORE_RESULT_OK;
        } else {
           result = D_STORE_RESULT_METADATA_MISMATCH;
           d_storeReport(store, D_LEVEL_SEVERE,
               "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n",
               _this->name, _this->typeName, _this->keyExpr);
           OS_REPORT_3(OS_ERROR, "d_topicInfoInject", (os_int32)result,
               "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n",
               _this->name, _this->typeName, _this->keyExpr);

        }
    } else {
        result = D_STORE_RESULT_METADATA_MISMATCH;
        OS_REPORT_1(OS_ERROR,
                  "d_topicInfoInject",(os_int32)result,
                  "Failed to register type '%s'.", _this->typeName);

    }
    return result;
}
示例#23
0
void
d_readerListenerInitField(
    d_readerListener listener,
    d_subscriber   subscriber,
    const c_char * typeName)
{
    struct createFieldArg arg;
    const c_char* fieldName = "userData";

    assert(d_objectIsValid(d_object(listener), D_LISTENER));
    arg.typeName = typeName;
    arg.fieldName = fieldName;
    arg.fieldOffset = 0;
    u_entityAction(u_entity(d_durabilityGetService(
                                d_adminGetDurability(
                                    d_subscriberGetAdmin(subscriber)))),
                                createField, &arg);
    listener->fieldOffset = arg.fieldOffset;
    assert(listener->fieldOffset > 0);
}
示例#24
0
static u_result
startMonitoring(
    const u_participant participant,
    const u_waitset waitset,
    const struct builtin_datareader_set *drset)
{
    c_iter events, topics;
    u_waitsetEvent event;
    c_time timeout;
    os_uint32 reportInterval;
    v_gid participantGid, publicationGid, subscriptionGid, gid;
    u_result result;
    u_dataReader dataReader;
    u_topic topic;
    c_iter vgroups;
    v_group vgroup;
    v_duration duration;
    c_long participantOffset, publicationOffset, subscriptionOffset;
    os_threadAttr attr;
    os_result osr;

    /*Resolve unique identifications of readers*/
    participantGid  = u_entityGid((u_entity)drset->participant_dr);
    publicationGid  = u_entityGid((u_entity)drset->publication_dr);
    subscriptionGid = u_entityGid((u_entity)drset->subscription_dr);

    /*Resolve topics to find offsets in the data. The offsets are used later on*/
    duration.seconds = 0;
    duration.nanoseconds = 0;

    topics = u_participantFindTopic(participant, V_PARTICIPANTINFO_NAME, duration);
    topic  = c_iterTakeFirst(topics);

    if(topic){
        result = u_entityAction(u_entity(topic), resolveOffset, &participantOffset);
    } else {
        result = U_RESULT_INTERNAL_ERROR;
        in_printf(IN_LEVEL_SEVERE, "Could not resolve participant info offset.\n");
    }
    c_iterFree(topics);

    if(result == U_RESULT_OK){
        topics = u_participantFindTopic(participant, V_PUBLICATIONINFO_NAME, duration);
        topic  = c_iterTakeFirst(topics);

        if(topic){
            result = u_entityAction(u_entity(topic), resolveOffset, &publicationOffset);
        } else {
            result = U_RESULT_INTERNAL_ERROR;
            in_printf(IN_LEVEL_SEVERE, "Could not resolve publication info offset.\n");
        }
        c_iterFree(topics);
    }

    if(result == U_RESULT_OK){
        topics = u_participantFindTopic(participant, V_SUBSCRIPTIONINFO_NAME, duration);
        topic  = c_iterTakeFirst(topics);

        if(topic){
            result = u_entityAction(u_entity(topic), resolveOffset, &subscriptionOffset);
        } else {
            result = U_RESULT_INTERNAL_ERROR;
            in_printf(IN_LEVEL_SEVERE, "Could not resolve subscription info offset.\n");
        }
        c_iterFree(topics);
    }

    if(result == U_RESULT_OK){
        timeout.seconds     = 0;
        timeout.nanoseconds = 100 * 1000 * 1000; /*100 ms*/

        in_printf(IN_LEVEL_FINE, "Collecting initial entities...\n");
        result = handleParticipant(drset->participant_dr, participantOffset);

        if(result == U_RESULT_OK){
            result = handlePublication(drset->publication_dr, publicationOffset,
                    drset->participant_dr, participantOffset);

            if(result == U_RESULT_OK){
                result = handleSubscription(drset->subscription_dr, subscriptionOffset,
                        drset->participant_dr, participantOffset);

                if(result == U_RESULT_OK){
                    vgroups = v_serviceTakeNewGroups(service);
                    vgroup = (v_group)c_iterTakeFirst(vgroups);

                    while(vgroup && result == U_RESULT_OK){
                        result = handleGroup(service, vgroup);
                        c_free(vgroup);
                        vgroup = (v_group)c_iterTakeFirst(vgroups);
                    }
                    c_iterFree(vgroups);

                    if(result == U_RESULT_OK){
                        in_printf(IN_LEVEL_FINE, "Waiting for entities to be created/deleted...\n");
                    } else {
                        in_printf(IN_LEVEL_SEVERE, "Could not collect initial groups...\n");
                    }
                } else {
                    in_printf(IN_LEVEL_SEVERE, "Could not collect initial subscriptions...\n");
                }
            } else {
                in_printf(IN_LEVEL_SEVERE, "Could not collect initial publications...\n");
            }
        } else {
            in_printf(IN_LEVEL_SEVERE, "Could not collect initial participants...\n");
        }
    }

    osr = os_threadAttrInit(&attr);

    if(osr == os_resultSuccess){
        osr = os_threadCreate(&clientWriterThread,
                "clientWriterMonitor", &attr,
                in_discoveryClientWriterMonitor, NULL);

        if(osr != os_resultSuccess){
            result = U_RESULT_INTERNAL_ERROR;
        }
    } else {
        result = U_RESULT_INTERNAL_ERROR;
    }
    reportInterval = 0;

    while(result == U_RESULT_OK && !terminate){
        events = NULL;
        /*Wait for events to occur*/
        result = u_waitsetTimedWaitEvents(waitset, timeout, &events);

        if(result == U_RESULT_OK){
            event = (u_waitsetEvent)(c_iterTakeFirst(events));

            while(event){
                if(((event->events) & V_EVENT_DATA_AVAILABLE) ==
                    V_EVENT_DATA_AVAILABLE)
                {
                    if(event->entity){
                        dataReader = (u_dataReader)event->entity;
                        gid        = u_entityGid(event->entity);

                        if(v_gidCompare(gid, participantGid) == C_EQ){
                            result = handleParticipant(
                                    drset->participant_dr, participantOffset);
                        } else if(v_gidCompare(gid, subscriptionGid) == C_EQ){
                            result = handleSubscription(
                                    drset->subscription_dr, subscriptionOffset,
                                    drset->participant_dr, participantOffset);
                        } else if(v_gidCompare(gid, publicationGid) == C_EQ){
                            result = handlePublication(
                                    drset->publication_dr, publicationOffset,
                                    drset->participant_dr, participantOffset);
                        } else {
                            in_printf(IN_LEVEL_SEVERE,
                                    "This is impossible...at least in my understanding of the world.\n");
                            result = U_RESULT_INTERNAL_ERROR;
                        }
                    } else {
                        in_printf(IN_LEVEL_WARNING, "DATA_AVAILABLE (%d) but no entity.\n",
                                event->events);
                    }
                } else if(((event->events) & V_EVENT_NEW_GROUP) ==
                    V_EVENT_NEW_GROUP)
                {
                    vgroups = v_serviceTakeNewGroups(service);
                    vgroup = (v_group)c_iterTakeFirst(vgroups);

                    while(vgroup && result == U_RESULT_OK){
                        result = handleGroup(service, vgroup);
                        c_free(vgroup);
                        vgroup = (v_group)c_iterTakeFirst(vgroups);
                    }
                    c_iterFree(vgroups);
                } else {
                    in_printf(IN_LEVEL_SEVERE, "Received unexpected event %d.\n", event->events);
                    result = U_RESULT_INTERNAL_ERROR;
                }
                u_waitsetEventFree(event);
                event = (u_waitsetEvent)(c_iterTakeFirst(events));
            }
        } else if(result == U_RESULT_DETACHING){
            in_printf(IN_LEVEL_INFO, "Starting termination now...\n");
        } else if(result == U_RESULT_TIMEOUT){
            result = U_RESULT_OK;
        } else {
            in_printf(IN_LEVEL_SEVERE, "Waitset wait failed.\n");
        }
        if(events){/* events may be null if waitset was deleted */
            c_iterFree(events);
        }
        reportInterval++;

        if(reportInterval >= 5){
            /*reportEntities();*/
            reportInterval = 0;
        }
    }
    return result;
}
示例#25
0
int
main (int argc, char *argv[])
{
   int opt;
   int interval = 3000;
   int sampleCount = 0;
   c_bool extended = FALSE;
   c_bool raw = FALSE;
   c_bool delta = FALSE;
   c_bool preallocated = FALSE;
   char *uri = "";
   u_result ur;
   u_participant participant;
   v_participantQos pqos;
   int no_break = TRUE;
   char c;
   int lost;
   const char* sddsURI = NULL;
   monitorMode selectedAction = memoryStats;
   monitor_ms msData = NULL;
   monitor_trc trcData = NULL;
   monitor_orc orcData = NULL;
   int delay = 0;
   int trigger = 0;
   int sample = 0;
   c_long objectCountLimit = 0;
   char *filterExpression = NULL;


   HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
   INPUT_RECORD buffer[1];
   DWORD events;

   orderKind selectedOrdering  = NO_ORDERING;
   int orderCount = INT_MAX;

   while (((opt = getopt (argc, argv, optflags)) != -1) && !errno) {
       switch (opt) {
           case 'i':
               if (!(sscanf (optarg, "%d", &interval)) > 0) {
                   fprintf(stderr, "mmstat: Not a valid interval.\n");
                   print_usage();
                   exit(-1);
               }
               break;
           case 's':
               if (!(sscanf (optarg, "%d", &sampleCount)) > 0) {
                   fprintf(stderr, "mmstat: Not a valid sample count.\n");
                   print_usage();
                   exit(-1);
               }
               break;
           case 'l':
               if (!(sscanf (optarg, "%d", &objectCountLimit)) > 0) {
                   fprintf(stderr, "mmstat: Not a valid limit.\n");
                   print_usage();
                   exit(-1);
               }
               break;
           case 'f':
               filterExpression = optarg;
               break;
           case 'e':
               extended = TRUE;
               break;
           case 'r':
               raw = TRUE;
               break;
           case 'a':
               preallocated = TRUE;
               break;
           case 'm':
               selectedAction = memoryStats;
               break;
           case 'M':
               selectedAction = memoryStats;
               delta = TRUE;
               break;
           case 't':
               selectedAction = typeRefCount;
               break;
           case 'T':
               selectedAction = typeRefCount;
               delta = TRUE;
               break;
           case 'o':
               if (selectedOrdering  == NO_ORDERING && strlen(optarg) == 1)
               {
                   switch (optarg[0])
                   {
                       case 'C':
                           selectedOrdering = ORDER_BY_COUNT;
                           break;
                       case 'S':
                           selectedOrdering = ORDER_BY_SIZE;
                           break;
                       case 'T':
                           selectedOrdering = ORDER_BY_TOTAL;
                           break;
                       default:
                           fprintf(stderr, "mmstat: Unknown ordering kind.\n");
                           print_usage();
                           exit(-1);
                   }
               }
               else
               {
                   fprintf(stderr, "mmstat: Cannot specify multiple orderings at the same time.\n");
                   print_usage();
                   exit(-1);
               }
               break;
           case 'n':
               if (!(sscanf (optarg, "%d", &orderCount)) > 0)
               {
                   fprintf(stderr, "mmstat: Not a valid ordering nrEntries.\n");
                   print_usage();
                   exit(-1);
               }
               break;
#ifdef OBJECT_WALK
           case 'r':
               selectedAction = objectRefCount;
               break;
           case 'R':
               selectedAction = objectRefCount;
               delta = TRUE;
               break;
#endif
           case 'h':
           case '?':
           default:
               print_usage ();
               exit(0);
               break;
       }
   }
   if (errno) {
       fprintf(stderr, strerror(errno));
       fprintf(stderr, "\n");
       print_usage();
       exit (-1);
   }
   if ((argc - optind) > 1) {
       fprintf(stderr, "Too many arguments");
       print_usage ();
       exit (-1);
   }
   if (selectedAction == memoryStats) {
       if (objectCountLimit > 0) {
           fprintf(stderr, "Can't use object limit in memory stats mode.\n");
           print_usage();
           exit(-1);
       }
       if (filterExpression != NULL) {
           fprintf(stderr, "Can't use filter expression in memory stats mode.\n");
           print_usage();
           exit(-1);
       }
   } else {
       if (extended) {
           fprintf(stderr, "Extended mode can only be used in memory stats mode.\n");
           print_usage();
           exit(-1);
       }
       if (preallocated) {
           fprintf(stderr, "Preallocated memory can only be shown in memory stats mode.\n");
           print_usage();
           exit(-1);
       }
   }
   if ((argc - optind) == 1)
   {
      uri = argv[optind];
   }

   if( !raw) {
      if(strlen(uri) > 0) {
         sddsURI = uri;
      } else {
         sddsURI = os_getenv ("OSPL_URI");
         if(!sddsURI) {
            sddsURI = DOMAIN_NAME;
         }
      }
      printf("Trying to open connection with the OpenSplice system using URI:\n" \
             "'%s'...\n", sddsURI);
   } else {
       sddsURI = uri;
   }

   ur = u_userInitialise();

   if(ur == U_RESULT_OK)
   {
      pqos = u_participantQosNew(NULL);
      participant = u_participantNew(sddsURI, 30, "mmstat", (v_qos)pqos, TRUE);
      u_participantQosFree(pqos);

      if(participant)
      {
         if( !raw )
         {
            printf("Connection established.\n\n");
         }

         lost = 0;
         switch (selectedAction)
         {
         case memoryStats:
            msData = monitor_msNew (extended, raw, delta, preallocated);
            break;
         case typeRefCount:
            trcData = monitor_trcNew (objectCountLimit, filterExpression, selectedOrdering, orderCount, delta);
            break;
         case objectRefCount:
            orcData = monitor_orcNew (objectCountLimit, filterExpression, delta);
            break;
         }

         while (no_break && !lost)
         {
            if (delay <= 0 || trigger)
            {
               switch (selectedAction)
               {
               case memoryStats:
                  ur = u_entityAction(u_entity(participant), monitor_msAction, msData);
                  break;
               case typeRefCount:
                  ur = u_entityAction(u_entity(participant), monitor_trcAction, trcData);
                  break;
               case objectRefCount:
                  ur = u_entityAction(u_entity(participant), monitor_orcAction, orcData);
                  break;
               }
               fflush (stdout);
               sample++;
               if (trigger)
               {
                  trigger = 0;
               }
               else
               {
                  delay = interval;
               }
            }

            if(ur == U_RESULT_OK)
            {
               if (_isatty(_fileno(stdin)) && !raw)
               {
                  c = '\0';
                  PeekConsoleInput( handle, buffer, 1, &events );

                  if(events > 0)
                  {
                     ReadConsoleInput(handle, buffer, 1, &events);

                     if(buffer[0].EventType == KEY_EVENT
                        && buffer[0].Event.KeyEvent.bKeyDown)
                     {
                        c = buffer[0].Event.KeyEvent.uChar.AsciiChar;
                     }

                  }

                  if (c == 'q' || c == '\03' /* ^C */)
                  {
                     no_break = FALSE;
                  }
                  else if (c == 't')
                  {
                     trigger = 1;
                  }

                  PeekConsoleInput( handle, buffer, 1, &events );

                  if(events > 0)
                  {
                     ReadConsoleInput(handle, buffer, 1, &events);

                     if(buffer[0].EventType == KEY_EVENT
                        && buffer[0].Event.KeyEvent.bKeyDown)
                     {
                        c = buffer[0].Event.KeyEvent.uChar.AsciiChar;
                     }
                  }
               }
               if (no_break && interval)
               {
                  delay -= 100;
                  os_nanoSleep (SLEEP_INTERVAL);
               }
            }
            else
            {
               /* Participant is no longer accessible, terminate now... */
               no_break = 0;
               lost = TRUE;
            }
            if (sampleCount && (sample == sampleCount))
            {
               printf ("\nsample_count limit reached\n");
               no_break = 0;
            }
         }
         PeekConsoleInput( handle, buffer, 1, &events );

         if(events > 0)
         {
            ReadConsoleInput(handle, buffer, 1, &events);

            if(buffer[0].EventType == KEY_EVENT
               && buffer[0].Event.KeyEvent.bKeyDown)
            {
               c = buffer[0].Event.KeyEvent.uChar.AsciiChar;
            }
         }

         if(lost)
         {
            printf("\nConnection with domain lost. The OpenSplice system has\n" \
                   "probably been shut down.\n");
         }
         u_participantFree(participant);
      }
      else
      {
         printf("Connection could NOT be established (creation of participant failed).\n");
         printf("Is the OpenSplice system running?\n");
         OS_REPORT(OS_ERROR,"mmstat", 0, "Creation of participant failed.");
      }
      u_userDetach();
      switch (selectedAction)
      {
      case memoryStats:
         monitor_msFree (msData);
         break;
      case typeRefCount:
         monitor_trcFree (trcData);
         break;
      case objectRefCount:
         monitor_orcFree (orcData);
         break;
      }
   }
   else
   {
      printf("Connection could NOT be established (could not initialise).\n");
      printf("Is the OpenSplice system running?\n");
      OS_REPORT(OS_ERROR,"mmstat", 0, "Failed to initialise.");
   }
   printf("\nExiting now...\n");


   return 0;
}
示例#26
0
jni_writer
jni_writerNew(
    jni_publisher pub,
    jni_topic top,
    v_writerQos qos)
{
    jni_writer wri;
    u_result ur;
    struct jni_writerTypeArg arg;
    
    if((pub == NULL) || (top == NULL)){
        OS_REPORT_2(OS_ERROR, "jni_writerNew", 0,
                "Bad parameter; jni_publisher (%p) and jni_topic (%p) may not be NULL.",
                pub,
                top);
        goto err_badParam;
    }

    assert(pub->upublisher);
    assert(top->utopic);

    if((ur = u_entityAction(u_entity(top->utopic), jni_writerTypeAction, &arg)) != U_RESULT_OK){
        OS_REPORT_1(OS_ERROR, "jni_writerNew", ur,
                "Failed to invoke jni_writerTypeAction(...) on top->utopic; u_entityAction(...) returned %s.",
                u_resultImage(ur));
        goto err_getWriterType;
    }

    if(arg.type == NULL){
        /* Error reported by jni_writerTypeAction */
        goto err_getWriterType;
    }

    if((wri = os_malloc(sizeof *wri)) == NULL){
        OS_REPORT_1(OS_ERROR, "jni_writerNew", 0,
                "Memory claim of %" PA_PRIuSIZE " denied.",
                sizeof *wri);
        goto err_malloc;
    }

    if((wri->deserializer = sd_serializerXMLNewTyped(arg.type)) == NULL){
        /* Error reported by sd_serializerXMLNewTyped */
        goto err_sd_serializerXMLNewTyped;
    }

    if((wri->uwriter = u_writerNew(pub->upublisher, NULL, top->utopic, jni_writerCopy, qos, TRUE)) == NULL){
        /* Error reported by u_writerNew */
        goto err_uwriterNew;
    }

    wri->publisher = pub;
    wri->topic = top;

    return wri;

/* Error handling */
err_uwriterNew:
    sd_serializerFree(wri->deserializer);
err_sd_serializerXMLNewTyped:
    os_free(wri);
err_malloc:
/* No undo for jni_writerTypeAction */
err_getWriterType:
err_badParam:
    return NULL;
}
示例#27
0
int
main(
    int argc,
    char* argv[])
{
    int result = 0;
    v_participantQos participantQos;
    u_result uresult;
    os_boolean success;
    v_subscriberQos subscriberQos;
    c_time resolution;
    c_base base;
    v_kernel kernel;

    /* Necessary to initialize the user layer. Do this just once per process.*/
    mlv_init ();
    uresult = u_userInitialise();
    mlv_setforreal (1);

    if(uresult == U_RESULT_OK){
        /* Allocate default participant qos*/
        participantQos = u_participantQosNew(NULL);

        {
          os_mutexAttr mattr;
          os_mutexAttrInit (&mattr);
          mattr.scopeAttr = OS_SCOPE_PRIVATE;
          os_mutexInit (&gluelock, &mattr);
        }

        if(participantQos){
            if(argc > 1){
                SERVICE_NAME = argv[1];
            }
            if(argc > 2){
                SERVICE_URI = argv[2];
            }
            /*create participant*/
            participant = u_participant(u_serviceNew(
                                SERVICE_URI, 0, SERVICE_NAME,
                                NULL,
                                U_SERVICE_NETWORKING,
                                (v_qos)participantQos));

            if(participant){
                struct cfgst *cfgst;
                ddsi2_participant_gid = u_entityGid (u_entity (participant));

                /*Notify kernel that I am initializing. */
                u_serviceChangeState(u_service(participant),STATE_INITIALISING);

                /*Start monitoring the splicedaemon state. I need to terminate if he says so*/
                u_serviceWatchSpliceDaemon(
                        u_service(participant),
                        in_discoveryWatchSpliced,
                        &terminate);

                if ((cfgst = config_init (participant, SERVICE_NAME)) != NULL)
                {
                  unsigned rtps_flags = 0;
                  struct nn_servicelease *servicelease;

                  open_tracing_file ();
                  /* Dependencies between default values is not
                     handled automatically by the config processing
                     (yet) */
                  if (config.many_sockets_mode)
                  {
                    if (config.max_participants == 0)
                      config.max_participants = 100;
                  }
                  if (NN_STRICT_P)
                  {
                    /* Should not be sending invalid messages when strict */
                    config.respond_to_rti_init_zero_ack_with_invalid_heartbeat = 0;
                    config.acknack_numbits_emptyset = 1;
                  }
                  config_print_and_free_cfgst (cfgst);

                  servicelease = nn_servicelease_new (participant);
                  nn_servicelease_start_renewing (servicelease);

                  myNetworkId = getNetworkId ();

                  u_entityAction(u_entity(participant), resolveKernelService, NULL);
                  base = c_getBase(service);
                  kernel = v_object(service)->kernel;
                  rtps_init (base, kernel, config.domainId, config.participantIndex,
                             rtps_flags, config.networkAddressString, config.peers);

                  /* Initialize entity administration. */
                  success = in_entityAdminInit(participant);

                  if(success){
                    /*Create subscriber to receive client writers' messages.*/
                    subscriberQos = u_subscriberQosNew(NULL);
                    os_free(subscriberQos->partition);
                    subscriberQos->partition = NULL;

                    clientSubscriber = u_subscriberNew(
                            participant,
                            "clientSubscriber",
                            subscriberQos,
                            TRUE);

                    if(clientSubscriber){
                      /*Create networkReader to be able to receive client writers' messages.*/
                      clientReader = u_networkReaderNew(
                              clientSubscriber,
                              "clientReader",
                              NULL,
                              TRUE);

                      if(clientReader){
                        resolution.seconds = 0;
                        resolution.nanoseconds = 10 * 1000 * 1000; /*10 ms*/

                        /*Create network queue*/
                        uresult = u_networkReaderCreateQueue(
                                clientReader,
                                1000, 0, FALSE, FALSE,
                                resolution,
                                TRUE, &queueId,
                                "DDSi");

                        if(uresult == U_RESULT_OK){
                          struct builtin_datareader_set drset;
                          u_entityAction(u_entity(clientReader), resolveKernelReader, NULL);

                          uresult = create_builtin_readers (&drset, participant);
                          if (uresult == U_RESULT_OK)
                          {
                            u_serviceChangeState(u_service(participant),STATE_OPERATIONAL);
                            uresult = attachAndMonitor(participant, &drset);

                            if((uresult != U_RESULT_OK) &&
                               (uresult != U_RESULT_DETACHING))
                            {
                              nn_log (LC_ERROR, "Abnormal termination...\n");
                              result = -1;
                            } else {
                              nn_log (LC_INFO, "Deleting entities...\n");
                            }
                            destroy_builtin_readers (&drset);
                          } else {
                            nn_log (LC_FATAL, "Could not create subscription + readers for builtin topics.\n");
                            result = -1;
                          }
                          terminate = TRUE;
                          v_networkReaderTrigger(vclientReader, queueId);
                          os_threadWaitExit(clientWriterThread, NULL);
                        } else {
                          nn_log (LC_FATAL, "Could not create networkQueue.\n");
                          result = -1;
                        }
                        /*Clean up networkReader*/
                        os_mutexLock (&gluelock);
                        u_networkReaderFree(clientReader);
                        clientReader = NULL;
                        vclientReader = NULL;
                        os_mutexUnlock (&gluelock);
                      } else {
                        nn_log (LC_FATAL, "Could not create networkReader.\n");
                        result = -1;
                      }
                      /*Clean up subscriber*/
                      u_subscriberFree(clientSubscriber);
                    } else {
                      nn_log (LC_FATAL, "Could not create subscriber.\n");
                      result = -1;
                    }

                    /*Clean up entity administration*/
                    in_entityAdminDestroy();
                  } else {
                    nn_log (LC_FATAL, "Could not initialize entity adminstration.\n");
                    result = -1;
                  }

                  /* RTPS layer now defines types, cleanup before detaching */
                  rtps_term();

                  /*Notify kernel that I've terminated*/
                  u_serviceChangeState(u_service(participant),STATE_TERMINATED);
                  nn_servicelease_free (servicelease);
                  /*Delete participant*/
                  uresult = u_serviceFree(u_service(participant));

                  if(uresult != U_RESULT_OK){
                    nn_log (LC_FATAL, "Deletion of participant failed.\n");
                    result = -1;
                  }
                } else {
                    nn_log (LC_FATAL, "Initialization of configuration failed.\n");
                    result = -1;
                }
            } else {
                nn_log (LC_FATAL, "Could not create participant.\n");
                result = -1;
            }
            u_participantQosFree (participantQos);
        } else {
            nn_log (LC_FATAL, "Could not allocate participantQos.\n");
            result = -1;
        }
        os_mutexDestroy (&gluelock);
        /* Detach user layer */
        mlv_setforreal (0);
        uresult = u_userDetach();
        mlv_fini ();

        if(uresult != U_RESULT_OK){
            nn_log (LC_FATAL, "Detachment of user layer failed.\n");
            result = -1;
        }
    } else {
        nn_log (LC_FATAL, "Initialization of user layer failed.\n");
        result = -1;
    }
    nn_log (LC_INFO, "Finis.\n");

    /* Must be really late, or nn_log becomes unhappy -- but it should
       be before os_osExit (which appears to be called from
       u_userExit(), which is not called by u_userDetach but by an
       exit handler, it appears.) */
    config_fini ();
    return result;
}
示例#28
0
d_storeResult
d_groupInfoInject(
    d_groupInfo _this,
    const d_store store,
    u_participant participant,
    d_group* group)
{
    d_storeResult result;
    u_group ugroup;
    u_partition upartition;
    v_partitionQos partitionQos;
    v_duration timeout;
    c_string name;

    if(_this && store && participant){
        result = d_topicInfoInject(_this->topic, store, participant);

        if(result == D_STORE_RESULT_OK){
           partitionQos = u_partitionQosNew(NULL);

           if(partitionQos) {
               d_storeReport(store, D_LEVEL_FINE, "PartitionQoS created.\n");

               upartition = u_partitionNew(participant, _this->partition,
                       partitionQos);

               if(upartition) {
                   name = d_topicInfoGetName(_this->topic);
                   d_storeReport(store, D_LEVEL_FINE,
                           "Partition %s created.\n", _this->partition);

                   timeout.seconds = 0;
                   timeout.nanoseconds = 0;
                   ugroup = u_groupNew(participant, _this->partition, name,
                           timeout);

                   if(ugroup) {
                       d_storeReport(store,
                               D_LEVEL_INFO, "Group %s.%s created.\n",
                               _this->partition, name);

                       *group = d_groupNew(_this->partition, name,
                               D_DURABILITY_PERSISTENT, _this->completeness,
                               _this->quality);

                       u_entityAction(u_entity(ugroup), setKernelGroup, *group);
                       u_entityFree(u_entity(ugroup));
                       result = D_STORE_RESULT_OK;
                   } else {
                       result = D_STORE_RESULT_OUT_OF_RESOURCES;
                       d_storeReport(store, D_LEVEL_SEVERE,
                               "Group %s.%s could NOT be created.\n",
                               _this->partition, name);
                       OS_REPORT_2(OS_ERROR, "d_groupInfoInject",
                               (os_int32)result,
                               "Group %s.%s could NOT be created.\n",
                               _this->partition, name);
                   }
                   c_free(name);
                   u_partitionFree(upartition);
               } else {
                   result = D_STORE_RESULT_OUT_OF_RESOURCES;
                   d_storeReport(store, D_LEVEL_SEVERE,
                           "Partition %s could NOT be created.\n",
                           _this->partition);
                   OS_REPORT_1(OS_ERROR, "d_groupInfoInject", (os_int32)result,
                           "Partition %s could NOT be created.\n",
                           _this->partition);
               }
               u_partitionQosFree(partitionQos);
           } else {
               result = D_STORE_RESULT_OUT_OF_RESOURCES;
               d_storeReport(store, D_LEVEL_SEVERE,
                       "PartitionQos could NOT be created.\n");
               OS_REPORT(OS_ERROR, "d_groupInfoInject", (os_int32)result,
                       "PartitionQos could NOT be created.\n");
           }
        }
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
示例#29
0
c_char*
cmx_dataReaderNew(
    const c_char* subscriber,
    const c_char* name,
    const c_char* view,
    const c_char* qos)
{
    u_subscriber sub;
    u_dataReader rea;
    c_char* result;
    cmx_entityArg arg;
    u_result ur;
    cmx_entityKernelArg kernelArg;
    v_readerQos rqos;
    q_expr qexpr;

    result = NULL;
    sub = u_subscriber(cmx_entityUserEntity(subscriber));

    if(sub != NULL){
        kernelArg = cmx_entityKernelArg(os_malloc(C_SIZEOF(cmx_entityKernelArg)));
        u_entityAction(u_entity(sub),
                       cmx_entityKernelAction,
                       (c_voidp)kernelArg);

        if(qos != NULL){
            rqos = v_readerQos(cmx_qosKernelQosFromKind(qos, K_DATAREADER, c_getBase(c_object(kernelArg->kernel))));

            if(rqos == NULL){
                rqos = v_readerQosNew(kernelArg->kernel, NULL);
            }
        } else {
            rqos = v_readerQosNew(kernelArg->kernel, NULL);
        }
        if(view != NULL){
            qexpr = q_parse(view);

            if(qexpr != NULL){
                rea = u_dataReaderNew(sub, name,  qexpr, NULL, rqos, TRUE);
                q_dispose(qexpr);
            } else {
                rea = NULL;
                OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0,
                    "cmx_dataReaderNew: invalid view expression.");
            }
        } else {
            rea = u_dataReaderNew(sub, name,  NULL, NULL, rqos, TRUE);
        }
        c_free(rqos);
        os_free(kernelArg);

        if(rea != NULL){
            cmx_registerEntity(u_entity(rea));
            arg = cmx_entityArg(os_malloc((os_uint32)(C_SIZEOF(cmx_entityArg))));
            arg->entity = u_entity(rea);
            arg->create = FALSE;
            arg->participant = NULL;
            arg->result = NULL;
            ur = u_entityAction(u_entity(rea),
                                cmx_entityNewFromAction,
                                (c_voidp)(arg));

            if(ur == U_RESULT_OK){
                result = arg->result;
                os_free(arg);
            }
        }
    }
    return result;
}
示例#30
0
d_publisher
d_publisherNew(
    d_admin admin)
{
    d_publisher     publisher;
    d_durability    durability;
    d_configuration config;
    v_publisherQos  publisherQos;
    v_writerQos     writerQos;

    publisher = NULL;

    if(admin){
        publisher            = d_publisher(os_malloc(C_SIZEOF(d_publisher)));
        d_objectInit(d_object(publisher), D_PUBLISHER, d_publisherDeinit);
        publisher->enabled   = TRUE;
        publisher->admin     = admin;
        durability           = d_adminGetDurability(admin);
        config               = d_durabilityGetConfiguration(durability);
        publisherQos         = d_publisherQosNew(config->partitionName);
        publisher->publisher = u_publisherNew(
                                    u_participant(d_durabilityGetService(durability)),
                                    config->publisherName, publisherQos, TRUE);

        d_publisherQosFree(publisherQos);

        if(publisher->publisher){


            publisher->statusWriter            = NULL;
            publisher->newGroupWriter          = NULL;
            publisher->groupsRequestWriter     = NULL;
            publisher->statusRequestWriter     = NULL;
            publisher->sampleRequestWriter     = NULL;
            publisher->sampleChainWriter       = NULL;
            publisher->nameSpacesWriter        = NULL;
            publisher->nameSpacesRequestWriter = NULL;
            publisher->deleteDataWriter        = NULL;
            writerQos                          = d_writerQosNew(
                                                    V_DURABILITY_VOLATILE,
                                                    V_RELIABILITY_RELIABLE,
                                                    config->heartbeatLatencyBudget,
                                                    config->heartbeatTransportPriority);

            publisher->statusNumber = 0;
            publisher->statusWriter = u_writerNew (publisher->publisher,
                                                   "statusWriter",
                                                   d_adminGetStatusTopic(admin),
                                                   d_publisherStatusWriterCopy,
                                                   writerQos,
                                                   TRUE);
            assert(publisher->statusWriter);

            d_writerQosFree(writerQos);
            writerQos = d_writerQosNew (V_DURABILITY_VOLATILE,
                                        V_RELIABILITY_RELIABLE,
                                        config->latencyBudget,
                                        config->transportPriority);

            u_entityAction(u_entity(publisher->statusWriter), d_publisherEnsureServicesAttached, durability);

            publisher->newGroupNumber = 0;
            publisher->newGroupWriter = u_writerNew (publisher->publisher,
                                                     "newGroupWriter",
                                                     d_adminGetNewGroupTopic(admin),
                                                     d_publisherNewGroupWriterCopy,
                                                     writerQos,
                                                     TRUE);
            assert(publisher->newGroupWriter);
            u_entityAction(u_entity(publisher->newGroupWriter), d_publisherEnsureServicesAttached, durability);


            publisher->groupsRequestNumber = 0;
            publisher->groupsRequestWriter = u_writerNew (publisher->publisher,
                                                          "groupsRequestWriter",
                                                          d_adminGetGroupsRequestTopic(admin),
                                                          d_publisherGroupsRequestWriterCopy,
                                                          writerQos,
                                                          TRUE);
            assert(publisher->groupsRequestWriter);
            u_entityAction(u_entity(publisher->groupsRequestWriter), d_publisherEnsureServicesAttached, durability);

            publisher->statusRequestNumber = 0;
            publisher->statusRequestWriter = u_writerNew (publisher->publisher,
                                                          "statusRequestWriter",
                                                          d_adminGetStatusRequestTopic(admin),
                                                          d_publisherStatusRequestWriterCopy,
                                                          writerQos,
                                                          TRUE);
            assert(publisher->statusRequestWriter);
            u_entityAction(u_entity(publisher->statusRequestWriter), d_publisherEnsureServicesAttached, durability);

            publisher->sampleRequestNumber = 0;
            publisher->sampleRequestWriter = u_writerNew (publisher->publisher,
                                                          "sampleRequestWriter",
                                                          d_adminGetSampleRequestTopic(admin),
                                                          d_publisherSampleRequestWriterCopy,
                                                          writerQos,
                                                          TRUE);
            assert(publisher->sampleRequestWriter);
            u_entityAction(u_entity(publisher->sampleRequestWriter), d_publisherEnsureServicesAttached, durability);

            publisher->nameSpacesNumber = 0;
            publisher->nameSpacesWriter = u_writerNew (publisher->publisher,
                                                       "nameSpacesWriter",
                                                       d_adminGetNameSpacesTopic(admin),
                                                       d_publisherNameSpacesWriterCopy,
                                                       writerQos,
                                                       TRUE);
            assert(publisher->nameSpacesWriter);
            u_entityAction(u_entity(publisher->nameSpacesWriter), d_publisherEnsureServicesAttached, durability);

            publisher->nameSpacesRequestNumber = 0;
            publisher->nameSpacesRequestWriter = u_writerNew (publisher->publisher,
                                                              "nameSpacesRequestWriter",
                                                              d_adminGetNameSpacesRequestTopic(admin),
                                                              d_publisherNameSpacesRequestWriterCopy,
                                                              writerQos,
                                                              TRUE);
            assert(publisher->nameSpacesRequestWriter);
            u_entityAction(u_entity(publisher->nameSpacesRequestWriter), d_publisherEnsureServicesAttached, durability);

            publisher->deleteDataNumber = 0;
            publisher->deleteDataWriter = u_writerNew (publisher->publisher,
                                                       "deleteDataWriter",
                                                       d_adminGetDeleteDataTopic(admin),
                                                       d_publisherDeleteDataWriterCopy,
                                                       writerQos,
                                                       TRUE);
            assert(publisher->deleteDataWriter);
            u_entityAction(u_entity(publisher->deleteDataWriter), d_publisherEnsureServicesAttached, durability);

            d_writerQosFree(writerQos);
            writerQos = d_writerQosNew (V_DURABILITY_VOLATILE,
                                        V_RELIABILITY_RELIABLE,
                                        config->alignerLatencyBudget,
                                        config->alignerTransportPriority);
            publisher->sampleChainNumber = 0;
            publisher->sampleChainWriter = u_writerNew (publisher->publisher,
                                                        "sampleChainWriter",
                                                        d_adminGetSampleChainTopic(admin),
                                                        d_publisherSampleChainWriterCopy,
                                                        writerQos,
                                                        TRUE);
            assert(publisher->sampleChainWriter);
            u_entityAction(u_entity(publisher->sampleChainWriter), d_publisherEnsureServicesAttached, durability);

            d_writerQosFree(writerQos);
        } else {
            d_publisherFree(publisher);
            publisher = NULL;
        }
    }
    return publisher;
}