Leave feedback
  • Discussion

    HAFT script functions: Thread safe (cluster environment friendly) script functions

Enter a new topic
  • Anders Ekstrom Anders Ekstrom
    0 likes 2761 views

    I propose that posts to this discussion will be about script functions that are safe / not safe to use in a clustered environment.

    My first question is regarding getserno(), is it possible to use this in a clustered environment (by placing the table file containing the number sequence on a shared disk / common disk area) - or do you have to create your own similar function using e.g. a database or other solution?

    GetSerNo

    Syntax:

    GetSerNo(str_path, str_key);

    Description:

    Calculates the next counter value in a number sequence according to a specified key. Returns the next counter value and amends the value to the number sequence.

    Accepts:

    A string (str_path) specifying the path and filename of the file containing the number sequence, and a string (str_key) specifying the key.

    Returns:

    A number specifying the next value in a number sequence.

    Monday 18 January, 2010
  • Anders Ekstrom Anders Ekstrom
    0 likes

    I reply to my own message because I recieved an answer from Henrik W on email (very roughly translated by me):

    "The only safe way is to use a database (implementing script-functions and appropriate table for this by yourself) OR use separate table files. If you use separate tables I would rather use a counter per server and then add the server number e.g.  ”myfilename_serverno_serno” = mynewinvoices_1_00035.pdf.

    Note: A database version of getserno might be delivered by R&D later on - but a date is not set for this"

    Thanks Henrik. /A
    Monday 18 January, 2010
  • Stefan Cohen Stefan Cohen StreamServe Employee Administrator
    0 likes

    How about: CreateGlobalSerNo(key, initial, min, max); GetGlobalSerNo(key); GetGlobalSerNoRange(key, range); These are available in SP4. ClusterSafe table functions are in progress for some other release.

    Monday 18 January, 2010
  • Henrik Wejdmark Henrik Wejdmark StreamServe Employee Administrator
    0 likes

    Excellent news!

    //Cheers

        Henrik

    Monday 18 January, 2010
  • Jérôme Tison Jérôme Tison Partner
    0 likes

    Hi,

    Do you have guidelines/ best practices on how to use tbl files on a cluster environment ?

    Regards,

    Jérôme

    Friday 11 June, 2010
  • Stefan Cohen Stefan Cohen StreamServe Employee Administrator
    0 likes

     Jérôme,

    Tbl files doesn't mix well with cluster environments as the read/writes aren't transactional. The main advantages of tbl files are that they are easy to use, deploy and that they are very fast (especially when kept in memory). 

    The only best practice that I found on short notice is this from the cluster guidelines (available here)

    Scripting functions
    When using scripting functions in the StreamServe Project, you must be aware of  how and where these functions access and store data.

    • Avoid (or use with caution) any scripting functions that store data temporarily on the local disk. In a failover or load balancing situation, such data is not available to the other StreamServer applications. This concerns, for example, the substitution table functions (Subst).
    • If you want to create or access the value of a serial number in a numbered sequence, you must use the GlobalSerNo scripting functions (CreateGlobalSerNo, SetGlobalSerNo, (GetGlobalSerNoRange). Do not use the SerNo functions (SetSerNo, GetSerNo), since this may cause conflict when several StreamServer applications try to create or access the same number.

     

    For cluster environments i would personally prefer a custom database table and to access it using the ODBC scripting functions.

    Standardised relational database-based tbl functions is something we have on our todo list for a future version.

     

     

    Friday 11 June, 2010
  • Jérôme Tison Jérôme Tison Partner
    0 likes

    Hello Stefan,

    You confirmed my thoughts about substitution table functions.

    Standardised relational database-based tbl functions is really a great news. Is it planned for SP5 ?

    Monday 14 June, 2010
  • Stefan Cohen Stefan Cohen StreamServe Employee Administrator
    0 likes

    It is not in the SP5 scope. It originally was, but had to be dropped for functionality with higher priority. We'll see if it makes the cut for SP6.

    Monday 14 June, 2010
  • L vd M L vd M
    0 likes

    Nice function (GlobalSerNo). But how is it possible to delete those key? Is there a overview/list about all used keys?

     

    Regards,

    Luc

    Friday 16 October, 2015