openr66.database.data
Class DbTaskRunner

java.lang.Object
  extended by goldengate.common.database.data.AbstractDbData
      extended by openr66.database.data.DbTaskRunner

public class DbTaskRunner
extends goldengate.common.database.data.AbstractDbData

Task Runner from pre operation to transfer to post operation, except in case of error

Author:
Frederic Bregier

Nested Class Summary
static class DbTaskRunner.Columns
           
static class DbTaskRunner.TASKSTEP
          GlobalStep Value
 
Nested classes/interfaces inherited from class goldengate.common.database.data.AbstractDbData
goldengate.common.database.data.AbstractDbData.UpdatedInfo
 
Field Summary
static int[] dbTypes
           
static String fieldseq
           
static DbTaskRunner.Columns[] indexes
           
protected static String insertAllValues
           
static int NBPRKEY
          Special For DbTaskRunner
protected static String selectAllFields
           
static String table
           
protected static String updateAllFields
           
static String XMLEXTENSION
           
static String XMLRUNNER
           
static String XMLRUNNERS
           
 
Fields inherited from class goldengate.common.database.data.AbstractDbData
allFields, dbSession, isSaved, otherFields, primaryKey
 
Constructor Summary
DbTaskRunner(goldengate.common.database.DbSession dbSession, DbRule rule, boolean isSender, RequestPacket requestPacket, String requested, Timestamp startTime)
          Constructor for submission (no transfer session), from database.
DbTaskRunner(goldengate.common.database.DbSession dbSession, long id, String requested)
          Constructor to initiate a request with a valid previous Special Id so loaded from database.
DbTaskRunner(goldengate.common.database.DbSession dbSession, R66Session session, DbRule rule, boolean isSender, RequestPacket requestPacket)
          Constructor from a request with a valid Special Id to be inserted into database
DbTaskRunner(goldengate.common.database.DbSession dbSession, R66Session session, DbRule rule, long id, String requester, String requested)
          Constructor from a request with a valid Special Id so loaded from database
 
Method Summary
 String backendXmlFilename()
           
static void changeFinishedToDone(goldengate.common.database.DbSession session)
          Change CompleteOk+ALLDONETASK to Updated = DONE TaskRunner from database.
 void changeUpdatedInfo(goldengate.common.database.data.AbstractDbData.UpdatedInfo info)
           
 void checkThroughMode()
           
 void clear()
          Clear the runner
 boolean continueTransfer()
           
 void create()
          As insert but with the ability to change the SpecialId
 void delete()
           
 void deleteTempFile()
          Delete the temporary empty file (retrieved file at rank 0)
 void deleteXmlWorkNoDb()
          Delete the backend XML file for the current TaskRunner for NoDb Client
 boolean exist()
           
 boolean existXmlWorkNoDb()
           
 void finalizeTransfer(LocalChannelReference localChannelReference, R66File file, R66Result finalValue, boolean status)
          Once the transfer is over, finalize the Runner by running the error or post operation according to the status.
static void finishSelectOrCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt)
          Set the current time in the given updatedPreparedStatement
static void finishSelectOrCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt, long time)
          Set the current time in the given updatedPreparedStatement
 int finishTransferTask(ErrorCode code)
          Set the status of the transfer
 long freespace(R66Session session)
           
 int getBlocksize()
           
static goldengate.common.database.DbPreparedStatement getCountInfoPrepareStatement(goldengate.common.database.DbSession session)
           
static goldengate.common.database.DbPreparedStatement getCountInOutErrorPrepareStatement(goldengate.common.database.DbSession session, boolean in)
          Running or not transfers are concerned
static goldengate.common.database.DbPreparedStatement getCountInOutRunningPrepareStatement(goldengate.common.database.DbSession session, boolean in, boolean running)
          Running or not transfers are concerned
static goldengate.common.database.DbPreparedStatement getCountStatusPrepareStatement(goldengate.common.database.DbSession session)
           
static goldengate.common.database.DbPreparedStatement getCountStatusRunningPrepareStatement(goldengate.common.database.DbSession session, ErrorCode status)
          Only running transfers
static goldengate.common.database.DbPreparedStatement getCountStepPrepareStatement(goldengate.common.database.DbSession session, DbTaskRunner.TASKSTEP globalstep)
           
 ErrorCode getErrorInfo()
           
 String getFileInformation()
           
 String getFilename()
           
static goldengate.common.database.DbPreparedStatement getFilterPrepareStatement(goldengate.common.database.DbSession session, int limit, boolean orderBySpecialId, String startid, String stopid, Timestamp start, Timestamp stop, String rule, String req, boolean pending, boolean transfer, boolean error, boolean done, boolean all)
           
static DbTaskRunner getFromStatement(goldengate.common.database.DbPreparedStatement preparedStatement)
          For instance from Commander when getting updated information
 int getGloballaststep()
           
protected  String getInsertAllValues()
           
 String getKey()
          Used internally
 LocalChannelReference getLocalChannelReference()
           
static goldengate.common.database.DbPreparedStatement getLogPrepareStatement(goldengate.common.database.DbSession session, Timestamp start, Timestamp stop)
           
 int getMode()
           
 String getOriginalFilename()
           
 int getRank()
           
 RequestPacket getRequest()
           
 String getRequested()
           
static String getRequested(R66Session session, RequestPacket requestPacket)
           
 String getRequester()
           
static String getRequester(R66Session session, RequestPacket requestPacket)
           
static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt)
           
static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt, goldengate.common.database.data.AbstractDbData.UpdatedInfo info, long time)
           
static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt, ErrorCode error, long time)
           
 DbRule getRule()
           
 String getRuleId()
           
protected  String getSelectAllFields()
           
static goldengate.common.database.DbPreparedStatement getSelectFromInfoPrepareStatement(goldengate.common.database.DbSession session, goldengate.common.database.data.AbstractDbData.UpdatedInfo info, boolean orderByStart, int limit)
           
 long getSpecialId()
           
 Timestamp getStart()
           
 ErrorCode getStatus()
           
static goldengate.common.database.DbPreparedStatement getStatusPrepareStatement(goldengate.common.database.DbSession session, ErrorCode status, int limit)
           
 int getStep()
           
static goldengate.common.database.DbPreparedStatement getStepPrepareStatement(goldengate.common.database.DbSession session, DbTaskRunner.TASKSTEP globalstep, int limit)
           
 Timestamp getStop()
           
protected  String getTable()
           
protected  String getUpdateAllFields()
           
 goldengate.common.database.data.AbstractDbData.UpdatedInfo getUpdatedInfo()
           
protected  String getWherePrimaryKey()
           
static String headerHtml()
           
 void incrementRank()
          Increment the rank of the transfer
protected  void initObject()
           
 void insert()
           
 boolean isAllDone()
           
 boolean isFileMoved()
           
 boolean isFinished()
           
 boolean isInError()
           
 boolean isInTransfer()
           
 boolean isPreTaskStarting()
          To be called before executing Pre execution
 boolean isRecvThrough()
           
 boolean isRescheduledTransfer()
           
 boolean isSelfRequested()
           
 boolean isSender()
           
 boolean isSendThrough()
           
 void loadXmlWorkNoDb()
          Method to load a previous existing DbTaskRunner for NoDb client from File instead of from DB.
static int purgeLogPrepareStatement(goldengate.common.database.DbSession session, String startid, String stopid, Timestamp start, Timestamp stop, String rule, String req, boolean pending, boolean transfer, boolean error, boolean done, boolean all)
           
static int purgeLogPrepareStatement(goldengate.common.database.DbSession session, Timestamp start, Timestamp stop)
          purge in same interval all runners with globallaststep as ALLDONETASK or UpdatedInfo as Done
 boolean ready()
           
 boolean reset()
          Reset the runner (ready to be run again)
static void resetToSubmit(goldengate.common.database.DbSession session)
          Change RUNNING, INTERRUPTED to TOSUBMIT TaskRunner from database.
 boolean restart(boolean submit)
          Make this Runner ready for restart
 void restartRank()
          Decrease if necessary the rank
 void run()
          Run all task from current status (globalstep and step)
 void saveStatus()
          This method is to be called each time an operation is happening on Runner
 void select()
           
 void setAllDone()
          Set the global step as finished (after post task in success)
 void setErrorExecutionStatus(ErrorCode code)
          Set the ErrorCode for the UpdatedInfo
 void setErrorTask(LocalChannelReference localChannelReference)
          Set the Error Task step
 void setExecutionStatus(ErrorCode status)
          Change the status from Task Execution
 void setFileMoved(String newFilename, boolean isFileMoved)
           
 void setFilename(String filename)
           
 void setFrom(DbTaskRunner runner)
          Partial set from another runner (infostatus, rank, status, step, stop, filename, globallastep, globalstep, isFileMoved)
protected  void setFromArray()
           
 void setLocalChannelReference(LocalChannelReference localChannelReference)
          Set a localChannelReference
 void setOriginalFilename(String originalFilename)
           
 void setPostTask()
          Set the Post Task step
 void setPreTask()
          Set Pre Task step
protected  void setPrimaryKey()
          Set the primary Key as current value
 void setRankAtStartup(int rank)
          To set the rank at startup of the request if the request specify a specific rank
 void setRescheduledTransfer()
          Set this DbTaskRunner as rescheduled (valid only while still in memory)
 void setStart(Timestamp start)
           
protected  void setToArray()
           
 void setTransferTask(int rank)
          Set Transfer rank
 boolean stopOrCancelRunner(ErrorCode code)
          Stop or Cancel a Runner from database point of view
 String toHtml(R66Session session, String running)
           
 String toLogRunStep()
           
 String toShortNoHtmlString(String newline)
           
 String toShortString()
           
 String toSpecializedHtml(R66Session session, String body, String running)
           
 String toString()
           
 void update()
           
static NbAndSpecialId writeXML(goldengate.common.database.DbPreparedStatement preparedStatement, org.dom4j.io.XMLWriter xmlWriter)
          Write the selected TaskRunners from PrepareStatement to a XMLWriter
 void writeXmlWorkNoDb()
          Method to write the current DbTaskRunner for NoDb client instead of updating DB.
static NbAndSpecialId writeXMLWriter(goldengate.common.database.DbPreparedStatement preparedStatement, String filename)
          Write selected TaskRunners to an XML file using an XMLWriter
static void writeXMLWriter(String filename)
          Write all TaskRunners to an XML file using an XMLWriter
 
Methods inherited from class goldengate.common.database.data.AbstractDbData
get, getTrueValue, getValue, getValues, setTrueValue, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbTypes

public static final int[] dbTypes

table

public static final String table
See Also:
Constant Field Values

fieldseq

public static final String fieldseq
See Also:
Constant Field Values

indexes

public static final DbTaskRunner.Columns[] indexes

XMLRUNNERS

public static final String XMLRUNNERS
See Also:
Constant Field Values

XMLRUNNER

public static final String XMLRUNNER
See Also:
Constant Field Values

XMLEXTENSION

public static final String XMLEXTENSION
See Also:
Constant Field Values

NBPRKEY

public static final int NBPRKEY
Special For DbTaskRunner

See Also:
Constant Field Values

selectAllFields

protected static final String selectAllFields

updateAllFields

protected static final String updateAllFields

insertAllValues

protected static final String insertAllValues
See Also:
Constant Field Values
Constructor Detail

DbTaskRunner

public DbTaskRunner(goldengate.common.database.DbSession dbSession,
                    DbRule rule,
                    boolean isSender,
                    RequestPacket requestPacket,
                    String requested,
                    Timestamp startTime)
             throws goldengate.common.database.exception.GoldenGateDatabaseException
Constructor for submission (no transfer session), from database. It is created, so with a new specialId if necessary

Parameters:
dbSession -
rule -
isSender -
requestPacket -
requested -
startTime -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

DbTaskRunner

public DbTaskRunner(goldengate.common.database.DbSession dbSession,
                    R66Session session,
                    DbRule rule,
                    boolean isSender,
                    RequestPacket requestPacket)
             throws goldengate.common.database.exception.GoldenGateDatabaseException
Constructor from a request with a valid Special Id to be inserted into database

Parameters:
dbSession -
session -
rule -
isSender -
requestPacket -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

DbTaskRunner

public DbTaskRunner(goldengate.common.database.DbSession dbSession,
                    R66Session session,
                    DbRule rule,
                    long id,
                    String requester,
                    String requested)
             throws goldengate.common.database.exception.GoldenGateDatabaseException
Constructor from a request with a valid Special Id so loaded from database

Parameters:
dbSession -
session -
rule -
id -
requester -
requested -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

DbTaskRunner

public DbTaskRunner(goldengate.common.database.DbSession dbSession,
                    long id,
                    String requested)
             throws goldengate.common.database.exception.GoldenGateDatabaseException
Constructor to initiate a request with a valid previous Special Id so loaded from database. This object cannot be used except to retrieve information.

Parameters:
dbSession -
id -
requested -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException
Method Detail

initObject

protected void initObject()
Specified by:
initObject in class goldengate.common.database.data.AbstractDbData

getSelectAllFields

protected String getSelectAllFields()
Specified by:
getSelectAllFields in class goldengate.common.database.data.AbstractDbData

getTable

protected String getTable()
Specified by:
getTable in class goldengate.common.database.data.AbstractDbData

getInsertAllValues

protected String getInsertAllValues()
Specified by:
getInsertAllValues in class goldengate.common.database.data.AbstractDbData

getUpdateAllFields

protected String getUpdateAllFields()
Specified by:
getUpdateAllFields in class goldengate.common.database.data.AbstractDbData

setToArray

protected void setToArray()
Specified by:
setToArray in class goldengate.common.database.data.AbstractDbData

setFromArray

protected void setFromArray()
                     throws goldengate.common.database.exception.GoldenGateDatabaseSqlException
Specified by:
setFromArray in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getWherePrimaryKey

protected String getWherePrimaryKey()
Specified by:
getWherePrimaryKey in class goldengate.common.database.data.AbstractDbData
Returns:
The Where condition on Primary Key

setPrimaryKey

protected void setPrimaryKey()
Set the primary Key as current value

Specified by:
setPrimaryKey in class goldengate.common.database.data.AbstractDbData

getRequested

public static String getRequested(R66Session session,
                                  RequestPacket requestPacket)
Parameters:
session -
requestPacket -
Returns:
The associated requested Host Id

getRequester

public static String getRequester(R66Session session,
                                  RequestPacket requestPacket)
Parameters:
session -
requestPacket -
Returns:
The associated requester Host Id

checkThroughMode

public void checkThroughMode()

delete

public void delete()
            throws goldengate.common.database.exception.GoldenGateDatabaseException
Overrides:
delete in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

insert

public void insert()
            throws goldengate.common.database.exception.GoldenGateDatabaseException
Overrides:
insert in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

create

public void create()
            throws goldengate.common.database.exception.GoldenGateDatabaseException
As insert but with the ability to change the SpecialId

Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

exist

public boolean exist()
              throws goldengate.common.database.exception.GoldenGateDatabaseException
Overrides:
exist in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

select

public void select()
            throws goldengate.common.database.exception.GoldenGateDatabaseException
Overrides:
select in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

update

public void update()
            throws goldengate.common.database.exception.GoldenGateDatabaseException
Overrides:
update in class goldengate.common.database.data.AbstractDbData
Throws:
goldengate.common.database.exception.GoldenGateDatabaseException

setFrom

public void setFrom(DbTaskRunner runner)
Partial set from another runner (infostatus, rank, status, step, stop, filename, globallastep, globalstep, isFileMoved)

Parameters:
runner -

isRecvThrough

public boolean isRecvThrough()

isSendThrough

public boolean isSendThrough()

setLocalChannelReference

public void setLocalChannelReference(LocalChannelReference localChannelReference)
Set a localChannelReference

Parameters:
localChannelReference -

getLocalChannelReference

public LocalChannelReference getLocalChannelReference()
Returns:
the localChannelReference

getFromStatement

public static DbTaskRunner getFromStatement(goldengate.common.database.DbPreparedStatement preparedStatement)
                                     throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                            goldengate.common.database.exception.GoldenGateDatabaseSqlException
For instance from Commander when getting updated information

Parameters:
preparedStatement -
Returns:
the next updated DbTaskRunner
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getStatusPrepareStatement

public static goldengate.common.database.DbPreparedStatement getStatusPrepareStatement(goldengate.common.database.DbSession session,
                                                                                       ErrorCode status,
                                                                                       int limit)
                                                                                throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                       goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
status -
limit - limit the number of rows
Returns:
the DbPreparedStatement for getting Runner according to status ordered by start
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getStepPrepareStatement

public static goldengate.common.database.DbPreparedStatement getStepPrepareStatement(goldengate.common.database.DbSession session,
                                                                                     DbTaskRunner.TASKSTEP globalstep,
                                                                                     int limit)
                                                                              throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                     goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
globalstep -
limit - limit the number of rows
Returns:
the DbPreparedStatement for getting Runner according to globalstep ordered by start
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getFilterPrepareStatement

public static goldengate.common.database.DbPreparedStatement getFilterPrepareStatement(goldengate.common.database.DbSession session,
                                                                                       int limit,
                                                                                       boolean orderBySpecialId,
                                                                                       String startid,
                                                                                       String stopid,
                                                                                       Timestamp start,
                                                                                       Timestamp stop,
                                                                                       String rule,
                                                                                       String req,
                                                                                       boolean pending,
                                                                                       boolean transfer,
                                                                                       boolean error,
                                                                                       boolean done,
                                                                                       boolean all)
                                                                                throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                       goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
limit -
orderBySpecialId -
startid -
stopid -
start -
stop -
rule -
req -
pending -
transfer -
error -
done -
all -
Returns:
the DbPreparedStatement according to the filter
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getSelectFromInfoPrepareStatement

public static goldengate.common.database.DbPreparedStatement getSelectFromInfoPrepareStatement(goldengate.common.database.DbSession session,
                                                                                               goldengate.common.database.data.AbstractDbData.UpdatedInfo info,
                                                                                               boolean orderByStart,
                                                                                               int limit)
                                                                                        throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                               goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
info -
orderByStart - If true, sort on Start ; If false, does not set the limit on start
limit -
Returns:
the DbPreparedStatement for getting Updated Object
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getCountInfoPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountInfoPrepareStatement(goldengate.common.database.DbSession session)
                                                                                   throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                          goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
Returns:
the DbPreparedStatement for getting Updated Object
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getResultCountPrepareStatement

public static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt,
                                                  goldengate.common.database.data.AbstractDbData.UpdatedInfo info,
                                                  long time)
Parameters:
pstt -
info -
time -
Returns:
the number of elements (COUNT) from the statement

getCountStepPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountStepPrepareStatement(goldengate.common.database.DbSession session,
                                                                                          DbTaskRunner.TASKSTEP globalstep)
                                                                                   throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                          goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
globalstep -
Returns:
the DbPreparedStatement for getting Runner according to globalstep ordered by start
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getCountStatusPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountStatusPrepareStatement(goldengate.common.database.DbSession session)
                                                                                     throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                            goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
Returns:
the DbPreparedStatement for getting Runner according to status ordered by start
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getResultCountPrepareStatement

public static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt,
                                                  ErrorCode error,
                                                  long time)
Parameters:
pstt -
error -
time -
Returns:
the number of elements (COUNT) from the statement

getCountStatusRunningPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountStatusRunningPrepareStatement(goldengate.common.database.DbSession session,
                                                                                                   ErrorCode status)
                                                                                            throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                                   goldengate.common.database.exception.GoldenGateDatabaseSqlException
Only running transfers

Parameters:
session -
status -
Returns:
the DbPreparedStatement for getting Runner according to status ordered by start
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getCountInOutErrorPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountInOutErrorPrepareStatement(goldengate.common.database.DbSession session,
                                                                                                boolean in)
                                                                                         throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                                goldengate.common.database.exception.GoldenGateDatabaseSqlException
Running or not transfers are concerned

Parameters:
session -
in - True for Incoming, False for Outgoing
Returns:
the DbPreparedStatement for getting Runner according to in or out going way and Error
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getCountInOutRunningPrepareStatement

public static goldengate.common.database.DbPreparedStatement getCountInOutRunningPrepareStatement(goldengate.common.database.DbSession session,
                                                                                                  boolean in,
                                                                                                  boolean running)
                                                                                           throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                                  goldengate.common.database.exception.GoldenGateDatabaseSqlException
Running or not transfers are concerned

