Project

General

Profile

Actions

Task #1995

closed

nfdc: accept FaceUri in all commands

Added by Junxiao Shi over 10 years ago. Updated about 10 years ago.

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

100%

Estimated time:
3.00 h

Description

Change nfdc to use Face Query Operation, so that it can accept FaceUri in place of FaceId in all commands.

Note: FaceUri must be canonized before passing as a query filter.


Related issues 2 (0 open2 closed)

Blocked by NFD - Task #1909: nfdc: ensure FaceUri is in canonical formClosedChengyu Fan

Actions
Blocked by NFD - Task #1993: Face query operationClosedChengyu Fan

Actions
Actions #1

Updated by Junxiao Shi over 10 years ago

  • Blocked by Task #1909: nfdc: ensure FaceUri is in canonical form added
Actions #2

Updated by Chengyu Fan about 10 years ago

  • Assignee set to Chengyu Fan
Actions #3

Updated by Junxiao Shi about 10 years ago

  • Blocked by Task #1993: Face query operation added
Actions #4

Updated by Chengyu Fan about 10 years ago

I don't get why nfdc needs Face Query Operation?

Do you mean nfd-status?

Actions #5

Updated by Junxiao Shi about 10 years ago

nfdc unregister /example udp://router.example.com is processed as:

  1. canonize udp://router.example.com
  2. Use face query operation to find the FaceId
  3. Unregister that FaceId for /example prefix
Actions #6

Updated by Chengyu Fan about 10 years ago

I see, will do that

Actions #7

Updated by Chengyu Fan about 10 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 30
Actions #8

Updated by Chengyu Fan about 10 years ago

I have a FATAL error when run nfd-start on OS X Yosemite.

Below is the error output, does anyone know how to solve it?

1416938168.921410 INFO: [StrategyChoice] setDefaultStrategy /localhost/nfd/strategy/best-route/%FD%02
1416938168.921826 INFO: [InternalFace] registering callback for /localhost/nfd/fib
1416938168.921937 INFO: [InternalFace] registering callback for /localhost/nfd/faces
1416938168.922108 INFO: [InternalFace] registering callback for /localhost/nfd/strategy-choice
1416938168.922251 INFO: [InternalFace] registering callback for /localhost/nfd/status
1416938168.922383 INFO: [FaceTable] Added face id=1 remote=internal:// local=internal://
1416938170.733959 FATAL: [NFD] Unrecognized option "listen" in "unix" section
1416938170.916780 INFO: [RibManager] Listening on: /localhost/nfd/rib
1416938170.963689 INFO: [RibManager] Start monitoring face create/destroy events
1416938170.983865 FATAL: [NRD] error while connecting to the forwarder (No such file or directory)
Actions #9

Updated by Junxiao Shi about 10 years ago

1416938170.733959 FATAL: [NFD] Unrecognized option "listen" in "unix" section

Configuration file format has been changed in commit dbcb1a119245d1ecb56e72ea35b57b95e119c12e.

Please delete custom configuration file, and recreate it from the sample.

Actions #10

Updated by Chengyu Fan about 10 years ago

Thanks @Junxiao, it solves the issue.

Actions #11

Updated by Chengyu Fan about 10 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 30 to 100
Actions #12

Updated by Junxiao Shi about 10 years ago

There are lots of code duplication in uploaded commit e1e5a85933f3f72096cc70a98100a4cae4fffbb6.

Suggestions:

class ObtainFaceId
{
public:
  typedef std::function<void(uint32_t)> SuccessCallback;
  typedef std::function<void(std::string)> FailureCallback;

  /** \brief obtain FaceId from input
   *  \param input user input, either FaceId or FaceUri
   *  \param allowCreate whether creating face is allowed
   */
  static void
  start(const std::string& input, bool allowCreate,
        SuccessCallback onSucceed,
               FailureCallback onFail);
}

The procedure is:

  1. try parse input as FaceId, if input is FaceId, succeed with parsed FaceId
  2. try parse input as FaceUri, if input is not FaceUri, fail
  3. canonize faceUri
  4. if canonization fails, fail
  5. query for face
  6. if query succeeds and finds a face, succeed with found FaceId
  7. create face
  8. if face creation succeeds, succeed with created FaceId
  9. fail

ObtainFaceId::start static method is the entrypoint to this procedure.

This method should create a ObtainFaceId instance, and assign necessary arguments onto the instance as members.

Subsequent steps are declared as instance methods on ObtainFaceId class.

Since arguments are stored as instance members, it's unnecessary to pass many variable with std::bind.

When we have ObtainFaceId::start function, Nfdc class needs only one method per sub-command in most cases.
That method:

  1. get FaceId-or-FaceUri from command line as a string (but don't pass it)
  2. invoke ObtainFaceId::start function
  3. in the success callback (written as a lambda expression), perform the next steps.
Actions #13

Updated by Junxiao Shi about 10 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF