Bag architecture

Introduction

TBD add a schema with the interaction from the outside and a global description of what is generic, what can be refined by the programmer, ...

Bag primitives

1-Creation/destruction

To create a customize bag, you must begin to create a python module prefixed by "bag_".

In this, module, you create a new class named "Behavior" and herited of "LINC.Bags.bag_Meta.Behavior"

(or a sub-herited class like "LINC.Bags.bag_Bag.Behavior" or "LINC.Bags.bag_Template.Behavior").

For customize intialization of your bag, you can override 2 functions:

  • def init(self, args) The bag constructor with args for bag context

  • def init(self) This function is called by container in ending of associating with its object (All bag fields are initialized).

  • def can_be_destroyed(self, why) Return True if this bag can be destroyed.

Functions involved by the coordination protocol

Precondition

To implement bag precondition, you must override the 3 functions:

  • def bagaction_openstream(self, mask) create a new resource search stream in bag.'mask' is a tuple of resource to search in the bag. '*' is used for joker. The function must return the stream_id associate to this searching.

  • def bagaction_read(self, stream_id) Return a tuple contains the stoage_id and the resource associated to this 'stream_id' searching. If all value are returned, this function must returned a double of 'LINC.Lib.const.NO_MORE_RESOURCE' constant.

  • def bagaction_closestream(self, stream_id) Close the 'stream_id' searching.

  • def get_list_of_aspects(self) Return list of aspects associate to this bag.

Performance

To implement bag performance, you must override the 4 functions:

  • def bagaction_put(self, resource) Store in memory 'resource' and return a 'storage_id' associated to allow to confirm or release this new data. If this put is not avalable, return LINC.Lib.const.RESULT_FAIL

  • def bagaction_get(self, resource) Store in memory a existing 'storage_id' (returned by a set of bagaction_openstream/bagaction_read/bagaction_closestream) like reserved. Return 1 if succes, -1 if this resource doesn't not exist and 0 if another transaction as yet reserved.

  • def bagaction_release(self, storage_id) Release 'storage_id' read/get or put

  • def bagaction_confirm(self, storage_id) Confirm action about 'storage_id'. If it is associated to a put: new resource is added in the bag. If it is associated to a get: resource is remove in the bag

TBD how do we do a read ?

4-Advanced functions

Others functions can be called within the object hosting the bag.

  • def get_resource_list(self, mask, number) Return a list of resources defined by 'mask'. If 'number'#0, return all resources, else return 'number' first resources. The default is an empty list for "LINC.Bags.bag_Meta.Behavior" object.

  • def get_resource_count(self, mask) Return number of resources for this 'mask'.

Aspects

TBD