endurox-java
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
org.endurox.AtmiCtx Class Reference

Public Member Functions

long getCtx ()
 
void setCtx (long ctx)
 
Server getSvr ()
 
native TypedBuffer tpalloc (String btype, String bsubtype, long size)
 
 AtmiCtx ()
 
 AtmiCtx (long ctx)
 
native void tpterm ()
 
void cleanup ()
 
native void tpreturn (int rval, long rcode, TypedBuffer data, long flags)
 
native void tpforward (String svcname, TypedBuffer data, long flags)
 
synchronized int tprun (Server svr, String[] arg)
 
synchronized int tprun (Server svr)
 
void tpadvertise (String svcname, String funcname, Service svc)
 
native void tplogdelbufreqfile (TypedBuffer data)
 
native int tplogqinfo (int lev, long flags)
 
native void tplogex (int lev, String msg, Throwable e)
 
native void tplogsetreqfile (TypedBuffer data, String filename, String filesvc)
 
native String tploggetbufreqfile (TypedBuffer data)
 
native String tploggetreqfile ()
 
native void tplogsetreqfile_direct (String filename)
 
native void tplogclosereqfile ()
 
native void tplogconfig (int logger, int lev, String debug_string, String module, String new_file)
 
native void userlogex (String msg, Throwable e)
 
void tplog (int lev, boolean directCall, String format, Object... arguments)
 
void tplogAlways (String format, Object... arguments)
 
void tplogError (String format, Object... arguments)
 
void tplogWarn (String format, Object... arguments)
 
void tplogInfo (String format, Object... arguments)
 
void tplogDebug (String format, Object... arguments)
 
native void tplogDump (int lev, String msg, byte[] data)
 
native void tplogDumpDiff (int lev, String msg, byte[] data1, byte[] data2)
 
native void tpinit (TpInit tpinfo)
 
void userlog (String format, Object... arguments)
 
native TypedBuffer tpcall (String svc, TypedBuffer idata, long flags)
 
native int tpacall (String svc, TypedBuffer idata, long flags)
 
native TpgetrplyResult tpgetrply (int cd, TypedBuffer odata, long flags)
 
native int tpconnect (String svc, TypedBuffer idata, long flags)
 
native long tpsend (int cd, TypedBuffer idata, long flags)
 
native TprecvResult tprecv (int cd, TypedBuffer idata, long flags)
 
native void tpdiscon (int cd)
 
native void tpcancel (int cd)
 
native BExprTree Bboolco (String expr)
 
native void Bboolpr (BExprTree cexpr, OutputStream ostream)
 
void Bboolsetcbf (String funcname, Bboolcbf callback)
 
native String Btype (int bfldid)
 
native String Bfname (int bfldid)
 
native int Bfldid (String fldnm)
 
native int tptoutget ()
 
native long tpurcode ()
 
native void tptoutset (int tout)
 
TypedString newString (String s)
 
TypedJson newJson (String j)
 
TypedCarray newCarray (byte[] b)
 
native long[] getBuffers ()
 
UnsolCallback tpsetunsol (UnsolCallback cb)
 
native void tpnotify (ClientId clientid, TypedBuffer idata, long flags)
 
native void tpbroadcast (String lmid, String usrname, String cltname, TypedBuffer idata, long flags)
 
native int tpchkunsol ()
 
native void tpenqueue (String qspace, String qname, TPQCTL ctl, TypedBuffer idata, long flags)
 
native void tpenqueueex (short nodeid, short srvid, String qname, TPQCTL ctl, TypedBuffer idata, long flags)
 
native TypedBuffer tpdequeue (String qspace, String qname, TPQCTL ctl, TypedBuffer odata, long flags)
 
native TypedBuffer tpdequeueex (short nodeid, short srvid, String qname, TPQCTL ctl, TypedBuffer odata, long flags)
 
native long tpsrvgetctxdata ()
 
native void tpsrvsetctxdata (long dataptr, long flags)
 
native void tpsrvfreectxdata (long dataptr)
 
native void tpcontinue ()
 
native void tpopen ()
 
native void tpclose ()
 
native void tpbegin (long timeout, long flags)
 
native void tpcommit (long flags)
 
native void tpabort (long flags)
 
native TPTRANID tpsuspend (long flags)
 
native void tpresume (TPTRANID tid, long flags)
 
Connection tpgetconn () throws SQLException
 
native int tpgetlev ()
 
native void installTermSigHandler (java.lang.Runnable run)
 

Static Public Member Functions

static AtmiCtx createAtmiCtx (long ctx)
 

Public Attributes

XAConnection xaConn = null
 
XAResource xaRes = null
 

Protected Member Functions

void finalize () throws Throwable
 

Constructor & Destructor Documentation

◆ AtmiCtx() [1/2]

org.endurox.AtmiCtx.AtmiCtx ( )

Allocate new ATMI Context

Exceptions
AtmiTPESYSTEMExceptionFailed to allocate new context object in C space.

◆ AtmiCtx() [2/2]

org.endurox.AtmiCtx.AtmiCtx ( long  ctx)

Create new ATMI Context, from existing C/external context. This does not perform C context deallocation

Parameters
ctxptr to C context

Member Function Documentation

◆ Bfldid()

native int org.endurox.AtmiCtx.Bfldid ( String  fldnm)

Method is used to dynamically resolve field id from given field name See Bfldid(3) manpage for more information.

Parameters
fldnmField name
Returns
compiled field id
Exceptions
UbfBEINVALExceptionnull value passed in fldnm

◆ Bfname()

native String org.endurox.AtmiCtx.Bfname ( int  bfldid)

Get field name by give compiled field id. If field tables are bad or field is not found, then output id is formatted as: "((BFLDID32)%d)" where "%d" is filled with bfldid See Bfname(3) manpage for more information.

Parameters
bfldidcompiled filed
Returns
String name of the field

◆ Btype()

native String org.endurox.AtmiCtx.Btype ( int  bfldid)

Return field type in string format. The possible values are following: 'short', 'long', 'char', 'float', 'double', 'string', 'carray' See Btype(3) manpage for more information.

Parameters
bfldidcompiled field id.
Returns
returns field type string
Exceptions
UbfBTYPERRExceptionInvalid field - bad type extracted from oldest bits.

◆ cleanup()

void org.endurox.AtmiCtx.cleanup ( )

Clean up the object (basically this is destructor) as we cannot relay on finalize() auto call of from the Garbage Collector. Thus we object goes out of the scope, this method needs to be called. This automatically invokes tpterm() too.

◆ createAtmiCtx()

static AtmiCtx org.endurox.AtmiCtx.createAtmiCtx ( long  ctx)
static

Create ATMI Context by static call.

Parameters
ctxC pointer
Returns
Atmi Context Object

◆ finalize()

void org.endurox.AtmiCtx.finalize ( ) throws Throwable
protected

Terminate the ATMI Context

Exceptions
Throwable

◆ getBuffers()

native long [] org.endurox.AtmiCtx.getBuffers ( )

List XATMI buffers (C side pointers). Note these pointer might not be valid after the call due to possible work of GC and/or other threads (if used). The method shall not be normally used. It is provided soley for Enduro/X internal purposes.

Returns
List of allocated XATMI buffers. May be used for debug purposes, i.e. detect gc operations.

◆ getCtx()

long org.endurox.AtmiCtx.getCtx ( )

Get The C Context

Returns

◆ getSvr()

Server org.endurox.AtmiCtx.getSvr ( )

Get server object (if any)

Returns

◆ installTermSigHandler()

native void org.endurox.AtmiCtx.installTermSigHandler ( java.lang.Runnable  run)

This set a callback method indicating that shutdown is initiated from the OS. This captures the SIGTERM, SIGINT, SIGHUP signals. I.e. hides from the Java. On first method call, new signals are masked, and new thread is started which monitors the arrival of these signals. Once the signal is detected, the \r run object is executed.

Parameters
runobject to be executed (if set) in case if termination signal is received. In case of NULL, the signal thread is not terminated, but it will do nothing in case of receiving the shutdown signals.

◆ newCarray()

TypedCarray org.endurox.AtmiCtx.newCarray ( byte[]  b)

◆ newJson()

TypedJson org.endurox.AtmiCtx.newJson ( String  j)

Allocate JSON object

Parameters
jstring value to set
Returns
Typed string filled with value

◆ newString()

TypedString org.endurox.AtmiCtx.newString ( String  s)

Allocate string object with value

Parameters
sstring value to set
Returns
Typed string filled with value

◆ setCtx()