Parameters:
session -
in - True for Incoming, False for Outgoing
running - True for Running only, False for all
Returns:
the DbPreparedStatement for getting Runner according to in or out going way
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getResultCountPrepareStatement

public static long getResultCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt)
Parameters:
pstt -
Returns:
the number of elements (COUNT) from the statement

finishSelectOrCountPrepareStatement

public static void finishSelectOrCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt)
                                                throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                       goldengate.common.database.exception.GoldenGateDatabaseSqlException
Set the current time in the given updatedPreparedStatement

Parameters:
pstt -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

finishSelectOrCountPrepareStatement

public static void finishSelectOrCountPrepareStatement(goldengate.common.database.DbPreparedStatement pstt,
                                                       long time)
                                                throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                       goldengate.common.database.exception.GoldenGateDatabaseSqlException
Set the current time in the given updatedPreparedStatement

Parameters:
pstt -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

getLogPrepareStatement

public static goldengate.common.database.DbPreparedStatement getLogPrepareStatement(goldengate.common.database.DbSession session,
                                                                                    Timestamp start,
                                                                                    Timestamp stop)
                                                                             throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                                                                    goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
start -
stop -
Returns:
the DbPreparedStatement for getting Selected Object, whatever their status
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

purgeLogPrepareStatement

public static int purgeLogPrepareStatement(goldengate.common.database.DbSession session,
                                           Timestamp start,
                                           Timestamp stop)
                                    throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                           goldengate.common.database.exception.GoldenGateDatabaseSqlException
purge in same interval all runners with globallaststep as ALLDONETASK or UpdatedInfo as Done

Parameters:
session -
start -
stop -
Returns:
the number of log purged
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

purgeLogPrepareStatement

public static int purgeLogPrepareStatement(goldengate.common.database.DbSession session,
                                           String startid,
                                           String stopid,
                                           Timestamp start,
                                           Timestamp stop,
                                           String rule,
                                           String req,
                                           boolean pending,
                                           boolean transfer,
                                           boolean error,
                                           boolean done,
                                           boolean all)
                                    throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                           goldengate.common.database.exception.GoldenGateDatabaseSqlException
Parameters:
session -
startid -
stopid -
start -
stop -
rule -
req -
pending -
transfer -
error -
done -
all -
Returns:
the DbPreparedStatement according to the filter and ALLDONE, ERROR globallaststep
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException

resetToSubmit

public static void resetToSubmit(goldengate.common.database.DbSession session)
                          throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
Change RUNNING, INTERRUPTED to TOSUBMIT TaskRunner from database. This method is to be used when the commander is starting the very first time, in order to be ready to rerun tasks that are pending.

Parameters:
session -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException

changeFinishedToDone

public static void changeFinishedToDone(goldengate.common.database.DbSession session)
                                 throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
Change CompleteOk+ALLDONETASK to Updated = DONE TaskRunner from database. This method is a clean function to be used for instance before log export or at the very beginning of the commander.

Parameters:
session -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException

reset

public boolean reset()
Reset the runner (ready to be run again)

Returns:
True if OK, False if already finished

restartRank

public void restartRank()
Decrease if necessary the rank


restart

public boolean restart(boolean submit)
                throws OpenR66RunnerErrorException
Make this Runner ready for restart

Parameters:
submit - True to resubmit this task, else False to keep it as running (only reset)
Returns:
True if OK or False if Already finished or if submitted and the request is a selfRequested and is not ready to restart locally
Throws:
OpenR66RunnerErrorException

stopOrCancelRunner

public boolean stopOrCancelRunner(ErrorCode code)
Stop or Cancel a Runner from database point of view

Parameters:
code -
Returns:
True if correctly stopped or canceled

changeUpdatedInfo

public void changeUpdatedInfo(goldengate.common.database.data.AbstractDbData.UpdatedInfo info)
Specified by:
changeUpdatedInfo in class goldengate.common.database.data.AbstractDbData

setErrorExecutionStatus

public void setErrorExecutionStatus(ErrorCode code)
Set the ErrorCode for the UpdatedInfo

Parameters:
code -

getUpdatedInfo

public goldengate.common.database.data.AbstractDbData.UpdatedInfo getUpdatedInfo()
Returns:
The current UpdatedInfo value

