Jump to content
OpenSplice DDS Forum
aphelix

Deleted persistent records in xml file?

Recommended Posts

Hi!

I can see the messages in persistent xml file (MyMessage_Topic.xml) after publishing them. But after a while, restarting the application, the topic records in persistent xml file are deleted. Only a few of them remain.Why are the written records deleted? Is there any configuration that i am missed?

Note: I am using opensplice version 6.9 .

Thanks in advance for your help.

Share this post


Link to post
Share on other sites

Hi aphelix,

 

Are the messages disappearing when their Writer is deleted? If so you might want to check your WriterDataLifecycleQosPolicy in your WriterQos for a field named auto_dispose_unregistered_instances. The default setting of this field is TRUE, meaning that when you unregister an instance (and deleting a Writer implicitly unregisters all its instances) you also automatically dispose it. For the persistent store this means the persistent data samples should all be purged, hence an empty store is left.

If this is indeed the case, try setting the auto_dispose_unregistered_instances field to FALSE (which is the right thing to do for any TRANSIENT/PERSISTENT data) and see if that solved your problem. (And let us know if it indeed does solve your problem.)

Regards,

Erik Hendriks.

 

Share this post


Link to post
Share on other sites

Hello Erik.

Topic records in persistent xml file are deleted when I stop the publisher, as you mentioned. But i have set autodispose_unregistered_instances value as below; But the result is as you indicate.

 

Note:

i have 3 durability type. Doesn't seem very important

TRANSIENT -> ospl-volatile

RESIDENT -> ospl-transient

PERSISTENT -> ospl-persistent

 

CREATING_OSPL_RESOURCE;

 

