EntityManager.findEntities(arg0, arg1, arg2, arg3, arg4, arg5, arg6)

Has anyone used the Entity Manager findEntities or findChildEntities method. I am trying to find out what each of the input parameters represent.
There is no documentation for EntityManager in the OIM API documentation.
Thanks in advance

Thank you very much for that and the quick response.
I am hoping I can fill in the description for these parameters. I got the description from the oracle.iam.identity.usermgmt.api.UserManager.Search() function, so they more or less they should match the description for the entity manager.findentities() parameters.
The only thing missing here would be the EntityType which can be "User" this is to retrieve a user entity. or you can do orchestration.getTarget().getType() if you have the orchestration object
Parameters:
criteria - The search criteria based on which entries will be retrieved from the backend. The SearchCriteria Operators supported are AND, OR, NOT, GREATER_THAN, GREATER_EQUAL, LESS_THAN, LESS_EQUAL, EQUAL and NOT_EQUAL. For additional comparisons like contains the SearchCriteria Operator will be EQUAL with value to be searched will be '*<value>*'
retAttrs - The list of attributes which are to be returned for each user.
There are four configuration parameters. STARTROW, ENDROW, SORTEDBY and SORTORDER.
The STARTROW and ENDROW search configuration parameters indicates which subset of the complete search result is to be fetched.
The SORTEDBY search configuration parameter indicates the attribute on which search result is to be sorted.
The SORTORDER search configuration parameter indicates the order of sorting. There are two possible values for this parameter. To sort the result in ascending order use SortOrder.ASCENDING and to sort the result in descending order use SortOrder.DESCENDING. This parameter is optional and is set to SortOrder.ASCENDING by default.
Returns:
the list of users which matched the search criteria. This list is filtered based on the attribute and entity permissions of the logged-in User.

