Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15158] ReadConditions Implementation #2872

Merged
merged 41 commits into from
Jul 28, 2022

Conversation

MiguelBarro
Copy link
Contributor

@MiguelBarro MiguelBarro commented Jul 22, 2022

Description

ReadCondition DDS 1.4 feature implementation & testing

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added.
  • Any new/modified methods have been properly documented using Doxygen.
  • Fast DDS test suite has been run locally.
  • Changes are ABI compatible.
  • Changes are API compatible.
  • Documentation builds and tests pass locally.
  • New feature has been added to the versions.md file (if applicable).
  • New feature has been documented/Current behavior is correctly described in the documentation.

Reviewer Checklist

  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

@MiguelCompany MiguelCompany added this to the v2.7.1 milestone Jul 22, 2022
@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch from 7a6b4d3 to 7c4ed4d Compare July 22, 2022 10:46
@@ -304,6 +314,16 @@ DataReaderImpl::~DataReaderImpl()

bool DataReaderImpl::can_be_deleted() const
{
{
std::lock_guard<std::recursive_mutex> _(get_conditions_mutex());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutex's scope should cover the whole operation.

Copy link
Contributor Author

@MiguelBarro MiguelBarro Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. To prevent any issues on notification the get_conditions_mutex() must be taken after the reader_->getMutex() one (doxygen on the mutex has been updated) because notification callbacks are done with the reader mutex taken.
Nevertheless the ReturnCode_t SubscriberImpl::delete_datareader(const DataReader* reader) will not take the mutex between DataReaderImpl::can_be_deleted() check and the actual deletion.
This happens too for the loans. A mechanism is need to disable all resource allocation within this method (flag or something) and assure can_be_deleted value will hold through it.

${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/QosPolicyUtils.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/QosPolicyUtils.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove duplicated line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch 2 times, most recently from 4398b7d to a3dce99 Compare July 22, 2022 14:20
@MiguelCompany
Copy link
Member

@MiguelBarro I think I got #2842 finally right. Would you mind rebasing this?

@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch 2 times, most recently from 6586676 to b08745f Compare July 26, 2022 08:17
@MiguelCompany MiguelCompany force-pushed the feature/read-condition/implementation branch from b08745f to 4eb8f91 Compare July 26, 2022 08:54
@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch from 4eb8f91 to d925e4e Compare July 26, 2022 10:20
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me 🤯

@MiguelBarro MiguelBarro marked this pull request as ready for review July 26, 2022 14:43
@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch from 8de1e55 to 891142b Compare July 26, 2022 15:30
@MiguelCompany
Copy link
Member

@MiguelBarro #2842 has been merged. This one can be rebased onto master

}
conds.clear();

// 4- Create several ReadConditions associated to different same masks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different same masks? Please clarify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

conds.push_front(reader.create_readcondition( ++sample_states, ++view_states, ++instance_states));
}

EXPECT_EQ(reader.delete_contained_entities(), ReturnCode_t::RETCODE_OK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the functionality of delete_contained_entities changed its tests should reflect this by adding new test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the possible cases are tested here:

// 7- Check the DataReader cannot be deleted with outstanding conditions
EXPECT_EQ(subscriber_->delete_datareader(another_reader), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET);
// but delete_contained_entities() succeeds with outstanding ReadConditions
EXPECT_EQ(another_reader->delete_contained_entities(), ReturnCode_t::RETCODE_OK);
// no outstanding conditions (killed above)
EXPECT_EQ(subscriber_->delete_datareader(another_reader), ReturnCode_t::RETCODE_OK);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to adding ReadConditions deletion to this test. I think that's where the delete_contained_entities functionality tests should go (even if you are using and checking its return code elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍


#include <fastdds/dds/subscriber/ReadCondition.hpp>
#include <fastdds/dds/core/StackAllocatedSequence.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the style guide, this line should come before the previous one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file has been removed in favor of DataReaderTests.cpp

InstanceStateMask instance_states = ANY_INSTANCE_STATE;
EXPECT_EQ(
nullptr,
data_reader->create_readcondition(sample_states, view_states, instance_states));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove create_readcondition from the list of unimplemented methods in this test comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
EXPECT_EQ(
ReturnCode_t::RETCODE_UNSUPPORTED,
data_reader->delete_readcondition(nullptr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove delete_readcondition from the list of unimplemented methods in this test comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

EXPECT_EQ(reader.delete_readcondition(cond), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET);

// 7- Check the DataReader cannot be deleted with outstanding conditions
EXPECT_EQ(another_manager.get_native_subscriber().delete_contained_entities(),
Copy link
Contributor

@jsan-rt jsan-rt Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the existence of ReadConditions should cause the delete_contained_entities call to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) ReturnCode_t DataReaderImpl::delete_contained_entities()

My implementation clears all ReadConditions (we can do that because Company implementation unlinks the WaitSets on Condition destruction.

According to the DDS standard 1.4 in 2.2.2.2.1.18 & 2.2.2.5.3.31 delete_contained_entities() will be used recursively and remove all API created objects (including Read & QueryConditions object created by the DataReader).

The operation will return PRECONDITION_NOT_MET if the any of the contained entities is in a state where it cannot be deleted. This is quite vague but seems our DataReaderImpl fulfills the spirit.

b) ReturnCode_t SubscriberImpl::delete_contained_entities()

The implementation tries to destroy all DataReaders checking DataReaderImpl::can_be_deleted().
My can_be_deleted() implementation takes into account outstanding ReadConditions (formerly only loans).
This doesn't match the DDS standard 2.2.2.5.2.14 behaviour.

c) ReturnCode_t SubscriberImpl::delete_datareader(const DataReader* reader)
The implementation tries to destroy all the readers querying can_be_deleted() too.
This matches standard 2.2.2.5.2.6 description (any outstanding ReadConditions will lead to failure).

It's clear the issue is b). b) and c) are supposed to behave differently but are calling the same DataReaderImpl::can_be_deleted()
method. The solution is make clear to the method which function is calling it by using a parameter as:

bool DataReaderImpl::can_be_deleted(bool recursive = true) const

// Check the data is there
EXPECT_EQ(reader.get_native_reader().get_unread_count(), 1);

// Check the conditions triggered where the expected ones
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Replace where with were

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

MiguelCompany and others added 13 commits July 27, 2022 07:48
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
…ies component.

This pull request mandatory piggyback.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…read_conditions)

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…hecks

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguel.barro@live.com>
MRicoIE2CS added a commit that referenced this pull request Jul 27, 2022
…2872, some methods of DataReader.hpp are going to be implemented. This commit removes the not-supported warning for the merge.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany MiguelCompany force-pushed the feature/read-condition/implementation branch from bf26dca to 75ea11b Compare July 27, 2022 09:25
EduPonz pushed a commit that referenced this pull request Jul 27, 2022
…2879)

* Refs #14686: Add warning to indicate unsupported APIs in DomainParticipant.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in DomainParticipantFactory.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in DataWriter.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in Publisher.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in DataReader.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in Subscriber.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: Add warning to indicate unsupported APIs in Topic.hpp

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #14686: In accordance with  [15158] ReadConditions Implementation #2872, some methods of DataReader.hpp are going to be implemented. This commit removes the not-supported warning for the merge.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>
@MiguelCompany
Copy link
Member

@richiprosima Please test this

// Should failed with outstanding ReadConditions
ASSERT_EQ(subscriber->delete_datareader(data_reader), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET);

std::cout << "Before recursive?" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right

@@ -2580,7 +2587,17 @@ TEST_F(DataReaderTests, delete_contained_entities)
// To be updated when Query Conditions are available
ASSERT_EQ(query_condition, nullptr);

std::cout << "check non-recursive?" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ASSERT_EQ(data_reader->delete_contained_entities(), ReturnCode_t::RETCODE_OK);

std::cout << "Where is the SEH?" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope it's nowhere to be seen. Please remove this trace 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -2580,7 +2587,17 @@ TEST_F(DataReaderTests, delete_contained_entities)
// To be updated when Query Conditions are available
ASSERT_EQ(query_condition, nullptr);

std::cout << "check non-recursive?" << std::endl;

// Should failed with outstanding ReadConditions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: failed -> fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


std::cout << "Before recursive?" << std::endl;

// Should not failed with outstanding ReadConditions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: failed -> fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch 2 times, most recently from 53002ba to 66e7784 Compare July 27, 2022 09:47
Signed-off-by: Miguel Barro <miguel.barro@live.com>
@MiguelBarro MiguelBarro force-pushed the feature/read-condition/implementation branch from 66e7784 to 65c58a1 Compare July 27, 2022 09:51
jsan-rt
jsan-rt previously approved these changes Jul 27, 2022
Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EduPonz
Copy link

EduPonz commented Jul 27, 2022

@richiprosima please test this

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguel.barro@live.com>
@MiguelBarro
Copy link
Contributor Author

@richiprosima please test this

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany
Copy link
Member

@richiprosima Please test windows

@MiguelCompany
Copy link
Member

@richiprosima Please test mac and test linux

…thods.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
…e_deleted.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany MiguelCompany force-pushed the feature/read-condition/implementation branch from e0a125c to 9774494 Compare July 27, 2022 15:47
@MiguelCompany
Copy link
Member

@richiprosima Please test this

Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants