1 / 75

MediaBroker++

MediaBroker++. Created: 2005/05/23 Last Updated: 2005/05/26. Coding Conventions (1). C++ API, C API = Java coding convention C API Generic rule Combine words by an underscore “_”. Function name ::= { (a-z,0-9,“_”)+ } Structure name ::= { (a-z,0-9,”_”)+ “_t” }

hateya
Télécharger la présentation

MediaBroker++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MediaBroker++ Created: 2005/05/23 Last Updated: 2005/05/26

  2. Coding Conventions (1) • C++ API, C API = Java coding convention • C API • Generic rule • Combine words by an underscore “_”. • Function name ::= { (a-z,0-9,“_”)+ } • Structure name ::= { (a-z,0-9,”_”)+ “_t” } • Variable/Parameter name ::= Function name

  3. Coding Conventions • Comments • Write comments for everything! • file, class, method, function, structure, parameter, and variable! • Format • Free, but include your name (and possibly e-mail address, too). • C++ codes will be treated with CppDoc (http://www.cppdoc.com/)

  4. Version Control • CVS • Nate • 1-2 week(s)

  5. Editor • Vim • Vi • Emacs • Eclipse + CDT

  6. Common

  7. Data Structure • Status structures contain dynamically changeable/modifiable information of a MB++ entity. Static/public information is stored in attributes structures. • struct mb_sockaddr_t • char *name : represents a host name in a host byte order • int port : represents a port number in a host byte order • struct mb_server_stat_t • struct mb_server_attr_t *attr : a pointer to the static information of this server

  8. MB++ Server

  9. Overview

  10. Naming and Lookup jin

  11. Naming and Lookup API • int mb_advertise_server ( mb_server_attr_t *attr) • Advertise the existence of a server to a MB domain. • int mb_advertise_producer ( mb_producer_attr_t *attr) • Advertise the existence of a producer. • int mb_advertise_consumer ( mb_consumer_attr_t *attr) • Advertise the existence of a consumer. • int mb_stop_advertisement ( int ad) • Stop advertisement for the specified advertisement descriptor, which is returned by one of advertisement functions. • int mb_find_server ( long timeout_msec, struct mb_server_attr_t ** attrs) • Locate MB++ servers in a MB domain in the given amount of time. • int mb_resolve_server (long timeout_msec, struct mb_server_attr_t *template, struct mb_server_attr_t **attrs) • Locate an MB++ producer in a MB domain that match the template in the given amount of time. • int mb_find_producer ( long timeout_msec, struct mb_producer_attr_t ** attrs) • Locate MB++ producers in a MB domain in the given amount of time. • int mb_resolve_producer ( long timeout_msec, struct mb_producer_attr_t *template, struct mb_producer_attr_t ** attrs) • Locate an MB++ producer in a MB domain that match the template in the given amount of time. • int mb_find_consumer ( long timeout_msec, struct mb_consumer_attr_t ** attrs) • Locate MB++ consumers in a MB domain in the given amount of time. • int mb_resolve_server ( long timeout_msec, struct mb_consumer_attr_t *template, struct mb_consumer_attr_t ** attrs) • Locate an MB++ consumer in a MB domain that match the template in the given amount of time.

  12. Overview • Naming and lookup layer of MB++ mutually advertises entities on it. The advertisement is not necessarily be periodic or reliable, thus we might require explicit lookup operation between hosts. • The attribute of an entity can change, so we need (a kind of) the observer-observable pattern between the attribute and the naming/lookup layer implementation. This means when a producer/consumer/server changes a part of its attribute, the naming/lookup layer must be aware of the event to affect the change for later lookups across hosts.

  13. Figure producer and consumer Host 2 server Host 1 client notify lookup advertise advertise MB++ Naming/Lookup Layer MB++ Naming/Lookup Layer lookup advertisement advertisement / lookup

  14. Data Structures • Attributes structure contains static information of a MB++ entity. Dynamically changeable/modifiable information is stored in status structures. • struct mb_server_attr_t • struct mb_sockaddr_t *mb : represents a socket address where MB++ server is opening a socket • struct mb_sockaddr_t *spd : represents a socket address where D-Stampede server is opening a socket • char *name : represents the name of a MB++ server • Bla • struct mb_producer_attr_t • char *name : represents the name of this producer • struct mb_stream_attr_t *stream : represents the attributes of the stream produced by this producer. • struct mb_server_attr_t *server : represents the MB++ server which this producer is connecting to. • struct mb_consumer_attr_t • char *name • struct mb_stream_attr_t • long start : the (real) time in msec since the epoc when this stream started. • long end : the (real) time in msec since the epoc when this stream ended. If this stream is an ongoing live, this must be 0 meaning unfinished.

  15. MB++ Server Advertisement • int mb_advertise_server(mb_server_attr_t *attr) • Description • Advertise the existence of a server to a MB domain. Every MB++ server must advertise itself using this function when it started running. • Parameters • attr <out> : a pointer to a buffer that includes a server attribute. • Returns • An integer representing an advertisement descriptor, or an error code (UNDEFINED yet). • Constraints • Advertisement descriptor is unique in each instance of Naming / Lookup Layer. In other words, the uniqueness may not be guaranteed in a MB domain-wide. • [MEMORY] No memory allocation across functions. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  16. MB++ Producer Advertisement • int mb_advertise_producer(mb_producer_attr_t *attr) • Description • Advertise the existence of a producer. Every MB++ server must advertise itself using this function when it started running. • Parameters • attr <out> : a pointer to a buffer that includes a producer attribute. • Returns • An integer representing an advertisement descriptor, or an error code (UNDEFINED yet). • Constraints • Advertisement descriptor is unique in each instance of Naming / Lookup Layer. In other words, the uniqueness may not be guaranteed in a MB domain-wide. • [MEMORY] No memory allocation across functions. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  17. MB++ consumer Advertisement • int mb_advertise_consumer(mb_consumer_attr_t *attr) • Description • Advertise the existence of a consumer. Every MB++ server must advertise itself using this function when it started running. • Parameters • attr <out> : a pointer to a buffer that includes a consumer attribute. • Returns • An integer representing an advertisement descriptor, or an error code (UNDEFINED yet). • Constraints • Advertisement descriptor is unique in each instance of Naming / Lookup Layer. In other words, the uniqueness may not be guaranteed in a MB domain-wide. • [MEMORY] No memory allocation across functions. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  18. MB++ Stop Advertisement • int mb_stop_advertisement(int ad) • Description • Stop advertisement for the specified advertisement descriptor, which is returned by one of advertisement functions. If no advertisement exists for the descriptor, this returns an error code (UNDEFINED yet). • Parameters • ad <in> : an advertisement descriptor. • Returns • An integer representing an advertisement descriptor. • Constraints • Advertisement descriptor is unique in each instance of Naming / Lookup Layer. In other words, the uniqueness may not be guaranteed in a MB domain-wide. • [MEMORY] No memory allocation across functions. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  19. MB++ Server Finding (1) • int mb_find_server( long timeout_msec, struct mb_server_attr_t ** attrs ) • Description Locate MB++ servers in a MB domain in the given amount of time. Returns the number of servers, or an error code (UNDEFINED yet). If no server exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new server appears in the segment. If timeout_msec is 0, this call immediately returns whether or not a server exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where server attributes will be stored. • Returns • An integer representing the number of servers running in the domain, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_server_attr_t. Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  20. MB++ Server Finding (2) • int mb_resolve_server( long timeout_msec, struct mb_server_attr_t *template, struct mb_server_attr_t **attrs ) • Description • Locate an MB++ server in a MB domain that match the template in the given amount of time. When one or more servers are found, the attrs buffer are allocated, otherwise NULL will be set to attrs. If no server exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new server appears in the domain. If timeout_msec is 0, this call immediately returns whether or not a server exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • template <in> : a pointer to a buffer containing a template attribute. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where server attributes will be stored. • Returns • An integer representing the number of servers in the domain that match the template, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_server_attr_t. Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  21. MB++ Producer Finding (1) • int mb_find_producer( long timeout_msec, struct mb_producer_attr_t ** attrs ) • Description Locate MB++ producers in a MB domain in the given amount of time. Returns the number of producers, or an error code (UNDEFINED yet). If no producer exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new producer appears in the domain. If timeout_msec is 0, this call immediately returns whether or not a producer exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where producer attributes will be stored. • Returns • An integer representing the number of producers in the domain, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_producer_attr_t . Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  22. MB++ Producer Finding (2) • int mb_resolve_producer( long timeout_msec, struct mb_producer_attr_t *template, struct mb_producer_attr_t ** attrs ) • Description • Locate an MB++ producer in a MB domain that match the template in the given amount of time. When one or more producers are found, the attrs buffer are allocated, otherwise NULL will be set to attrs. If no producer exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new server appears in the segment. If timeout_msec is 0, this call immediately returns whether or not a producer exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • template <in> : a pointer to a buffer containing a template attribute. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where server attributes will be stored. • Returns • An integer representing the number of producers in the domain that match the template, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_producer_attr_t . Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  23. MB++ consumer Finding (1) • int mb_find_consumer( long timeout_msec, struct mb_consumer_attr_t ** attrs ) • Description Locate MB++ consumers in a MB domain in the given amount of time. Returns the number of consumers, or an error code (UNDEFINED yet). If no consumer exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new consumer appears in the domain. If timeout_msec is 0, this call immediately returns whether or not a consumer exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where consumer attributes will be stored. • Returns • An integer representing the number of consumers in the domain, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_consumer_attr_t . Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  24. MB++ consumer Finding (2) • int mb_resolve_server( long timeout_msec, struct mb_consumer_attr_t *template, struct mb_consumer_attr_t ** attrs ) • Description • Locate an MB++ consumer in a MB domain that match the template in the given amount of time. When one or more consumers are found, the attrs buffer are allocated, otherwise NULL will be set to attrs. If no consumer exists in the domain when this function is invoked, the caller will be blocked for timeout_msec milliseconds or until a new server appears in the segment. If timeout_msec is 0, this call immediately returns whether or not a consumer exists. If timeout_msec is less than 0, this call will never timeout. • Parameters • timeout_msec <in> : specifies the amount of time that the caller can wait for. • template <in> : a pointer to a buffer containing a template attribute. • attrs <out> : a pointer to a buffer, malloc’ed in this function, where server attributes will be stored. • Returns • An integer representing the number of consumers in the domain that match the template, or an error code (UNDEFINED yet) when an error occurs. • Constraints • [MEMORY] This function malloc’s one or more struct mb_consumer_attr_t . Callers must free them. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  25. Note for Implementation • Use of Bonjour (a.k.a. Rendezvous from Apple) could make implementation and its operation easier. • http://developer.apple.com/networking/bonjour • Bonjour limits the amount of traffic per second, so that implementer should be aware of that. • Maximum of 10 lookup/advertisement/update traffic per second • I (Jin) want to avoid use of any centralized server-based directory/lookup servers, since it brings us additional work load for operation. • LDAP, etc.

  26. Client Common implementor: Nate

  27. Client Common API • int mb_connect( struct mb_server_attr_t *server) • Connects to a MB++ server’s bare socket interface. • int mb_disconnect( struct mb_server_attr_t *server) • Disconnects from a MB++ server’s bare socket interface. • int mb_listen_command ( int clientDescriptor, long sleepMsec ) • Counts the number of unread server commands. • int mb_read_command ( int clientDescriptor, struct mb_command_t *cmd ) • Reads the next server command from command queue 1. • int mb_write_reply ( int clientDescriptor, struct mb_producer_status_t *status ) • Updates a producer status stored in the status register 0.

  28. Data Structures • struct mb_server_stat_t • The number of consumers chained to this producer • How many consumers are currently connected. • The chain of transformers acting on this stream • How many transformers are working, and what order. • Business • How busy the server is. • What else? • struct mb_command_t • long timestamp : a long integer representing the time • int dataType : an integer representing the type of the data. • int bufSize : an integer representing the size of this data • void *command_reply : a buffer containing a command or a reply • struct mb_reply_t • long timestamp : a long integer representing the time • int dataType : an integer representing the type of the data • int reply : an integer representing SUCCESS, or FAIL • Int bufSize : an integer representing the size of this data • void *data : a buffer containing a producer’s/consumer’s/server’s status info. • struct mb_data_t • long start : a long integer representing the start (real) time of this data • long end : a long integer representing the end (real) time of this data • int bufSize : an integer representing the size of this data • void *data : the data • struct mb_qos_params_t • int priority :an integer representing a priority value between 1 and 9. Default is 5.

  29. Figure-Clients State- inactive mb_{producer|consumer}_create mb_{producer|consumer}_destroy mb_{producer|consumer}_start mb_{producer|consumer}_stop active mb_{producer|consumer}_destroy

  30. Upstream/Downstream Queues A producer’s case item = readFromQueue; If(item is a producer command){ process the command; write a server reply: }else{ // item is a producer reply check the reply; update my status; } If(need to dispatch command){ write a server command; } mb_read(stream); item = mb_read_command; If(item is a server command){ process the command; write a producer reply: }else{ // item is a server reply check the reply; update my status; } If(need to dispatch command){ write a producer command; } mb_write(stream); upstream PC1 PC2 PC3 PR1 PC4 PC5 PR2 PR3 PC6 PR4 PR5 PR6 SC6 SC5 SC4 SR6 SC3 SC2 SR5 SR4 SC1 SR3 SR2 SR1 downstream

  31. Downstream Queue • A producer reads server commands or replies from this queue. This queue is FIFO ordered. • Server replies contains the same timestamp as the corresponding producer commands. • The producer creates a producer reply for each server command with the timestamp of the command. • This queue must be read entirely by the producer before dispatching commands through the upstream command queue. • Server-to-producer commands • Find LUB data type • the LUB of data types requested by consumers • Find [LUB or LCD] transmission rate • the LUB/LCD of the requested transmission rates • Receive QoS requests from MB server

  32. Server Command-Check/Wait Server Command- • int mb_listen_command ( int clientDescriptor long sleepMsec ) • Description • Counts the number of unread server commands or replies. Parameter sleepMsec can be used to control blocking/non-blocking policy. If sleepMsec is 0, this function returns as quick as possible after counting the unread server items. If it is more than 0, it blocks as maximum as that time until valid items arrive. If it is less than 0, it blocks for unlimited time until valid items arrive. “Well-behaved” producers read every item and write replies each time before writing a chunk of data to their data channels. “Well-behaved” consumers read every item and write replies each time before reading a chunk of data from their data channels. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • sleepMsec <in> : a long integer representing an amount of time to wait for the next command. • Returns • An integer representing the number of unread command. Can be 0. • Errors • Invalid descriptor • Server not responding • Constraints • This function must not be invoked before starting the producer or consumer. • The client descriptor is unique in a process. • [MEMORY] • [THREAD]

  33. Server Command-Read Server Command- • int mb_read_command( int clientDescriptor, struct mb_command_t *cmd ) • Description • Reads the next server command from downstream queue. If no command is found in the queue, this call waits for the next command available. The producer writes a producer reply to the upstream queue for each server command. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • cmd <out> : a pointer to a pre-allocated command/reply buffer. • Returns • On success ?. • Errors • Invalid descriptor (not yet started, not a producer) • Server not responding • Constraints • This function must not be invoked before starting the producer. • The client descriptor is unique in a process. • [NOTE] we may need an up-call interface to process commands and replies. • [MEMORY] • [THREAD]

  34. Producer Status • int mb_write_reply( int clientDescriptor, struct mb_reply_t *reply ) • Description • Write a reply, through a producer’s or consumer’s upstream queue, for a command issued by the server. This updates a producer/consumer status stored in the server. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • reply <in> : a pointer to a status buffer. • Returns • On success ?. • Errors • Invalid descriptor (not yet created, not a producer) • Server not responding • Constraints • This function must not be invoked before starting the producer. • The client descriptor is unique in a process. • [MEMORY] • [THREAD]

  35. Producer design: jin implementor: Eric

  36. Producer API • int mb_create_producer ( struct mb_server_attr_t *server, char *name, void *func, struct mb_producer_attr_t *producer ) • Allocates resources required to run a new producer. • int mb_start_producer ( int clientDescriptor, int argc, void **argv ) • Start running a producer specified by a client descriptor. • int mb_stop_producer ( int clientDescriptor ) • Stop running a producer specified by a client descriptor. • int mb_destroy_producer ( int clientDescriptor ) • Destroy a producer specified by a client descriptor. • int mb_set_access_key ( int clientDescriptor, char *key ) • Sets an access key to require consumers on connection. • int mb_request_producer_qos ( int clientDescriptor, struct mb_producer_qos_params_t *qos ) • Request a certain set of QoS parameters for this producer. • int mb_listen_command ( int clientDescriptor, long sleepMsec ) • Counts the number of unread server commands. • int mb_read_command ( int clientDescriptor, struct mb_command_t *cmd ) • Reads the next server command from command queue 1. • int mb_write_reply ( int clientDescriptor, struct mb_producer_status_t *status ) • Updates a producer status stored in the status register 0. • int mb_write ( int clientDescriptor, struct mb_data_t *data ) • Write a chunk of stream to the channel.

  37. Overview • Producer is an MB entity that creates a stream, transmits the stream to the server, answers requests for lower/higher fidelity of types issued by the server, and possibly inject transformers to the server. • Producer is required to create a type map that represents relationships between types in terms of their fidelity. The transformers should be located between two different fidelities of types. • Virtual Time Stamp

  38. Figure MB++ Type Server MB++ server producer clientDescriptor producer command upstream queue producer reply data channel consumer server command data channel downstream queue T server reply T P channelDescriptor profiler Per-producer resources

  39. Producer Behavior Sequence producer server mb_connect mb_create_consumer mb_start_consumer mb_stop_consumer mb_destroy_consumer mb_disconnect

  40. Data Structure • struct mb_producer_stat_t • struct mb_producer_attr_t *attr : a pointer to the static information of this producer • char *securityKey : a pointer to an array of char containing the key • mb_qos_params_t *qos : a structure holding the current QoS parameters

  41. Upstream Queue • The producer commands, except for “Join the system”, are written into the upstream (producer to server) queue. The server reads producer commands from the queue in FIFO order. • Commands must be ordered with the non-over wrapping timestamp. • The server will write replies for the commands with the same timestamp as the commands to the downstream (server to producer) queue. Note that the downstream queue will also contains server commands dispatched to the producer, so the producer is responsible to switch the operation based on the item’s type, namely a reply or a command. • These commands will fail if the downstream queue contains items, meaning the existence of unprocessed server commands or replies. • Producer command • Join the system makes producer available for consumer to connect. • Get server status Requests the current server status related to this producer. • Set access rights modify who is allowed to connect to this producer. • Declare type set the set of types this producer is capable of producing, and the min/max transmission rate for each. • Request QoS Issues a certain value of a QoS parameters set, so that the producer be treated with by the server nicely. The parameter set includes priority. • Leave the system makes producer unavailable.

  42. Producer Command-Join the System- • int mb_create_producer( struct mb_server_attr_t *server, char *name, void *func, struct mb_producer_attr_t *producer ) • Description • Allocates resources required to run a new producer, if the specified server found, and it’s not too busy, and also the specified name doesn’t exist in the MB++ domain. Resources allocated by this function includes (1) mb_producer_attr_t, (2)command queues, (3)status registers, (4)a data channel, and (5) an infrastructure (D-Stampede in the initial impl) thread. • Parameters • server <in> : a set of attributes of a server to connect to. • name <in> : a string representing the name of this producer. The name must be unique in a single MB++ domain, so that if there is another producer who has the same name, this call will fail. • func <in> : a pointer pointing the entry to this producer’s body. • producer <out>: a pointer to a producer attribute created in this function. When this function returns, producer will contain the specified name and server attributes. To start the producer, the caller must fill in the rest of the attributes. • Returns • An integer representing a client descriptor, or an error code. • Errors • There is already another producer having the same name as this one. • Server not found • Server too busy • Server not responding • No such function (func is NULL or less than 0, probably) • Constraints • A return value (client descriptor) represents the producer just created, so the descriptor must be mapped to the mb_producer_attr_t during in this function. • The client descriptor is unique in a process. • This function cannot rely on Stampede’s channels/queues/registers since they are not allocated yet. So we need a bare socket interface to accommodate this. • [MEMORY] Param producer is allocated in this function. The caller must free the memory after leaving from MB++ system. • [THREAD] Multi-thread safe. Multiple threads can call this concurrently or parallelly.

  43. int mb_start_producer( int clientDescriptor, int argc, void **argv ) • Description • Start running a producer specified by a client descriptor, by invoking the specified function with arguments. Before invoking the function, this invokes mb_advertise_producer and other necessary functions. • Parameters • clientDescriptor <in> : an integer representing a producer in “inactive” state. • argc <in> : an integer representing the number of arguments passed to this producer • argv <in> : an array of pointers passed to this producer • Returns • An integer representing a client descriptor, or an error code. • Errors • Invalid thread (caller thread different from the creation thread) • Invalid descriptor (not yet created) • Specified producer is already started. • Server too busy. • Server not responding • Constraints • On success, the return value is equal to the parameter clientDescriptor. • The client descriptor is unique in a process. • [MEMORY] No memory allocation across functions. • [THREAD]

  44. Producer Command-Leave the System- • int mb_stop_producer( int clientDescriptor ) • Description • Stop running a producer specified by a client descriptor. This causes the threads in the MB++ server stop reading/writing through the allocated resources. But the resources are not released yet, and they are reusable. If this producer is already stopped, this function does nothing. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • Returns • An integer representing a client descriptor, or an error code. • Errors • Invalid descriptor (not yet created, or already destroyed) • Server not responding • Constraints • On success, the return value is equal to the parameter clientDescriptor. • The client descriptor is unique in a process. • Call the mb_stop_advertisement • [MEMORY] No memory allocation across functions • [THREAD]

  45. int mb_destroy_producer( int clientDescriptor ) • Description • Destroy a producer specified by a client descriptor. This causes the resources allocated by the producer to be released. If the producer specified by clientDescriptor is not yet stopped, this function first stops it. If this producer is already destroyed, this function does nothing; it is not an error. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • Returns • An integer representing a client descriptor, or an error code. • Errors • Invalid descriptor (not yet created) • Server not responding • Constraints • On success, the return value is equal to the parameter clientDescriptor. • The client descriptor is unique in a process. • Call the mb_stop_producer internally. • [MEMORY] No memory allocation across functions • [THREAD]

  46. Producer Command-Set Access Rights- • int mb_set_access_key( int clientDescriptor, char *key ) • Description • Sets an access key to require consumers on connection. This function must be called before starting the producer. The key first is transmitted to the server through the producer command channel, and then it’s successful, this function updates the status structure of the producer. The structure will be written to the producer command queue. The MB++ server actually changes the producer’s key, and updates the producer’s state structure in the ??? register with the new key. • Parameters • clientDescriptor <in> : an integer representing a producer in “inactive” state. • key <in> : a pointer to a pre-allocated array of char containing a key. Can be NULL. • Returns • An integer representing a client descriptor, or an error code. • Errors • Invalid descriptor (not yet created) • Already started • Server not responding • Constraints • On success, the return value is equal to the parameter clientDescriptor. • The client descriptor is unique in a process. • Wrap the parameter into mb_command_t. • [MEMORY] Copy the string specified by key, so that the caller can free the memory after this. • [THREAD]

  47. Producer Command-Request QoS- • int mb_request_producer_qos( int clientDescriptor, struct mb_producer_qos_params_t *qos ) • Description • Request a certain set of QoS parameters for this producer. The only parameter currently supported is priority. The priority affects on how well the particular producer is treaded by the MB++ server. This function can be called before or after starting the producer. The MB++ server actually changes the producer’s priority, and updates the producer’s state structure in the ??? register with the new priority value. If the specified parameter set is semantically the same as current, this function does nothing. • Parameters • clientDescriptor <in> : an integer representing a producer. • qos <in> : a pointer to a pre-allocated QoS parameter structure. • Returns • An integer representing a client descriptor, or an error code. • Errors • Invalid descriptor (not yet created, not a producer) • Invalid priority value • Server not responding • Constraints • On success, the return value is equal to the parameter clientDescriptor. • The client descriptor is unique in a process. • Wrap the parameter into mb_command_t. • [MEMORY] • [THREAD]

  48. Producer Command-Declare Type Set- • TBD • Based on the type server API

  49. Data Channel • A producer writes a chunk of stream to the channel. The chunk is asynchronously read by the MB++ server. • Constraints • The producer must keep its rate requested by the server through server commands.

  50. Write Channel • int mb_write( int clientDescriptor, struct mb_data_t *data ) • Description • Write a chunk of stream to the channel. The producer must entirely read the downstream queue before writing the data. • Parameters • clientDescriptor <in> : an integer representing a producer in “active” state. • data <in> : a pointer to a data buffer. • Returns • On success ?. • Errors • Unprocessed items in the downstream queue • Invalid descriptor (not yet created, not a producer) • Server not responding • Constraints • This function must not be invoked before starting the producer. • The client descriptor is unique in a process. • Increment the Stampede timestamp to trigger garbage collections. • [MEMORY] • [THREAD]

More Related