getErrorInfo

public ErrorCode getErrorInfo()
Returns:
the error code associated with the Updated Info

getStep

public int getStep()
Returns:
the step

isRescheduledTransfer

public boolean isRescheduledTransfer()
Returns:
the rescheduledTransfer

setRescheduledTransfer

public void setRescheduledTransfer()
Set this DbTaskRunner as rescheduled (valid only while still in memory)


setRankAtStartup

public void setRankAtStartup(int rank)
To set the rank at startup of the request if the request specify a specific rank

Parameters:
rank - the rank to set

setFilename

public void setFilename(String filename)
Parameters:
filename - the filename to set

setFileMoved

public void setFileMoved(String newFilename,
                         boolean isFileMoved)
Parameters:
newFilename - the new Filename to set
isFileMoved - the isFileMoved to set

setOriginalFilename

public void setOriginalFilename(String originalFilename)
Parameters:
originalFilename - the originalFilename to set

getRank

public int getRank()
Returns:
the rank

setExecutionStatus

public void setExecutionStatus(ErrorCode status)
Change the status from Task Execution

Parameters:
status -

getStatus

public ErrorCode getStatus()
Returns:
the status

isSender

public boolean isSender()
Returns:
the isSender

isFileMoved

public boolean isFileMoved()
Returns:
the isFileMoved

getBlocksize

public int getBlocksize()
Returns:
the blocksize

getFilename

public String getFilename()
Returns:
the filename

getOriginalFilename

public String getOriginalFilename()
Returns:
the originalFilename

getFileInformation

public String getFileInformation()
Returns:
the fileInformation

getSpecialId

public long getSpecialId()
Returns:
the specialId

getRule

public DbRule getRule()
Returns:
the rule

getRuleId

public String getRuleId()
Returns:
the ruleId

getMode

public int getMode()
Returns:
the mode

getGloballaststep

public int getGloballaststep()
Returns:
the globallaststep

ready

public boolean ready()
Returns:
True if this runner is ready for transfer or post operation

isInTransfer

public boolean isInTransfer()
Returns:
True if the runner is currently in transfer

isFinished

public boolean isFinished()
Returns:
True if this runner is finished, either in success or in error

isInError

public boolean isInError()
Returns:
True if this runner is in error and no more running

isAllDone

public boolean isAllDone()
Returns:
True if the runner is finished in success

isPreTaskStarting

public boolean isPreTaskStarting()
To be called before executing Pre execution

Returns:
True if the task is going to run PRE task from the first action

setPreTask

public void setPreTask()
Set Pre Task step


setTransferTask

public void setTransferTask(int rank)
Set Transfer rank

Parameters:
rank -

finishTransferTask

public int finishTransferTask(ErrorCode code)
Set the status of the transfer

Parameters:
code - TransferOk if success
Returns:
the current rank of transfer

continueTransfer

public boolean continueTransfer()
Returns:
True if the transfer is valid to continue

setPostTask

public void setPostTask()
Set the Post Task step


setErrorTask

public void setErrorTask(LocalChannelReference localChannelReference)
Set the Error Task step

Parameters:
localChannelReference - (to get session)

setAllDone

public void setAllDone()
Set the global step as finished (after post task in success)


run

public void run()
         throws OpenR66RunnerErrorException
Run all task from current status (globalstep and step)

Throws:
OpenR66RunnerErrorException

finalizeTransfer

public void finalizeTransfer(LocalChannelReference localChannelReference,
                             R66File file,
                             R66Result finalValue,
                             boolean status)
                      throws OpenR66RunnerErrorException,
                             OpenR66ProtocolSystemException
Once the transfer is over, finalize the Runner by running the error or post operation according to the status.

Parameters:
localChannelReference -
file -
finalValue -
status -
Throws:
OpenR66RunnerErrorException
OpenR66ProtocolSystemException

incrementRank

public void incrementRank()
                   throws OpenR66ProtocolPacketException
Increment the rank of the transfer

Throws:
OpenR66ProtocolPacketException

saveStatus

public void saveStatus()
                throws OpenR66RunnerErrorException
This method is to be called each time an operation is happening on Runner

Throws:
OpenR66RunnerErrorException

clear

public void clear()
Clear the runner


