| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 2322.2 | some clarification | CHOVAX::CUSATO | surname=Cusato/given=Robert/loc=CHO | Wed Feb 24 1993 20:57 | 27 | 
|  |     I will attempt to clarify...
    
    The application I am working on has nothing to do with ALL-IN-1... The
    only similarity is that the application manages many files, each
    requiring a unique name. 
    
    The application uses the DEC Storage Monitor to store files using an
    optical jukebox and magnetic caches (actually directories). When
    calling the Storage Monitor to save a file, the application must
    provide a unique filename for storing the file. The Storage Monitor
    acts on the filename with a hashing algorithm to select a directory on
    magnetic or optical to store the file. 
    
    So, the problem is to generate a unique filename. The filename can be
    totally random... The application will save the filename (actually a
    'tag') in a database to facilitate retrieval. 
    
    It was my impression that the filename portion of the file spec used by
    ALL-IN-1 (ie: zxcvbnma) was generated based on the date/time and is always
    unique. If so, my question is ... Is it possible to use this
    algorithm from another application? I certainly would not want to call
    ALL-IN-1 or use ALL-IN-1 facilities. Basically, I was looking to use
    the specific algorithm or the idea behind the algorithm. 
    
    I hope this clears up the question. Thanks for any replies. 
    
    Bob
 | 
| 2322.3 | We use a lock value block - you could do the same | IOSG::SHOVE | Dave Shove -- REO2-G/M6 | Thu Feb 25 1993 10:32 | 21 | 
|  |     It used to be generated purely from the date/time; we thought this
    would always be unique (don't forget, back in '82 when this was
    designed the largest VAX processor available was the 780, and clusters
    were just a twinkle in a few folks' eyes ;-))
    
    It turned out that it sometimes generated non-unique filenames,
    especially on clusters, so we changed the algorithm to include a number
    (which ranges from 1 to 40,000) which is guarenteed unique across a
    cluster as it's held in a Lock Value Block. 
    
    This lock is always held by at least one process (if all ALL-IN-1 users
    log out, the OAFCV process holds it - this is a tiny program (88 lines
    of Bliss source, including comments and Copyright notice!) which just
    takes out a lock on the resource, converts it NULL and Hibernates for
    ever). The lock resource is called OA$FILE_CREATION_LOCK, by the way.
    
    Your application could obviously use a similar algorithm. If
    performance isn't as critical as ours was, you can hold the unique
    number in a file instead of in a Lock Value Block.
    
    Dave.
 | 
| 2322.4 | re: 1.,.3 | CHOVAX::CUSATO | surname=Cusato/given=Robert/loc=CHO | Thu Feb 25 1993 14:02 | 11 | 
|  |     re: .1, .3     Thanks
    
    I am familiar with the use of a lock value block for synchronization of
    a value in a cluster... What I am still unclear on is how the unique
    number (1-40000) is used to generate a unique filename string...
    
    Can a pointer to the specific source be provided?
    
    Thanks,
    
    Bob
 | 
| 2322.5 | Here's the algorithm we use | IOSG::SHOVE | Dave Shove -- REO2-G/M6 | Fri Feb 26 1993 15:18 | 56 | 
|  |     I'm sure that all kinds of rules prevent me putting source in here.
    
    However, I will put in the comments from the relevant module, which
    explain the algorithm.
    
    Dave.
    
!+
! This routine makes up a file name form the current date/time.
! This might be a good candidate for an RTL routine.
!
! Previous commentary (author unknown) said:
! " However, it should be modified so that PROCESS slot is included in
! the name so that it's truly unique in the system."
!
! In fact what we have done here is to attempt to make it unique in a cluster
! by using a scheme devised by Stuart Maurice based on the current date,
! minutes since midnight and a "unique" number which is a cluster-wide
! resource (OA$FILENUMBER_CREATION_LOCK). This number has a range of 0 - 40,000.
!
! The first char is always a 'Z'. The next 3 chars are an expression of the
! days since Nov 17, 1858. in RADIX-26 as before. (In order to try and avoid
! conflicts when changing over to the new scheme, a one is added to "DAY"
! before conversion to RADIX-26.)
!
! The last 5 chars are produced like this:
! MIN is number of minutes since midnight.
! LVAL = "unique" cluster-wide value from OA$FILENUMBER_CREATION_LOCK
! NUM = 40000*MIN + LVAL
! NUM is then converted into 5 characters of RADIX-36 to make up the rest
! of the file name.
!
! This formula guarantees uniqueness assuming that no more that 40000 documents
! can be created cluster-wide per minute. Also there is an inherent assumption
! that a cluster node cannot reboot and be back running ALL-IN-1 within
! 1 minute (?!?).
!
! Additionally, there is the occasional case where the system time is changed
! (e.g. by � 1 hr for summer/winter time) when the limit will be 40000 files
! within 1 hour.
    Note -- "radix-26" means that the number is divided by 26 and the
    remainder added to ASCII "A" (so you get a letter A - Z), then repeat
    the process enough times (3 in this case) to get the quotient less than
    26.
    
    "radix-36" is the same, except that the remainder is added to ASCII "0"
    (zero) if it's between 0 and 9, or to (ASCII "A" - 10) if it's 10 or
    greater. (so you get a digit 0 - 9 or a letter A- Z). This is repeated
    5 times.
    
    So you get a total of 9 characters - "Z", then 3 from the radix-26 bit,
    then 5 from the radix-36 bit.
    
    Hope this helps,
    Dave.
 |