void org.endurox.AtmiCtx.setCtx ( long  ctx)

Set the C context

Parameters
ctx

◆ tpacall()

native int org.endurox.AtmiCtx.tpacall ( String  svc,
TypedBuffer  idata,
long  flags 
)

Asynchronous service call See tpacall(3) manpage for more information.

Parameters
svcservice name to call
idatainput typed buffer to send to service
flagscall flags: TPNOTRAN, TPSIGRSTRT, TPNOBLOCK, TPNOREPLY
Exceptions
AtmiTPEINVALExceptionInvalid parameter is given to function. Either service name is NULL or flags does not allow to change the value.
AtmiTPENOENTExceptionNo service (svc parameter) advertised in system.
AtmiTPETIMEExceptionService did not reply in given time (NDRX_TOUT).
AtmiTPESVCFAILExceptionService returned TPFAIL. This is application level failure.
AtmiTPESVCERRExceptionSystem level service failure. Server died during the message presence in service queue.
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEBLOCKExceptionService queue was full and TPNOBLOCK flag was specified.
AtmiTPNOTIMEExceptionDo not expire call by server process, If message age is older than NDRX_TOUT timeout (or timeout overridden by tptoutset(3)).
Returns
call descriptor

◆ tpadvertise()

void org.endurox.AtmiCtx.tpadvertise ( String  svcname,
String  funcname,
Service  svc 
)

Advertise service.

Parameters
svcnameService name
funcnameFunction name
svcinterface to object implementing Service
Exceptions
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info. That could insufficient memory or other error.

◆ tpalloc()

native TypedBuffer org.endurox.AtmiCtx.tpalloc ( String  btype,
String  bsubtype,
long  size 
)

Allocate buffer

Parameters
btypebuffer type name
bsubtypebuffer sub type or empty string (if no subtype)
sizebuffer size in bytes
Returns
allocate ATMI buffer
Exceptions
AtmiTPEINVALExceptioninvalid arguments passed to
btype
or
bsubtype
AtmiTPEOTYPEExceptioninvalid types specified (or sub-type)
AtmiTPESYSTEMExceptionsystem exception occurred
AtmiTPEOSExceptionOperating System error occurred

◆ tpcall()

native TypedBuffer org.endurox.AtmiCtx.tpcall ( String  svc,
TypedBuffer  idata,
long  flags 
)

Call the service See tpcall(3) manpage for more information.

Parameters
svcXATMI service name to call
idataInput buffer
flagsATMI flags; TPNOTRAN, TPSIGRSTRT, TPNOTIME, TPNOCHANGE, TPTRANSUSPEND, TPNOBLOCK
Exceptions
AtmiTPEINVALExceptionInvalid parameter is given to function. Either service name is NULL or flags does not allow to change the value.
AtmiTPENOENTExceptionNo service (svc parameter) advertised in system.
AtmiTPETIMEExceptionService did not reply in given time (NDRX_TOUT).
AtmiTPESVCFAILExceptionService returned TPFAIL. This is application level failure.
AtmiTPESVCERRExceptionSystem level service failure. Server died during the message presence in service queue.
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEBLOCKExceptionService request queue was full and TPNOBLOCK flag was specified.
AtmiTPNOABORTExceptionDo not abort global transaction (if one in progress), even if service failed.
Returns
We return the buffer form the call.

◆ tpcancel()

native void org.endurox.AtmiCtx.tpcancel ( int  cd)

Cancel a tpacall(). This basically marks the in the call descriptor registry that response is no more waited from the caller.

Parameters
cdcall descriptor from the tpacall()
Exceptions
AtmiTPEBADDESCExceptionInvalid call descriptor (out of range).
AtmiTPEINVALExceptionEnduro/X is not configured.
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.

◆ tpforward()

native void org.endurox.AtmiCtx.tpforward ( String  svcname,
TypedBuffer  data,
long  flags 
)

Forward the call to other service for processing

Parameters
svctarget service name
datadata buffer to send
flagscall flags (reserved )

◆ tpgetrply()

native TpgetrplyResult org.endurox.AtmiCtx.tpgetrply ( int  cd,
TypedBuffer  odata,
long  flags 
)

Get reply from Asynchronous call tpacall(). See tpgetrply(3) manpage for more information.