deleteTempFile

public void deleteTempFile()
Delete the temporary empty file (retrieved file at rank 0)


toString

public String toString()
Overrides:
toString in class Object

toLogRunStep

public String toLogRunStep()

toShortNoHtmlString

public String toShortNoHtmlString(String newline)

toShortString

public String toShortString()

headerHtml

public static String headerHtml()
Returns:
the header for a table of runners in Html format

freespace

public long freespace(R66Session session)
Parameters:
session -
Returns:
The associated freespace of the current directory

toHtml

public String toHtml(R66Session session,
                     String running)
Parameters:
session -
running - special info
Returns:
the runner in Html format compatible with the header from headerHtml method

toSpecializedHtml

public String toSpecializedHtml(R66Session session,
                                String body,
                                String running)
Parameters:
session -
body -
running - special info
Returns:
the runner in Html format specified by body by replacing all instance of fields

isSelfRequested

public boolean isSelfRequested()
Returns:
True if the current host is the requested host (to prevent request to itself)

getRequested

public String getRequested()
Returns:
the requested HostId

getRequester

public String getRequester()
Returns:
the requester HostId

getStart

public Timestamp getStart()
Returns:
the start

setStart

public void setStart(Timestamp start)
              throws OpenR66RunnerErrorException
Parameters:
start - new Start time to apply when reschedule
Throws:
OpenR66RunnerErrorException - (in fact a GoldenGateDatabaseException)

getStop

public Timestamp getStop()
Returns:
the stop

getRequest

public RequestPacket getRequest()
Returns:
the associated request

getKey

public String getKey()
Used internally

Returns:
a Key representing the primary key as a unique string

writeXML

public static NbAndSpecialId writeXML(goldengate.common.database.DbPreparedStatement preparedStatement,
                                      org.dom4j.io.XMLWriter xmlWriter)
                               throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                      goldengate.common.database.exception.GoldenGateDatabaseSqlException,
                                      OpenR66ProtocolBusinessException
Write the selected TaskRunners from PrepareStatement to a XMLWriter

Parameters:
preparedStatement - ready to be executed
xmlWriter -
Returns:
the NbAndSpecialId for the number of transfer and higher rank found
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException
OpenR66ProtocolBusinessException

writeXMLWriter

public static NbAndSpecialId writeXMLWriter(goldengate.common.database.DbPreparedStatement preparedStatement,
                                            String filename)
                                     throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                            goldengate.common.database.exception.GoldenGateDatabaseSqlException,
                                            OpenR66ProtocolBusinessException
Write selected TaskRunners to an XML file using an XMLWriter

Parameters:
preparedStatement -
filename -
Returns:
the NbAndSpecialId for the number of transfer and higher rank found
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException
OpenR66ProtocolBusinessException

writeXMLWriter

public static void writeXMLWriter(String filename)
                           throws goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException,
                                  goldengate.common.database.exception.GoldenGateDatabaseSqlException,
                                  OpenR66ProtocolBusinessException
Write all TaskRunners to an XML file using an XMLWriter

Parameters:
filename -
Throws:
goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException
goldengate.common.database.exception.GoldenGateDatabaseSqlException
OpenR66ProtocolBusinessException

backendXmlFilename

public String backendXmlFilename()
Returns:
the backend XML filename for the current TaskRunner in NoDb Client mode

writeXmlWorkNoDb

public void writeXmlWorkNoDb()
                      throws OpenR66ProtocolBusinessException
Method to write the current DbTaskRunner for NoDb client instead of updating DB. 'setToArray' must be called priorly to be able to store the values.

Throws:
OpenR66ProtocolBusinessException

loadXmlWorkNoDb

public void loadXmlWorkNoDb()
                     throws OpenR66ProtocolBusinessException
Method to load a previous existing DbTaskRunner for NoDb client from File instead of from DB. 'setFromArray' must be called after.

Throws:
OpenR66ProtocolBusinessException

existXmlWorkNoDb

public boolean existXmlWorkNoDb()
Returns:
True if the backend XML for NoDb client is available for this TaskRunner

deleteXmlWorkNoDb

public void deleteXmlWorkNoDb()
Delete the backend XML file for the current TaskRunner for NoDb Client



Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.