use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class StartupMessageReplyProcessor method process.
@Override
public void process(DistributionMessage msg) {
final LogWriterI18n log = this.system.getLogWriter().convertToLogWriterI18n();
super.process(msg);
if (log.fineEnabled()) {
log.fine(this.toString() + " done processing " + msg + " from " + msg.getSender());
}
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class ContainsKey66 method writeContainsKeyResponse.
private static void writeContainsKeyResponse(boolean containsKey, Message origMsg, ServerConnection servConn) throws IOException {
LogWriterI18n logger = servConn.getLogWriter();
Message responseMsg = servConn.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setNumberOfParts(1);
responseMsg.setTransactionId(origMsg.getTransactionId());
responseMsg.addObjPart(containsKey ? Boolean.TRUE : Boolean.FALSE);
responseMsg.send(servConn);
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class PDXQueryTestBase method printResults.
public void printResults(SelectResults results, String message) {
Object r;
Struct s;
LogWriterI18n logger = GemFireCacheImpl.getInstance().getLoggerI18n();
logger.fine(message);
int row = 0;
for (Iterator iter = results.iterator(); iter.hasNext(); ) {
r = iter.next();
row++;
if (r instanceof Struct) {
s = (Struct) r;
String[] fieldNames = ((Struct) r).getStructType().getFieldNames();
for (int i = 0; i < fieldNames.length; i++) {
logger.fine("### Row " + row + "\n" + "Field: " + fieldNames[i] + " > " + s.get(fieldNames[i]).toString());
}
} else {
logger.fine("#### Row " + row + "\n" + r);
}
}
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class GlobalTransaction method commit.
/**
* Delists the XAResources associated with the Global Transaction and Completes the Global
* transaction associated with the current thread. If any exception is encountered, rollback is
* called on the current transaction.
*
* Concurrency: Some paths invoke this method after taking a lock on "this" while other paths
* invoke this method without taking a lock on "this". Since both types of path do act on the
* resourceMap collection, it is being protected by a lock on resourceMap too.
*
* @throws RollbackException - Thrown to indicate that the transaction has been rolled back rather
* than committed.
* @throws HeuristicMixedException - Thrown to indicate that a heuristic decision was made and
* that some relevant updates have been committed while others have been rolled back.
* @throws HeuristicRollbackException - Thrown to indicate that a heuristic decision was made and
* that all relevant updates have been rolled back.
* @throws java.lang.SecurityException - Thrown to indicate that the thread is not allowed to
* commit the transaction.
* @throws java.lang.IllegalStateException - Thrown if the current thread is not associated with a
* transaction.
* @throws SystemException - Thrown if the transaction manager encounters an unexpected error
* condition.
*
* @see javax.transaction.TransactionManager#commit()
*/
// Asif : Changed the return type to int indicating the nature of Exception
// encountered during commit
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException {
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
try {
XAResource xar = null;
XAResource xar1 = null;
int loop = 0;
Boolean isActive = Boolean.FALSE;
synchronized (this.resourceMap) {
Map.Entry entry;
Iterator iterator = resourceMap.entrySet().iterator();
while (iterator.hasNext()) {
try {
entry = (Map.Entry) iterator.next();
xar = (XAResource) entry.getKey();
isActive = (Boolean) entry.getValue();
if (loop == 0)
xar1 = xar;
loop++;
if (isActive.booleanValue()) {
// delistResource(xar, XAResource.TMSUCCESS);
xar.end(xid, XAResource.TMSUCCESS);
entry.setValue(Boolean.FALSE);
}
} catch (Exception e) {
if (VERBOSE)
writer.info(LocalizedStrings.ONE_ARG, "GlobalTransaction::commit:Exception in delisting XAResource", e);
}
}
}
if (xar1 != null)
xar1.commit(xid, true);
status = Status.STATUS_COMMITTED;
if (VERBOSE)
writer.fine("GlobalTransaction::commit:Transaction committed successfully");
} catch (Exception e) {
status = Status.STATUS_ROLLING_BACK;
try {
rollback();
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
// Whenever you catch Error or Throwable, you must also
// catch VirtualMachineError (see above). However, there is
// _still_ a possibility that you are dealing with a cascading
// error condition, so you also need to check to see if the JVM
// is still usable:
SystemFailure.checkFailure();
// we will throw an error later, make sure that the synchronizations rollback
status = Status.STATUS_ROLLEDBACK;
String exception = LocalizedStrings.GlobalTransaction_GLOBALTRANSACTION_COMMIT_ERROR_IN_COMMITTING_BUT_TRANSACTION_COULD_NOT_BE_ROLLED_BACK_DUE_TO_EXCEPTION_0.toLocalizedString(t);
if (VERBOSE)
writer.fine(exception, t);
SystemException sysEx = new SystemException(exception);
sysEx.initCause(t);
throw sysEx;
}
String exception = LocalizedStrings.GlobalTransaction_GLOBALTRANSACTION_COMMIT_ERROR_IN_COMMITTING_THE_TRANSACTION_TRANSACTION_ROLLED_BACK_EXCEPTION_0_1.toLocalizedString(new Object[] { e, " " + (e instanceof XAException ? ("Error Code =" + ((XAException) e).errorCode) : "") });
if (VERBOSE)
writer.fine(exception, e);
RollbackException rbEx = new RollbackException(exception);
rbEx.initCause(e);
throw rbEx;
} finally {
// Map globalTransactions = tm.getGlobalTransactionMap();
TransactionManagerImpl.getTransactionManager().cleanGlobalTransactionMap(transactions);
// Asif : Clear the list of transactions
transactions.clear();
}
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class GlobalTransaction method addTransaction.
/**
* Add a transaction to the list of transactions participating in this global Transaction The list
* of transactions is being maintained so that we can remove the local transaction to global
* transaction entries from the map being maintained by the Transaction Manager
*
* @param txn Transaction instance which is participating in this Global Transaction
*/
public void addTransaction(Transaction txn) throws SystemException {
if (txn == null) {
String exception = LocalizedStrings.GlobalTransaction_GLOBALTRANSACTION_ADDTRANSACTION_CANNOT_ADD_A_NULL_TRANSACTION.toLocalizedString();
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (VERBOSE)
writer.fine(exception);
throw new SystemException(exception);
}
transactions.add(txn);
}
Aggregations