public class AsyncEventHelper extends Object
AsyncEventListener and WAN. Note that since
this is also used by the GemFireXD WAN layer, users should not change this
class, rather should extend it and then modify for custom changes to
DBSynchronizer.| Modifier and Type | Field and Description |
|---|---|
static String |
CONNECTIVITY_PREFIX
prefix for SQLStates of connection exceptions
|
static String |
EVENT_ERROR_LOG_ENTRIES_FILE |
static String |
EVENT_ERROR_LOG_FILE |
protected static int |
FAILURE_LOG_MAX_INTERVAL
The maximum interval for logging failures of the same event in millis.
|
protected static int |
FAILURE_MAP_MAXSIZE
The maximum size of
failureLogInterval beyond which it will start
logging all failure instances. |
static String |
INTEGRITY_VIOLATION_PREFIX
prefix for SQLStates of integrity violations
|
static String |
LOGGER_NAME
the name of the
Logger used by GemFireXD |
static String |
LSE_COMPILATION_PREFIX
prefix for SQLStates of syntax and other errors during query prepare
|
static boolean |
POSTGRESQL_SYNTAX |
| Constructor and Description |
|---|
AsyncEventHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Any cleanup required when closing.
|
void |
createEventErrorLogger(String errorFileName) |
static String |
decryptPassword(String user,
String encPassword,
String transformation,
int keySize)
Decrypt the password of a given user encrypted using
encryptPassword(String, String, String, int). |
static String |
encryptPassword(String user,
String password,
String transformation,
int keySize)
Encrypt the password of a given user for storage in file or memory.
|
static String |
getDeleteString(String tableName,
ResultSetMetaData pkMetaData)
Get a DML string that can be used to delete rows in given table.
|
static String |
getInsertString(String tableName,
TableMetaData tableMetaData,
boolean hasAutoIncrementColumns)
Get a DML string that can be used to insert rows in given table.
|
void |
getStackTrace(Throwable t,
StringBuilder sb)
Append the backtrace of given exception to provided
StringBuilder. |
static String |
getUpdateString(String tableName,
ResultSetMetaData pkMetaData,
ResultSetMetaData updateMetaData)
Get a DML string that can be used to update rows in given table.
|
boolean |
hasFailures()
Return true if failure map has entries.
|
void |
log(Logger logger,
Level level,
Throwable t,
String message)
Log the given message and exception to the provided logger.
|
void |
logEventError(Event ev,
Exception e) |
boolean |
logFineEnabled()
Returns true if fine-level logging is enabled in this GemFireXD instance.
|
void |
logFormat(Logger logger,
Level level,
Throwable t,
String format,
Object... params)
Log the given formatted message and exception to the provided logger.
|
static AsyncEventHelper |
newInstance() |
RuntimeException |
newRuntimeException(String message,
Throwable t)
Return a new GemFireXD runtime exception to wrap an underlying exception with
optional message detail.
|
boolean |
removeEventFromFailureMap(Event event)
After a successful event execution remove from failure map if present (i.e.
|
void |
setColumnInPrepStatement(int javaSqlType,
PreparedStatement ps,
ResultSet row,
int rowPosition,
int paramIndex,
DBSynchronizer sync)
Set column value at given index in a prepared statement.
|
boolean |
setParamsInBulkPreparedStatement(Event event,
Event.Type evType,
PreparedStatement ps,
PreparedStatement prevPS,
DBSynchronizer sync)
Set the parameters to the prepared statement for a
Event.Type.BULK_DML or Event.Type.BULK_INSERT operation. |
boolean |
skipFailureLogging(Event event)
Check if logging for the same event repeatedly has to be skipped.
|
boolean |
traceDBSynchronizer()
Returns true if "TraceDBSynchronizer" debug flag is enabled in this GemFireXD
instance (via gemfirexd.debug.true=TraceDBSynchronizer).
|
boolean |
traceDBSynchronizerHA()
Returns true if "TraceDBSynchronizerHA" debug flag is enabled in this GemFireXD
instance (via gemfirexd.debug.true=TraceDBSynchronizerHA).
|
boolean |
traceExecute()
Returns true if minimal execution tracing is enabled in this GemFireXD
instance.
|
public static final String LOGGER_NAME
Logger used by GemFireXDpublic static final String INTEGRITY_VIOLATION_PREFIX
public static final String CONNECTIVITY_PREFIX
public static final String LSE_COMPILATION_PREFIX
protected static final int FAILURE_MAP_MAXSIZE
failureLogInterval beyond which it will start
logging all failure instances. Hopefully this should never happen in
practise.protected static final int FAILURE_LOG_MAX_INTERVAL
public static final boolean POSTGRESQL_SYNTAX
public static final String EVENT_ERROR_LOG_FILE
public static final String EVENT_ERROR_LOG_ENTRIES_FILE
public static AsyncEventHelper newInstance()
public final void getStackTrace(Throwable t, StringBuilder sb)
StringBuilder.t - the exception whose backtrace is requiredsb - the StringBuilder to which the stack trace is to be
appendedpublic final boolean logFineEnabled()
public final boolean traceExecute()
public final boolean traceDBSynchronizer()
public final boolean traceDBSynchronizerHA()
public final void log(Logger logger, Level level, Throwable t, String message)
public final void logFormat(Logger logger, Level level, Throwable t, String format, Object... params)
String.format(String, Object...).logger - the Logger to log the message tolevel - the Level to use for logging the messaget - the exception whose backtrace is to be logged; can be null in
which case it is ignoredformat - the message formatparams - the parameters to the message formatString.format(String, Object...),
Formatter.format(String, Object...)public static final String getInsertString(String tableName, TableMetaData tableMetaData, boolean hasAutoIncrementColumns) throws SQLException
tableName - name of the tabletableMetaData - meta-data of the columns of the tablehasAutoIncrementColumns - should be true if table has any auto-increment columns and those
are to be skipped in the insert stringSQLException - in case of an error in getting column information from table
meta-datapublic static final String getDeleteString(String tableName, ResultSetMetaData pkMetaData) throws SQLException
ResultSetMetaData obtained from
Event.getPrimaryKeysAsResultSet().tableName - name of the tablepkMetaData - meta-data of the primary key columns of the tableSQLException - in case of an error in getting column information from primary
key meta-datapublic static final String getUpdateString(String tableName, ResultSetMetaData pkMetaData, ResultSetMetaData updateMetaData) throws SQLException
ResultSetMetaData obtained from
Event.getPrimaryKeysAsResultSet(), and the meta-data of updated
columns as a ResultSetMetaData obtained from
Event.getNewRowsAsResultSet().tableName - name of the tablepkMetaData - meta-data of the primary key columns of the tableupdateMetaData - meta-data of the updated columns of the tableSQLException - in case of an error in getting column information from primary
key meta-data, or from meta-data of updated columnspublic final boolean setParamsInBulkPreparedStatement(Event event, Event.Type evType, PreparedStatement ps, PreparedStatement prevPS, DBSynchronizer sync) throws SQLException
Event.Type.BULK_DML or Event.Type.BULK_INSERT operation.
The implementation creates a batch for Event.Type.BULK_INSERT and
also tries to add as a batch for Event.Type.BULK_DML in case the
previous prepared statement is same as this one.event - the Event objectevType - the Event.Type of the eventps - the prepared statement to be used for prepareprevPS - the prepared statement used for the previous event; in case it is
same as the current one the new update for a
Event.Type.BULK_DML operation will be added as a batchsync - the DBSynchronizer object, if any; it is used to store
whether the current driver is JDBC4 compliant to enable performing
BLOB/CLOB operations PreparedStatement.setBinaryStream(int, java.io.InputStream, int),
PreparedStatement.setCharacterStream(int, java.io.Reader, int)Event.Type.BULK_INSERT and false
otherwiseSQLException - in case of an exception in getting meta-data or setting
parameterspublic final void setColumnInPrepStatement(int javaSqlType,
PreparedStatement ps,
ResultSet row,
int rowPosition,
int paramIndex,
DBSynchronizer sync)
throws SQLException
Integer
for primitive int).javaSqlType - the SQL type of the column as specified by JDBC Types
classps - the prepared statement where the column value has to be setrow - the source row as a ResultSet from where the value has to
be extractedrowPosition - the 1-based position of the column in the provided
rowparamIndex - the 1-based position of the column in the target prepared
statement (provided ps argument)sync - the DBSynchronizer object, if any; it is used to store
whether the current driver is JDBC4 compliant to enable performing
BLOB/CLOB operations PreparedStatement.setBinaryStream(int, java.io.InputStream, int),
PreparedStatement.setCharacterStream(int, java.io.Reader, int)SQLException - in case of an exception in setting parameterspublic final boolean skipFailureLogging(Event event)
public final boolean removeEventFromFailureMap(Event event)
public final boolean hasFailures()
public static final String encryptPassword(String user, String password, String transformation, int keySize) throws Exception
user - the name of userpassword - the password to be encryptedtransformation - the algorithm to use for encryption e.g. AES/ECB/PKCS5Padding or
Blowfish (e.g. see Sun Providers for the available names in Oracle's Sun JDK}keySize - the size of the private key of the given "transformation" to useExceptionpublic static final String decryptPassword(String user, String encPassword, String transformation, int keySize) throws Exception
encryptPassword(String, String, String, int).user - the name of userencPassword - the encrypted password to be decryptedtransformation - the algorithm to use for encryption e.g. AES/ECB/PKCS5Padding or
Blowfish (e.g. see Sun Providers for the available names in Oracle's Sun JDK}keySize - the size of the private key of the given "transformation" to useExceptionpublic void close()
public RuntimeException newRuntimeException(String message, Throwable t)
message - the detail message of the exceptiont - the underlying exception to be wrappedpublic void createEventErrorLogger(String errorFileName)
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.