{
    ReturnCode_t status;  
    CHAR* topicName = const_cast<CHAR*>(osplParam->topicName.c_str());

    //(1) Registering type...
    CORBA::String_var typeName = osplParam->typeSupport->get_type_name();

    status = osplParam->typeSupport->register_type(participant.in(), typeName);
    if (status != DDS::RETCODE_OK){  
        const STRING excp = "Cannot call TypeSupport::register_type.RetCode is " + OSPLConnector::RetCodeName[status];
        ERROR(excp.c_str());
        return false;
    }        
   
    TopicQos topic_qos;
    status = participant->get_default_topic_qos(topic_qos);
    if (status != DDS::RETCODE_OK){
        const STRING excp = "Cannot call DomainParticipant_var::get_default_topic_qos.RetCode is " + OSPLConnector::RetCodeName[status];
        ERROR(excp.c_str());    
        return false;
    }
   
    // RELIABILITY....
    switch(osplParam->reliability){
        case RELIABLE:{
            topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
            break;
        }
       
        case BEST_EFFORT:{
            topic_qos.reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
            break;
        }        
    }
   
    // DURABILITY....  
    // Setting topic qos policies...
    HistoryQosPolicy tmpHistoryQosPolicy;
    switch(osplParam->durability){
       
        case TRANSIENT:{
           
            topic_qos.durability.kind = VOLATILE_DURABILITY_QOS;
            tmpHistoryQosPolicy.kind = KEEP_LAST_HISTORY_QOS;
            tmpHistoryQosPolicy.depth = DpsApplication::GetInstance()->GetTransientBufferSize();
           
            break;
        }

        case RESIDENT:{  
           
            topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;
            tmpHistoryQosPolicy.kind = KEEP_LAST_HISTORY_QOS;
            tmpHistoryQosPolicy.depth = isKeyed ? 1 : DpsApplication::GetInstance()->GetResidentBufferSize();            
           
            break;
        }
       
        case PERSISTENT:{  
           
            topic_qos.durability.kind = PERSISTENT_DURABILITY_QOS;
            tmpHistoryQosPolicy.kind = KEEP_LAST_HISTORY_QOS;
            tmpHistoryQosPolicy.depth = isKeyed ? 1 : DpsApplication::GetInstance()->GetPersistentBufferSize();                            

            break;
        }
       
        default:{
            ERROR("Undefined durability type.");      
            return false;            
        }            
    }
   
    // SETTING TOPIC HISTORY QOS.
    topic_qos.history.kind = tmpHistoryQosPolicy.kind;
    topic_qos.history.depth = tmpHistoryQosPolicy.depth;    


    //(2) CREATING TOPIC.
    Topic_ptr topic = participant->create_topic(topicName, typeName, topic_qos, NULL, STATUS_MASK_NONE);
    if(!topic){
        ERROR("Cannot call DDS::DomainParticipant::create_topic.");      
        return false;
    }


    //(3) CREATING WRITER.  
    DataWriter_ptr writer = publisher->create_datawriter(topic, DATAWRITER_QOS_USE_TOPIC_QOS, NULL, STATUS_MASK_NONE);
    if(!writer){        
        ERROR("while calling DDS::Publisher::create_datawriter.");    
        return false;
    }

    //(4) CREATING READER.
    DataReader_ptr reader = subscriber->create_datareader(topic, DATAREADER_QOS_USE_TOPIC_QOS, NULL, STATUS_MASK_NONE);
    if(!reader){
        ERROR("Cannot call DDS::Subscriber::create_datareader.");  
        return false;
    }
   
    //(5) PERSISTENT SPECIFIC OPERATIONS.
    if(osplParam->durability == PERSISTENT){    <<<<<<<<<<<<<<<<<<<<<<  HERE  Erik :))))

        /*
        Topic instances are runtime entities for which DDS keeps track of whether
        (1) there are any live writers,
        (2) the instance has appeared in the system for the first time
        (3) the instance has been disposed--meaning explicitly removed from the system.

        Setting dataWriter’s autodispose_unregistered_instances QoS policy to FALSE (as default is TRUE causing your persistent samples to become
        NOT_ALIVE_DISPOSED after termination of your writer application causes the instances to be disposed before being unregistered).
         */
        DataWriterQos dw_qos;
        writer->get_qos(dw_qos);
        dw_qos.writer_data_lifecycle.autodispose_unregistered_instances = false;
        writer->set_qos(dw_qos);
       
        /*
         * The wait_for_historical_data() operation waits (blocks) until all "historical" data is received from matched DataWriters.                          <<<<<<<<<<<<<<<<<<<<<<  WAITING HISTORY HERE  Erik :))))
         * "Historical" data means DDS samples that were written before the DataReader joined the DDS domain.(For persistent and resident)          
         */
        DDS::Duration_t a_timeout;
        a_timeout.sec = 20;
        a_timeout.nanosec = 0;
        reader->wait_for_historical_data(a_timeout);        
    }

    //(6) Reader qos.
    DataReaderQos dr_qos;
    reader->get_qos(dr_qos);
    dr_qos.history.kind = tmpHistoryQosPolicy.kind;
    dr_qos.history.depth = tmpHistoryQosPolicy.depth;
    reader->set_qos(dr_qos);

    vars->osplTopic = topic;
    vars->osplWriter = writer;
    vars->osplReader = reader;
    osplResourceMap.insert(OSPL_RESOURCE_PAIR(topicName, *vars)); // Storing it.  :))           

    return true;
   
   
    /*
     * Possible others qos services to do...,
     * Latency budget
     * Deadline
     * Transport priority    
     */
}

So. I guess I can't set the qos policies properly  :(((

Thanks...

Share this post


Link to post
Share on other sites

Hi aphelix,

I see that you first create your writer using the topicQos (in which case the non-overlapping parts such as WriterDataLifecycleQosPolicy get initialized to their default settings which is TRUE in this case), then get the WriterQos, modify its auto_dispose setting and set it back as the new WriterQos. Although that is not illegal according to the DDS specification, we don't support changeable Qos in our DDSI stack yet. Can you try modifying the autodispose setting before you create your Writer and see if that solves your problem? I am curious to hear the result.

Regards,

Erik.

Share this post


Link to post
Share on other sites

Hi Eric.

Quote

Can you try modifying the autodispose setting before you create your Writer and see if that solves your problem? I am curious to hear the result.

I created all qos variables and set all properties first . Then i created topic, reader and writer like you said. It is now working properly. Thank you very much for your help.

Best reagards.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...