Project

General

Profile

Actions

Task #2579

closed

Provide send/sendData in Face() and deprecate in Transport

Added by Jeff Burke about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Start date:
08/24/2014
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)

Description

send/sendData are most appropriately associated with Face. App should not need to use Transport object in typical situations except at startup, perhaps.


Subtasks 1 (0 open1 closed)

Task #1921: Provide equivalent to NDN_MAX_PACKET_SIZEClosed08/24/2014

Actions
Actions #1

Updated by Alex Afanasyev about 9 years ago

This should not be "send", as semantically we are not sending anything, rather make data available if it is requested.

For the lack of a better word, i suggest sticking with put, as it was used in old codebase and is used (=is familiar to developers) in mdn-cxx library.

Actions #2

Updated by Jeff Burke about 9 years ago

Just so I am clear: What are the exact semantics requested of the library / forwarder by this call? ("Send" to the forwarder / "put" in the content store) or something different?

Actions #3

Updated by Alex Afanasyev about 9 years ago

I think what you mentioned is not semantics, rather side effects, though not sure. May be it should be just "make data packet available for the application/library and forwarder". What forwarder and app will do with the data (forward, cache, or discard) could be outside definition of the method.

May be we need some arguments to put yo indicate the desired side-effect.

Actions #4

Updated by Anonymous about 9 years ago

Hi Jeff,

Right now, the OnInterest callback passes a Transport to the application so it can give it the data packet. We would want to change the the callback to pass a Face instead of a Transport. I'm thinking of ways to change the signature of the callback in a way where we can deprecate the old usage and add a new one.

For Python and JavaScript which don't have signatures on the callbacks, my idea in issue #2550 was to add sendData to Transport and deprecate the application calling send, so that we could add sendData to Face and it would work when the Python or JavaScript onInterest is passed a Face object instead of a Transport.

For C++ and Java, I suggest we would add new overloads of registerPrefix which take the OnInterest callback with the new signature and deprecate the previous. What do you think?

Actions #5

Updated by Alex Afanasyev about 9 years ago

The callback interface should be a different discussion. I personally do not like that the callback is forced receive information that is not related to the interest. This forces more work for the developer

I would even go in saying that this should be just Interest (may be InterestFilter too, but not 100% convinced either way). Other parts (registered filter, face, registered id, etc.) are useful, but all of them are naturally bound in some languages (js, java, may be python) or can be explicitly bound to the callback when needed.

Actions #6

Updated by Anonymous about 9 years ago

  • Project changed from 4 to NDN-CCL
  • Subject changed from Provide send/sendData in Face() and deprecate in Transport (across all CCL) to Provide send/sendData in Face() and deprecate in Transport
Actions #7

Updated by Anonymous about 9 years ago

  • Due date changed from 03/13/2015 to 04/03/2015
Actions #8

Updated by Anonymous about 9 years ago

We will add Face.putData(data) and deprecate the application's access to Transport.send. Also the OnInterest callback given to registerPrefix should pass a Face, and deprecate the OnInterest with Transport. We name it Face.putData(data) instead of put(data) to make it work better with Python and JavaScript where it is harder to overload methods.

Actions #9

Updated by Alex Afanasyev about 9 years ago

What exactly is the problem with python and javascript?

Actions #10

Updated by Anonymous about 9 years ago

For example, KeyChain.sign is overloaded to sign a data buffer, an Interest and a Data. They all do very different things. In C++ each overloaded method is separate code and can be documented and followed clearly. But in Python and JavaScript the documentation and code all has to be mashed together.

https://github.com/named-data/PyNDN2/blob/17aabaeb3dd529d622bc5f3b114cb7e7e23fa8fc/python/pyndn/security/key_chain.py#L262

We are naming the method "put" instead of "send" because the library may do something other than simply send the packet. And the library will likely do something different in put for Data and put for Interest. So I prefer to keep them separate with putData, etc. It is not a burden on the application to call putData instead of put.

Actions #11

Updated by Alex Afanasyev about 9 years ago

I'm not sure that I'm following the reasoning (I cannot foresee a need for "putInterest") and documentation may not be a big problem.

In any case. I'm ok with "Face.putData", as it would match "Face.expressInterest" name.

Actions #12

Updated by Anonymous about 9 years ago

Question: In ndn-cxx, Face.put says "It is highly recommended to use a Data packet that was created using make_shared(...). Otherwise, put() will make an extra copy of the Data packet to ensure validity of published Data until the asynchronous put() operation finishes."
https://github.com/named-data/ndn-cxx/blob/a8659ff5709a27404e69e85e0fd27823c4abc76d/src/face.hpp#L481

But internally, the library only needs to keep the wire encoding blob until the asynchronous put() operation finishes, not the whole Data object. So can we remove the requirement to pass a shared_ptr?

Actions #13

Updated by Alex Afanasyev about 9 years ago

Not exactly. Data packet can has other fields that are bundled with the Data (e.g., LocalControlHeader), which needs to be accessed during async operation execution.

The main reason for putData to be internally async is to ensure thread safety (essentially, every Face operation is serialized).

Actions #14

Updated by Anonymous about 9 years ago

  • Status changed from New to In Progress

See updates in Feature #2566.

Actions #15

Updated by Anonymous almost 9 years ago

  • Status changed from In Progress to Closed

As part of implementing setInterestFilter for feature #2566, the onInterest callback was changed to use a Face instead of Transport. Transport support is deprecated. Added the method Face.putData. See the updated onInterest parameter of registerPrefix:

http://named-data.net/doc/ndn-ccl-api/face.html#face-registerprefix-method

Actions

Also available in: Atom PDF