Parameters
[in]cdcall descriptor returned by tpacall(). In case if TPGETANY flag is set, the field value is ignored
[in]odatainput data buffer used for receiving the reply data copied/reallocated to TpgetrplyResult
flagsTPGETANY, TPNOBLOCK, TPSIGRSTRT, TPNOTIME, TPNOCHANGE, TPNOABORT
Returns
result buffer and call descriptor of call returned.
Exceptions
AtmiTPEBLOCKExceptionTPENOBLOCK was specified in flags and no message is in queue.
AtmiTPEINVALExceptionInvalid parameter is given to function. Particularly pointer parameters are NULL.
AtmiTPETIMEExceptionService did not reply in given time (NDRX_TOUT time).
AtmiTPESVCFAILExceptionService returned TPFAIL. This is application level failure.
AtmiTPESVCERRExceptionSystem level service failure. Server died during the message presence in service queue.
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEBADDESCExceptionInvalid call descriptor - out of range or not issued/canceled value. This exception is thrown only in case if TPGETANY flag is not passed to the call.

◆ tpinit()

native void org.endurox.AtmiCtx.tpinit ( TpInit  tpinfo)

Initialize current ATMI Context as a ATMI client

Parameters
tpinfomight be NULL. Currently not used by Enduro/X
Exceptions
AtmiTPEINVALExceptionenvironment not configured
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info.

◆ tpreturn()

native void org.endurox.AtmiCtx.tpreturn ( int  rval,
long  rcode,
TypedBuffer  data,
long  flags 
)

Perform tp return

Parameters
rvalreturn value (TPSUCCESS/TPFAIL)
rcodeuser return code
datadata buffer to return, can be NULL to?
flags

◆ tprun() [1/2]

synchronized int org.endurox.AtmiCtx.tprun ( Server  svr)

Run server using Enduro/X environment variables

Parameters
svrserver class instance
Returns
-1 (failed with out specified error) or 0 Success (finished ok)
Exceptions
AtmiTPEINVALExceptioninvalid command line arguments or invalid ATMI context.

◆ tprun() [2/2]

synchronized int org.endurox.AtmiCtx.tprun ( Server  svr,
String[]  arg 
)

Run server instance. Only one thread is allowed to step into this

Parameters
svrserver class
argCommand line argumenst passed to the Enduro/X core. This is optional and can be NULL. In that case NDRX_SV* environment variables are used.
Returns
-1 (failed with out specified error) or 0 Success (finished ok)
Exceptions
AtmiTPEINVALExceptioninvalid command line arguments or invalid ATMI context.

◆ tpterm()

native void org.endurox.AtmiCtx.tpterm ( )

Terminate XATMI Session. This does not remove the context. To remove context (including XATMI terminate), use cleanup() method.

Exceptions
AtmiTPEPROTOExceptionCalled from XATMI server (main thread)
AtmiTPESYSTEMExceptionFailed to close conversations
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info. That could insufficient memory or other error

◆ tptoutget()

native int org.endurox.AtmiCtx.tptoutget ( )

Return current XATMI timeout for IPC communications. By default method uses NDRX_TOUT env variable for readings if value is not override by

See also
AtmiCtx::tptoutset See tptoutget(3) manpage for more information.
Returns
timeout in seconds currently used by XATMI IPC sub-system

◆ tptoutset()

native void org.endurox.AtmiCtx.tptoutset ( int  tout)

Set XATMI sub-system timeout value

Parameters
toutnumber of seconds for XATMI calls like tpcall or tpgetrply before returning timeout exception See tptoutset(3) manpage for more information.
Exceptions
AtmiTPEINVALExceptiontout parameter is less or equal to 0.

◆ tpurcode()

native long org.endurox.AtmiCtx.tpurcode ( )

Returns last user return code from tpcall/tpgetrply result. See tpurcode(3) manpage for more information.

Returns
User return code (a second argument used to pass in tpreturn)

◆ userlog()

void org.endurox.AtmiCtx.userlog ( String  format,
Object...  arguments 
)

Write user log (for more critical events)

Parameters
formatjava format string
argumentsarguments for format string

Member Data Documentation

◆ xaConn

XAConnection org.endurox.AtmiCtx.xaConn = null

XA Connection handler, i.e. if the context have invoked tpopen().

◆ xaRes

XAResource org.endurox.AtmiCtx.xaRes = null

Currently active connection

public Connection dbConn = null; Currently active resource