Similar Messages

  • Network.addNode (arg1,arg2,arg3) is there a bug in Spatial Java API ?

    Hi
    when I try to add a Node on a Link to the Network - I'm really confused. I have a LinearLineString {0 0 10 0). When I try to add a Node on the position (2,0) my first new Link have the right coordinates (0,0,2,0) but the second new link have the coordinates (2,0,8,0) when I expected (2,0,10,0)?
    maybe somebody have any idea?
    Thanks Jens
    //new SDONetwork
    Network net = NetworkFactory.createSDONetwork("myNetwork", 0, false, 0,
                        2);
    Node start = NetworkFactory.createSDONode(1, "start", 0, 0);
    Node end = NetworkFactory.createSDONode(2, "end", 10, 0);
    // LinkGeometry x=0 y=0 x=10 y=0
    JGeometry linkGeom = JGeometry.createLinearLineString(new double[] { 0,0,10, 0 }, 2, 0);
    try {
    net.addNode(start);
    net.addNode(end);
    net.addLink(NetworkFactory.createSDOLink(1, "firstLink", start,end, 1, linkGeom));
    //add new SDONode to Link
    Node n = net.addNode(net.getLink(1), 0.2, false);
    //all new Links on Node
    for (int i = 0; i < net.getNode(n.getID()).getIncidentLinks().length; i++) {
    for (int j = 0; j < net.getNode(n.getID()).getIncidentLinks()
    .getGeometry().getOrdinatesArray().length; j++) {
    System.out.println(net.getNode(n.getID())
    .getIncidentLinks()[i].getGeometry()
    .getOrdinatesArray()[j]);
    System.out.println("----");
    } catch (NetworkDataException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();

    Hi,
    This has been verified as a bug in 10203.
    You can track this bug in Oracle bug database.
    The bug number is 6070333.
    Regards,
    -Jack

  • ANE function parameters display as arg0, arg1, etc. how do I fix this?

    I am creating an ANE and all my functions that take parameters show them as arg0, arg1, arg2, etc..
    for example:
    ShowAlert(arg0:String, arg1:String, arg2:String = "Ok", arg3:Array = null)
    when it should be
    ShowAlert(title:String, message:String, defaultButtonText:String = "Ok", additionalButtons:Array = null)
    I did some searching and the only thing I was able to find was this:
    By default, these are defined as arg0 and arg1, but you can give them more descriptive names. Change the call() function definition to look like this:
    public FREObject call(FREContext context, FREObject[] passedArgs)
    from http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html
    hrm..
    I assume it's using flex (as pretty much everyone else is these days - I should get around to learning that) but I am using Flash Pro.
    Anyway, I don't really understand what he meant, so I started reading the rest of the document and I saw this line:
    Set the superclass to com.adobe.fre.FREContext.
    Hrm...
    Does this mean I am supposed my ANE is supposed to extend that? Right now, it's extending EventDispatcher.
    Regardless, can someone clarrify what he means, or what I am supposed to do to get my parameters appearing correctly?

    It does look like you want to extend FREContext.

  • Can WLW display the real names of method parameters, not arg0, arg1...

    Hello
    I am new to Java development and as I used to work with MS.NET usually rely on parameter names, so that I don't have to read documentations each time I use a method. However I noticed that WLW replaces the names of method parameters with arg0, arg1, arg2 etc. Is there a way to somehow make WLW display the real argument names and not those argX strings?
    Thanks in advance.
    Best regards,
    Vasil Svetoslavov

    In wlw select...
    Tools
    +-- IDE Properties
    --Editor
    Ensure that the following are Checked
    Use Method Completion
    Use Parameter Completion

  • EJB model showing arg1 , arg2 etc as input parameter attributes

    Hi All ,
    I am working on EJB models. I have done all required settings at EJB session and application dc and deployed EJB Dcs
    successfully. When i am adding application dc as used dc i can see public part which i have created for EJB model. when i create EJB model my input parameterts are not showing exact names. they are shown as agr1 ,arg2 etc. i have worked earlier
    on EJB models but never faced such issue. What can be reason for this? How to resolve this?
    Thnx in advance.
    Regards
    Kavita

    Hi,
    Check the procedure you followed in the below links if helpful:
    http://help.sap.com/saphelp_nwce10/helpdata/en/45/dd45e4bc295595e10000000a1553f7/content.htm
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20b21892-c31c-2a10-f484-fcef1eaf8c4f?overridelayout=true
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0914ef0d-0d01-0010-beb9-d85ef5a6188d?overridelayout=true
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e93a5c?overridelayout=true
    Using EJB as model
    Regards,
    Charan

  • Convert ORA_FFI to WEBUTIL_C_API to print locally

    I am trying to figure out how to convert this package to WEBUTIL_C_API to be able to print to a users local printer (EPSON slip printer)... ANY help would be appreciated...
    PACKAGE EPSON_SLIP_PRINTER_INTERFACE IS
    * This package provides functions to interact with the EPSON
    * TM-U295 slip printers.
    * The OPEN_PRINTER function must be called to obtain a printer ID.
    * This printer ID can then be used when calling other functions
    * that require a printer to be specified.
    * NOTE that the printer ID is only valid within the same thread
    * that called the OPEN_PRINTER function.
    * Brendan Rickey 2004-JAN-09
    -- AVAILABLE PRINTERS
    CHEQUE_PRINTER     VARCHAR2(50) := 'Generic / Text Only droite';
    INVOICE_PRINTER     VARCHAR2(50) := 'Generic / Text Only left';
    -- ERROR CODES
    -- Some of the provided functions return a NUMBER value that may hold
    -- an error code (negative number).
    -- These are the possible error codes:
    SUCCESS                    NUMBER := 0;     --no error
    ERR_TYPE               NUMBER := -10;     --parameter type error
    ERR_OPENED               NUMBER := -20; --printer already opened
    ERR_NO_PRINTER     NUMBER := -30;     --the printer driver does not exist
    ERR_NO_TARGET          NUMBER := -40;     --no printer found (could of off, faulty, unsupported)
    ERR_NO_MEMORY          NUMBER := -50;     --insufficient memory
    ERR_HANDLE               NUMBER := -60;     --invalid printer ID
    ERR_TIMEOUT               NUMBER := -70;     --time out error
    ERR_ACCESS               NUMBER := -80;     --cannot read/write to printer (printing in progress)
    ERR_PARAM               NUMBER := -90;     --parameter error
    ERR_OFFLINE               NUMBER := -110;     --printer was opened in offline state.  Status must be changed to online.
    ERR_NOT_EPSON          NUMBER := -120;     --printer is not an EPSON printer
    * INITIALIZE
    * Initializes the interface between Forms and the EPSON library (call before any other function in the package).
    * Returns:
    * TRUE if the library is registered successfully,
    * FALSE otherwise (library not found etc...)
    function INITIALIZE return BOOLEAN;
    * OPEN_PRINTER
    * Obtains a handle on the specified EPSON slip printer (either CHEQUE_PRINTER or INVOICE_PRINTER).
    * Returns:
    *           a printer ID for the specified printer (greater than 0)
    *           an error code on failure (less than 0):
    * ERR_TYPE, ERR_OPENED, ERR_NO_PRINTER, ERR_NO_TARGET, ERR_NO_MEMORY, ERR_PARAM
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER;
    * CLOSE_PRINTER
    * Releases the handle on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE on failure
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER;
    * IS_PAPER_OUT
    * Tests if there is no paper in the printer.
    * Returns:
    *           1 if there is no paper in the printer, 0 if paper is in the printer
    *           ERR_HANDLE or ERR_PARAM on failure.
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER;
    * PRINT_TEXT
    * Prints the specified text to the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER;
    * RELEASE_PAPER
    * Performs the Release function on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER;
    /* PRIVATE FUNCTIONS
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    END;
    PACKAGE BODY EPSON_SLIP_PRINTER_INTERFACE IS
    v_msg_b VARCHAR2(20);
    v_EPSON_LIBRARY_OK BOOLEAN:= FALSE;
    --ORA_FFI function handles and library handle
    lh_EpsStmApi ora_ffi.libHandleType;                    --DLL library handle
    fh_BiOpenMonPrinter ora_ffi.funcHandleType;          --DLL function handle
    fh_BiCloseMonPrinter ora_ffi.funcHandleType;     --DLL function handle
    fh_BiGetStatus ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIO ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIOEx ora_ffi.funcHandleType;               --DLL function handle
    --constant
    ASB_SLIP_BOF     PLS_INTEGER := 4*power(16,5);     --BOF printer status flag 0x00400000
    c_release_code      CHAR(2) := CHR(27)||CHR(113);     --ESC+q, to release the paper
    -------PRIVATE FUNCTIONS--------
    * Brendan Rickey 2004-JAN-09
    * The following are functions that are required to interface with the
    * EPSON StatusAPI DLL (C library) though ORA_FFI.
    * The following describes the DLL functions that are made available
    * through this ORA_FFI implementation:
    Function Purpose
    BiOpenMonPrinter Get a handle on a printer.
    Parameters
    p_Type --int: 1 if p_Name is a port, 2 if a printer name.
    ,p_Name --varchar2: the port of printer name to open.
    Return printer identifier number (>0) on success, < 0 on failure.
    BiCloseMonPrinter Close the monitor on the printer.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    Return 0 on success, < 0 on failure.
    BiGetStatus Returns the status of the printer.
    Parameters     
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_Status OUT --long: The status of the printer (use AND bitwise operator to test for statuses).
    Return 0 on success, < 0 on failure.
    BiDirectIO Sends data to and Reads data from the printer. Use BiDirectIOEx if more that 255 chars are to be written/read.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --short: The length of the command/data being sent to the printer (max 255).
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --short: The length of the data to be read from the printer (max 255)
    (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    Return 0 on success, < 0 on failure.
    BiDirectIOEx Sends data to and Reads data from the printer (handles larger quantities of write/read data).
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --long: The length of the command/data being sent to the printer.
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --long: The length of the data to be read from the printer (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    ,p_Option --short: 0 => prevents Automatic Status Back (ASB) during execution of this function (as does BiDirectIO).
    1 => does not disable Automatic Status Back (ASB).
    Return 0 on success, < 0 on failure.
    function icd_BiOpenMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    pragma interface(c, icd_BiOpenMonPrinter, 11265);
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER is
    begin
    return(icd_BiOpenMonPrinter(fh_BiOpenMonPrinter,
    arg0,
    arg1));
    end;
    function icd_BiCloseMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiCloseMonPrinter, 11265);
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiCloseMonPrinter(fh_BiCloseMonPrinter,
    arg0));
    end;
    function icd_BiGetStatus(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiGetStatus, 11265);
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiGetStatus(fh_BiGetStatus,
    arg0,
    arg1));
    end;
    function icd_BiDirectIO(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIO, 11265);
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIO(fh_BiDirectIO,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6));
    end;
    function icd_BiDirectIOEx(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIOEx, 11265);
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIOEx(fh_BiDirectIOEx,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6,
    arg7));
    end;
    --------PUBLIC FUNCTIONS--------
    function INITIALIZE return BOOLEAN IS
    BEGIN
    --When this is the first package function called, code in the package's
    --body is executed and sets v_EPSON_LIBRARY_OK.
    RETURN v_EPSON_LIBRARY_OK;
    END;
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER IS
         v_printer                    PLS_INTEGER;
         v_printer_name     VARCHAR2(50) := p_printer_name;
         v_name_type           PLS_INTEGER := 2; --use printer Name to specify printer     
    BEGIN
         /* Open a monitor for the printer */
         v_printer := BiOpenMonPrinter(v_name_type,v_printer_name);
         RETURN v_printer;
    END;
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER IS
    v_return PLS_INTEGER;
    BEGIN
    /* CLOSE the printer monitor */
         v_return := BiCloseMonPrinter(p_printer_id);
         RETURN v_return;
    END;
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER IS
         v_return          PLS_INTEGER;
         v_status          PLS_INTEGER := -123456;
    BEGIN
         /* Test if paper is in the printer by first getting the status (a binary integer) */
         v_return := BiGetStatus(p_printer_id,v_status);
         IF v_return <> 0 THEN
              RETURN v_return;
         ELSE
         --Test for BOF status flag
         IF WIN_API_BITOP.BITWISE_AND(v_status,ASB_SLIP_BOF) = ASB_SLIP_BOF THEN
              RETURN 1; --paper out
         ELSE
              RETURN 0; --paper in
         END IF;
         END IF;
    END;
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER IS
    v_return          PLS_INTEGER;
    v_text               VARCHAR2(2000) := p_text;
    v_text_len          PLS_INTEGER;                    --number of characters to be printed
    v_read_len      PLS_INTEGER := 0;               --number of characters to be read from the printer
    v_read_buff      VARCHAR2(255) := NULL;          --not used: holds characters read from the printer
    v_timeout      PLS_INTEGER := 1000;          --not used: amount of time to wait for response (msecs)
         v_nullTerm          PLS_INTEGER := 0;               --not used: 0 means read until reached v_read_len or v_timeout
         -- 1 means read until NULL received from printer
         v_option          PLS_INTEGER := 0;           --0 means do not answer other requests while printing
                                                                --1 means do not stop answering other requests while printing
    BEGIN
         --Get the number of chars to be printed and then print.
         v_text_len := length(p_text);
         v_return := BiDirectIOEx(p_printer_id,
         v_text_len,
         v_text,
         v_read_len,
         v_read_buff,
         v_timeout,
         v_nullTerm,
         v_option);
         --Ignore timeout(-70) errors, otherwise return error
         IF v_return = -70 THEN
              v_return := 0;     
         END IF;
         RETURN v_return;
    END;
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER IS
    BEGIN
    /* Release the paper by sending the release escape code to the printer */
         RETURN PRINT_TEXT(p_printer_id, c_release_code);
    END;
    -----END OF FUNCTION IMPLEMENTATIONS-----
    BEGIN
    * Load the EPSON printer driver's StatusAPI library.
    * Create an ORA_FFI interface to the library by doing the following for each desired function:
    *          1- Create a handle on the function,
    *          2- Register the return value,
    *          3- Register the arguments/parameters in the correct order.
    lh_EpsStmApi := ora_ffi.load_library('', 'EpsStmApi.DLL');
    IF Ora_Ffi.Is_Null_Ptr(lh_EpsStmApi) THEN
         AFC_MESSAGES('I','MAIN-0020','E',v_msg_b);
         v_EPSON_LIBRARY_OK := FALSE;
    ELSE
    fh_BiOpenMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiOpenMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    fh_BiCloseMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiCloseMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    fh_BiGetStatus := ora_ffi.register_function(lh_EpsStmApi, 'BiGetStatus', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    fh_BiDirectIO := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIO', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    fh_BiDirectIOEx := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIOEx', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    v_EPSON_LIBRARY_OK := TRUE;
    END IF;
    EXCEPTION
         WHEN OTHERS THEN
              AFC_MESSAGES('I','MAIN-0021','E',v_msg_b);
              v_EPSON_LIBRARY_OK := FALSE;
    END;

    Hi Duncan,
    Thanks for the response. Beyond the problem you pointed out I found that the "open server" command is requiring a window handle parameter, even though it isn't used by the program. I talked with Oracle Support and it turns out that even if the window handle isn't used, it's existence makes it not work with the current version of webutil.
    The program I am working with also has a COM interface, so I decided to back up and redo the interface using webutil OLE2. I've got it working now, just a little more polishing to do.
    Thanks again for the help.
    Mark

  • API problem

    I'm trying to load all the objects into Repository and it runs smoothly to load .fmb or .rpt files.
    But when I use my own API script to load some files written in AccessSQL from a Legacy system.
    Module Components are empty. There are nothing in there under the directory of "Module Components", "Modules", of "Repository Object Navigator".
    Could you please tell me what's wrong with my API?
    REM Process Name : MAPI1.SQL
    REM Module Name/Reference:N/A
    REM Module Type: PL/Sql
    REM Global Variables: N/A
    REM Process : API Call to insert module components .
    REM Calling Module: N/A
    REM Modification History :
    REM Comments:
    set serveroutput on size 1000000
    DECLARE
    module_to_add ciomodule_component.data; -- Property list for MODULE
    act_status varchar2(1); -- Activity status
    act_warnings varchar2(1); -- Activity warning flag
    mname varchar2(30); -- For Short name
    mlname varchar2(70); -- For Name
    Mpurp varchar2(70); -- For Purpose
    mtype varchar2(40); -- fOR tYPE
    cannot_init_appsys exception;
    no_matching_mod_found exception;
    CURSOR NEW_MODULE IS
    SELECT rtrim(a.app_file) app_file,rtrim(a.mod_name) mod_name,rtrim(a.purpose) purpose,c.id id
    FROM app_files a,app_dir b,ci_general_modules c
    where a.apdir_id = b.id
    and c.short_name = upper(b.appdir)
    and c.short_name = '&r';
    procedure instantiate_messages
    is
    m_facility varchar2(3);
    m_code number;
    arg1 varchar2(240);
    arg2 varchar2(64);
    arg3 varchar2(64);
    arg4 varchar2(64);
    arg5 varchar2(20);
    arg6 varchar2(20);
    arg7 varchar2(20);
    arg8 varchar2(20);
    begin
    -- Report all violations regardless of the activity status
    -- VIOLATIONS ARE SELECTED FROM THE API VIEW CI_VIOLATIONS
    for viol in (select * from ci_violations) loop
    dbms_output.put_line( cdapi.instantiate_message(viol.facility,viol.code,
    viol.p0,viol.p1,viol.p2,viol.p3,viol.p4,viol.p5,viol.p6,viol.p7 ) );
    end loop;
    -- Pop messages off the stack and format them into a single text string
    while cdapi.stacksize > 0 loop
    rmmes.pop( m_facility,m_code,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8 );
    dbms_output.put_line( cdapi.instantiate_message( m_facility,m_code,
    arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8 ) );
    end loop;
    end;
    BEGIN
    -- Initialize API if not already done
    if cdapi.initialized = false then
    -- Initialize the API globals
    cdapi.initialize(upper('spoc'),1);
    end if;
    -- Open a new activity
    dbms_output.put_line('Opening a new activity');
    cdapi.open_activity;
    for new_module_rec in new_module loop
    -- Get the module values and insert them into variables
    -- LOAD THE NEW VALUES INTO THE API VARIABLES
    module_to_add.v.name := substr(new_module_rec.app_file,1,20);
    module_to_add.v.language_reference := 107;
    module_to_add.v.general_module_reference := new_module_rec.id;
    -- module_to_add.v.short_name := substr(new_module_rec.mod_name,1,36);
    -- module_to_add.v.purpose := substr(new_module_rec.purpose,1,60);
    -- SET THE INDICATORS FOR DATA LOAD
    -- if module_to_add.v.short_name is not null then
    -- module_to_add.i.short_name := true;
    -- end if;
    if module_to_add.v.name is not null then
    module_to_add.i.name := true;
    end if;
    -- if module_to_add.v.purpose is not null then
    -- module_to_add.i.purpose := true;
    -- end if;
    -- if module_to_add.v.module_type is not null then
    -- module_to_add.i.module_type := true;
    -- end if;
    -- Call the insert procedure for the new module
    -- dbms_output.put_line('short_name : '&#0124; &#0124;module_to_add.v.short_name);
    dbms_output.put_line('name : '&#0124; &#0124;module_to_add.v.name);
    -- dbms_output.put_line('purpose : '&#0124; &#0124;module_to_add.v.purpose);
    dbms_output.put_line('Inserting the new module');
    ciomodule_component.ins(null,module_to_add);
    end loop;
    -- Select the property list
    -- dbms_output.put_line('type : '&#0124; &#0124;module_to_add.v.module_type);
    -- Validate the activity
    cdapi.validate_activity(act_status,act_warnings);
    -- Display all violations and other messages regardless of the activity
    -- warnings flag
    inst antiate_messages;
    -- Attempt to close the activity
    cdapi.close_activity(act_status);
    dbms_output.put_line ('activity status is '&#0124; &#0124; act_status);
    -- If the activity did not close successfully, roll back all changes made
    -- during the activity
    if act_status != 'Y' then
    cdapi.abort_activity;
    dbms_output.put_line('Activity aborted with constraint violations');
    -- Otherwise, we're done
    else
    dbms_output.put_line('Activity closed successfully');
    end if;
    EXCEPTION
    WHEN CANNOT_INIT_APPSYS THEN
    dbms_output.put_line('cannot initialize API for Application System' &#0124; &#0124; 'SPOC');
    WHEN NO_MATCHING_MOD_FOUND THEN
    dbms_output.put_line('No Module to insert');
    WHEN OTHERS THEN
    -- If any messages have been posted on the stack, then print them now
    -- and then roll back all changes made during the activity
    if cdapi.stacksize > 0 then
    -- Print all messages on the API stack
    while cdapi.stacksize > 0 loop
    dbms_output.put_line(cdapi.pop_instantiated_message);
    end loop;
    if cdapi.activity is not null then
    cdapi.abort_activity;
    dbms_output.put_line('Activity aborted with API errors');
    else
    dbms_output.put_line('API Session aborted with API errors');
    end if;
    -- Otherwise, this must have been an ORACLE SQL or internal error so
    -- roll back all changes made during the activity and re-raise the
    -- exception
    else
    if cdapi.activity is not null then
    cdapi.abort_activity;
    dbms_output.put_line('Activity aborted with ORACLE internal errors');
    else
    dbms_output.put_line('API Session aborted with ORACLE internal errors');
    end if;
    raise;
    end if;
    END;
    null

    Hi,
    Dont use private API's as its not feasible to use as AMG.
    Use pa_project_pub.update_project API where u can pass class codes as record type.
    Regards,
    SS.

  • Help with a basic dbx question

    Solaris 10. DBX'ing a core file that was not compiled with any debugging information. When you do a basic "where", you typically get:
    [1] someFile::someFunction(arg1, arg2, arg3, arg4, arg5, arg6) at 0x5ab32x
    Can someone tell me what each of the addresses for the args above are? And what the "at 0x...." is ?
    I am trying to examine the arguments passed into the functions using "examine addr" but having difficulty.
    Thanks

    Without any debugging information, dbx cannot know how many arguments, or of what type, the function has.
    It displays the contents of the stack where the first 6 arguments would be if the registers were spilled, assuming that each argument was one word. Since the actual arguments might not be one word each, and since the registers might not have been spilled, the values displayed don't always have any significance. (If the function has fewer than 6 arguments, the remaining values have no significance.)
    The 0x5ab32x looks like a copying error. Dbx shows the (hex) address where the program crashed. The trailing x cannot be correct.
    You can get a disassembly starting at the function's address, or at some point ahead of the address shown, and try to match it to the source code.

  • Trying to add a listener to a JComboBox in a JTable

    Hi all.
    I have a little problem which I can't resolve.
    I made a program in which I create a table using a class which extends JTable (but this isn't the point with the problem, I think. It's only for rendering purposes)
    In this table I put various types of items (such as Strings, JButton, JComboBox). I have no problem with the visualization of them, but the problem is with the listener for the combo boxes. I created a listener of my own and registered it in the constructor of the combo box editor, but when I change a value it's never fired. Can someone please help me?
    Here's some code which can help understanding the problem
    Combo box editor:
    public class MyComboBoxEditor extends DefaultCellEditor{
    public MyComboBoxEditor(JTableX _tabellaDiAppartenenza) {
    super(new JComboBox());                  
    (JComboBox)super.editorComponent).addItemListener(new MyItemListener((JComboBox)super.editorComponent));    
    public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {
    String elementi[]=new String[((JComboBox)arg1).getItemCount()];
    for(int i=0;i<((JComboBox)arg1).getItemCount();i++){
    elementi=(String)((JComboBox)arg1).getItemAt(i);
    super.editorComponent=new JComboBox(elementi);
    return super.getTableCellEditorComponent(arg0, arg1, arg2, arg3, arg4);
    }combo box listener:public class MyItemListener implements ItemListener{
    private JComboBox combo;
    public MyItemListener(JComboBox object){
    combo=object;
    public void itemStateChanged(ItemEvent arg0) {
    int changeEvent = arg0.getStateChange();
    if(changeEvent==ItemEvent.SELECTED){
    Object value=arg0.getItem();
    combo.setSelectedItem(value);
    }table:public class JTableX extends JTable{
    protected MyCellEditorModel myCellEditorModel;
    public JTableX(MyDataModel tm){
    super(tm);
    Object ge = defaultEditorsByColumnClass.get(Boolean.class);
    DefaultCellEditor dce = (DefaultCellEditor)ge;
    dce.setClickCountToStart(0);
    MyButtonEditor mbe = new MyButtonEditor(new JCheckBox("Bottone"), this);
    mbe.setClickCountToStart(0);
    MyComboBoxEditor mcbe = new MyComboBoxEditor(this);
    mcbe.setClickCountToStart(0);
    defaultEditorsByColumnClass.clear();
    Hashtable cellEditors = new Hashtable();
    cellEditors.put(JButton.class, mbe);
    cellEditors.put(JComboBox.class, mcbe);
    cellEditors.put(Boolean.class, dce);
    this.defaultRenderersByColumnClass.put(JButton.class, new MyButtonRenderer());
    this.defaultRenderersByColumnClass.put(JComboBox.class, new MyComboBoxRenderer());
    defaultEditorsByColumnClass.put(Object.class, new MyCellEditorModel1(cellEditors));
    public TableCellEditor getCellEditor(int row, int col){
    if(myCellEditorModel!=null) return myCellEditorModel;
    return super.getCellEditor(row,col);
    public TableCellRenderer getCellRenderer(int row, int column) {
    Object value = getValueAt(row,column);
    if (value !=null) {
    return getDefaultRenderer(value.getClass());
    return super.getCellRenderer(row,column);
    public void setCellEditor(MyCellEditorModel anEditor) {
    myCellEditorModel = anEditor;
    }Hoping the code is enough to understand the problem, I thanks all for watching and reading the post and for the future answeres.
    Bye all.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    super.editorComponent=new JComboBox(elementi);You create a new combo box each call to getTableCellEditComponent() (overriding the one of the constructor), but you aren't adding a ItemListener to it.

  • Facing Issue With Oracle SOA Suite 11.1.1.3.0

    Hi All,
    I am facing some issues with ORACLE SOA SUITE 11.1.1.3.0.
    Hope you people can help us out.
    Please find the issue details below along with all the relevant information’s
    I have following SOA suite installation at my server:
    Oracle 10g Express Edition Universal 10.2.0.1
    RCU 11.1.1.3.3
    Web Logic Server 10.3.3.0
    SOA suite 11.1.1.3.0
    JDeveloper 11.1.1.3.0
    The first thing what I have done is created a web service and deployed it to server without any issue.
    After that I created proxy client for that service and accessed it successfully from the client end.
    Till here no issue occurs.
    After that I applied few policies on top of web service and deployed it to server.
    The policy I had chosen was “oracle/wss_username_token_service_policy” [coming under OWSM policies list]
    While deploying there was no issue, all went well.
    2nd step I had created client using “oracle/wss_username_token_client_policy” policy which is counter part of above policy and tried to access the web service but failed.
    I have followed this blog:
    [http://biemond.blogspot.com/2010/08/things-you-need-to-do-for-owsm-11g.html ]
    Please have a look on service and client code:
    Service Code:
    package Demo_ScoreCard;
    import javax.jws.WebService;
    import weblogic.wsee.jws.jaxws.owsm.SecurityPolicy;
    @WebService
    @SecurityPolicy(uri = "oracle/wss_username_token_service_policy")
    public class ScoreCardWithPolicy {
    public double getPercentageWithPolicy(double markEng,double markMath,double markHindi,double markScience,double markSsc)
    double result;
    result= ((markEng+markHindi+markMath+markScience+markSsc)/500)*100;
    return result;
    Client Code:
    package com.tec.proxy.client;
    import java.util.Map;
    import javax.xml.ws.BindingProvider;
    import javax.xml.ws.WebServiceRef;
    import weblogic.wsee.jws.jaxws.owsm.SecurityPolicyFeature;
    public class ScoreCardWithPolicyPortClient {
    @WebServiceRef
    private static ScoreCardWithPolicyService scoreCardWithPolicyService;
    public static void main(String[] args) {
    scoreCardWithPolicyService = new ScoreCardWithPolicyService();
    SecurityPolicyFeature[] securityFeatures =new SecurityPolicyFeature[] { new SecurityPolicyFeature("oracle/wss_http_token_client_policy") };
    ScoreCardWithPolicy scoreCardWithPolicy =scoreCardWithPolicyService.getScoreCardWithPolicyPort(securityFeatures);
    Map<String, Object> reqContext =((BindingProvider)scoreCardWithPolicy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "testclient");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "test12345"); // I have added this to the myrealm from console under security realms
    double arg1 = 77.2;
    double arg2 = 79.2;
    double arg3 = 77.2;
    double arg4 = 76.2;
    double arg5 = 67.2;
    double clientResult =scoreCardWithPolicy.getPercentageWithPolicy(arg1, arg2, arg3, arg4,arg5);
    System.out.println("clientResult with policy =====> " + clientResult);
    Error Log:
    SEVERE: WSM-07617 Policy: oracle/wss_http_token_client_policy contains unsupported assertions.
    SEVERE: WSMAgentHook: An Exception is thrown: WSM-07617 Policy Policy: oracle/wss_http_token_client_policy contains unsupported assertions.
    Exception in thread "main" javax.xml.rpc.JAXRPCException: oracle.wsm.common.sdk.WSMException: WSM-07617 Policy Policy: oracle/wss_http_token_client_policy contains unsupported assertions.
    at oracle.wsm.agent.handler.wls.WSMAgentHook.handleException(WSMAgentHook.java:395)
    at oracle.wsm.agent.handler.wls.WSMAgentHook.init(WSMAgentHook.java:206)
    at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory.newHandler(TubeFactory.java:105)
    at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory.createClient(TubeFactory.java:68)
    at weblogic.wsee.jaxws.WLSTubelineAssemblerFactory$TubelineAssemblerImpl.createClient(WLSTubelineAssemblerFactory.java:148)
    at com.sun.xml.ws.client.WSServiceDelegate.createPipeline(WSServiceDelegate.java:467)
    at com.sun.xml.ws.client.WSServiceDelegate.getStubHandler(WSServiceDelegate.java:689)
    at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:667)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:362)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.internalGetPort(WLSProvider.java:855)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate$PortClientInstanceFactory.createClientInstance(WLSProvider.java:967)
    at weblogic.wsee.jaxws.spi.ClientInstancePool.takeSimpleClientInstance(ClientInstancePool.java:621)
    at weblogic.wsee.jaxws.spi.ClientInstancePool.take(ClientInstancePool.java:486)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.getPort(WLSProvider.java:782)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:344)
    at javax.xml.ws.Service.getPort(Service.java:133)
    at com.tec.proxy.client.ScoreCardWithPolicyService.getScoreCardWithPolicyPort(ScoreCardWithPolicyService.java:86)
    at com.tec.proxy.client.ScoreCardWithPolicyPortClient.main(ScoreCardWithPolicyPortClient.java:23)
    Process exited with exit code 1.
    Not getting any help from any blog. Just wondering why this error is coming. I would be glad if you can help us in this regard.
    Apart from above issue I have few queries like:
    1.What is difference between OWSM policies and WLS policies?
    2.Are these the only policies we can apply on top of services?
    3.If some one wants to configure his own custom policies than what need to be done
    4.Could anyone please provide some useful links to implement ENCYPTION and SIGNATURE on top of web services?
    5.And If I am not wrong, I guess Oracle Service BUS OSB 11.1.1.3 has been removed from the main download link and version 11.1.1.4 has been provided. Is it
    compatible with SOA suite 11.1.1.3.0? If not where can I get OSB 11.1.1.3?
    Looking forward to hear from you people.
    Thanks
    Arvind
    Edited by: user8490871 on Apr 15, 2011 12:53 AM
    Edited by: user8490871 on Apr 15, 2011 12:53 AM

    Hi,
    I don't know why u get an error. Here are answers for additional questions:
    1. OWSM policies are for web services. WLS policies are based on Java EE security. They are used to protect resources e.g. URL, EJB
    2. I don't know about other policies
    3. See http://download.oracle.com/docs/cd/E14571_01/web.1111/e13713/owsm_appendix.htm#CHDCHFBH
    4. See http://download.oracle.com/docs/cd/E14571_01/security.1111/e10037/toc.htm
    5. I can see OSB 11.1.1.3 download link here
    http://www.oracle.com/technetwork/middleware/downloads/fmw-11-download-092893.html
    Regards,
    Milan

  • How can i  use  this  java program to access from  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }here i need to generate the strings like 'enter value1' and respective text boxes dynamically . i should use this java program as business logic and a jsp page for view.
    following given is my text file input.eqn
    input:enter value1:arg1
    input:enter value2:arg2
    input:enter value3:arg3
    constant:enter constant1:arg4
    constant:enter constant2:arg5
    equation:enter equation:(arg1+arg2)*(arg3+arg4)*arg5
    result:

    Why do you double post ? http://forum.java.sun.com/thread.jspa?threadID=646988&tstart=0
    Why dint that answer satisfy you ? And why dint you say so in that thread rather than posting the same question again ?
    ram.

  • Election problem after repeated split-brains with two nodes

    Hi
    I'm using a customized source based on BDB-5.1.19 (excxx_repquote)
    with two site one - MASTER and the other SLAVE...
    nsite=2
    ack=quorum
    - the master is writing to quotedb at a rate of 10 txn per sec
    - the test consist to isolate the client from the master (split brain) and reconnect it after a random time include from 1sec to 10sec
    the test run well about 10 times but at a moment the process slave receive DB_EVENT_REP_ELECTION_FAILED
    and the master enter in election mode and never exit from the CLIENT mode. I must say that to freeze the client I decide to kill me (kill -9 my pid) when I receive such event...
    here is the verbose log on the master...
    [1307872770:871621][6510/47655809107168] MASTER: rep_send_function returned: 110
    [1307872770:973655][6510/47655809107168] MASTER: bulk_msg: Send buffer after copy due to PERM
    [1307872770:973667][6510/47655809107168] MASTER: send_bulk: Send 266 (0x10a) bulk buffer bytes
    [1307872770:973672][6510/47655809107168] MASTER: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 68 eid -1, type bulk_log, LSN [21][986648] perm
    [1307872770:973693][6510/47655809107168] MASTER: will await acknowledgement: need 1
    [1307872771:26623][6510/47655809107168] MASTER: rep_send_function returned: 110
    [1307872771:126380][6510/1162996032] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type log, LSN [21][946345]
    [1307872771:126407][6510/1162996032] MASTER: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 68 eid -1, type dupmaster, LSN [0][0] nobuf
    [1307872771:126695][6510/1162996032] MASTER: rep_start: Found old version log 17
    [1307872771:126753][6510/1162996032] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 68 eid -1, type newclient, LSN [0][0] nobuf
    [1307872771:126833][6510/1183975744] CLIENT: starting election thread
    [1307872771:126876][6510/1183975744] CLIENT: Start election nsites 2, ack 1, priority 100
    [1307872771:126890][6510/1183975744] CLIENT: Election thread owns egen 69
    [1307872771:127423][6510/1173485888] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type newclient, LSN [0][0]
    [1307872771:130079][6510/1183975744] CLIENT: Tallying VOTE1[0] (2147483647, 69)
    [1307872771:130113][6510/1183975744] CLIENT: Beginning an election
    [1307872771:130134][6510/1183975744] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 68 eid -1, type vote1, LSN [21][986728] nobuf
    [1307872771:130147][6510/1173485888] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 68 eid -1, type master_req, LSN [0][0] nobuf
    [1307872771:130438][6510/1152506176] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type vote1, LSN [21][946437]
    [1307872771:130460][6510/1162996032] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type alive, LSN [21][986728]
    [1307872771:130467][6510/1152506176] CLIENT: Updating gen from 68 to 70
    [1307872771:130482][6510/1162996032] CLIENT: Received ALIVE egen of 71, mine 69
    [1307872771:130503][6510/1162996032] CLIENT: Election finished in 0.003602000 sec
    [1307872771:130515][6510/1162996032] CLIENT: Election done; egen 70
    [1307872771:130534][6510/1152506176] CLIENT: Received vote1 egen 71, egen 71
    [1307872771:130581][6510/1152506176] CLIENT: Tallying VOTE1[0] (0, 71)
    [1307872771:130593][6510/1089075520] CLIENT: starting election thread
    [1307872771:130619][6510/1152506176] CLIENT: Incoming vote: (eid)0 (pri)100 ELECTABLE (gen)70 (egen)71 [21,946437]
    [1307872771:130642][6510/1152506176] CLIENT: Not in election, but received vote1 0x282c 0x8
    [1307872771:130674][6510/1089075520] CLIENT: Start election nsites 2, ack 1, priority 100
    [1307872771:130692][6510/1089075520] CLIENT: Election thread owns egen 71
    [1307872771:130704][6510/1194465600] CLIENT: starting election thread
    [1307872771:130733][6510/1194465600] CLIENT: Start election nsites 2, ack 1, priority 100
    [1307872771:132922][6510/1089075520] CLIENT: Tallying VOTE1[1] (2147483647, 71)
    [1307872771:132949][6510/1089075520] CLIENT: Accepting new vote
    [1307872771:132958][6510/1089075520] CLIENT: Beginning an election
    [1307872771:132973][6510/1089075520] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid -1, type vote1, LSN [21][986728] nobuf
    [1307872771:132985][6510/1194465600] CLIENT: election thread is exiting
    [1307872771:133012][6510/1089075520] CLIENT: Tallying VOTE2[0] (2147483647, 71)
    [1307872771:133037][6510/1089075520] CLIENT: Counted my vote 1
    [1307872771:133048][6510/1089075520] CLIENT: Skipping phase2 wait: already got 1 votes
    [1307872771:133060][6510/1089075520] CLIENT: Got enough votes to win; election done; (prev) gen 70
    [1307872771:133071][6510/1089075520] CLIENT: Election finished in 0.002367000 sec
    [1307872771:133084][6510/1089075520] CLIENT: Election done; egen 72
    [1307872771:133111][6510/1089075520] CLIENT: Ended election with 0, e_th 1, egen 72, flag 0x2a2c, e_fl 0x0, lo_fl 0x6
    [1307872771:133170][6510/1173485888] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type alive, LSN [0][0]
    [1307872771:133187][6510/1173485888] CLIENT: Racing replication msg lockout, ignore message.
    [1307872771:173744][6510/1162996032] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type vote2, LSN [0][0]
    [1307872771:173769][6510/1162996032] CLIENT: Racing replication msg lockout, ignore message.
    [1307872771:231593][6510/1183975744] CLIENT: Ended election with 0, e_th 0, egen 72, flag 0x2a2c, e_fl 0x0, lo_fl 0x1c
    [1307872771:231629][6510/1183975744] CLIENT: election thread is exiting
    [1307872777:443794][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307872971:644194][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307873165:844583][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307873360:44955][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307873554:245347][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307873748:445736][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307873942:646117][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    [1307874136:846509][6510/1131526464] CLIENT: init connection to site 2.0.0.210:12345 with result 115
    .... and infinite stay to this situation
    My question is why the Master is suddenly transformed into CLIENT and why it's never returning to the MASTER
    Thanks in advance ...
    here is the log for the client
    [1307872315:455113][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type log, LSN [21][984396]
    [1307872315:455134][1282/1160603968] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type log, LSN [21][984483] perm
    [1307872315:609962][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][984733] perm
    [1307872315:764958][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][984986] perm
    [1307872315:919962][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][985238] perm
    [1307872316:75018][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][985491] perm
    [1307872316:229959][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][985741] perm
    [1307872316:384949][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][985993] perm
    [1307872316:499899][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][986141] perm
    [1307872316:539895][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type log, LSN [21][986221]
    [1307872316:540078][1282/1171093824] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type log, LSN [21][986307]
    [1307872316:540100][1282/1160603968] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type log, LSN [21][986394] perm
    [1307872316:694950][1282/1171093824] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type bulk_log, LSN [21][986648] perm
    [1307872316:847349][1282/1129134400] MASTER: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid -1, type log, LSN [21][946345]
    [1307872316:847698][1282/1171093824] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type dupmaster, LSN [0][0]
    [1307872316:847999][1282/1181583680] MASTER: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type newclient, LSN [0][0]
    [1307872316:848168][1282/1171093824] MASTER: rep_start: Found old version log 17
    [1307872316:848222][1282/1181583680] CLIENT: Racing replication msg lockout, ignore message.
    [1307872316:848398][1282/1171093824] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid -1, type newclient, LSN [0][0] nobuf
    [1307872316:848504][1282/1192073536] CLIENT: starting election thread
    [1307872316:848542][1282/1192073536] CLIENT: Start election nsites 2, ack 1, priority 100
    [1307872316:848566][1282/1192073536] CLIENT: Election thread owns egen 71
    [1307872316:849634][1282/1192073536] CLIENT: Tallying VOTE1[0] (2147483647, 71)
    [1307872316:849654][1282/1192073536] CLIENT: Beginning an election
    [1307872316:849680][1282/1192073536] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid -1, type vote1, LSN [21][946437] nobuf
    [1307872316:851403][1282/1160603968] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type vote1, LSN [21][986728]
    [1307872316:851448][1282/1160603968] CLIENT: Received vote1 egen 69, egen 71
    [1307872316:851470][1282/1160603968] CLIENT: Received old vote 69, egen 71, ignoring vote1
    [1307872316:851481][1282/1160603968] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid 0, type alive, LSN [21][986728] nobuf
    [1307872316:851538][1282/1171093824] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 68 eid 0, type master_req, LSN [0][0]
    [1307872316:851558][1282/1171093824] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid 0, type alive, LSN [0][0] nobuf
    [1307872316:854254][1282/1160603968] CLIENT: /opt/bdb/ rep_process_message: msgv = 5 logv 17 gen = 70 eid 0, type vote1, LSN [21][986728]
    [1307872316:854275][1282/1160603968] CLIENT: Received vote1 egen 71, egen 71
    [1307872316:854317][1282/1160603968] CLIENT: Tallying VOTE1[1] (0, 71)
    [1307872316:854339][1282/1160603968] CLIENT: Incoming vote: (eid)0 (pri)100 ELECTABLE (gen)70 (egen)71 [21,986728]
    [1307872316:854353][1282/1160603968] CLIENT: Existing vote: (eid)2147483647 (pri)100 (gen)70 (sites)2 [21,946437]
    [1307872316:854369][1282/1160603968] CLIENT: Accepting new vote
    [1307872316:854379][1282/1160603968] CLIENT: Phase1 election done
    [1307872316:854395][1282/1160603968] CLIENT: Voting for 0
    [1307872316:854407][1282/1160603968] CLIENT: /opt/bdb/ rep_send_message: msgv = 5 logv 17 gen = 70 eid 0, type vote2, LSN [0][0] nobuf
    [1307872317:960344][1282/1192073536] CLIENT: After phase 2: votes 0, nvotes 1, nsites 2
    [1307872317:960389][1282/1192073536] CLIENT: Election finished in 1.111809000 sec
    [1307872317:960401][1282/1192073536] CLIENT: Election done; egen 72
    [1307872317:960412][1282/1192073536] CLIENT: Ended election with -30974, e_th 0, egen 72, flag 0x282c, e_fl 0x0, lo_fl 0x0
    Kill me !!
    --- my source
    on the master I run manually :
    txn_rate 1
    loop_rate 10
    loop 1 20000
    * See the file LICENSE for redistribution information.
    * Copyright (c) 2001, 2010 Oracle and/or its affiliates. All rights reserved.
    * $Id$
    * In this application, we specify all communication via the command line. In
    * a real application, we would expect that information about the other sites
    * in the system would be maintained in some sort of configuration file. The
    * critical part of this interface is that we assume at startup that we can
    * find out
    *      1) what our Berkeley DB home environment is,
    *      2) what host/port we wish to listen on for connections; and
    *      3) an optional list of other sites we should attempt to connect to.
    * These pieces of information are expressed by the following flags.
    * -h home (required; h stands for home directory)
    * -l host:port (required; l stands for local)
    * -C or -M (optional; start up as client or master)
    * -r host:port (optional; r stands for remote; any number of these may be
    *     specified)
    * -R host:port (optional; R stands for remote peer; only one of these may
    * be specified)
    * -a all|quorum (optional; a stands for ack policy)
    * -b (optional; b stands for bulk)
    * -n nsites (optional; number of sites in replication group; defaults to 0
    *     to try to dynamically compute nsites)
    * -p priority (optional; defaults to 100)
    * -v (optional; v stands for verbose)
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <string>
    #include <sstream>
    #include <sys/types.h>
    #include <signal.h>
    #include <db_cxx.h>
    #include "RepConfigInfo.h"
    #include "dbc_auto.h"
    using std::cout;
    using std::cin;
    using std::cerr;
    using std::endl;
    using std::ends;
    using std::flush;
    using std::istream;
    using std::istringstream;
    using std::ostringstream;
    using std::string;
    using std::getline;
    #include <stdio.h>
    #include <readline/readline.h>
    #include <readline/history.h>
    #define     CACHESIZE     (10 * 1024 * 1024)
    #define     DATABASE     "quote.db"
    #define     DATABASE2     "quote2.db"
    const char *progname = "excxx_repquote";
    #include <errno.h>
    #ifdef _WIN32
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #define     snprintf          _snprintf
    #define     sleep(s)          Sleep(1000 * (s))
    extern "C" {
    extern int getopt(int, char * const *, const char *);
    extern char *optarg;
    typedef HANDLE thread_t;
    typedef DWORD thread_exit_status_t;
    #define     thread_create(thrp, attr, func, arg)                    \
    (((*(thrp) = CreateThread(NULL, 0,                         \
         (LPTHREAD_START_ROUTINE)(func), (arg), 0, NULL)) == NULL) ? -1 : 0)
    #define     thread_join(thr, statusp)                         \
    ((WaitForSingleObject((thr), INFINITE) == WAIT_OBJECT_0) &&          \
    GetExitCodeThread((thr), (LPDWORD)(statusp)) ? 0 : -1)
    #else /* !_WIN32 */
    #include <pthread.h>
    typedef pthread_t thread_t;
    typedef void* thread_exit_status_t;
    #define     thread_create(thrp, attr, func, arg)                    \
    pthread_create((thrp), (attr), (func), (arg))
    #define     thread_join(thr, statusp) pthread_join((thr), (statusp))
    #endif
    // Struct used to store information in Db app_private field.
    typedef struct {
         bool app_finished;
         bool in_client_sync;
         bool is_master;
         bool no_dummy_wr;
    } APP_DATA;
    static void log(const char *);
    void checkpoint_thread (void );
    void log_archive_thread (void );
    void dummy_write_thread (void );
    class RepQuoteExample {
    public:
         RepQuoteExample();
         void init(RepConfigInfo* config);
         void doloop();
         int terminate();
         static void event_callback(DbEnv* dbenv, u_int32_t which, void *info);
         void print_stocks_size(Db *dbp);
    private:
         // disable copy constructor.
         RepQuoteExample(const RepQuoteExample &);
         void operator = (const RepQuoteExample &);
         // internal data members.
         APP_DATA          app_data;
         RepConfigInfo *app_config;
         DbEnv          cur_env;
         thread_t ckp_thr;
         thread_t lga_thr;
         thread_t dmy_thr;
         // private methods.
         void print_stocks(Db *dbp);
         void print_env(DbEnv *dbenv);
         void prompt();
    RepQuoteExample *g_runner=NULL;
    RepConfigInfo *g_config=NULL;
    class DbHolder {
    public:
         DbHolder(DbEnv env, const char _dbname) : env(env)
              dbp = 0;
              if (_dbname) dbname=_dbname;
              else dbname=DATABASE;
         ~DbHolder() {
         try {
              close();
         } catch (...) {
              // Ignore: this may mean another exception is pending
         bool ensure_open(bool creating) {
         if (dbp)
              return (true);
         dbp = new Db(env, 0);
         u_int32_t flags = DB_AUTO_COMMIT;
         if (creating)
              flags |= DB_CREATE;
         try {
              //dbp->open(NULL, DATABASE, NULL, DB_BTREE, flags, 0);
              //dbp->open(NULL, dbname, NULL, DB_BTREE, flags, 0);
              dbp->open(NULL, NULL, dbname, DB_BTREE, flags, 0);
              return (true);
         } catch (DbDeadlockException e) {
         } catch (DbRepHandleDeadException e) {
         } catch (DbException e) {
              if (e.get_errno() == DB_REP_LOCKOUT) {
              // Just fall through.
              } else if (e.get_errno() == ENOENT && !creating) {
              // Provide a bit of extra explanation.
              log("Stock DB does not yet exist");
              } else
              throw;
         // (All retryable errors fall through to here.)
         log("please retry the operation");
         close();
         return (false);
         void close() {
         if (dbp) {
              try {
              dbp->close(0);
              delete dbp;
              dbp = 0;
              } catch (...) {
              delete dbp;
              dbp = 0;
              throw;
         operator Db *() {
         return dbp;
         Db *operator->() {
         return dbp;
    private:
         Db *dbp;
         DbEnv *env;
         const char *dbname;
    class StringDbt : public Dbt {
    public:
    #define GET_STRING_OK 0
    #define GET_STRING_INVALID_PARAM 1
    #define GET_STRING_SMALL_BUFFER 2
    #define GET_STRING_EMPTY_DATA 3
         int get_string(char **buf, size_t buf_len)
              size_t copy_len;
              int ret = GET_STRING_OK;
              if (buf == NULL) {
                   cerr << "Invalid input buffer to get_string" << endl;
                   return GET_STRING_INVALID_PARAM;
              // make sure the string is null terminated.
              memset(*buf, 0, buf_len);
              // if there is no string, just return.
              if (get_data() == NULL || get_size() == 0)
                   return GET_STRING_OK;
              if (get_size() >= buf_len) {
                   ret = GET_STRING_SMALL_BUFFER;
                   copy_len = buf_len - 1; // save room for a terminator.
              } else
                   copy_len = get_size();
              memcpy(*buf, get_data(), copy_len);
              return ret;
         size_t get_string_length()
              if (get_size() == 0)
                   return 0;
              return strlen((char *)get_data());
         void set_string(char *string)
              set_data(string);
              set_size((u_int32_t)strlen(string));
         StringDbt(char *string) :
         Dbt(string, (u_int32_t)strlen(string)) {};
         StringDbt() : Dbt() {};
         ~StringDbt() {};
         // Don't add extra data to this sub-class since we want it to remain
         // compatible with Dbt objects created internally by Berkeley DB.
    Db *g_repquote=NULL;
    RepQuoteExample::RepQuoteExample() : app_config(0), cur_env(0) {
         app_data.app_finished = 0;
         app_data.in_client_sync = 0;
         app_data.is_master = 0; // assume I start out as client
         app_data.no_dummy_wr = 0 ; //prevent to run dummy write
    int (*old_rep_process_message)
              __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *));
    int my_rep_process_message __P((DB_ENV arg1, DBT arg2, DBT arg3, int arg4, DB_LSN arg5))
         printf("EZ->>> my_rep_process_message:%p\n",arg5);
         old_rep_process_message(arg1,arg2,arg3,arg4,arg5);
    void RepQuoteExample::init(RepConfigInfo *config) {
         app_config = config;
         cur_env.set_app_private(&app_data);
         cur_env.set_errfile(stderr);
         app_data.no_dummy_wr=config->no_dummy_wr;
         if (app_data.no_dummy_wr)
              printf("No dummy !!!\n");
         //EZ->cur_env.set_errpfx(progname);
         cur_env.set_event_notify(event_callback);
         // Configure bulk transfer to send groups of records to clients
         // in a single network transfer. This is useful for master sites
         // and clients participating in client-to-client synchronization.
         if (app_config->bulk)
              cur_env.rep_set_config(DB_REP_CONF_BULK, 1);
         // Set the total number of sites in the replication group.
         // This is used by repmgr internal election processing.
         if (app_config->totalsites > 0)
              cur_env.rep_set_nsites(app_config->totalsites);
         // Turn on debugging and informational output if requested.
         if (app_config->verbose)
              cur_env.set_verbose(DB_VERB_REPLICATION, 1);
         cur_env.set_verbose(DB_VERB_REPMGR_MISC, 1);
         cur_env.set_verbose(DB_VERB_RECOVERY, 1);
         cur_env.set_verbose(DB_VERB_REPLICATION, 1);
         cur_env.set_verbose(DB_VERB_REP_ELECT, 1);
         cur_env.set_verbose(DB_VERB_REP_LEASE, 1);
         cur_env.set_verbose(DB_VERB_REP_SYNC, 1);
         cur_env.set_verbose(DB_VERB_REPMGR_MISC, 1);
         // Set replication group election priority for this environment.
         // An election first selects the site with the most recent log
         // records as the new master. If multiple sites have the most
         // recent log records, the site with the highest priority value
         // is selected as master.
         cur_env.rep_set_priority(app_config->priority);
         // Set the policy that determines how master and client sites
         // handle acknowledgement of replication messages needed for
         // permanent records. The default policy of "quorum" requires only
         // a quorum of electable peers sufficient to ensure a permanent
         // record remains durable if an election is held. The "all" option
         // requires all clients to acknowledge a permanent replication
         // message instead.
         cur_env.repmgr_set_ack_policy(app_config->ack_policy);
         // Set the threshold for the minimum and maximum time the client
         // waits before requesting retransmission of a missing message.
         // Base these values on the performance and load characteristics
         // of the master and client host platforms as well as the round
         // trip message time.
         cur_env.rep_set_request(20000, 500000);
         // Configure deadlock detection to ensure that any deadlocks
         // are broken by having one of the conflicting lock requests
         // rejected. DB_LOCK_DEFAULT uses the lock policy specified
         // at environment creation time or DB_LOCK_RANDOM if none was
         // specified.
         cur_env.set_lk_detect(DB_LOCK_DEFAULT);
         // The following base replication features may also be useful to your
         // application. See Berkeley DB documentation for more details.
         // - Master leases: Provide stricter consistency for data reads
         // on a master site.
         // - Timeouts: Customize the amount of time Berkeley DB waits
         // for such things as an election to be concluded or a master
         // lease to be granted.
         // - Delayed client synchronization: Manage the master site's
         // resources by spreading out resource-intensive client
         // synchronizations.
         // - Blocked client operations: Return immediately with an error
         // instead of waiting indefinitely if a client operation is
         // blocked by an ongoing client synchronization.
         cur_env.repmgr_set_local_site(app_config->this_host.host,
         app_config->this_host.port, 0);
         for ( REP_HOST_INFO *cur = app_config->other_hosts; cur != NULL;
              cur = cur->next) {
              cur_env.repmgr_add_remote_site(cur->host, cur->port,
              NULL, cur->peer ? DB_REPMGR_PEER : 0);
         // Configure heartbeat timeouts so that repmgr monitors the
         // health of the TCP connection. Master sites broadcast a heartbeat
         // at the frequency specified by the DB_REP_HEARTBEAT_SEND timeout.
         // Client sites wait for message activity the length of the
         // DB_REP_HEARTBEAT_MONITOR timeout before concluding that the
         // connection to the master is lost. The DB_REP_HEARTBEAT_MONITOR
         // timeout should be longer than the DB_REP_HEARTBEAT_SEND timeout.
         cur_env.rep_set_timeout(DB_REP_HEARTBEAT_SEND, 5000000);
         cur_env.rep_set_timeout(DB_REP_HEARTBEAT_MONITOR, 10000000);
         // The following repmgr features may also be useful to your
         // application. See Berkeley DB documentation for more details.
         // - Two-site strict majority rule - In a two-site replication
         // group, require both sites to be available to elect a new
         // master.
         // - Timeouts - Customize the amount of time repmgr waits
         // for such things as waiting for acknowledgements or attempting
         // to reconnect to other sites.
         // - Site list - return a list of sites currently known to repmgr.
         // We can now open our environment, although we're not ready to
         // begin replicating. However, we want to have a dbenv around
         // so that we can send it into any of our message handlers.
         cur_env.set_cachesize(0, CACHESIZE, 0);
         cur_env.set_flags(DB_REP_PERMANENT, 1);
         //cur_env.set_flags(DB_TXN_WRITE_NOSYNC, 1);
    /*     u_int32_t maxlocks=300000;
         if (maxlocks != 0)
              cur_env.set_lk_max_locks(maxlocks);
         u_int32_t maxlocks_o=300000;
         if (maxlocks_o != 0)
              cur_env.set_lk_max_objects(maxlocks_o);
         u_int32_t maxmutex=300000;
         if (maxmutex != 0)
              cur_env.mutex_set_max(maxmutex);
         DbEnv          *m_env=&cur_env;
         m_env->set_flags(DB_TXN_NOSYNC, 1);
         m_env->set_lk_max_lockers(60000);
         m_env->set_lk_max_objects(60000);
         m_env->set_lk_max_locks(60000);
         m_env->set_tx_max(60000);
         //m_env->repmgr_set_ack_policy(DB_REPMGR_ACKS_NONE);
         m_env->rep_set_timeout(DB_REP_ACK_TIMEOUT, 50 * 1000); //50ms
         m_env->rep_set_timeout(DB_REP_CHECKPOINT_DELAY, 0);
         //m_env->rep_set_timeout(DB_REP_CONNECTION_RETRY, 30 * 1000 * 1000); // 30 seconds
         m_env->rep_set_timeout(DB_REP_ELECTION_TIMEOUT, 1 * 1000 * 1000); // 5 seconds
         m_env->rep_set_timeout(DB_REP_FULL_ELECTION_TIMEOUT, 5 * 1000 * 1000); // 5 seconds
         m_env->rep_set_timeout(DB_REP_CONNECTION_RETRY, 5 * 1000 * 1000);
         //m_env->rep_set_timeout(DB_REP_ELECTION_RETRY, 10 * 1000 * 1000); //10 seconds
         //m_env->rep_set_timeout(DB_REP_HEARTBEAT_MONITOR, 80 * 1000 * 1000); //80 seconds
         //m_env->rep_set_timeout(DB_REP_HEARTBEAT_SEND, 500 * 1000); //500 milli seconds
         //The minimum number of microseconds a client waits before requesting retransmission
         u_int32_t rep_req_min = 40000; //40 000 microsec = 40 mili
         //The maximum number of microseconds a client waits before requesting retransmission
         u_int32_t rep_req_max = 1280000;// 1 280 000 microsec = 1.28 sec
         u_int32_t rep_limit_gbytes = 0;
         u_int32_t rep_limit_bytes = 100 * 1024 * 1024; // 100MB
         m_env->rep_set_request(rep_req_min, rep_req_max);
         m_env->rep_set_limit(rep_limit_gbytes, rep_limit_bytes);
         cur_env.open(app_config->home, DB_CREATE | DB_RECOVER |
         DB_THREAD | DB_INIT_REP | DB_INIT_LOCK | DB_INIT_LOG |
         DB_INIT_MPOOL | DB_INIT_TXN , 0);
         //keep old function for chain
         //old_rep_process_message=cur_env.get_DB_ENV()->rep_process_message;
         //derouting
         //cur_env.get_DB_ENV()->rep_process_message=my_rep_process_message;
         /*int _i;
         cur_env.log_get_config(DB_LOG_DIRECT, &_i);printf ("DB_LOG_DIRECT = %d\n",_i);
         cur_env.log_get_config(DB_LOG_DSYNC, &_i);printf ("DB_LOG_DSYNC = %d\n",_i);
         cur_env.log_get_config(DB_LOG_AUTO_REMOVE, &_i);printf ("DB_LOG_AUTO_REMOVE = %d\n",_i);
         cur_env.log_get_config(DB_LOG_IN_MEMORY, &_i);printf ("DB_LOG_IN_MEMORY = %d\n",_i);
         cur_env.log_get_config(DB_LOG_ZERO,&_i);printf ("DB_LOG_ZERO = %d\n",_i);
         // Start checkpoint and log archive support threads.
         (void)thread_create(&ckp_thr, NULL, checkpoint_thread, &cur_env);
         (void)thread_create(&lga_thr, NULL, log_archive_thread, &cur_env);
         (void)thread_create(&dmy_thr, NULL, dummy_write_thread, &cur_env);
         cur_env.repmgr_start(3, app_config->start_policy);
    }

    int RepQuoteExample::terminate() {
         try {
              // Wait for checkpoint and log archive threads to finish.
              // Windows does not allow NULL pointer for exit code variable.
              thread_exit_status_t exstat;
              (void)thread_join(lga_thr, &exstat);
              (void)thread_join(ckp_thr, &exstat);
              (void)thread_join(dmy_thr, &exstat);
              // We have used the DB_TXN_NOSYNC environment flag for
              // improved performance without the usual sacrifice of
              // transactional durability, as discussed in the
              // "Transactional guarantees" page of the Reference
              // Guide: if one replication site crashes, we can
              // expect the data to exist at another site. However,
              // in case we shut down all sites gracefully, we push
              // out the end of the log here so that the most
              // recent transactions don't mysteriously disappear.
              cur_env.log_flush(NULL);
              cur_env.close(0);
         } catch (DbException dbe) {
              cout << "error closing environment: " << dbe.what() << endl;
         return 0;
    void RepQuoteExample::prompt() {
         cout << "QUOTESERVER";
         if (!app_data.is_master)
              cout << "(read-only)";
         cout << "> " << flush;
    void log(const char *msg) {
    time_t currentTime;
    // get and print the current time
    time (&currentTime); // fill now with the current time
         char buff[255];
         strncpy(buff,ctime(&currentTime),sizeof(buff));
         char *p;
         for(p =buff ; *p != '\n'; p++);
         *p = '\0';
         cerr << buff << " - " << msg << endl;
    // Simple command-line user interface:
    // - enter "<stock symbol> <price>" to insert or update a record in the
    //     database;
    // - just press Return (i.e., blank input line) to print out the contents of
    //     the database;
    // - enter "quit" or "exit" to quit.
    void RepQuoteExample::doloop() {
         DbHolder dbh1(&cur_env,DATABASE);
         DbHolder dbh2(&cur_env,DATABASE2);
         DbHolder *dbh=&dbh1;
         DbTxn *txn;
         string input;
    bool truncate = false;
         char *c;
         using_history();
         g_repquote=*dbh;
         int loop_rate = 0;
         int txn_rate = 500;
         while (prompt(), /*getline(cin, input)*/c=readline(NULL)) {
              input=std::string(c);
              add_history(c);
              free(c);
              int start_loop = 0;
              int end_loop = 0;
              int start_loop_d = 0;
              int end_loop_d = 0;
              istringstream is(input);
              string token1, token2, token3;
    truncate = false;
    start_loop = 0;
    end_loop = 0;
              // Read 0, 1 or 2 tokens from the input.
              int count = 0;
              if (is >> token1) {
                   count++;
                   if (is >> token2)
                   count++;
                   if (is >> token3)
                   count++;
              if (count == 1) {
         if (token1 == "truncate" ) {
                        truncate = true;     
                   else if (token1 == "env" ){
                        print_env(&cur_env);
                        continue;
         else if (token1 == "verbose" ) {
                        app_config->verbose = !app_config->verbose;
                        if (app_config->verbose)
                             cur_env.set_verbose(DB_VERB_REPLICATION, 1);
                             cur_env.set_verbose(DB_VERB_REPMGR_MISC, 1);
                             cur_env.set_verbose(DB_VERB_RECOVERY, 1);
                             cur_env.set_verbose(DB_VERB_REP_ELECT, 1);
                             cur_env.set_verbose(DB_VERB_REP_LEASE, 1);
                             cur_env.set_verbose(DB_VERB_REP_SYNC, 1);
                             cur_env.set_verbose(DB_VERB_REPMGR_MISC, 1);
                             log("verbose is on");
                        else
                             cur_env.set_verbose(DB_VERB_REPLICATION, 0);
                             cur_env.set_verbose(DB_VERB_REPMGR_MISC, 0);
                             cur_env.set_verbose(DB_VERB_RECOVERY, 0);
                             cur_env.set_verbose(DB_VERB_REP_ELECT, 0);
                             cur_env.set_verbose(DB_VERB_REP_LEASE, 0);
                             cur_env.set_verbose(DB_VERB_REP_SYNC, 0);
                             cur_env.set_verbose(DB_VERB_REPMGR_MISC, 0);
                             log("verbose is off");
                        continue;
         else if (token1 == "print" ) {
                   print_stocks(*dbh);
                        count = 0;      
         else if (token1 == "db1" ) {
                        dbh=&dbh1;
                        g_repquote=*dbh;
                        log( "switch to Db1");
                        count = 0;      
         else if (token1 == "db2" ) {
                        dbh=&dbh2;
                        g_repquote=*dbh;
                        log( "switch to Db2");
                        count = 0;      
                   else if (token1 == "exit" || token1 == "quit") {
                        app_data.app_finished = 1;
                        break;
                   } else {
                        log("Format: <stock> <price>");
                        continue;
    else if (count == 2)
                   if (token1 == "loop_rate" ){
         loop_rate = atoi(token2.c_str());
                        continue;
                   if (token1 == "txn_rate" ){
         txn_rate = atoi(token2.c_str());
                        continue;
    else if (count == 3)
    if (token1 == "loop" ) {
    start_loop = atoi(token2.c_str());
    end_loop = start_loop + atoi(token3.c_str());
    if (token1 == "delete" ) {
    start_loop_d = atoi(token2.c_str());
    end_loop_d = start_loop_d + atoi(token3.c_str());
              // Here we know count is either 0 or 2, so we're about to try a
              // DB operation.
              // Open database with DB_CREATE only if this is a master
              // database. A client database uses polling to attempt
              // to open the database without DB_CREATE until it is
              // successful.
              // This DB_CREATE polling logic can be simplified under
              // some circumstances. For example, if the application can
              // be sure a database is already there, it would never need
              // to open it with DB_CREATE.
              if (!dbh->ensure_open(app_data.is_master))
                   continue;
              try {
                   if (count == 0)
                        if (app_data.in_client_sync)
                             log( "Cannot read data during client initialization - please try again.");
                        else
                             print_stocks_size(*dbh);
                   else if (!app_data.is_master)
                        log("Can't update at client");
                   else {
                        if (truncate)
    u_int32_t no_remove;
                        txn = NULL;
    cur_env.txn_begin(NULL, &txn, DB_TXN_NOWAIT);
                             try
              (*dbh)->truncate(txn, &no_remove, 0);
    // commit
    txn->commit(0);
    txn = NULL;
    } catch (DbException &e) {
    std::cout << "Error on txn commit: " << e.what() << std::endl;
                        //     } catch (DbDeadlockException &) {
                        if (txn != NULL)
                             (void)txn->abort();
    // std::cout << "Error on txn commit: " << std::endl;
    else if (start_loop)
    int j=0;
    for (int i=start_loop; i<=end_loop; i=i+txn_rate)
    //transaction begin
                   txn = NULL;
                   cur_env.txn_begin(NULL, &txn, 0);
    for (j=i; j<=end_loop && j<=(i+txn_rate); j++)
                                  Dbt key, value;
         std::string key1, value1;
         std::stringstream sstrm;
         sstrm << "key" << j << ends;
         key1 = sstrm.str();
                   key.set_data((void *)key1.c_str());
                   key.set_size((u_int32_t)strlen(key1.c_str()));
         sstrm.str("");
         int payload = rand() + j;
                                  sstrm << "price" << payload << ends;
         value1 = sstrm.str();
                   value.set_data((void *)value1.c_str());
                   value.set_size((u_int32_t)strlen(value1.c_str()));
         // Perform the database put
         (*dbh)->put(txn, &key, &value, 0);
                             printf("Kill me !!\n");
                             kill(getpid(),-9);
                             exit(0);
         try
                                  // commit
                        txn->commit(0);
                        txn = NULL;
                   } catch (DbException &e) {
                        std::cout << "Error on txn commit: " << e.what() << std::endl;
                             if (loop_rate>0)
                                  usleep(txn_rate * 1000 * 1000 / loop_rate);
                        else if (start_loop_d)
    int j=0;
    for (int i=start_loop_d; i<=end_loop_d; i=i+100)
    //transaction begin
                   txn = NULL;
                   cur_env.txn_begin(NULL, &txn, 0);
    for (j=i; j<=end_loop_d && j<=(i+100); j++)
                                  Dbt key, value;
         std::string key1, value1;
         std::stringstream sstrm;
         sstrm << "key" << j << ends;
         key1 = sstrm.str();
                   key.set_data((void *)key1.c_str());
                   key.set_size((u_int32_t)strlen(key1.c_str()));
         // Perform the database put
         (*dbh)->del(txn, &key, 0);
         try
                                  // commit
                        txn->commit(0);
                        txn = NULL;
                   } catch (DbException &e) {
                        std::cout << "Error on txn commit: " << e.what() << std::endl;
                        else
                             const char *symbol = token1.c_str();
                             StringDbt key(const_cast<char*>(symbol));
                             const char *price = token2.c_str();
                             StringDbt data(const_cast<char*>(price));
                             (*dbh)->put(NULL, &key, &data, 0);
              } catch (DbDeadlockException e) {
                   log("please retry the operation");
                   dbh->close();
              } catch (DbRepHandleDeadException e) {
                   log("please retry the operation");
                   dbh->close();
              } catch (DbException e) {
                   if (e.get_errno() == DB_REP_LOCKOUT) {
                   log("please retry the operation");
                   dbh->close();
                   } else
                   throw;
         dbh->close();
    void RepQuoteExample::event_callback(DbEnv* dbenv, u_int32_t which, void *info)
         static char buf[256];
         APP_DATA app = (APP_DATA)dbenv->get_app_private();
         info = NULL;          /* Currently unused. */
         switch (which) {
         case DB_EVENT_REP_CLIENT:
              app->is_master = 0;
              app->in_client_sync = 1;
              sprintf(buf,"%s - %s",progname,"CLIENT");
              //EZ->dbenv->set_errpfx(buf);
              log("DB_EVENT_REP_CLIENT.");
              break;
         case DB_EVENT_REP_MASTER:
              app->is_master = 1;
              app->in_client_sync = 0;
              sprintf(buf,"%s - %s",progname,"MASTER");
              //EZ->dbenv->set_errpfx(buf);
              log("DB_EVENT_REP_MASTER.");
              break;
         case DB_EVENT_REP_NEWMASTER:
              log("DB_EVENT_REP_NEWMASTER.");
              app->in_client_sync = 1;
              break;
         case DB_EVENT_REP_PERM_FAILED:
              // Did not get enough acks to guarantee transaction
              // durability based on the configured ack policy. This
              // transaction will be flushed to the master site's
              // local disk storage for durability.
              log("DB_EVENT_REP_PERM_FAILED.");
              log("Insufficient acknowledgements to guarantee transaction durability.");
              break;
         case DB_EVENT_REP_STARTUPDONE:
              app->in_client_sync = 0;
              log("DB_EVENT_REP_STARTUPDONE.");
              break;
         case DB_EVENT_REP_ELECTION_FAILED:
              log("DB_EVENT_REP_ELECTION_FAILED.");
              //g_runner->init(g_config);
              printf("Kill me !!\n");
              kill(getpid(),-9);
              exit(0);
              break;
         case DB_EVENT_REP_DUPMASTER:
              log("DB_EVENT_REP_DUPMASTER.");
              break;
         default:
              dbenv->errx("ignoring event %d", which);
    void RepQuoteExample::print_stocks_size(Db *dbp) {
         DB_BTREE_STAT *statp;
    dbp->stat(NULL, &statp, 0);
         log("db_stat");
    cout << "***************************************** >>>>>>>>>>> : database contains " << (u_long)statp->bt_ndata << " records\n";
    void RepQuoteExample::print_env(DbEnv *dbenv) {
         dbenv->stat_print(DB_STAT_ALL);
    void RepQuoteExample::print_stocks(Db *dbp) {
         StringDbt key, data;
    #define     MAXKEYSIZE     10
    #define     MAXDATASIZE     20
         char keybuf[MAXKEYSIZE + 1], databuf[MAXDATASIZE + 1];
         char kbuf, dbuf;
         memset(&key, 0, sizeof(key));
         memset(&data, 0, sizeof(data));
         kbuf = keybuf;
         dbuf = databuf;
         DbcAuto dbc(dbp, 0, 0);
         cout << "\tSymbol\tPrice" << endl
              << "\t======\t=====" << endl;
    int no_records =0;
         for (int ret = dbc->get(&key, &data, DB_FIRST);
              ret == 0;
              ret = dbc->get(&key, &data, DB_NEXT)) {
              key.get_string(&kbuf, MAXKEYSIZE);
              data.get_string(&dbuf, MAXDATASIZE);
    no_records++;
              cout << "\t" << keybuf << "\t" << databuf << endl;
    cout << "********************** NO Records " << no_records << endl;
         cout << endl << flush;
         dbc.close();
    static void usage() {
         cerr << "usage: " << progname << " -h home -l host:port [-CM]"
         << "[-r host:port][-R host:port]" << endl
         << " [-a all|quorum][-b][-n nsites][-p priority][-v]" << endl;
         cerr << "\t -h home (required; h stands for home directory)" << endl
         << "\t -l host:port (required; l stands for local)" << endl
         << "\t -C or -M (optional; start up as client or master)" << endl
         << "\t -r host:port (optional; r stands for remote; any "
         << "number of these" << endl
         << "\t may be specified)" << endl
         << "\t -R host:port (optional; R stands for remote peer; only "
         << "one of" << endl
         << "\t these may be specified)" << endl
         << "\t -a all|quorum (optional; a stands for ack policy)" << endl
         << "\t -b (optional; b stands for bulk)" << endl
         << "\t -n nsites (optional; number of sites in replication "
         << "group; defaults " << endl
         << "\t     to 0 to try to dynamically compute nsites)" << endl
         << "\t -p priority (optional; defaults to 100)" << endl
         << "\t -v (optional; v stands for verbose)" << endl;
         exit(EXIT_FAILURE);
    int main(int argc, char **argv) {
         RepConfigInfo config;
         char ch, portstr, tmphost;
         int tmpport;
         bool tmppeer;
         config.no_dummy_wr = false;
         // Extract the command line parameters
         while ((ch = getopt(argc, argv, "E:a:bCh:l:Mn:p:R:r:vw")) != EOF) {
              tmppeer = false;
              switch (ch) {
              case 'a':
                   if (strncmp(optarg, "all", 3) == 0)
                        config.ack_policy = DB_REPMGR_ACKS_ALL;
                   else if (strncmp(optarg, "quorum", 6) != 0)
                        usage();
                   break;
              case 'b':
                   config.bulk = true;
                   break;
              case 'C':
                   config.start_policy = DB_REP_CLIENT;
                   break;
              case 'E':
    config.start_policy = DB_REP_ELECTION;
    break;
              case 'h':
                   config.home = optarg;
                   break;
              case 'l':
                   config.this_host.host = strtok(optarg, ":");
                   if ((portstr = strtok(NULL, ":")) == NULL) {
                        cerr << "Bad host specification." << endl;
                        usage();
                   config.this_host.port = (unsigned short)atoi(portstr);
                   config.got_listen_address = true;
                   break;
              case 'M':
                   config.start_policy = DB_REP_MASTER;
                   break;
              case 'n':
                   config.totalsites = atoi(optarg);
                   break;
              case 'p':
                   config.priority = atoi(optarg);
                   break;
              case 'R':
                   tmppeer = true; // FALLTHROUGH
              case 'r':
                   tmphost = strtok(optarg, ":");
                   if ((portstr = strtok(NULL, ":")) == NULL) {
                        cerr << "Bad host specification." << endl;
                        usage();
                   tmpport = (unsigned short)atoi(portstr);
                   config.addOtherHost(tmphost, tmpport, tmppeer);
                   break;
              case 'v':
                   config.verbose = true;
                   break;
              case 'w':
                   config.no_dummy_wr = true;
                   //config.priority = 2;
                   break;
              case '?':
              default:
                   usage();
         // Error check command line.
         if ((!config.got_listen_address) || config.home == NULL)
              usage();
         RepQuoteExample runner;
         g_runner=&runner;
         g_config=&config;
         try {
              runner.init(&config);
              runner.doloop();
         } catch (DbException dbe) {
              cerr << "Caught an exception during initialization or"
                   << " processing: " << dbe.what() << endl;
         runner.terminate();
         return 0;
    // This is a very simple thread that performs checkpoints at a fixed
    // time interval. For a master site, the time interval is one minute
    // plus the duration of the checkpoint_delay timeout (30 seconds by
    // default.) For a client site, the time interval is one minute.
    void checkpoint_thread(void args)
         DbEnv *env;
         APP_DATA *app;
         int i, ret;
         env = (DbEnv *)args;
         app = (APP_DATA *)env->get_app_private();
         for (;;) {
              // Wait for one minute, polling once per second to see if
              // application has finished. When application has finished,
              // terminate this thread.
              for (i = 0; i < 60; i++) {
                   sleep(1);
                   if (app->app_finished == 1)
                        return ((void *)EXIT_SUCCESS);
              // Perform a checkpoint.
              // original line
              if ((ret = env->txn_checkpoint(0, 0, 0)) != 0) {
              //if ((ret = env->txn_checkpoint(0, 0, DB_FORCE)) != 0) {
                   env->err(ret, "Could not perform checkpoint.\n");
                   return ((void *)EXIT_FAILURE);
    // This is a simple log archive thread. Once per minute, it removes all but
    // the most recent 3 logs that are safe to remove according to a call to
    // DBENV->log_archive().
    // Log cleanup is needed to conserve disk space, but aggressive log cleanup
    // can cause more frequent client initializations if a client lags too far
    // behind the current master. This can happen in the event of a slow client,
    // a network partition, or a new master that has not kept as many logs as the
    // previous master.
    // The approach in this routine balances the need to mitigate against a
    // lagging client by keeping a few more of the most recent unneeded logs
    // with the need to conserve disk space by regularly cleaning up log files.
    // Use of automatic log removal (DBENV->log_set_config() DB_LOG_AUTO_REMOVE
    // flag) is not recommended for replication due to the risk of frequent
    // client initializations.
    void log_archive_thread(void args)
         DbEnv *env;
         APP_DATA *app;
         char **begin, **list;
         int i, listlen, logs_to_keep, minlog, ret;
         env = (DbEnv *)args;
         app = (APP_DATA *)env->get_app_private();
         logs_to_keep = 3;
         for (;;) {
              // Wait for one minute, polling once per second to see if
              // application has finished. When application has finished,
              // terminate this thread.
              for (i = 0; i < 60; i++) {
                   sleep(1);
                   if (app->app_finished == 1)
                        return ((void *)EXIT_SUCCESS);
              // Get the list of unneeded log files.
              if ((ret = env->log_archive(&list, DB_ARCH_ABS)) != 0) {
                   env->err(ret, "Could not get log archive list.");
                   return ((void *)EXIT_FAILURE);
              if (list != NULL) {
                   listlen = 0;
                   // Get the number of logs in the list.
                   for (begin = list; *begin != NULL; begin++, listlen++);
                   // Remove all but the logs_to_keep most recent
                   // unneeded log files.
                   minlog = listlen - logs_to_keep;
                   for (begin = list, i= 0; i < minlog; list++, i++) {
                        if ((ret = unlink(*list)) != 0) {
                             env->err(ret,
                             "logclean: remove %s", *list);
                             env->errx(
                             "logclean: Error remove %s", *list);
                             free(begin);
                             return ((void *)EXIT_FAILURE);
                   free(begin);
    #define DATABASE_DUMMY "dummy.db"
    void create_dummy_db(DB_ENV env, DB *dbp)
    DB_ENV *dbenv=env;
    int ret;
    u_int32_t db_flags;
    if ((ret = db_create(dbp, dbenv, 0)) != 0)
    dbenv->err(dbenv, ret, "create_dummy_db: db_create");
    db_flags = DB_AUTO_COMMIT | DB_CREATE;
    //if ((ret = (*dbp)->open(*dbp,NULL, DATABASE, NULL, DB_BTREE, db_flags, 0)) != 0)
    if ((ret = (*dbp)->open(*dbp,NULL, NULL, DATABASE_DUMMY, DB_BTREE, db_flags, 0)) != 0)
    dbenv->err(dbenv, ret, "create_dummy_db: DB->open");
    void reopen_dummy_db(DB_ENV env, DB *dbp)
    DB_ENV *dbenv=env;
    int ret;
    u_int32_t db_flags;
    if ((ret = db_create(dbp, dbenv, 0)) != 0)
    dbenv->err(dbenv, ret, "create_dummy_db: db_create");
    db_flags = DB_AUTO_COMMIT | DB_CREATE;
    //if ((ret = (*dbp)->open(*dbp,NULL, DATABASE, NULL, DB_BTREE, db_flags, 0)) != 0)
    if ((ret = (*dbp)->open(*dbp,NULL, NULL, DATABASE_DUMMY, DB_BTREE, db_flags, 0)) != 0)
    dbenv->err(dbenv, ret, "reopen_dummy_db: DB->open");
    void perform_db_operation(DB_ENV env, DB *dbp, bool bRead)
    //main loop
    //DB *dbp=NULL;
    DB_ENV *dbenv=env;
    int ret;
    u_int32_t db_flags;
    DBT key, data;
    char buf[20]="dummy", *rbuf;
    rbuf=buf;
    if (*dbp == NULL)
    create_dummy_db(dbenv, dbp);
    if (! bRead)
         memset(&key, 0, sizeof(key));
         memset(&data, 0, sizeof(data));
         key.data = buf;
         key.size = (u_int32_t)strlen(buf);
         data.data = rbuf;
         data.size = (u_int32_t)strlen(rbuf);
         if ((ret = (*dbp)->put(*dbp, NULL, &key, &data, 0)) != 0)
              if (ret == DB_REP_HANDLE_DEAD)
                   //create_dummy_db(dbenv, dbp);
                   reopen_dummy_db(dbenv, dbp);
                   (*dbp)->err(*dbp, ret, "DB->put :");
              else
              if (ret != DB_KEYEXIST)
                   (*dbp)->err(*dbp, ret, "perform_db_operation: DB->put");
         else
              DB_BTREE_STAT *statp;
              (*dbp)->stat(*dbp,NULL, &statp, 0);
              std::cout<<"dbp read stats: key#"<< statp->bt_nkeys <<std::endl;
    void dummy_write_thread(void args)
         DbEnv *env;
         APP_DATA *app;
         char **begin, **list;
         int i, listlen, logs_to_keep, minlog, ret;
         DB *m_dbp; // a pointer
         env = (DbEnv *)args;
         app = (APP_DATA *)env->get_app_private();
         logs_to_keep = 3;
         for (;;) {
              if (! app->no_dummy_wr)
                   if (app->is_master)
                   perform_db_operation(env->get_DB_ENV(),&m_dbp,false);
                        //env->txn_checkpoint(0, 0, DB_FORCE);
              usleep(1 * 1000 * 1000);
              else
                   if (app->is_master)
                        //DB *db_quote=g_repquote->get_DB();
                        //perform_db_operation(env->get_DB_ENV(),&db_quote,true);
                        //if (g_repquote)
                        //     g_runner->print_stocks_size(g_repquote);
                        //env->txn_checkpoint(0, 0, DB_FORCE);
                        //perform_db_operation(env->get_DB_ENV(),&m_dbp,false);
                        env->rep_flush();
              usleep(4 * 1000 * 1000);
    my script to simulate the split brain
    #!/bin/sh
    [ -z "$node1" ] && node1=10.10.32.121
    [ -z "$node2" ] && node2=10.10.32.91
    trap myend 0 1 2 3 6 9 14 15
    myend()
         echo "Receive signal to stop test..."
         un_split_brain
         echo "done"
         exit 1
    split_brain()
         echo -n "Split-Brain at node $node..."
         snmpset -m ALL -v 2c -c svil 10.10.0.100 ifAdminStatus.41 i 2 >/dev/null 2>&1
         echo "done"
    un_split_brain()
         echo -n "Undo Split-Brain at node $node..."
         snmpset -m ALL -v 2c -c svil 10.10.0.100 ifAdminStatus.41 i 1 >/dev/null 2>&1
         echo "done"
    is_slave()
         local r=$(ssh root@$1 "tail -2 /tmp/BDB.log" | grep -c CLIENT)
         [ $r -gt 1 ] && ret=1 || ret=0
         return $ret
    is_master()
         local r=$(ssh root@$1 "tail -2 /tmp/BDB.log" | grep -c MASTER)
         [ $r -gt 1 ] && ret=1 || ret=0
         return $ret
    wait_for_master()
         echo -n "Waiting for MASTER at node $node ... "
         is_master $node
         r=$?
         while ( [ ! $r -eq 1 ] )
         do
         usleep 500000
         is_master $node
         r=$?
         echo -n "."
         done
         echo "done"
    wait_for_slave()
         local r
         local tm
         tm=0
         echo -n "Waiting for SLAVE at node $node ... "
         is_slave $node
         r=$?
         while ( [ ! $r -eq 1 ] )
         do
              usleep 500000
              is_slave $node
              r=$?
              echo -n "."
              tm=$((tm+1))
              [ $tm -gt 120 ] && break
         done
         [ $tm -gt 120 ] && ret=0 || ret=1
         echo "done"
         return $ret
    run_test_split_brain()
         local nt
         nt=1
         nfails=0
         x=4
         [ -z "$1" ] && node=$node2
         while ((1))
         do
              printf "*************** TEST [%02d] ********************\n" $nt
              split_brain
              wait_for_master
              x=$((RANDOM%9))
              echo -n " waiting $x sec ..."
              sleep $x
              echo "done"
              un_split_brain
              wait_for_slave
              r=$?
              [ ! $r -eq 1 ] && echo "`date` - test [$nt] - fails ..." || echo "`date` - test [$nt] - OK ."
              [ ! $r -eq 1 ] && nfails=$((nfails+1))
              perc_failure=$(echo "100.0 - $nfails / $nt * 100.0" | bc -l)
              echo "************************************************ [% Success test $perc_failure % ]"
              nt=$((nt+1))
              x=$((RANDOM%9))
              echo -n " waiting $x sec ..."
              sleep $x
         done
    run_test_split_brain
    here is the makefile to run to two environments
    i run:
    - make run
    and in another window sh test_split_brain.sh
    node1?=10.10.32.121
    node2?=10.10.32.91
    nsite?=2
    debug?=0
    all: RepQuoteExampleEric install
    RepConfigInfo.o: RepConfigInfo.cpp RepConfigInfo.h
         g++ -I/usr/local/BerkeleyDB.5.1/include/ -g -O0 -c RepConfigInfo.cpp -o RepConfigInfo.o
    RepQuoteExampleEric: RepQuoteExampleEric.cpp RepConfigInfo.o
         g++ -I/usr/local/BerkeleyDB.5.1/include/ -g -O0 RepQuoteExampleEric.cpp RepConfigInfo.o -o RepQuoteExampleEric -L /usr/local/BerkeleyDB.5.1/lib/ -lreadline -lcurses -ldb_cxx
    kill:
         -ssh -X root@$(node1) "killall -9 /root/RepQuoteExampleEric"
         -ssh -X root@$(node2) "killall -9 /root/RepQuoteExampleEric"
    run: RepQuoteExampleEric kill install clean_env
         ssh -X root@$(node1) "xterm -geom 100x20+100+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.110:12345 -r 2.0.0.210:12345 -a quorum -b -n $(nsite) -v | tee /tmp/BDB.log\"" &
         ssh -X root@$(node2) "xterm -geom 100x20+800+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.210:12345 -r 2.0.0.110:12345 -a quorum -b -n $(nsite) -v -w | tee /tmp/BDB.log\"" &
    run_node2: clean_env2
         ssh -X root@$(node2) "xterm -geom 100x20+800+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.210:12345 -r 2.0.0.110:12345 -a quorum -b -n $(nsite) -v -w | tee /tmp/BDB.log\"" &
    debug_node2: clean_env2
         ssh -X root@$(node2) "xterm -geom 100x20+800+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.210:12345 -r 2.0.0.110:12345 -a quorum -b -n $(nsite) -v -w | tee /tmp/BDB.log\"" &
         sleep 3
         ssh -X root@$(node2) /sbin/pidof RepQuoteExampleEric >/tmp/pid
         ssh -X root@$(node2) ~/kdbg /root/db-5.1.19/examples/cxx/excxx_repquote/RepQuoteExampleEric -p `cat /tmp/pid`
    run_debug_node1: RepQuoteExampleEric kill install clean_env
         ssh -X root@$(node1) "xterm -geom 100x20+100+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/kdbg /root/RepQuoteExampleEric\" " &
         ssh -X root@$(node2) "xterm -geom 100x20+800+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.210:12345 -r 2.0.0.110:12345 -a quorum -b -n $(nsite) -v\"" &
    run_debug_node2: RepQuoteExampleEric kill install clean_env
         ssh -X root@$(node1) "xterm -geom 100x20+100+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/RepQuoteExampleEric -h /opt/bdb/ -l 2.0.0.110:12345 -r 2.0.0.210:12345 -a quorum -b -n $(nsite) -v\" " &
         ssh -X root@$(node2) "xterm -geom 100x20+800+100 -e \"LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.1/lib/ /root/kdbg /root/RepQuoteExampleEric\"" &
    install: RepQuoteExampleEric
         scp RepQuoteExampleEric root@$(node1):~
         scp RepQuoteExampleEric root@$(node2):~
    clean_env: clean_env1 clean_env2
    clean_env1:
         ssh -X root@$(node1) rm -rf /opt/bdb/*
    clean_env2:
         ssh -X root@$(node2) rm -rf /opt/bdb/*

  • [JS,AS,CS3]running javascript in bridge from applescript

    Sorry for the cryptic subject description, and you might think this is a bit off topic, but i hope you could shed some light on this.
    I need to execute a Javascript in Bridge from an applsecript using an Applescript. Bridge only has one AS command: do javascript with arguments.
    My testtude looks like this:
    set myJS to "
    alert(arguments[0].toString());
    alert(arguments[1].toString());
    alert(arguments[2].toString());
    alert(arguments[3].toString());
    alert(arguments[4][0].toString());
    set arg1 to 12
    set arg2 to "some text"
    set arg3 to "'some single quoted text'"
    set arg4 to "\"some double quoted text\""
    set arg5 to {1, 2, 3, "a", "b", "c"}
    tell application "Bridge CS3"
    do javascript myJS with arguments {arg1, arg2, arg3, arg4, arg5}
    end tell
    --tell application "Adobe Photoshop CS3"
    -- do javascript myJS with arguments {arg1,arg2,arg3,arg4,arg5}
    --end tell
    You would expect a series of dialogs to appear with the content of the arguments, but you'll get nothing! If you omit the '[0]', you'll get any numerical value, but all strings, however they are quoted, are ignored.
    Strange.
    Stranger still is, that if do the exact same thing in Photoshop, it works like a charm and you can pass any kind of data as argument.
    Any ideas on what's going on?
    Thanks!

    Here is my AS script from Xcode project:
    Some text is in Russian don't mind it. Most important that this is a
    working example.
    global myBridgeLabel
    on clicked theObject
    if name of theObject is "b1" then
      set processName to (StringToUnicode "Начало работы")
      set myBridgeLabel to "Red"
      set myLabel to 1
    else if name of theObject is "b2" then
      set processName to (StringToUnicode "Сдано на цв-корр")
      set myBridgeLabel to "Green"
      set myLabel to 2
    else if name of theObject is "b3" then
      set processName to (StringToUnicode "Сдано на ДТП")
      set myBridgeLabel to "Yellow"
      set myLabel to 3
    else if name of theObject is "b4" then
      set processName to (StringToUnicode "Забрано")
      set myBridgeLabel to "Blue"
      set myLabel to 4
    else if name of theObject is "b5" then
      set processName to (StringToUnicode "Пересдано")
      set myBridgeLabel to "Purple"
      set myLabel to 5
    end if
    tell application "Adobe InDesign CS2"
      set mydocument to active document
      set myDocumentPath to full name of mydocument
      set workerName to "Сервецкий"
      tell metadata preferences of mydocument
       set theDate to current date
       set myWeekday to weekday of theDate as string
       set myDenNedeli to my convertWeekday(myWeekday)
       set myRecord to (processName & "  " & workerName & "  ") & myDenNedeli & " " & text 1 thru -4 of time string of theDate & "
       set myHistory to get property namespace "http://ns.adobe.com/photoshop/1.0/" path "History"
       set property namespace "http://ns.adobe.com/photoshop/1.0/" path "History" value myHistory & myRecord
      end tell
      set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate(); var bt = new BridgeTalk; bt.target = \"bridge\"; myScript = 'app.displayDialogs = \"none\"; var t = new Thumbnail (File (\"" & myDocumentPath & "\")); var mdata = t.metadata; mdata.namespace = \"http://ns.adobe.com/xap/1.0/\"; mdata.Label = \"' + myLabel + '\";'; bt.body = myScript; bt.send();"
      do script myJavaScript language javascript
      tell mydocument to save
    end tell
    tell application "Finder"
      set myFile to a reference to file myDocumentPath
      set label index of myFile to myLabel
    end tell
    end clicked
    on convertWeekday(myWeekday)
    if myWeekday = "Monday" then
      return "Пн"
    else if myWeekday = "Tuesday," then
      return "Вторник"
    else if myWeekday = "Wednesday" then
      return "Среда"
    else if myWeekday = "Thursday" then
      return "Четверг"
    else if myWeekday = "Friday" then
      return "Пятница"
    else if myWeekday = "Saturday" then
      return "Суббота"
    else if myWeekday = "Sunday" then
      return "Воскресенье"
    else
      return "N/a"
    end if
    end convertWeekday

  • Oracle adf file handling af: inputFile and convert to binary to send in

    Hi ...
    I want to try to do is select a file by a <af: inputFile and convert it to binary without having to upload it to the UCM .... I have some idea of how it would be something like this ....
    <af:form usesUpload="true">
    <af:inputFile label="Upload:"
    valueChangeListener="#{backingBean.fileUploaded}"/>
    <af:commandButton text="Begin"/>
    </af:form>
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.faces.application.FacesMessage;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    import javax.faces.event.ValueChangeEvent;
    import javax.xml.namespace.QName;
    import javax.xml.ws.Holder;
    import org.apache.myfaces.trinidad.model.UploadedFile;
    import org.tempuri.*;
    String Binary = new String();
    public void fileUploaded(ValueChangeEvent event) {
    UploadedFile file = (UploadedFile) event.getNewValue();
    if (file != null)
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message = new FacesMessage(
    "Successfully uploaded file " + file.getFilename() +
    " (" + file.getLength() + " bytes)");
    context.addMessage(event.getComponent().getClientId(context), message);
    public void llamarWs(UploadedFile file){
    URL url;
    try {
    Holder<String> holder = new Holder<String>();
    Holder<Boolean> holderResponse = new Holder<Boolean>();
    url = new URL("10.10.20.152:8088/VTDWEntelSAEDWS/DWSAEDService.asmx?wsdl");
    DWSAEDServiceSoap servicePort = new DWSAEDService(url, new QName("http://tempuri.org/","DWSAEDService")).getDWSAEDServiceSoap();
    servicePort.uploadDocument(holder, arg1, arg2, arg3, arg4, arg5, holderResponse);
    String respuest = holder.value;
    } catch (MalformedURLException e) {
      but I can not make it work ...
    Edited by: 892270 on 16-Aug-2012 08:46

    User, please always tell us your jdev version as the solution might depend on it.
    Instead of posting some code, can you please elaborate on the use case? From the code I don'T understand what you try to do. Data (file) uploaded through the af:inputFile is binary. The file may only be a text file, but it might be an image. The inputFile doen not know as it only represents the data stream send from the client.
    In you code I don't see that you actually read the data from the stream, neither do I see any action on the stream. Can you describe what you mean by
    but I can not make it work ...You may read http://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-1/ for more info about file handling in ADF
    Timo

  • Using Runtime.exec to execute Java.exe

    I am trying to use Runtime.exec to spawn a thread that runs java.exe, but havn't had any luck. I have two versions of code, the first one works (example 1), but I want to eliminate the use of "cmd /c" to keep system independance. The second example (example 2) does not work. Both versions work if invoked from the command line. I'm running Win2000. Any Ideas?
    Example 1:
    aProcess = aRuntime.exec("cmd /c java.exe
    -cp "<MyClassPathHere>" <arg1> <arg2> <arg3> <arg4> <arg5>");
    Example 2:
    aProcess = aRuntime.exec("java.exe
    -cp "MyClassPathHere" <arg1> <arg2> <arg3> <arg4> <arg5>");

    I think you mix two concepts: "threads" and "processes". A "thread" is a thread of execution inside the VM, but you want to actually start a new VM in a new process, which is an OS level thing, right?
    I've tried Idea 2 also, same result: works if
    i specify cmd c/, doesn't if I don't.It should work if java.exe is in your path... are you taking care of the standard streams of your process?

Maybe you are looking for