Ropa - callbacks
================

Thoughts by Love <lha@stacken.kth.se>

$Id: README,v 1.1 1999/11/12 04:50:19 lha Exp $

Design
======

Think before doing. This isn't that simple. Figure out a way to do
everything in O(1) but with minium memory requirement.

What sizes should we optimize for ? Linked list might be used for
small datasets.  W/o knowing anything, it seams many fids will have
few clients, and few fids will have many clients.

We need to have statistics. Guess we need to do it the simple way to get
statistics, and then do it the right way. KISS!

Data-storage
============

name = { contain } [ index1, index2, ... ]

client = { uuid, port, interfaceAddr, callbacks[] }
					[ interfaceAddr, uuid ( & port) ]
callback = { fid, client[] (, times[], heapptr[])  }
					[ fid ]

LRU(clients);
HEAP(callbacks);

Resolve
=======

fid -> { RW -> time(#clients), RO -> time(history) }
							[1]

fid -> clients[] \ sender-client			[2]

{callback (* time) * client} (heap) --> clients		[3]

client -> fids[]					[4]

Comments
========

Use UUID for all clients ? Cook and mark cooked for pre 3.5 clients.

[1] From a given fid we need to figure out a suitable time.

    Without thinking:

    * Callbacks on WR volumes should give
    back callback-times based on number of clients using this fid.

    * Callbacks on RO volumes should be based on how often volumes
    are released (average - (timenow() - lasttime())) * rand(10).
    The rand is to avoid fetch-storms.

[2] When breaking callbacks we need to get all clients.
    This need to be storted on UUID so we can avoid sending cb
    to the client.

[3] Should callbacks be given all to the same time, or should diffrent
    clients have diffrent callbacks ? Will we get fetch-storms when
    callbacks expire for wellused files (or RO volumes).

[4] We need to query the client when i contacts us the first time
    There is also need to break fids when clients fall out of the lru.

Lock order and expiration
=========================

The easy way out might be to globallock the whole module except a
expirationthread. In this module all enterence function must enter
with complete data. There must also be a way to function to match
(addr,port) -> uuid.
