Project

General

Profile

Actions

Task #3546

closed

PIT entry: move away forwarding semantics

Added by Junxiao Shi almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tables
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
9.00 h

Description

Currently pit::Entry class has many methods that are unrelated to table structure, but reflect forwarding semantics used by pipelines or strategies.
The semantics of these methods are problematic, and are not general enough for all forwarding strategies.

They should be moved away from pit::Entry, and placed into forwarding.

The pit::Entry class shall only contain methods that operate on the table structure, include but are not limited to:

  • access to the representative Interest
  • insert/delete/get/enumerate in-records
  • insert/delete/get/enumerate out-records

Other methods should be moved away, and turned into helper functions in forwarding.


Related issues 1 (0 open1 closed)

Related to NFD - Task #3164: Reduce usage of shared_ptr in FIB/PIT/StrategyChoice/MeasurementsClosedJunxiao Shi

Actions
Actions #1

Updated by Junxiao Shi almost 9 years ago

Specific design for pit-entry.hpp as of nfd:commit:5e5e44518286e89a0092ea0ad93c22e64128bdd2 :

class Entry : public StrategyInfoHost, noncopyable
{
public:
  const Interest& getInterest() const;
  const Name& getName() const;
  InRecordCollection inRecords;
  OutRecordCollection outRecords;
public: // misc
  int findNonce(nonce, face) const;
  scheduler::EventId unsatisfyTimer;
  scheduler::EventId stragglerTimer;
};

class InRecordCollection
{
  size_t size() const;
  const_iterator begin() const;
  const_iterator end() const;
  const_iterator find(face) const;
  iterator find(face);
  iterator add(face, interest);
  bool remove(face);
  void clear();
};

class OutRecordCollection
{
  (same as InRecordCollection)
};
  • Entry methods under "misc" are not strictly for structure, but they are used by pipelines and it would be inefficient to turn them into StrategyInfo, so they can stay.
  • Operations on in-records and out-records are entirely through the collection type. It has been cumbersome to write outRecord = pitEntry->getOutRecord(inFace); if (outRecord == pitEntry->getOutRecords().end()) ... (src) because getOutRecord and end are on different objects; it would look better through the collection type because find and end are on the same object.

canForwardTo violatesScope hasLocalInRecord hasUnexpiredOutRecords should be moved to forwarding as free functions, and included by whatever pipeline or strategy that needs them.

A function would look like: bool violatesScope(const pit::Entry& pitEntry, const Face& inFace).

Actions #2

Updated by Junxiao Shi almost 9 years ago

  • Related to Task #3164: Reduce usage of shared_ptr in FIB/PIT/StrategyChoice/Measurements added
Actions #3

Updated by Junxiao Shi almost 9 years ago

  • Assignee set to Junxiao Shi

20160315 call approves the idea, but the design is changed as:
find add remove operations for in-record and out-record shall be kept on PIT entry; getters like in_begin() in_end() may be added for easier access.
Rationale: adding/removing an in-record or out-record not only involves modifications on the collection, but also can change the PIT entry itself.

Actions #4

Updated by Davide Pesavento almost 9 years ago

Junxiao Shi wrote:

Rationale: adding/removing an in-record or out-record not only involves modifications on the collection, but also can change the PIT entry itself.

Just for the record, I don't think that kind of reasoning is correct. The fact that adding an in-record changes the pit entry is an implementation detail, and it should not dictate or influence the API in any way.

Actions #5

Updated by Junxiao Shi almost 9 years ago

I agree with note-4.

Could @Alex approve the API in note-1 then?

Actions #6

Updated by Alex Afanasyev almost 9 years ago

Just for the record, I don't think that kind of reasoning is correct. The fact that adding an in-record changes the pit entry is an implementation detail, and it should not dictate or influence the API in any way.

I disagree with this. The semantics of PIT entry is not just a collection of in and out interests. It is a state that remembers in and out, which is being update whenever you add/remove in/out interests. Yes, it can be separated, but we then we simply moving the logic to somewhere and potentially "violate" PIT entry semantics.

Actions #7

Updated by Davide Pesavento almost 9 years ago

Maintaining a class or object invariant is also an implementation detail. Of course the API must not provide a way for its consumer to break the invariant. I wasn't suggesting to do that.

I think the question is whether a pit entry is (from an API point of view) an atomic, stateful entity that appears as a black box, or an aggregate of inRecords + outRecords + some other state. I have no strong opinion on this. All I'm saying is that the rationale in note-3 should not --by itself-- rule out the second definition of pit entry.

Actions #8

Updated by Junxiao Shi almost 9 years ago

whether a pit entry is an atomic, stateful entity that appears as a black box, or an aggregate of inRecords + outRecords + some other state

Conceptually, a PIT entry should be an atomic entity, because an in-record or out-record is meaningless without a PIT entry.

However, I'm unsure how this question affects API design.

Actions #9

Updated by Davide Pesavento almost 9 years ago

Junxiao Shi wrote:

However, I'm unsure how this question affects API design.

It doesn't have to. What a pit entry conceptually is doesn't necessarily shape every aspect of its API. It can certainly influence it, but some invariants can be maintained even if the "API model" is different from the "conceptual model". That's why I said "from an API point of view" in note-7.

Actions #10

Updated by Junxiao Shi almost 9 years ago

It doesn't have to. What a pit entry conceptually is doesn't necessarily shape every aspect of its API.

In this case, I'll stick with note-3 design which has been approved.

Actions #11

Updated by Junxiao Shi almost 9 years ago

  • Status changed from New to In Progress
Actions #12

Updated by Junxiao Shi almost 9 years ago

http://gerrit.named-data.net/2787

patchset1 moves canForwardTo violatesScope findNonce to forwarding.

I'll do API refactoring (according to note-3) in next patchset.

I'm waiting for a decision on #3545 before moving hasUnexpiredOutRecords.

This task is easier than expected.

Actions #13

Updated by Junxiao Shi over 8 years ago

  • % Done changed from 0 to 50

http://gerrit.named-data.net/2787 patchset2 moves away forwarding semantics.

I plan to refactor pit::Entry APIs according to note-3 in another commit, to keep this commit small.

Actions #14

Updated by Junxiao Shi over 8 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 50 to 100
Actions #15

Updated by Junxiao Shi over 8 years ago

http://gerrit.named-data.net/2806

This commit deduplicates Forwarder::LOCALHOST_NAME and scope_prefix::LOCALHOST.

Actions #16

Updated by Junxiao Shi over 8 years ago

  • Status changed from Code review to In Progress
  • % Done changed from 100 to 80

The algorithms should be introduced in NFD devguide "forwarding" section.

Actions #17

Updated by Junxiao Shi over 8 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 80 to 100

nfd-docs:commit:a3cc734117d558bb0ff76f54827aa2894fad3ba2

Actions

Also available in: Atom PDF