Esempio n. 1
0
u_partition
u_partitionNew(
    u_participant p,
    const c_char *name,
    v_partitionQos qos)
{
    u_partition _this = NULL;
    v_kernel ke = NULL;
    v_partition kd;
    u_result result;

    if (name == NULL) {
        name = "No partition specified";
    }
    if (p != NULL) {
        result = u_entityWriteClaim(u_entity(u_participantDomain(p)),(v_entity*)(&ke));
        if ((result == U_RESULT_OK) && (ke != NULL)) {
            kd = v_partitionNew(ke,name,qos);
            if (kd != NULL) {
                _this = u_entityAlloc(p,u_partition,kd,FALSE);
                if (_this != NULL) {
                    result = u_partitionInit(_this);
                    if (result != U_RESULT_OK) {
                        OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                                    "Initialisation failed. "
                                    "For Partition: <%s>.", name);
                        u_partitionFree(_this);
                    }
                } else {
                    OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                                "Create proxy failed. "
                                "For Partition: <%s>.", name);
                }
                c_free(kd);
            } else {
                OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                            "Create kernel entity failed. "
                            "For Partition: <%s>", name);
            }
            result = u_entityRelease(u_entity(u_participantDomain(p)));
        } else {
            OS_REPORT_1(OS_WARNING, "u_partitionNew", 0,
                        "Claim Participant failed. "
                        "For Partition: <%s>", name);
        }
    } else {
        OS_REPORT_1(OS_ERROR,"u_partitionNew",0,
                    "No Participant specified. "
                    "For Partition: <%s>", name);
    }
    return _this;
}
Esempio n. 2
0
jni_result
jni_partitionFree(
    jni_partition _this)
{
    jni_result r;
    
    r = JNI_RESULT_OK;
    
    if((_this == NULL) || (_this->upartition == NULL)){
        OS_REPORT(OS_ERROR, CONT_DCPSJNI, 0, "Supplied partition is NULL"); 
        r = JNI_RESULT_BAD_PARAMETER;
    }
    else{
        r = jni_convertResult(u_partitionFree(_this->upartition));
        
        if(r == JNI_RESULT_OK){            
            os_free(_this);
        }
    }
    return r;
}
Esempio n. 3
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;
}