You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by sa...@apache.org on 2016/07/08 07:39:23 UTC
[1/6] incubator-trafodion git commit: [TRAFODION-1988] Better Java
exception handling in Trafodion - Part2
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 2dd9d3a6e -> c75214e5f
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
index 11b17ce..8a28d8e 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
@@ -188,15 +188,10 @@ public class TmAuditTlog {
byte[] endKey_orig;
byte[] endKey;
- TlogCallable(TransactionState txState, HRegionLocation location, HConnection connection) {
+ TlogCallable(TransactionState txState, HRegionLocation location, HConnection connection) throws IOException {
transactionState = txState;
this.location = location;
- try {
- table = new HTable(location.getRegionInfo().getTable(), connection, tlogThreadPool);
- } catch(IOException e) {
- LOG.error("Error obtaining HTable instance ", e);
- table = null;
- }
+ table = new HTable(location.getRegionInfo().getTable(), connection, tlogThreadPool);
startKey = location.getRegionInfo().getStartKey();
endKey_orig = location.getRegionInfo().getEndKey();
endKey = TransactionManager.binaryIncrementPos(endKey_orig, -1);
@@ -213,7 +208,6 @@ public class TmAuditTlog {
int retryCount = 0;
int retrySleep = TLOG_SLEEP;
do {
- try {
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASNX -- ENTRY ASN: " + auditSeqNum);
Batch.Call<TrxRegionService, TlogDeleteResponse> callable =
new Batch.Call<TrxRegionService, TlogDeleteResponse>() {
@@ -242,17 +236,16 @@ public class TmAuditTlog {
+ " startKey: " + new String(startKey, "UTF-8") + " endKey: " + new String(endKey, "UTF-8"));
result = table.coprocessorService(TrxRegionService.class, startKey, endKey, callable);
} catch (Throwable e) {
- e.printStackTrace();
String msg = new String("ERROR occurred while calling deleteTlogEntries coprocessor service in deleteEntriesOlderThanASNX: " + e);
- LOG.error(msg);
- throw new Exception(msg);
+ LOG.error(msg, e);
+ throw new IOException(msg, e);
}
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASNX -- after coprocessorService ASN: " + auditSeqNum
+ " startKey: " + new String(startKey, "UTF-8") + " result size: " + result.size());
if(result.size() != 1) {
LOG.error("deleteEntriesOlderThanASNX, received incorrect result size: " + result.size() + " ASN: " + auditSeqNum);
- throw new Exception("Wrong result size in deleteEntriesOlderThanASNX");
+ throw new IOException("Wrong result size in deleteEntriesOlderThanASNX");
}
else {
// size is 1
@@ -260,18 +253,13 @@ public class TmAuditTlog {
if(TD_response.getHasException()) {
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASNX coprocessor exception: "
+ TD_response.getException());
- throw new Exception(TD_response.getException());
+ throw new IOException(TD_response.getException());
}
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASNX coprocessor deleted count: "
+ TD_response.getCount());
}
retry = false;
}
- } catch (Exception e) {
- LOG.error("deleteEntriesOlderThanASNX retrying due to Exception: ", e);
- refresh = true;
- retry = true;
- }
if (refresh) {
HRegionLocation lv_hrl = table.getRegionLocation(startKey);
@@ -328,49 +316,31 @@ public class TmAuditTlog {
}
- private void bufferAdd(Put localPut) throws Exception {
+ private void bufferAdd(Put localPut) {
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("BufferAdd start in thread " + threadId );
- try {
- buffer.add(localPut);
- }
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("AuditBuffer Exception trying bufferAdd", e);
- throw e;
- }
+ buffer.add(localPut);
if (LOG.isTraceEnabled()) LOG.trace("BufferAdd end in thread " + threadId );
}
- private int bufferSize() throws Exception {
+ private int bufferSize() {
int lvSize;
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("BufferSize start in thread " + threadId );
- try {
- lvSize = buffer.size();
- }
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("AuditBuffer Exception trying bufferSize", e);
- throw e;
- }
+ lvSize = buffer.size();
if (LOG.isTraceEnabled()) LOG.trace("AuditBuffer bufferSize end; returning " + lvSize + " in thread "
+ Thread.currentThread().getId());
return lvSize;
}
- private void bufferClear() throws Exception {
+ private void bufferClear() {
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("AuditBuffer bufferClear start in thread " + threadId);
- try {
- buffer.clear();
- }
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("Exception trying bufferClear.clear", e);
- throw e;
- }
+ buffer.clear();
if (LOG.isTraceEnabled()) LOG.trace("AuditBuffer bufferClear end in thread " + threadId);
}
- private ArrayList<Put> getBuffer() throws Exception {
+ private ArrayList<Put> getBuffer() {
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("getBuffer start in thread " + threadId );
return this.buffer;
@@ -408,8 +378,8 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("controlPointFlush != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_FLUSH_CONTROL_POINT is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_FLUSH_CONTROL_POINT is not valid in ms.env");
}
LOG.info("forceControlPoint is " + forceControlPoint);
@@ -421,8 +391,8 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("autoFlush != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_AUTO_FLUSH is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_AUTO_FLUSH is not valid in ms.env");
}
LOG.info("useAutoFlush is " + useAutoFlush);
@@ -434,8 +404,8 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("ageCommittedRecords != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_AGE_COMMITTED_RECORDS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_AGE_COMMITTED_RECORDS is not valid in ms.env");
}
LOG.info("ageCommitted is " + ageCommitted);
@@ -446,8 +416,8 @@ public class TmAuditTlog {
versions = (Integer.parseInt(maxVersions) > versions ? Integer.parseInt(maxVersions) : versions);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_MAX_VERSIONS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_MAX_VERSIONS is not valid in ms.env");
}
TlogRetryDelay = 5000; // 3 seconds
@@ -457,8 +427,8 @@ public class TmAuditTlog {
TlogRetryDelay = (Integer.parseInt(retryDelayS) > TlogRetryDelay ? Integer.parseInt(retryDelayS) : TlogRetryDelay);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_RETRY_DELAY is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_RETRY_DELAY is not valid in ms.env");
}
TlogRetryCount = 60;
@@ -468,8 +438,8 @@ public class TmAuditTlog {
TlogRetryCount = (Integer.parseInt(retryCountS) > TlogRetryCount ? Integer.parseInt(retryCountS) : TlogRetryCount);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_RETRY_COUNT is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_RETRY_COUNT is not valid in ms.env");
}
connection = HConnectionManager.createConnection(config);
@@ -481,8 +451,8 @@ public class TmAuditTlog {
tlogNumLogs = Math.max( 1, Integer.parseInt(numLogs));
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_NUM_LOGS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_NUM_LOGS is not valid in ms.env");
}
disableBlockCache = false;
try {
@@ -492,8 +462,8 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("disableBlockCache != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_DISABLE_BLOCK_CACHE is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_DISABLE_BLOCK_CACHE is not valid in ms.env");
}
LOG.info("disableBlockCache is " + disableBlockCache);
@@ -567,30 +537,28 @@ public class TmAuditTlog {
long lvAsn = 0;
- try {
- if (LOG.isTraceEnabled()) LOG.trace("try new HBaseAuditControlPoint");
- tLogControlPoint = new HBaseAuditControlPoint(config);
- }
- catch (Exception e) {
- LOG.error("Unable to create new HBaseAuditControlPoint object ", e);
- }
+ if (LOG.isTraceEnabled()) LOG.trace("try new HBaseAuditControlPoint");
+ tLogControlPoint = new HBaseAuditControlPoint(config);
tlogAuditLock = new Object[tlogNumLogs];
table = new HTable[tlogNumLogs];
- try {
+// try {
// Get the asn from the last control point. This ignores
// any asn increments between the last control point
// write and a system crash and could result in asn numbers
// being reused. However this would just mean that some old
// records are held onto a bit longer before cleanup and is safe.
asn.set(tLogControlPoint.getStartingAuditSeqNum());
+/*
+ // TODO: revisit
}
catch (Exception e2){
if (LOG.isDebugEnabled()) LOG.debug("Exception setting the ASN " + e2);
if (LOG.isDebugEnabled()) LOG.debug("Setting the ASN to 1");
asn.set(1L); // Couldn't read the asn so start asn at 1
}
+*/
for (int i = 0 ; i < tlogNumLogs; i++) {
tlogAuditLock[i] = new Object();
@@ -603,22 +571,17 @@ public class TmAuditTlog {
if (lvTlogExists == false) {
// Need to prime the asn for future writes
try {
- if (LOG.isTraceEnabled()) LOG.trace("Creating the table " + lv_tLogName);
+ if (LOG.isTraceEnabled()) LOG.trace("Creating the table " + lv_tLogName);
admin.createTable(desc);
asn.set(1L); // TLOG didn't exist previously, so start asn at 1
}
catch (TableExistsException e) {
+ // TODO: ignoring the exception
LOG.error("Table " + lv_tLogName + " already exists");
}
}
- try {
- if (LOG.isTraceEnabled()) LOG.trace("try new HTable index " + i);
- table[i] = new HTable(config, desc.getName());
- }
- catch(Exception e){
- LOG.error("TmAuditTlog Exception on index " + i + "; ", e);
- throw new RuntimeException(e);
- }
+ if (LOG.isTraceEnabled()) LOG.trace("try new HTable index " + i);
+ table[i] = new HTable(config, desc.getName());
table[i].setAutoFlushTo(this.useAutoFlush);
@@ -644,11 +607,11 @@ public class TmAuditTlog {
return asn.getAndIncrement();
}
- public void putSingleRecord(final long lvTransid, final long lvCommitId, final String lvTxState, final Set<TransactionRegionLocation> regions, boolean forced) throws Exception {
+ public void putSingleRecord(final long lvTransid, final long lvCommitId, final String lvTxState, final Set<TransactionRegionLocation> regions, boolean forced) throws IOException {
putSingleRecord(lvTransid, lvCommitId, lvTxState, regions, forced, -1);
}
- public void putSingleRecord(final long lvTransid, final long lvCommitId, final String lvTxState, final Set<TransactionRegionLocation> regions, boolean forced, long recoveryASN) throws Exception {
+ public void putSingleRecord(final long lvTransid, final long lvCommitId, final String lvTxState, final Set<TransactionRegionLocation> regions, boolean forced, long recoveryASN) throws IOException {
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("putSingleRecord start in thread " + threadId);
StringBuilder tableString = new StringBuilder();
@@ -717,27 +680,15 @@ public class TmAuditTlog {
try {
recoveryTable.put(p);
}
- catch (Exception e2){
- // create record of the exception
- LOG.error("putSingleRecord Exception in recoveryTable", e2);
- throw e2;
- }
finally {
- try {
- recoveryTable.close();
- recoveryTableConnection.close();
- }
- catch (IOException e) {
- LOG.error("putSingleRecord IOException closing recovery table or connection for table " + lv_tLogName);
- e.printStackTrace();
- }
+ recoveryTable.close();
+ recoveryTableConnection.close();
}
}
else {
// This goes to our local TLOG
if (LOG.isTraceEnabled()) LOG.trace("TLOG putSingleRecord synchronizing tlogAuditLock[" + lv_lockIndex + "] in thread " + threadId );
startSynch = System.nanoTime();
- try {
synchronized (tlogAuditLock[lv_lockIndex]) {
endSynch = System.nanoTime();
try {
@@ -750,20 +701,13 @@ public class TmAuditTlog {
}
endTimes[lv_TimeIndex] = System.nanoTime();
}
- catch (Exception e2){
+ catch (IOException e2){
// create record of the exception
LOG.error("putSingleRecord Exception ", e2);
- e2.printStackTrace();
throw e2;
}
} // End global synchronization
- }
- catch (Exception e) {
- // create record of the exception
- LOG.error("Synchronizing on tlogAuditLock[" + lv_lockIndex + "] Exception ", e);
- e.printStackTrace();
- throw e;
- }
+
if (LOG.isTraceEnabled()) LOG.trace("TLOG putSingleRecord synchronization complete in thread " + threadId );
synchTimes[lv_TimeIndex] = endSynch - startSynch;
@@ -835,102 +779,15 @@ public class TmAuditTlog {
TransState lvTxState = TransState.STATE_NOTX;
String stateString;
int lv_lockIndex = (int)(lvTransid & tLogHashKey);
- try {
- String transidString = new String(String.valueOf(lvTransid));
- Get g;
- //create our own hashed key
- long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
- if (LOG.isTraceEnabled()) LOG.trace("key: " + key + " hex: " + Long.toHexString(key));
- g = new Get(Bytes.toBytes(key));
- try {
- Result r = table[lv_lockIndex].get(g);
- byte [] value = r.getValue(TLOG_FAMILY, ASN_STATE);
- stateString = new String (Bytes.toString(value));
- if (LOG.isTraceEnabled()) LOG.trace("stateString is " + stateString);
- if (stateString.compareTo("COMMITTED") == 0){
- lvTxState = TransState.STATE_COMMITTED;
- }
- else if (stateString.compareTo("ABORTED") == 0){
- lvTxState = TransState.STATE_ABORTED;
- }
- else if (stateString.compareTo("ACTIVE") == 0){
- lvTxState = TransState.STATE_ACTIVE;
- }
- else if (stateString.compareTo("PREPARED") == 0){
- lvTxState = TransState.STATE_PREPARED;
- }
- else if (stateString.compareTo("NOTX") == 0){
- lvTxState = TransState.STATE_NOTX;
- }
- else if (stateString.compareTo("FORGOTTEN") == 0){
- lvTxState = TransState.STATE_FORGOTTEN;
- }
- else if (stateString.compareTo("ABORTING") == 0){
- lvTxState = TransState.STATE_ABORTING;
- }
- else if (stateString.compareTo("COMMITTING") == 0){
- lvTxState = TransState.STATE_COMMITTING;
- }
- else if (stateString.compareTo("PREPARING") == 0){
- lvTxState = TransState.STATE_PREPARING;
- }
- else if (stateString.compareTo("FORGETTING") == 0){
- lvTxState = TransState.STATE_FORGETTING;
- }
- else if (stateString.compareTo("FORGETTING_HEUR") == 0){
- lvTxState = TransState.STATE_FORGETTING_HEUR;
- }
- else if (stateString.compareTo("BEGINNING") == 0){
- lvTxState = TransState.STATE_BEGINNING;
- }
- else if (stateString.compareTo("HUNGCOMMITTED") == 0){
- lvTxState = TransState.STATE_HUNGCOMMITTED;
- }
- else if (stateString.compareTo("HUNGABORTED") == 0){
- lvTxState = TransState.STATE_HUNGABORTED;
- }
- else if (stateString.compareTo("IDLE") == 0){
- lvTxState = TransState.STATE_IDLE;
- }
- else if (stateString.compareTo("FORGOTTEN_HEUR") == 0){
- lvTxState = TransState.STATE_FORGOTTEN_HEUR;
- }
- else if (stateString.compareTo("ABORTING_PART2") == 0){
- lvTxState = TransState.STATE_ABORTING_PART2;
- }
- else if (stateString.compareTo("TERMINATING") == 0){
- lvTxState = TransState.STATE_TERMINATING;
- }
- else {
- lvTxState = TransState.STATE_BAD;
- }
-
- if (LOG.isTraceEnabled()) LOG.trace("transid: " + lvTransid + " state: " + lvTxState);
- }
- catch (IOException e){
- LOG.error("getRecord IOException ", e);
- throw e;
- }
- catch (Exception e){
- LOG.error("getRecord Exception ", e);
- throw e;
- }
- }
- catch (Exception e2) {
- LOG.error("getRecord Exception2 ", e2);
- e2.printStackTrace();
- }
-
if (LOG.isTraceEnabled()) LOG.trace("getRecord end; returning " + lvTxState);
return lvTxState.getValue();
}
- public static String getRecord(final String transidString) throws IOException, Exception {
+ public static String getRecord(final String transidString) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("getRecord start");
long lvTransid = Long.parseLong(transidString, 10);
int lv_lockIndex = (int)(lvTransid & tLogHashKey);
String lvTxState = new String("NO RECORD");
- try {
Get g;
//create our own hashed key
long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
@@ -948,10 +805,6 @@ public class TmAuditTlog {
LOG.error("getRecord IOException: ", e);
throw e;
}
- } catch (Exception e){
- LOG.error("getRecord Exception: ", e);
- throw e;
- }
if (LOG.isTraceEnabled()) LOG.trace("getRecord end; returning String:" + lvTxState);
return lvTxState;
}
@@ -961,7 +814,7 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord start " + lvTransid);
String transidString = new String(String.valueOf(lvTransid));
int lv_lockIndex = (int)(lvTransid & tLogHashKey);
- try {
+ //try {
Delete d;
//create our own hashed key
long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
@@ -969,10 +822,6 @@ public class TmAuditTlog {
d = new Delete(Bytes.toBytes(key));
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord (" + lvTransid + ") ");
table[lv_lockIndex].delete(d);
- }
- catch (Exception e) {
- LOG.error("deleteRecord Exception: ", e );
- }
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord - exit");
return true;
}
@@ -1051,44 +900,23 @@ public class TmAuditTlog {
}
}
}
- catch(Exception e){
- LOG.error("deleteAgedEntries Exception getting results for table " + lv_tLogName + "; ", e);
- throw new RuntimeException(e);
- }
finally {
if (LOG.isTraceEnabled()) LOG.trace("deleteAgedEntries closing ResultScanner");
ss.close();
}
if (LOG.isTraceEnabled()) LOG.trace("attempting to delete list with " + deleteList.size()
+ " elements from table " + lv_tLogName);
- try {
- deleteTable.delete(deleteList);
- }
- catch(IOException e){
- LOG.error("deleteAgedEntries Exception deleting from table " + lv_tLogName + "; ", e);
- throw new RuntimeException(e);
- }
- }
- catch (IOException e) {
- LOG.error("deleteAgedEntries IOException setting up scan on table "
- + lv_tLogName + ", Exception: ", e);
- e.printStackTrace();
+ deleteTable.delete(deleteList);
}
finally {
- try {
deleteTable.close();
- }
- catch (IOException e) {
- LOG.error("deleteAgedEntries IOException closing table " + lv_tLogName);
- e.printStackTrace();
- }
}
}
if (LOG.isTraceEnabled()) LOG.trace("deleteAgedEntries - exit");
return true;
}
- public long writeControlPointRecords (final Map<Long, TransactionState> map) throws IOException, Exception {
+ public long writeControlPointRecords (final Map<Long, TransactionState> map) throws IOException {
int lv_lockIndex;
int cpWrites = 0;
long startTime = System.nanoTime();
@@ -1109,13 +937,13 @@ public class TmAuditTlog {
putSingleRecord(transid, value.getCommitId(), value.getStatus(), value.getParticipatingRegions(), forceControlPoint);
}
}
- catch (Exception ex) {
+ catch (IOException ex) {
LOG.error("formatRecord Exception ", ex);
throw ex;
}
}
} catch (ConcurrentModificationException cme){
- LOG.info("writeControlPointRecords ConcurrentModificationException; delaying control point ");
+ LOG.info("writeControlPointRecords ConcurrentModificationException; delaying control point ", cme);
// Return the current value rather than incrementing this interval.
controlPointDeferred = true;
return tLogControlPoint.getCurrControlPt() - 1;
@@ -1132,7 +960,7 @@ public class TmAuditTlog {
}
- public long addControlPoint (final Map<Long, TransactionState> map) throws IOException, Exception {
+ public long addControlPoint (final Map<Long, TransactionState> map) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("addControlPoint start with map size " + map.size());
long lvCtrlPt = 0L;
long agedAsn; // Writes older than this audit seq num will be deleted
@@ -1156,7 +984,6 @@ public class TmAuditTlog {
}
}
- try {
lvAsn = asn.getAndIncrement();
if (LOG.isTraceEnabled()) LOG.trace("lvAsn reset to: " + lvAsn);
@@ -1172,7 +999,7 @@ public class TmAuditTlog {
// deleteAgedEntries(agedAsn);
deleteEntriesOlderThanASN(agedAsn, ageCommitted);
}
- catch (Exception e){
+ catch (IOException e){
LOG.error("deleteAgedEntries Exception ", e);
throw e;
}
@@ -1180,8 +1007,9 @@ public class TmAuditTlog {
try {
tLogControlPoint.deleteAgedRecords(lvCtrlPt - 5);
}
- catch (Exception e){
- if (LOG.isDebugEnabled()) LOG.debug("addControlPoint - control point record not found ");
+ catch (IOException e){
+ // TODO: ignoring the exception
+ LOG.error("addControlPoint - control point record not found ");
}
}
catch (IOException e){
@@ -1189,10 +1017,6 @@ public class TmAuditTlog {
throw e;
}
}
- } catch (Exception e){
- LOG.error("addControlPoint Exception ", e);
- throw e;
- }
if (LOG.isTraceEnabled()) LOG.trace("addControlPoint returning " + lvCtrlPt);
return lvCtrlPt;
}
@@ -1211,7 +1035,6 @@ public class TmAuditTlog {
unknownTransactionTable = connection.getTable(TableName.valueOf(lv_tLogName));
- try {
String transidString = new String(String.valueOf(lvTransid));
Get g;
long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
@@ -1221,7 +1044,6 @@ public class TmAuditTlog {
String stateString = "";
String transidToken = "";
String commitIdToken = "";
- try {
Result r = unknownTransactionTable.get(g);
if (r == null) {
if (LOG.isTraceEnabled()) LOG.trace("getTransactionState: tLog result is null: " + transidString);
@@ -1361,15 +1183,6 @@ public class TmAuditTlog {
ts.setStatus(lvTxState);
if (LOG.isTraceEnabled()) LOG.trace("getTransactionState: returning transid: " + ts.getTransactionId() + " state: " + lvTxState);
- } catch (Exception e){
- LOG.error("getTransactionState Exception " + Arrays.toString(e.getStackTrace()));
- throw e;
- }
- }
- catch (Exception e2) {
- LOG.error("getTransactionState Exception2 ", e2);
- e2.printStackTrace();
- }
if (LOG.isTraceEnabled()) LOG.trace("getTransactionState end transid: " + ts.getTransactionId());
return;
}
@@ -1392,7 +1205,6 @@ public class TmAuditTlog {
TransactionState transactionState = new TransactionState(0);
CompletionService<Integer> compPool = new ExecutorCompletionService<Integer>(tlogThreadPool);
- try {
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASN: "
+ pv_ASN + ", in thread: " + threadId);
HTableInterface targetTable;
@@ -1415,24 +1227,26 @@ public class TmAuditTlog {
return deleteEntriesOlderThanASNX(regionName, pv_ASN, pv_ageCommitted);
}
});
-
+ boolean loopBreak = false;
+ do
+ {
try {
int partialResult = compPool.take().get();
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASN partial result: " + partialResult
+ " loopIndex " + loopIndex + " regionIndex " + regionIndex);
}
- catch (Exception e2) {
+ catch (InterruptedException e2) {
LOG.error("exception retieving reply in deleteEntriesOlderThanASN for interval ASN: " + pv_ASN
+ " ", e2);
- throw new IOException(e2);
+ loopBreak = true;
+ }
+ catch (ExecutionException ee) {
+ LOG.error("Execution exception", ee);
+ throw new IOException(ee);
}
+ } while (loopBreak);
}
}
- } catch (Exception e) {
- LOG.error("exception in deleteEntriesOlderThanASN for ASN: "
- + pv_ASN + " ", e);
- throw new IOException(e);
- }
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASN tlog callable requests completed in thread "
+ threadId);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TrafInfo.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TrafInfo.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TrafInfo.java
index ab1305b..1cd335b 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TrafInfo.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TrafInfo.java
@@ -54,15 +54,7 @@ public class TrafInfo {
public void init() throws IOException {
this.config = HBaseConfiguration.create();
this.connection = HConnectionManager.createConnection(config);
-
- try {
- hbadmin = new HBaseAdmin(config);
- //H98 hmaster = hbadmin.getMaster();
- } catch(Exception e) {
- System.out.println("ERROR: Unable to obtain HBase accessors, Exiting");
- e.printStackTrace();
- System.exit(1);
- }
+ hbadmin = new HBaseAdmin(config);
}
public static void printHelp() {
@@ -156,8 +148,6 @@ public class TrafInfo {
}
}
*/
-
-
}
public static void main(String[] args) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
index 11e4f2e..18fa596 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
@@ -170,11 +170,7 @@ public class HBaseClient {
+ ") called.");
HBaseAdmin.checkHBaseAvailable(config);
- try {
- table = new RMInterface();
- } catch (Exception e) {
- if (logger.isDebugEnabled()) logger.debug("HBaseClient.init: Error in RMInterface instace creation.");
- }
+ table = new RMInterface();
return true;
}
@@ -1292,7 +1288,6 @@ public class HBaseClient {
if (logger.isDebugEnabled())
logger.debug("after HTable call in getRegionsNodeName");
- try {
NavigableMap<HRegionInfo, ServerName> locations = htbl.getRegionLocations();
if (logger.isDebugEnabled())
logger.debug("after htable.getRegionLocations call in getRegionsNodeName");
@@ -1309,11 +1304,6 @@ public class HBaseClient {
if (logger.isDebugEnabled()) logger.debug("Hostname for region " + regCount + " is " + hostName);
regCount++;
}
- } catch (Exception ie) {
- if (logger.isDebugEnabled())
- logger.debug("getRegionLocations throws exception " + ie.getMessage());
- return false;
- }
return true;
}
@@ -1717,7 +1707,7 @@ public class HBaseClient {
return true;
}
- public long incrCounter(String tabName, String rowId, String famName, String qualName, long incrVal) throws Exception
+ public long incrCounter(String tabName, String rowId, String famName, String qualName, long incrVal) throws IOException
{
if (logger.isDebugEnabled()) logger.debug("HBaseClient.incrCounter() - start");
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java b/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java
index e80df3d..6b2d192 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java
@@ -286,7 +286,7 @@ public class HBulkLoadClient
}
private boolean createSnapshot( String tableName, String snapshotName)
- throws MasterNotRunningException, IOException, SnapshotCreationException, InterruptedException, Exception
+ throws MasterNotRunningException, IOException, SnapshotCreationException, InterruptedException
{
HBaseAdmin admin = null;
try
@@ -338,7 +338,7 @@ public class HBulkLoadClient
return true;
}
private boolean deleteSnapshot( String snapshotName, String tableName)
- throws IOException, Exception
+ throws IOException
{
HBaseAdmin admin = null;
@@ -376,7 +376,7 @@ public class HBulkLoadClient
}
private void doSnapshotNBulkLoad(Path hFilePath, String tableName, HTable table, LoadIncrementalHFiles loader, boolean snapshot)
- throws MasterNotRunningException, IOException, SnapshotCreationException, InterruptedException, RestoreSnapshotException, Exception
+ throws MasterNotRunningException, IOException, SnapshotCreationException, InterruptedException, RestoreSnapshotException
{
HBaseAdmin admin = new HBaseAdmin(config);
String snapshotName= null;
@@ -394,7 +394,7 @@ public class HBulkLoadClient
}
catch (IOException e)
{
- if (logger.isDebugEnabled()) logger.debug("HbulkLoadClient.doSnapshotNBulkLoad() - Exception: " + e.toString());
+ if (logger.isDebugEnabled()) logger.debug("HbulkLoadClient.doSnapshotNBulkLoad() - Exception: ", e);
if (snapshot)
{
restoreSnapshot(snapshotName, tableName);
@@ -414,7 +414,8 @@ public class HBulkLoadClient
}
}
- public boolean doBulkLoad(String prepLocation, String tableName, boolean quasiSecure, boolean snapshot) throws Exception
+ public boolean doBulkLoad(String prepLocation, String tableName, boolean quasiSecure, boolean snapshot) throws UnsupportedOperationException,
+ MasterNotRunningException, IOException, SnapshotCreationException, InterruptedException, RestoreSnapshotException
{
if (logger.isDebugEnabled()) logger.debug("HBulkLoadClient.doBulkLoad() - start");
if (logger.isDebugEnabled()) logger.debug("HBulkLoadClient.doBulkLoad() - Prep Location: " + prepLocation +
@@ -424,7 +425,15 @@ public class HBulkLoadClient
HTable table = new HTable(config, tableName);
- LoadIncrementalHFiles loader = new LoadIncrementalHFiles(config);
+ LoadIncrementalHFiles loader = null;
+ // The constructor below throws Exception, so it is caught
+ // and thrown as IOException
+ try {
+ loader = new LoadIncrementalHFiles(config);
+ }
+ catch (Exception e) {
+ throw new IOException(e);
+ }
Path prepPath = new Path(prepLocation );
prepPath = prepPath.makeQualified(prepPath.toUri(), null);
FileSystem prepFs = FileSystem.get(prepPath.toUri(),config);
@@ -458,7 +467,7 @@ public class HBulkLoadClient
return true;
}
- public boolean bulkLoadCleanup(String location) throws Exception
+ public boolean bulkLoadCleanup(String location) throws IOException
{
Path dir = new Path(location );
dir = dir.makeQualified(dir.toUri(), null);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sql/src/main/java/org/trafodion/sql/HTableClient.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/HTableClient.java b/core/sql/src/main/java/org/trafodion/sql/HTableClient.java
index 72269b3..52de8ba 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HTableClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HTableClient.java
@@ -264,7 +264,7 @@ public class HTableClient {
}
class ScanHelper implements Callable {
- public Result[] call() throws Exception {
+ public Result[] call() throws IOException {
return scanner.next(numRowsCached);
}
}
@@ -796,7 +796,7 @@ public class HTableClient {
String tmpLoc,
int espNum,
int versions)
- throws IOException, Exception {
+ throws IOException {
if (logger.isTraceEnabled()) logger.trace("Enter startScan() " + tableName + " txid: " + transID+ " CacheBlocks: " + cacheBlocks + " numCacheRows: " + numCacheRows + " Bulkread: " + useSnapshotScan);
Scan scan;
@@ -1006,8 +1006,13 @@ public class HTableClient {
if (!snapHelper.snapshotExists())
throw new IOException ("Snapshot " + snapHelper.getSnapshotName() + " does not exist.");
-
- snapHelper.createTableSnapshotScanner(snapTimeout, 5, espNum, scan);
+
+ try {
+ snapHelper.createTableSnapshotScanner(snapTimeout, 5, espNum, scan);
+ }
+ catch (InterruptedException ie) {
+ throw new IOException(ie);
+ }
}
if (useSnapshotScan)
@@ -1366,7 +1371,7 @@ public class HTableClient {
}
if (asyncOperation) {
future = executorService.submit(new Callable() {
- public Object call() throws Exception {
+ public Object call() throws IOException {
boolean res = true;
if (useTRex && (transID != 0))
table.delete(transID, del);
@@ -1419,7 +1424,7 @@ public class HTableClient {
}
if (asyncOperation) {
future = executorService.submit(new Callable() {
- public Object call() throws Exception {
+ public Object call() throws IOException {
boolean res = true;
if (useTRex && (transID != 0))
table.delete(transID, listOfDeletes);
@@ -1522,7 +1527,7 @@ public class HTableClient {
final byte[] qualifier1 = qualifier;
if (asyncOperation) {
future = executorService.submit(new Callable() {
- public Object call() throws Exception {
+ public Object call() throws IOException {
boolean res = true;
if (checkAndPut) {
@@ -1618,7 +1623,7 @@ public class HTableClient {
}
if (asyncOperation) {
future = executorService.submit(new Callable() {
- public Object call() throws Exception {
+ public Object call() throws IOException {
boolean res = true;
if (useTRex && (transID != 0))
table.put(transID, listOfPuts);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sql/src/main/java/org/trafodion/sql/OrcFileReader.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/OrcFileReader.java b/core/sql/src/main/java/org/trafodion/sql/OrcFileReader.java
index a7cb22e..f3c09c5 100644
--- a/core/sql/src/main/java/org/trafodion/sql/OrcFileReader.java
+++ b/core/sql/src/main/java/org/trafodion/sql/OrcFileReader.java
@@ -22,6 +22,7 @@
package org.trafodion.sql;
import java.io.IOException;
+import java.io.FileNotFoundException;
import java.util.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -65,46 +66,25 @@ public class OrcRowReturnSQL
//********************************************************************************
// ORIGINAL VERSION BEFORE ADDING SUPPORT FOR COLUMN SELECTION
- public String open(String pv_file_name) throws IOException {
+ public String open(String pv_file_name) throws IOException, FileNotFoundException {
// pv_file_name= pv_file_name + "/000000_0";
m_file_path = new Path(pv_file_name);
- try{
- m_reader = OrcFile.createReader(m_file_path, OrcFile.readerOptions(m_conf));
- } catch (java.io.FileNotFoundException e1) {
- return "file not found";
- }
- if (m_reader == null)
- return "open failed!";
+ m_reader = OrcFile.createReader(m_file_path, OrcFile.readerOptions(m_conf));
m_types = m_reader.getTypes();
m_oi = (StructObjectInspector) m_reader.getObjectInspector();
m_fields = m_oi.getAllStructFieldRefs();
-
- try{
- m_rr = m_reader.rows();
- } catch (java.io.IOException e1) {
- return (e1.getMessage());
- }
-
- if (m_rr == null)
- return "open:RecordReader is null";
+ m_rr = m_reader.rows();
return null;
}
//********************************************************************************
/*
- public String open(String pv_file_name) throws Exception {
+ public String open(String pv_file_name) throws IOException, FileNotFoundException {
// pv_file_name= pv_file_name + "/000000_0";
m_file_path = new Path(pv_file_name);
-
- try{
- m_reader = OrcFile.createReader(m_file_path, OrcFile.readerOptions(m_conf));
- } catch (java.io.FileNotFoundException e1) {
- return "file not found";
- }
- if (m_reader == null)
- return "open failed!";
+ m_reader = OrcFile.createReader(m_file_path, OrcFile.readerOptions(m_conf));
m_types = m_reader.getTypes();
m_oi = (StructObjectInspector) m_reader.getObjectInspector();
m_fields = m_oi.getAllStructFieldRefs();
@@ -134,7 +114,7 @@ public class OrcRowReturnSQL
}
- public void printFileInfo() throws Exception {
+ public void printFileInfo() throws IOException {
System.out.println("Reader: " + m_reader);
@@ -211,7 +191,7 @@ public class OrcRowReturnSQL
}
// Dumps the content of the file. The columns are '|' separated.
- public void readFile_String() throws Exception {
+ public void readFile_String() throws IOException {
seeknSync(0);
OrcStruct lv_row = null;
@@ -234,7 +214,7 @@ public class OrcRowReturnSQL
// Dumps the contents of the file as ByteBuffer.
- public void readFile_ByteBuffer() throws Exception {
+ public void readFile_ByteBuffer() throws IOException {
OrcStruct lv_row = null;
Object lv_field_val = null;
@@ -262,7 +242,7 @@ public class OrcRowReturnSQL
}
}
- public String getNext_String(char pv_ColSeparator) throws Exception {
+ public String getNext_String(char pv_ColSeparator) throws IOException {
if ( ! m_rr.hasNext()) {
return null;
@@ -285,7 +265,7 @@ public class OrcRowReturnSQL
}
// returns the next row as a byte array
- public byte[] fetchNextRow() throws Exception {
+ public byte[] fetchNextRow() throws IOException {
if ( ! m_rr.hasNext()) {
return null;
@@ -317,7 +297,7 @@ public class OrcRowReturnSQL
//****************************************************************************
//THIS IS THE ORIGINAL FORM BEFORE ADDING SUPPORT FOR COLUMN SELECTION !!!!
-public OrcRowReturnSQL fetchNextRowObj() throws Exception
+public OrcRowReturnSQL fetchNextRowObj() throws IOException
{
// int lv_integerLength = Integer.Bytes;
int lv_integerLength = 4;
@@ -361,7 +341,7 @@ public OrcRowReturnSQL fetchNextRowObj() throws Exception
//****************************************************************************
/*
-public OrcRowReturnSQL fetchNextRowObj() throws Exception
+public OrcRowReturnSQL fetchNextRowObj() throws IOException
{
// int lv_integerLength = Integer.Bytes;
int lv_integerLength = 4;
@@ -415,7 +395,7 @@ String getLastError() {
}
//****************************************************************************
-public boolean isEOF() throws Exception
+public boolean isEOF() throws IOException
{
if (m_rr.hasNext())
{
@@ -427,7 +407,7 @@ public boolean isEOF() throws Exception
}
}
//****************************************************************************
- public String fetchNextRow(char pv_ColSeparator) throws Exception {
+ public String fetchNextRow(char pv_ColSeparator) throws IOException {
if ( ! m_rr.hasNext()) {
return null;
@@ -451,7 +431,7 @@ public boolean isEOF() throws Exception
- public static void main(String[] args) throws Exception
+ public static void main(String[] args) throws IOException
{
System.out.println("OrcFile Reader main");
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sql/src/main/java/org/trafodion/sql/SequenceFileWriter.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/SequenceFileWriter.java b/core/sql/src/main/java/org/trafodion/sql/SequenceFileWriter.java
index a47c2f4..3e6fdf0 100644
--- a/core/sql/src/main/java/org/trafodion/sql/SequenceFileWriter.java
+++ b/core/sql/src/main/java/org/trafodion/sql/SequenceFileWriter.java
@@ -83,7 +83,8 @@ public class SequenceFileWriter {
FSDataOutputStream fsOut = null;
OutputStream outStream = null;
-
+ boolean sameStream = true;
+
FileSystem fs = null;
/**
* Class Constructor
@@ -95,8 +96,7 @@ public class SequenceFileWriter {
}
- public String open(String path) {
- try {
+ public String open(String path) throws IOException {
Path filename = new Path(path);
writer = SequenceFile.createWriter(conf,
SequenceFile.Writer.file(filename),
@@ -104,14 +104,9 @@ public class SequenceFileWriter {
SequenceFile.Writer.valueClass(BytesWritable.class),
SequenceFile.Writer.compression(CompressionType.NONE));
return null;
- } catch (Exception e) {
- //e.printStackTrace();
- return e.getMessage();
- }
}
- public String open(String path, int compressionType) {
- try {
+ public String open(String path, int compressionType) throws IOException {
Path filename = new Path(path);
CompressionType compType=null;
@@ -129,49 +124,32 @@ public class SequenceFileWriter {
break;
default:
- return "Wrong argument for compression type.";
- }
-
+ throw new IOException("Wrong argument for compression type.");
+ }
writer = SequenceFile.createWriter(conf,
SequenceFile.Writer.file(filename),
SequenceFile.Writer.keyClass(BytesWritable.class),
SequenceFile.Writer.valueClass(Text.class),
SequenceFile.Writer.compression(compType));
return null;
- } catch (Exception e) {
- //e.printStackTrace();
- return e.getMessage();
- }
}
- public String write(String data) {
- if (writer == null)
- return "open() was not called first.";
+ public String write(String data) throws IOException {
+ if (writer == null)
+ throw new IOException("open() was not called first.");
- try {
- writer.append(new BytesWritable(), new Text(data.getBytes()));
+ writer.append(new BytesWritable(), new Text(data.getBytes()));
return null;
- } catch (IOException e) {
- //e.printStackTrace();
- return e.getMessage();
- }
}
- public String close() {
- if (writer == null)
- return "open() was not called first.";
-
- try {
- writer.close();
+ public String close() throws IOException {
+ if (writer != null) {
+ writer.close();
+ writer = null;
+ }
return null;
- } catch (Exception e) {
- //e.printStackTrace();
- return e.getMessage();
- }
}
-
-
boolean hdfsCreate(String fname , boolean compress) throws IOException
{
if (logger.isDebugEnabled()) logger.debug("SequenceFileWriter.hdfsCreate() - started" );
@@ -192,6 +170,7 @@ public class SequenceFileWriter {
GzipCodec gzipCodec = (GzipCodec) ReflectionUtils.newInstance( GzipCodec.class, conf);
Compressor gzipCompressor = CodecPool.getCompressor(gzipCodec);
outStream = gzipCodec.createOutputStream(fsOut, gzipCompressor);
+ sameStream = false;
}
if (logger.isDebugEnabled()) logger.debug("SequenceFileWriter.hdfsCreate() - compressed output stream created" );
@@ -199,7 +178,6 @@ public class SequenceFileWriter {
}
boolean hdfsWrite(byte[] buff, long len) throws IOException
- //,OutOfMemoryError
{
if (logger.isDebugEnabled()) logger.debug("SequenceFileWriter.hdfsWrite() - started" );
@@ -212,8 +190,23 @@ public class SequenceFileWriter {
boolean hdfsClose() throws IOException
{
if (logger.isDebugEnabled()) logger.debug("SequenceFileWriter.hdfsClose() - started" );
- outStream.close();
- fsOut.close();
+ if (sameStream) {
+ if (outStream != null) {
+ outStream.close();
+ outStream = null;
+ }
+ fsOut = null;
+ }
+ else {
+ if (outStream != null) {
+ outStream.close();
+ outStream = null;
+ }
+ if (fsOut != null) {
+ fsOut.close();
+ fsOut = null;
+ }
+ }
return true;
}
@@ -353,7 +346,7 @@ public class SequenceFileWriter {
public boolean deleteSnapshot( String snapshotName)
throws MasterNotRunningException, IOException, SnapshotCreationException,
- InterruptedException, ZooKeeperConnectionException, ServiceException, Exception
+ InterruptedException, ZooKeeperConnectionException, ServiceException
{
if (admin == null)
admin = new HBaseAdmin(conf);
[4/6] incubator-trafodion git commit: [TRAFODION-1988] Better Java
exception handling in Trafodion - Part2
Posted by sa...@apache.org.
[TRAFODION-1988] Better Java exception handling in Trafodion - Part2
Changes as per the review comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/2fd0e4ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/2fd0e4ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/2fd0e4ff
Branch: refs/heads/master
Commit: 2fd0e4ff7b01ff0caf1d848e46cde2ebc3f539bc
Parents: ca9f2fb
Author: selvaganesang <se...@esgyn.com>
Authored: Wed Jul 6 18:54:23 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Wed Jul 6 18:54:23 2016 +0000
----------------------------------------------------------------------
.../main/java/org/trafodion/dtm/HBaseTxClient.java | 9 ++++++++-
.../main/java/org/trafodion/dtm/TmAuditTlog.java | 16 ++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2fd0e4ff/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
index e7f863a..c4cb7dc 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
@@ -338,6 +338,7 @@ public class HBaseTxClient {
boolean loopBack = false;
do {
try {
+ loopBack = false;
rt.join();
} catch (InterruptedException e) {
LOG.warn("Problem while waiting for the recovery thread to stop for node ID: " + nodeID, e);
@@ -406,9 +407,10 @@ public class HBaseTxClient {
if ((stallWhere == 1) || (stallWhere == 3)) {
LOG.info("Stalling in phase 2 for abortTransaction");
- boolean loopBack = true;
+ boolean loopBack = false;
do {
try {
+ loopBack = false;
Thread.sleep(300000); // Initially set to run every 5 min
} catch(InterruptedException ie) {
loopBack = true;
@@ -441,6 +443,7 @@ public class HBaseTxClient {
boolean loopBack = false;
do {
try {
+ loopBack = false;
commitDDLLock.wait();
} catch(InterruptedException ie) {
LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
@@ -548,6 +551,7 @@ public class HBaseTxClient {
boolean loopBack = false;
do {
try {
+ loopBack = false;
Thread.sleep(300000); // Initially set to run every 5 min
} catch(InterruptedException ie) {
loopBack = true;
@@ -577,6 +581,7 @@ public class HBaseTxClient {
boolean loopBack = false;
do {
try {
+ loopBack = false;
commitDDLLock.wait();
} catch(InterruptedException ie) {
LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
@@ -615,6 +620,7 @@ public class HBaseTxClient {
do {
try {
if (LOG.isTraceEnabled()) LOG.trace("TEMP completeRequest Calling CompleteRequest() Txid :" + transactionId);
+ loopBack = false;
ts.completeRequest();
} catch(InterruptedException ie) {
LOG.warn("Interrupting HBaseTxClient:completeRequest but retrying, ts.completeRequest: txid: " + transactionId + ", EXCEPTION: ", ie);
@@ -964,6 +970,7 @@ public class HBaseTxClient {
boolean loopBack = false;
do {
try {
+ loopBack = false;
regions = zookeeper.checkForRecovery();
} catch(InterruptedException ie) {
loopBack = true;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2fd0e4ff/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
index 8a28d8e..78fe712 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
@@ -814,14 +814,13 @@ public class TmAuditTlog {
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord start " + lvTransid);
String transidString = new String(String.valueOf(lvTransid));
int lv_lockIndex = (int)(lvTransid & tLogHashKey);
- //try {
- Delete d;
- //create our own hashed key
- long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
- if (LOG.isTraceEnabled()) LOG.trace("key: " + key + " hex: " + Long.toHexString(key));
- d = new Delete(Bytes.toBytes(key));
- if (LOG.isTraceEnabled()) LOG.trace("deleteRecord (" + lvTransid + ") ");
- table[lv_lockIndex].delete(d);
+ Delete d;
+ //create our own hashed key
+ long key = (((lvTransid & tLogHashKey) << tLogHashShiftFactor) + (lvTransid & 0xFFFFFFFF));
+ if (LOG.isTraceEnabled()) LOG.trace("key: " + key + " hex: " + Long.toHexString(key));
+ d = new Delete(Bytes.toBytes(key));
+ if (LOG.isTraceEnabled()) LOG.trace("deleteRecord (" + lvTransid + ") ");
+ table[lv_lockIndex].delete(d);
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord - exit");
return true;
}
@@ -1231,6 +1230,7 @@ public class TmAuditTlog {
do
{
try {
+ loopBack = false;
int partialResult = compPool.take().get();
if (LOG.isTraceEnabled()) LOG.trace("deleteEntriesOlderThanASN partial result: " + partialResult
+ " loopIndex " + loopIndex + " regionIndex " + regionIndex);
[6/6] incubator-trafodion git commit: Merge remote branch
'origin/pr/559/head' into merge_559
Posted by sa...@apache.org.
Merge remote branch 'origin/pr/559/head' into merge_559
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/c75214e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/c75214e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/c75214e5
Branch: refs/heads/master
Commit: c75214e5fe94a9f62de7a11195a0955be2f92a8b
Parents: 2dd9d3a 4e26e1c
Author: Sandhya Sundaresan <sa...@apache.org>
Authored: Fri Jul 8 07:38:50 2016 +0000
Committer: Sandhya Sundaresan <sa...@apache.org>
Committed: Fri Jul 8 07:38:50 2016 +0000
----------------------------------------------------------------------
.../hbase/client/transactional/TmDDL.java | 65 +--
.../trafodion/dtm/HBaseAuditControlPoint.java | 150 ++----
.../main/java/org/trafodion/dtm/HBaseTmZK.java | 22 +-
.../java/org/trafodion/dtm/HBaseTxClient.java | 535 ++++++++-----------
.../java/org/trafodion/dtm/TmAuditTlog.java | 332 +++---------
.../main/java/org/trafodion/dtm/TrafInfo.java | 12 +-
.../java/org/trafodion/sql/HBaseClient.java | 14 +-
.../java/org/trafodion/sql/HBulkLoadClient.java | 23 +-
.../java/org/trafodion/sql/HTableClient.java | 21 +-
.../java/org/trafodion/sql/OrcFileReader.java | 52 +-
.../org/trafodion/sql/SequenceFileWriter.java | 75 ++-
11 files changed, 430 insertions(+), 871 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c75214e5/core/sql/src/main/java/org/trafodion/sql/HBulkLoadClient.java
----------------------------------------------------------------------
[3/6] incubator-trafodion git commit: [TRAFODION-1988] Better Java
exception handling in Trafodion - Part2
Posted by sa...@apache.org.
[TRAFODION-1988] Better Java exception handling in Trafodion - Part2
Fixed as per the review comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/ca9f2fb9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/ca9f2fb9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/ca9f2fb9
Branch: refs/heads/master
Commit: ca9f2fb9eb2eecb4a847db8078df7155cb3ebccd
Parents: f585bc8
Author: selvaganesang <se...@esgyn.com>
Authored: Mon Jun 27 18:06:12 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Mon Jun 27 18:06:12 2016 +0000
----------------------------------------------------------------------
.../java/org/trafodion/dtm/HBaseTxClient.java | 83 +++++++++++---------
1 file changed, 46 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ca9f2fb9/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
index e6e09ac..e7f863a 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
@@ -337,12 +337,12 @@ public class HBaseTxClient {
rt.stopThread();
boolean loopBack = false;
do {
- try {
- rt.join();
- } catch (InterruptedException e) {
- LOG.warn("Problem while waiting for the recovery thread to stop for node ID: " + nodeID, e);
- loopBack = true;
- }
+ try {
+ rt.join();
+ } catch (InterruptedException e) {
+ LOG.warn("Problem while waiting for the recovery thread to stop for node ID: " + nodeID, e);
+ loopBack = true;
+ }
} while (loopBack);
mapRecoveryThreads.remove(nodeID);
if(LOG.isTraceEnabled()) LOG.trace("nodeUp -- mapRecoveryThreads size: " + mapRecoveryThreads.size());
@@ -407,10 +407,12 @@ public class HBaseTxClient {
if ((stallWhere == 1) || (stallWhere == 3)) {
LOG.info("Stalling in phase 2 for abortTransaction");
boolean loopBack = true;
- try {
- Thread.sleep(300000); // Initially set to run every 5 min
- } catch(InterruptedException ie) {
+ do {
+ try {
+ Thread.sleep(300000); // Initially set to run every 5 min
+ } catch(InterruptedException ie) {
loopBack = true;
+ }
} while (loopBack);
}
@@ -437,11 +439,13 @@ public class HBaseTxClient {
synchronized(commitDDLLock)
{
boolean loopBack = false;
- try {
- commitDDLLock.wait();
- } catch(InterruptedException ie) {
- LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
- loopBack = true;
+ do {
+ try {
+ commitDDLLock.wait();
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
+ loopBack = true;
+ }
} while (loopBack);
}
return TransReturnCode.RET_EXCEPTION.getShort();
@@ -542,10 +546,12 @@ public class HBaseTxClient {
if ((stallWhere == 2) || (stallWhere == 3)) {
LOG.info("Stalling in phase 2 for doCommit");
boolean loopBack = false;
- try {
- Thread.sleep(300000); // Initially set to run every 5 min
- } catch(InterruptedException ie) {
- loopBack = true;
+ do {
+ try {
+ Thread.sleep(300000); // Initially set to run every 5 min
+ } catch(InterruptedException ie) {
+ loopBack = true;
+ }
} while (loopBack);
}
@@ -569,11 +575,13 @@ public class HBaseTxClient {
synchronized(commitDDLLock)
{
boolean loopBack = false;
- try {
- commitDDLLock.wait();
- } catch(InterruptedException ie) {
- LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
- loopBack = true;
+ do {
+ try {
+ commitDDLLock.wait();
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
+ loopBack = true;
+ }
} while (loopBack);
}
return TransReturnCode.RET_EXCEPTION.getShort();
@@ -604,14 +612,14 @@ public class HBaseTxClient {
}
boolean loopBack = false;
- try {
-
- if (LOG.isTraceEnabled()) LOG.trace("TEMP completeRequest Calling CompleteRequest() Txid :" + transactionId);
-
- ts.completeRequest();
- } catch(InterruptedException ie) {
- LOG.warn("Interrupting HBaseTxClient:completeRequest but retrying, ts.completeRequest: txid: " + transactionId + ", EXCEPTION: ", ie);
- loopBack = true;
+ do {
+ try {
+ if (LOG.isTraceEnabled()) LOG.trace("TEMP completeRequest Calling CompleteRequest() Txid :" + transactionId);
+ ts.completeRequest();
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting HBaseTxClient:completeRequest but retrying, ts.completeRequest: txid: " + transactionId + ", EXCEPTION: ", ie);
+ loopBack = true;
+ }
} while (loopBack);
synchronized(mapLock) {
@@ -955,12 +963,13 @@ public class HBaseTxClient {
new HashMap<Long, TransactionState>();
boolean loopBack = false;
do {
- try {
- regions = zookeeper.checkForRecovery();
- } catch(InterruptedException ie) {
- loopBack = true;
- } catch (KeeperException ze) {
- }
+ try {
+ regions = zookeeper.checkForRecovery();
+ } catch(InterruptedException ie) {
+ loopBack = true;
+ } catch (KeeperException ze) {
+ loopBack = true;
+ }
} while (loopBack);
if(regions != null) {
[5/6] incubator-trafodion git commit: [TRAFODION-1988] Better Java
exception handling in Trafodion - Part2
Posted by sa...@apache.org.
[TRAFODION-1988] Better Java exception handling in Trafodion - Part2
Changes as per the review comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4e26e1ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4e26e1ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4e26e1ce
Branch: refs/heads/master
Commit: 4e26e1ce1ebf990d0d1b30f8d1fec034d2d9298e
Parents: 2fd0e4f
Author: selvaganesang <se...@esgyn.com>
Authored: Wed Jul 6 19:10:39 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Wed Jul 6 19:10:39 2016 +0000
----------------------------------------------------------------------
.../src/main/java/org/trafodion/dtm/TmAuditTlog.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4e26e1ce/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
index 78fe712..bd423ea 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/TmAuditTlog.java
@@ -1226,7 +1226,7 @@ public class TmAuditTlog {
return deleteEntriesOlderThanASNX(regionName, pv_ASN, pv_ageCommitted);
}
});
- boolean loopBreak = false;
+ boolean loopBack = false;
do
{
try {
@@ -1238,13 +1238,13 @@ public class TmAuditTlog {
catch (InterruptedException e2) {
LOG.error("exception retieving reply in deleteEntriesOlderThanASN for interval ASN: " + pv_ASN
+ " ", e2);
- loopBreak = true;
+ loopBack = true;
}
catch (ExecutionException ee) {
LOG.error("Execution exception", ee);
throw new IOException(ee);
}
- } while (loopBreak);
+ } while (loopBack);
}
}
[2/6] incubator-trafodion git commit: [TRAFODION-1988] Better Java
exception handling in Trafodion - Part2
Posted by sa...@apache.org.
[TRAFODION-1988] Better Java exception handling in Trafodion - Part2
This time the focus is on hbasetmlib2 improvements
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/f585bc80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/f585bc80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/f585bc80
Branch: refs/heads/master
Commit: f585bc80f73cd4a303b87be298436e87b405f725
Parents: a4ec8cd
Author: selvaganesang <se...@esgyn.com>
Authored: Fri Jun 24 23:48:04 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Sat Jun 25 04:52:03 2016 +0000
----------------------------------------------------------------------
.../hbase/client/transactional/TmDDL.java | 65 +--
.../trafodion/dtm/HBaseAuditControlPoint.java | 150 ++----
.../main/java/org/trafodion/dtm/HBaseTmZK.java | 22 +-
.../java/org/trafodion/dtm/HBaseTxClient.java | 501 +++++++------------
.../java/org/trafodion/dtm/TmAuditTlog.java | 318 +++---------
.../main/java/org/trafodion/dtm/TrafInfo.java | 12 +-
.../java/org/trafodion/sql/HBaseClient.java | 14 +-
.../java/org/trafodion/sql/HBulkLoadClient.java | 23 +-
.../java/org/trafodion/sql/HTableClient.java | 21 +-
.../java/org/trafodion/sql/OrcFileReader.java | 52 +-
.../org/trafodion/sql/SequenceFileWriter.java | 75 ++-
11 files changed, 398 insertions(+), 855 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TmDDL.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TmDDL.java b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TmDDL.java
index 783b70c..72f0b9f 100644
--- a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TmDDL.java
+++ b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TmDDL.java
@@ -68,7 +68,7 @@ public class TmDDL {
private static Object tablePutLock; // Lock for synchronizing table.put operations
private static HTable table;
- public TmDDL (Configuration config) throws Exception {
+ public TmDDL (Configuration config) throws IOException {
this.config = config;
this.dtmid = Integer.parseInt(config.get("dtmid"));
@@ -76,26 +76,14 @@ public class TmDDL {
if (LOG.isTraceEnabled()) LOG.trace("Enter TmDDL constructor for dtmid: " + dtmid);
- try {
- hbadmin = new HBaseAdmin(config);
- } catch(Exception e) {
- LOG.error("Unable to obtain HBaseAdmin accessor, exiting with exception: " + e);
- e.printStackTrace();
- System.exit(1);
- }
+ hbadmin = new HBaseAdmin(config);
boolean tDDLTableExists = hbadmin.tableExists(tablename);
if(tDDLTableExists==false && dtmid ==0) {
- try {
HTableDescriptor desc = new HTableDescriptor(tablename);
desc.addFamily(new HColumnDescriptor(TDDL_FAMILY));
hbadmin.createTable(desc);
- } catch(Exception e) {
- LOG.error("Unable to create TDDL table, exception: " + e);
- e.printStackTrace();
- throw e;
- }
}
tablePutLock = new Object();
@@ -217,40 +205,25 @@ public class TmDDL {
if (LOG.isTraceEnabled()) LOG.trace("TmDDL putRow exit, TxId:" + transid);
}
- public void setState(final long transid, final String state) throws Exception {
+ public void setState(final long transid, final String state) throws IOException {
long threadId = Thread.currentThread().getId();
if (LOG.isTraceEnabled()) LOG.trace("TmDDL setState start in thread: " + threadId + "TxId:" + transid + "State :" + state);
Put p = new Put(Bytes.toBytes(transid));
p.add(TDDL_FAMILY, TDDL_STATE, Bytes.toBytes(state));
- try {
- synchronized (tablePutLock) {
- try {
- if (LOG.isTraceEnabled()) LOG.trace("TmDDL setState method. table.put. TxId: " + transid + "Put:" + p );
-
- table.put(p);
- }
- catch (Exception e2){
- //Avoiding logging within a lock. Throwing Exception.
- throw e2;
- }
- } // End global synchronization
- }
- catch (Exception e) {
- //create record of the exception
- LOG.error("TmDDL setState method. tablePutLock or Table.put Exception. TxID: " + transid + "Exception :" + e);
- throw e;
- }
+ synchronized (tablePutLock) {
+ if (LOG.isTraceEnabled()) LOG.trace("TmDDL setState method. table.put. TxId: " + transid + "Put:" + p );
+ table.put(p);
+ } // End global synchronization
if (LOG.isTraceEnabled()) LOG.trace("TmDDL setState exit, TxID:" + transid);
}
public void getRow(final long lvTransid, StringBuilder state, ArrayList<String> createList, ArrayList<String> dropList, ArrayList<String> truncateList)
- throws IOException, Exception {
+ throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("TmDDL getRow start, TxID: " + lvTransid);
String recordString = null;
StringTokenizer st = null;
byte [] value = null;
- try {
Get g = new Get(Bytes.toBytes(lvTransid));
Result r = table.get(g);
@@ -296,18 +269,11 @@ public class TmDDL {
state.append(Bytes.toString(value));
}
}
-
- }
- catch(Exception e){
- LOG.error("TmDDL getRow Exception, TxId: " + lvTransid + "Exception:" + e);
- throw e;
- }
}
- public void getState(final long lvTransid, StringBuilder state) throws IOException, Exception {
+ public void getState(final long lvTransid, StringBuilder state) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("TmDDL getState start, TxID:" + lvTransid);
byte [] value = null;
- try {
Get g = new Get(Bytes.toBytes(lvTransid));
Result r = table.get(g);
@@ -327,22 +293,11 @@ public class TmDDL {
{
state.append("INVALID");
}
- }
- catch(Exception e){
- LOG.error("TmDDL getState Exception, TxID: " + lvTransid + "Exception: " + e);
- throw e;
- }
}
- public void deleteRow(final long lvTransid) throws IOException, Exception {
+ public void deleteRow(final long lvTransid) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("TmDDL deleteRow start, TxID: " + lvTransid);
- try {
Delete d = new Delete(Bytes.toBytes(lvTransid));
table.delete(d);
- }
- catch(Exception e){
- LOG.error("TmDDL deleteRow Exception, TxID: " + lvTransid + "Exception:" + e);
- throw e;
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseAuditControlPoint.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseAuditControlPoint.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseAuditControlPoint.java
index e50fe3b..12128f5 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseAuditControlPoint.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseAuditControlPoint.java
@@ -96,15 +96,10 @@ public class HBaseAuditControlPoint {
HColumnDescriptor hcol = new HColumnDescriptor(CONTROL_POINT_FAMILY);
disableBlockCache = false;
- try {
- String blockCacheString = System.getenv("TM_TLOG_DISABLE_BLOCK_CACHE");
- if (blockCacheString != null){
- disableBlockCache = (Integer.parseInt(blockCacheString) != 0);
- if (LOG.isDebugEnabled()) LOG.debug("disableBlockCache != null");
- }
- }
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_DISABLE_BLOCK_CACHE is not in ms.env");
+ String blockCacheString = System.getenv("TM_TLOG_DISABLE_BLOCK_CACHE");
+ if (blockCacheString != null){
+ disableBlockCache = (Integer.parseInt(blockCacheString) != 0);
+ if (LOG.isDebugEnabled()) LOG.debug("disableBlockCache != null");
}
LOG.info("disableBlockCache is " + disableBlockCache);
if (disableBlockCache) {
@@ -115,15 +110,10 @@ public class HBaseAuditControlPoint {
admin = new HBaseAdmin(config);
useAutoFlush = true;
- try {
- String autoFlush = System.getenv("TM_TLOG_AUTO_FLUSH");
- if (autoFlush != null){
- useAutoFlush = (Integer.parseInt(autoFlush) != 0);
- if (LOG.isDebugEnabled()) LOG.debug("autoFlush != null");
- }
- }
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_AUTO_FLUSH is not in ms.env");
+ String autoFlush = System.getenv("TM_TLOG_AUTO_FLUSH");
+ if (autoFlush != null){
+ useAutoFlush = (Integer.parseInt(autoFlush) != 0);
+ if (LOG.isDebugEnabled()) LOG.debug("autoFlush != null");
}
LOG.info("useAutoFlush is " + useAutoFlush);
@@ -140,22 +130,12 @@ public class HBaseAuditControlPoint {
LOG.error("Table " + CONTROL_POINT_TABLE_NAME + " already exists");
}
}
- try {
- if (LOG.isDebugEnabled()) LOG.debug("try new HTable");
- table = new HTable(config, desc.getName());
- table.setAutoFlushTo(this.useAutoFlush);
- }
- catch (IOException e) {
- LOG.error("new HTable IOException");
- }
+ if (LOG.isDebugEnabled()) LOG.debug("try new HTable");
+ table = new HTable(config, desc.getName());
+ table.setAutoFlushTo(this.useAutoFlush);
if (currControlPt == -1){
- try {
- currControlPt = getCurrControlPt();
- }
- catch (Exception e2) {
- if (LOG.isDebugEnabled()) LOG.debug("Exit getCurrControlPoint() exception " + e2);
- }
+ currControlPt = getCurrControlPt();
}
if (LOG.isDebugEnabled()) LOG.debug("currControlPt is " + currControlPt);
@@ -163,7 +143,7 @@ public class HBaseAuditControlPoint {
return;
}
- public long getCurrControlPt() throws Exception {
+ public long getCurrControlPt() throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("getCurrControlPt: start");
long highKey = -1;
if (LOG.isDebugEnabled()) LOG.debug("new Scan");
@@ -186,10 +166,6 @@ public class HBaseAuditControlPoint {
highKey = currKey;
}
}
- }
- catch (Exception e) {
- LOG.error("getCurrControlPt IOException" + e);
- e.printStackTrace();
} finally {
ss.close();
}
@@ -197,22 +173,16 @@ public class HBaseAuditControlPoint {
return highKey;
}
- public long putRecord(final long ControlPt, final long startingSequenceNumber) throws Exception {
+ public long putRecord(final long ControlPt, final long startingSequenceNumber) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("putRecord starting sequence number (" + String.valueOf(startingSequenceNumber) + ")");
String controlPtString = new String(String.valueOf(ControlPt));
Put p = new Put(Bytes.toBytes(controlPtString));
p.add(CONTROL_POINT_FAMILY, ASN_HIGH_WATER_MARK, Bytes.toBytes(String.valueOf(startingSequenceNumber)));
- try {
- if (LOG.isTraceEnabled()) LOG.trace("try table.put with starting sequence number " + startingSequenceNumber);
- table.put(p);
- if (useAutoFlush == false) {
- if (LOG.isTraceEnabled()) LOG.trace("flushing controlpoint record");
- table.flushCommits();
- }
- }
- catch (Exception e) {
- LOG.error("HBaseAuditControlPoint:putRecord Exception" + e);
- throw e;
+ if (LOG.isTraceEnabled()) LOG.trace("try table.put with starting sequence number " + startingSequenceNumber);
+ table.put(p);
+ if (useAutoFlush == false) {
+ if (LOG.isTraceEnabled()) LOG.trace("flushing controlpoint record");
+ table.flushCommits();
}
if (LOG.isTraceEnabled()) LOG.trace("HBaseAuditControlPoint:putRecord returning " + ControlPt);
return ControlPt;
@@ -243,21 +213,13 @@ public class HBaseAuditControlPoint {
long lvValue = -1;
Get g = new Get(Bytes.toBytes(controlPt));
String recordString;
- try {
- Result r = table.get(g);
- byte [] currValue = r.getValue(CONTROL_POINT_FAMILY, ASN_HIGH_WATER_MARK);
- try {
- recordString = new String (Bytes.toString(currValue));
- if (LOG.isDebugEnabled()) LOG.debug("recordString is " + recordString);
- lvValue = Long.parseLong(recordString, 10);
- }
- catch (NullPointerException e){
- if (LOG.isDebugEnabled()) LOG.debug("control point " + controlPt + " is not in the table");
- }
- }
- catch (IOException e){
- LOG.error("getRecord IOException");
- throw e;
+ Result r = table.get(g);
+ byte [] currValue = r.getValue(CONTROL_POINT_FAMILY, ASN_HIGH_WATER_MARK);
+ if (currValue != null)
+ {
+ recordString = new String (Bytes.toString(currValue));
+ if (LOG.isDebugEnabled()) LOG.debug("recordString is " + recordString);
+ lvValue = Long.parseLong(recordString, 10);
}
if (LOG.isTraceEnabled()) LOG.trace("getRecord - exit " + lvValue);
return lvValue;
@@ -276,19 +238,13 @@ public class HBaseAuditControlPoint {
+ CONTROL_POINT_FAMILY + " ASN_HIGH_WATER_MARK " + ASN_HIGH_WATER_MARK);
byte [] currValue = r.getValue(CONTROL_POINT_FAMILY, ASN_HIGH_WATER_MARK);
if (LOG.isDebugEnabled()) LOG.debug("Starting asn setting recordString ");
- String recordString = "";
- try {
- recordString = new String(currValue);
- }
- catch (NullPointerException e) {
- if (LOG.isDebugEnabled()) LOG.debug("getStartingAuditSeqNum recordString is null");
+ if (currValue == null)
lvAsn = 1;
- if (LOG.isDebugEnabled()) LOG.debug("Starting asn is 1");
- return lvAsn;
+ else
+ {
+ String recordString = new String(currValue);
+ lvAsn = Long.valueOf(recordString);
}
- if (LOG.isDebugEnabled()) LOG.debug("getStartingAuditSeqNum recordString is good");
- if (LOG.isDebugEnabled()) LOG.debug("Starting asn for control point " + currControlPt + " is " + recordString);
- lvAsn = Long.valueOf(recordString);
if (LOG.isTraceEnabled()) LOG.trace("getStartingAuditSeqNum - exit returning " + lvAsn);
return lvAsn;
}
@@ -323,19 +279,10 @@ public class HBaseAuditControlPoint {
highValue = currValue;
}
}
- }
- catch (Exception e) {
- LOG.error("getNextAuditSeqNum IOException" + e);
- e.printStackTrace();
} finally {
ss.close();
}
- }
- catch (IOException e) {
- LOG.error("getNextAuditSeqNum IOException setting up scan for " + lv_tName);
- e.printStackTrace();
- }
- finally {
+ } finally {
try {
remoteTable.close();
remoteConnection.close();
@@ -351,17 +298,9 @@ public class HBaseAuditControlPoint {
public long doControlPoint(final long sequenceNumber) throws IOException {
- if (LOG.isTraceEnabled()) LOG.trace("doControlPoint start");
- try {
- currControlPt++;
- if (LOG.isTraceEnabled()) LOG.trace("doControlPoint interval (" + currControlPt + "), sequenceNumber (" + sequenceNumber+ ") try putRecord");
- putRecord(currControlPt, sequenceNumber);
- }
- catch (Exception e) {
- LOG.error("doControlPoint Exception" + e);
- }
-
- if (LOG.isTraceEnabled()) LOG.trace("doControlPoint - exit");
+ currControlPt++;
+ if (LOG.isTraceEnabled()) LOG.trace("doControlPoint interval (" + currControlPt + "), sequenceNumber (" + sequenceNumber+ ") try putRecord");
+ putRecord(currControlPt, sequenceNumber);
return currControlPt;
}
@@ -369,16 +308,10 @@ public class HBaseAuditControlPoint {
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord start for control point " + controlPoint);
String controlPtString = new String(String.valueOf(controlPoint));
- try {
- List<Delete> list = new ArrayList<Delete>();
- Delete del = new Delete(Bytes.toBytes(controlPtString));
- if (LOG.isDebugEnabled()) LOG.debug("deleteRecord (" + controlPtString + ") ");
- table.delete(del);
- }
- catch (Exception e) {
- LOG.error("deleteRecord IOException");
- }
-
+ List<Delete> list = new ArrayList<Delete>();
+ Delete del = new Delete(Bytes.toBytes(controlPtString));
+ if (LOG.isDebugEnabled()) LOG.debug("deleteRecord (" + controlPtString + ") ");
+ table.delete(del);
if (LOG.isTraceEnabled()) LOG.trace("deleteRecord - exit");
return true;
}
@@ -404,10 +337,7 @@ public class HBaseAuditControlPoint {
}
if (LOG.isDebugEnabled()) LOG.debug("attempting to delete list with " + deleteList.size() + " elements");
table.delete(deleteList);
- }
- catch (Exception e) {
- LOG.error("deleteAgedRecords IOException ", e);
- }finally {
+ } finally {
ss.close();
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTmZK.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTmZK.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTmZK.java
index 27411ec..82eaa9d 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTmZK.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTmZK.java
@@ -68,9 +68,9 @@ public class HBaseTmZK implements Abortable{
/**
* @param conf
- * @throws Exception
+ * @throws IOException
*/
- public HBaseTmZK(final Configuration conf) throws Exception {
+ public HBaseTmZK(final Configuration conf) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("HBaseTmZK(conf) -- ENTRY");
this.dtmID = 0;
this.zkNode = baseNode + "0";
@@ -80,9 +80,9 @@ public class HBaseTmZK implements Abortable{
/**
* @param conf
* @param dtmID
- * @throws Exception
+ * @throws IOException
*/
- public HBaseTmZK(final Configuration conf, final short dtmID) throws Exception {
+ public HBaseTmZK(final Configuration conf, final short dtmID) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("HBaseTmZK(conf, dtmID) -- ENTRY");
this.dtmID = dtmID;
this.zkNode = baseNode + String.format("%d", dtmID);
@@ -176,7 +176,7 @@ public class HBaseTmZK implements Abortable{
}
ZKUtil.createAndFailSilent(zooKeeper, zkNode + "/" + zNodeKey, data);
} catch (KeeperException e) {
- throw new IOException("HBaseTmZK:createRecoveryzNode: ZKW Unable to create recovery zNode: " + zkNode + " , throwing IOException " + e);
+ throw new IOException("HBaseTmZK:createRecoveryzNode: ZKW Unable to create recovery zNode: " + zkNode + " , throwing IOException ", e);
}
}
/**
@@ -193,7 +193,7 @@ public class HBaseTmZK implements Abortable{
String zNodeKey = dtmID+"";
ZKUtil.createSetData(zooKeeper, zNodeGCPath + "/" + zNodeKey, data);
} catch (KeeperException e) {
- throw new IOException("HBaseTmZK:createGCzNode: ZKW Unable to create GC zNode: " + zNodeGCPath +" , throwing IOException " + e);
+ throw new IOException("HBaseTmZK:createGCzNode: ZKW Unable to create GC zNode: " + zNodeGCPath +" , throwing IOException ", e);
}
}
@@ -216,14 +216,8 @@ public class HBaseTmZK implements Abortable{
String hostName = new String(tok.nextElement().toString());
int portNumber = Integer.parseInt(tok.nextElement().toString());
byte [] lv_byte_region_info = region.toByteArray();
- try{
- LOG.info("Calling createRecoveryzNode for encoded region: " + region.getEncodedName());
- createRecoveryzNode(hostName, portNumber, region.getEncodedName(), lv_byte_region_info);
- }
- catch (Exception e2){
- LOG.error("postAllRegionEntries exception in createRecoveryzNode " + region.getTable().getNameAsString() +
- " exception: " + e2);
- }
+ LOG.info("Calling createRecoveryzNode for encoded region: " + region.getEncodedName());
+ createRecoveryzNode(hostName, portNumber, region.getEncodedName(), lv_byte_region_info);
}// while
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f585bc80/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
index 4b1c4d8..e6e09ac 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/src/main/java/org/trafodion/dtm/HBaseTxClient.java
@@ -71,6 +71,8 @@ import org.apache.hadoop.hbase.regionserver.transactional.IdTm;
import org.apache.hadoop.hbase.regionserver.transactional.IdTmException;
import org.apache.hadoop.hbase.regionserver.transactional.IdTmId;
+import org.apache.zookeeper.KeeperException;
+
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.Callable;
@@ -113,7 +115,7 @@ public class HBaseTxClient {
PropertyConfigurator.configure(confFile);
}
- public boolean init(String hBasePath, String zkServers, String zkPort) throws Exception {
+ public boolean init(String hBasePath, String zkServers, String zkPort) throws IOException {
//System.out.println("In init - hbp");
setupLog4j();
if (LOG.isDebugEnabled()) LOG.debug("Enter init, hBasePath:" + hBasePath);
@@ -135,8 +137,8 @@ public class HBaseTxClient {
useForgotten = (Integer.parseInt(useAuditRecords) != 0);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_ENABLE_FORGOTTEN_RECORDS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_ENABLE_FORGOTTEN_RECORDS is not valid in ms.env");
}
LOG.info("useForgotten is " + useForgotten);
@@ -148,8 +150,8 @@ public class HBaseTxClient {
if (LOG.isDebugEnabled()) LOG.debug("forgottenForce != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_FORCE_FORGOTTEN is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_FORCE_FORGOTTEN is not valid in ms.env");
}
LOG.info("forceForgotten is " + forceForgotten);
@@ -161,32 +163,27 @@ public class HBaseTxClient {
useTlog = useRecovThread = (Integer.parseInt(useAudit) != 0);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_ENABLE_TLOG_WRITES is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_ENABLE_TLOG_WRITES is not valid in ms.env");
}
if (useTlog) {
- try {
tLog = new TmAuditTlog(config);
- } catch (Exception e ){
- LOG.error("Unable to create TmAuditTlog, throwing exception");
- throw new RuntimeException(e);
- }
}
try {
trxManager = TransactionManager.getInstance(config);
} catch (IOException e ){
- LOG.error("Unable to create TransactionManager, throwing exception");
- throw new RuntimeException(e);
+ LOG.error("Unable to create TransactionManager, throwing exception", e);
+ throw e;
}
if (useRecovThread) {
if (LOG.isDebugEnabled()) LOG.debug("Starting recovery thread for tm ID: " + dtmID);
try {
tmZK = new HBaseTmZK(config, dtmID);
- }catch (IOException e ){
- LOG.error("Unable to create HBaseTmZK TM-zookeeper class, throwing exception");
- throw new RuntimeException(e);
+ } catch (IOException e ){
+ LOG.error("Unable to create HBaseTmZK TM-zookeeper class, throwing exception", e);
+ throw e;
}
recovThread = new RecoveryThread(tLog, tmZK, trxManager);
recovThread.start();
@@ -195,7 +192,7 @@ public class HBaseTxClient {
return true;
}
- public boolean init(short dtmid) throws Exception {
+ public boolean init(short dtmid) throws IOException {
//System.out.println("In init - dtmId" + dtmid);
setupLog4j();
@@ -214,89 +211,68 @@ public class HBaseTxClient {
String useSSCC = System.getenv("TM_USE_SSCC");
TRANSACTION_ALGORITHM = AlgorithmType.MVCC;
- if (useSSCC != null)
- TRANSACTION_ALGORITHM = (Integer.parseInt(useSSCC) == 1) ? AlgorithmType.SSCC :AlgorithmType.MVCC ;
-
try {
- idServer = new IdTm(false);
- }
- catch (Exception e){
- LOG.error("Exception creating new IdTm: " + e);
+ if (useSSCC != null)
+ TRANSACTION_ALGORITHM = (Integer.parseInt(useSSCC) == 1) ? AlgorithmType.SSCC :AlgorithmType.MVCC ;
+ } catch (NumberFormatException e) {
+ LOG.error("TRANSACTION_ALGORITHM is not valid in ms.env");
}
+ idServer = new IdTm(false);
+
+ String useDDLTransactions = System.getenv("TM_ENABLE_DDL_TRANS");
+
try {
- String useDDLTransactions = System.getenv("TM_ENABLE_DDL_TRANS");
if (useDDLTransactions != null) {
useDDLTrans = (Integer.parseInt(useDDLTransactions) != 0);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_ENABLE_DDL_TRANS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_ENABLE_DDL_TRANS is not valid in ms.env");
}
- if(useDDLTrans){
- try {
- tmDDL = new TmDDL(config);
- }
- catch (Exception e) {
- LOG.error("Unable to create TmDDL, throwing exception " + e);
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
+ if (useDDLTrans)
+ tmDDL = new TmDDL(config);
useForgotten = true;
- try {
String useAuditRecords = System.getenv("TM_ENABLE_FORGOTTEN_RECORDS");
+ try {
if (useAuditRecords != null) {
useForgotten = (Integer.parseInt(useAuditRecords) != 0);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_ENABLE_FORGOTTEN_RECORDS is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_ENABLE_FORGOTTEN_RECORDS is not valid in ms.env");
}
LOG.info("useForgotten is " + useForgotten);
forceForgotten = false;
- try {
String forgottenForce = System.getenv("TM_TLOG_FORCE_FORGOTTEN");
+ try {
if (forgottenForce != null){
forceForgotten = (Integer.parseInt(forgottenForce) != 0);
- if (LOG.isDebugEnabled()) LOG.debug("forgottenForce != null");
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_TLOG_FORCE_FORGOTTEN is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_TLOG_FORCE_FORGOTTEN is not valid in ms.env");
}
LOG.info("forceForgotten is " + forceForgotten);
useTlog = false;
useRecovThread = false;
- try {
String useAudit = System.getenv("TM_ENABLE_TLOG_WRITES");
+ try {
if (useAudit != null){
useTlog = useRecovThread = (Integer.parseInt(useAudit) != 0);
}
}
- catch (Exception e) {
- if (LOG.isDebugEnabled()) LOG.debug("TM_ENABLE_TLOG_WRITES is not in ms.env");
+ catch (NumberFormatException e) {
+ LOG.error("TM_ENABLE_TLOG_WRITES is not valid in ms.env");
}
if (useTlog) {
- try {
- tLog = new TmAuditTlog(config);
- } catch (Exception e ){
- LOG.error("Unable to create TmAuditTlog, throwing exception " + e);
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- try {
- trxManager = TransactionManager.getInstance(config);
- } catch (IOException e ){
- LOG.error("Unable to create TransactionManager, Exception: " + e + "throwing new RuntimeException");
- throw new RuntimeException(e);
+ tLog = new TmAuditTlog(config);
}
-
+ trxManager = TransactionManager.getInstance(config);
if(useDDLTrans)
trxManager.init(tmDDL);
@@ -304,9 +280,9 @@ public class HBaseTxClient {
if (LOG.isDebugEnabled()) LOG.debug("Entering recovThread Usage");
try {
tmZK = new HBaseTmZK(config, dtmID);
- }catch (IOException e ){
- LOG.error("Unable to create HBaseTmZK TM-zookeeper class, throwing exception");
- throw new RuntimeException(e);
+ } catch (IOException e ) {
+ LOG.error("Unable to create HBaseTmZK TM-zookeeper class, throwing exception", e);
+ throw e;
}
recovThread = new RecoveryThread(tLog,
tmZK,
@@ -332,7 +308,6 @@ public class HBaseTxClient {
if(dtmID == nodeID)
throw new IOException("Down node ID is the same as current dtmID, Incorrect parameter");
- try {
if(mapRecoveryThreads.containsKey(nodeID)) {
if(LOG.isDebugEnabled()) LOG.debug("nodeDown called on a node that already has RecoveryThread running node ID: " + nodeID);
}
@@ -348,10 +323,6 @@ public class HBaseTxClient {
mapRecoveryThreads.put(nodeID, recovThread);
if(LOG.isTraceEnabled()) LOG.trace("nodeDown -- mapRecoveryThreads size: " + mapRecoveryThreads.size());
}
- }
- catch(Exception e) {
- LOG.error("Unable to create rescue recovery thread for TM" + dtmID);
- }
if(LOG.isTraceEnabled()) LOG.trace("nodeDown -- EXIT node ID: " + nodeID);
}
@@ -364,9 +335,15 @@ public class HBaseTxClient {
return;
}
rt.stopThread();
+ boolean loopBack = false;
+ do {
try {
rt.join();
- } catch (Exception e) { LOG.warn("Problem while waiting for the recovery thread to stop for node ID: " + nodeID); }
+ } catch (InterruptedException e) {
+ LOG.warn("Problem while waiting for the recovery thread to stop for node ID: " + nodeID, e);
+ loopBack = true;
+ }
+ } while (loopBack);
mapRecoveryThreads.remove(nodeID);
if(LOG.isTraceEnabled()) LOG.trace("nodeUp -- mapRecoveryThreads size: " + mapRecoveryThreads.size());
if(LOG.isTraceEnabled()) LOG.trace("nodeUp -- EXIT node ID: " + nodeID);
@@ -378,15 +355,17 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public long beginTransaction(final long transactionId) throws Exception {
+ public long beginTransaction(final long transactionId) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("Enter beginTransaction, txid: " + transactionId);
- TransactionState tx = trxManager.beginTransaction(transactionId);
+ TransactionState tx = null;
+ try {
+ tx = trxManager.beginTransaction(transactionId);
+ } catch (IdTmException ite) {
+ LOG.error("Begin Transaction Error caused by : ", ite);
+ throw new IOException("Begin Transaction Error caused by :", ite);
+ }
if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:beginTransaction new transactionState created: " + tx);
- if(tx == null) {
- LOG.error("null Transaction State returned by the Transaction Manager, txid: " + transactionId);
- throw new Exception("TransactionState is null");
- }
synchronized(mapLock) {
TransactionState tx2 = mapTransactionStates.get(transactionId);
@@ -406,7 +385,7 @@ public class HBaseTxClient {
return transactionId;
}
- public short abortTransaction(final long transactionID) throws Exception {
+ public short abortTransaction(final long transactionID) throws IOException {
if (LOG.isDebugEnabled()) LOG.debug("Enter abortTransaction, txid: " + transactionID);
TransactionState ts = mapTransactionStates.get(transactionID);
@@ -420,14 +399,19 @@ public class HBaseTxClient {
if (useTlog) {
tLog.putSingleRecord(transactionID, -1, "ABORTED", ts.getParticipatingRegions(), false);
}
- } catch(Exception e) {
- LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " tLog.putRecord: EXCEPTION");
+ } catch(IOException e) {
+ LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " tLog.putRecord: EXCEPTION", e);
return TransReturnCode.RET_EXCEPTION.getShort();
}
if ((stallWhere == 1) || (stallWhere == 3)) {
LOG.info("Stalling in phase 2 for abortTransaction");
- Thread.sleep(300000); // Initially set to run every 5 min
+ boolean loopBack = true;
+ try {
+ Thread.sleep(300000); // Initially set to run every 5 min
+ } catch(InterruptedException ie) {
+ loopBack = true;
+ } while (loopBack);
}
try {
@@ -436,11 +420,11 @@ public class HBaseTxClient {
synchronized(mapLock) {
mapTransactionStates.remove(transactionID);
}
- LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " retval: EXCEPTION");
+ LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " retval: EXCEPTION", e);
return TransReturnCode.RET_EXCEPTION.getShort();
}
catch (UnsuccessfulDDLException ddle) {
- LOG.error("FATAL DDL Exception from HBaseTxClient:abort, WAITING INDEFINETLY !! retval: " + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: " + transactionID);
+ LOG.error("FATAL DDL Exception from HBaseTxClient:abort, WAITING INDEFINETLY !! retval: " + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: " + transactionID, ddle);
//Reaching here means several attempts to perform the DDL operation has failed in abort phase.
//Generally if only DML operation is involved, returning error causes TM to call completeRequest()
@@ -452,7 +436,13 @@ public class HBaseTxClient {
Object commitDDLLock = new Object();
synchronized(commitDDLLock)
{
- commitDDLLock.wait();
+ boolean loopBack = false;
+ try {
+ commitDDLLock.wait();
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
+ loopBack = true;
+ } while (loopBack);
}
return TransReturnCode.RET_EXCEPTION.getShort();
}
@@ -470,7 +460,7 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public short prepareCommit(long transactionId) throws Exception {
+ public short prepareCommit(long transactionId) throws IOException {
if (LOG.isDebugEnabled()) LOG.debug("Enter prepareCommit, txid: " + transactionId);
if (LOG.isTraceEnabled()) LOG.trace("mapTransactionStates " + mapTransactionStates + " entries " + mapTransactionStates.size());
TransactionState ts = mapTransactionStates.get(transactionId);
@@ -503,20 +493,16 @@ public class HBaseTxClient {
return TransReturnCode.RET_EXCEPTION.getShort();
}
} catch (CommitUnsuccessfulException e) {
- LOG.error("Returning from HBaseTxClient:prepareCommit, txid: " + transactionId + " retval: " + TransReturnCode.RET_NOCOMMITEX.toString() + " CommitUnsuccessfulException");
+ LOG.error("Returning from HBaseTxClient:prepareCommit, txid: " + transactionId + " retval: " + TransReturnCode.RET_NOCOMMITEX.toString() + " CommitUnsuccessfulException", e);
return TransReturnCode.RET_NOCOMMITEX.getShort();
}
catch (IOException e) {
- LOG.error("Returning from HBaseTxClient:prepareCommit, txid: " + transactionId + " retval: " + TransReturnCode.RET_IOEXCEPTION.toString() + " IOException");
+ LOG.error("Returning from HBaseTxClient:prepareCommit, txid: " + transactionId + " retval: " + TransReturnCode.RET_IOEXCEPTION.toString() + " IOException", e);
return TransReturnCode.RET_IOEXCEPTION.getShort();
}
- catch (Exception e) {
- LOG.error("Returning from HBaseTxClient:prepareCommit, txid: " + transactionId + " retval: " + TransReturnCode.RET_NOCOMMITEX.toString() + " Exception " + e);
- return TransReturnCode.RET_NOCOMMITEX.getShort();
- }
}
- public short doCommit(long transactionId) throws Exception {
+ public short doCommit(long transactionId) throws IOException, CommitUnsuccessfulException {
if (LOG.isDebugEnabled()) LOG.debug("Enter doCommit, txid: " + transactionId);
TransactionState ts = mapTransactionStates.get(transactionId);
@@ -534,8 +520,8 @@ public class HBaseTxClient {
idServer.id(ID_TM_SERVER_TIMEOUT, commitId);
if (LOG.isTraceEnabled()) LOG.trace("doCommit idServer.id returned: " + commitId.val);
} catch (IdTmException exc) {
- LOG.error("doCommit: IdTm threw exception " + exc);
- throw new CommitUnsuccessfulException("doCommit: IdTm threw exception " + exc);
+ LOG.error("doCommit: IdTm threw exception " , exc);
+ throw new CommitUnsuccessfulException("doCommit: IdTm threw exception " , exc);
}
}
@@ -548,24 +534,29 @@ public class HBaseTxClient {
if (useTlog) {
tLog.putSingleRecord(transactionId, commitIdVal, "COMMITTED", ts.getParticipatingRegions(), true);
}
- } catch(Exception e) {
- LOG.error("Returning from HBaseTxClient:doCommit, txid: " + transactionId + " tLog.putRecord: EXCEPTION " + e);
+ } catch(IOException e) {
+ LOG.error("Returning from HBaseTxClient:doCommit, txid: " + transactionId + " tLog.putRecord: EXCEPTION ", e);
return TransReturnCode.RET_EXCEPTION.getShort();
}
if ((stallWhere == 2) || (stallWhere == 3)) {
LOG.info("Stalling in phase 2 for doCommit");
- Thread.sleep(300000); // Initially set to run every 5 min
+ boolean loopBack = false;
+ try {
+ Thread.sleep(300000); // Initially set to run every 5 min
+ } catch(InterruptedException ie) {
+ loopBack = true;
+ } while (loopBack);
}
try {
trxManager.doCommit(ts);
} catch (CommitUnsuccessfulException e) {
- LOG.error("Returning from HBaseTxClient:doCommit, retval: " + TransReturnCode.RET_EXCEPTION.toString() + " IOException" + " txid: " + transactionId);
+ LOG.error("Returning from HBaseTxClient:doCommit, retval: " + TransReturnCode.RET_EXCEPTION.toString() + " IOException" + " txid: " + transactionId, e);
return TransReturnCode.RET_EXCEPTION.getShort();
}
catch (UnsuccessfulDDLException ddle) {
- LOG.error("FATAL DDL Exception from HBaseTxClient:doCommit, WAITING INDEFINETLY !! retval: " + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: " + transactionId);
+ LOG.error("FATAL DDL Exception from HBaseTxClient:doCommit, WAITING INDEFINETLY !! retval: " + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: " + transactionId, ddle);
//Reaching here means several attempts to perform the DDL operation has failed in commit phase.
//Generally if only DML operation is involved, returning error causes TM to call completeRequest()
@@ -577,7 +568,13 @@ public class HBaseTxClient {
Object commitDDLLock = new Object();
synchronized(commitDDLLock)
{
- commitDDLLock.wait();
+ boolean loopBack = false;
+ try {
+ commitDDLLock.wait();
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting commitDDLLock.wait, but retrying ", ie);
+ loopBack = true;
+ } while (loopBack);
}
return TransReturnCode.RET_EXCEPTION.getShort();
}
@@ -597,7 +594,7 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public short completeRequest(long transactionId) throws Exception {
+ public short completeRequest(long transactionId) throws IOException, CommitUnsuccessfulException {
if (LOG.isDebugEnabled()) LOG.debug("Enter completeRequest, txid: " + transactionId);
TransactionState ts = mapTransactionStates.get(transactionId);
@@ -605,16 +602,17 @@ public class HBaseTxClient {
LOG.error("Returning from HBaseTxClient:completeRequest, (null tx) retval: " + TransReturnCode.RET_NOTX.toString() + " txid: " + transactionId);
return TransReturnCode.RET_NOTX.getShort();
}
-
+
+ boolean loopBack = false;
try {
if (LOG.isTraceEnabled()) LOG.trace("TEMP completeRequest Calling CompleteRequest() Txid :" + transactionId);
ts.completeRequest();
- } catch(Exception e) {
- LOG.error("Returning from HBaseTxClient:completeRequest, ts.completeRequest: txid: " + transactionId + ", EXCEPTION: " + e);
- throw new Exception("Exception during completeRequest, unable to commit. Exception: " + e);
- }
+ } catch(InterruptedException ie) {
+ LOG.warn("Interrupting HBaseTxClient:completeRequest but retrying, ts.completeRequest: txid: " + transactionId + ", EXCEPTION: ", ie);
+ loopBack = true;
+ } while (loopBack);
synchronized(mapLock) {
mapTransactionStates.remove(transactionId);
@@ -624,7 +622,7 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public short tryCommit(long transactionId) throws Exception {
+ public short tryCommit(long transactionId) throws IOException, CommitUnsuccessfulException {
if (LOG.isDebugEnabled()) LOG.debug("Enter tryCommit, txid: " + transactionId);
short err, commitErr, abortErr = TransReturnCode.RET_OK.getShort();
@@ -650,10 +648,10 @@ public class HBaseTxClient {
if (err != TransReturnCode.RET_OK.getShort()){
if (LOG.isDebugEnabled()) LOG.debug("tryCommit completeRequest for transaction " + transactionId + " failed with error " + err);
}
- } catch(Exception e) {
+ } catch(IOException e) {
mapTransactionStates.remove(transactionId);
- LOG.error("Returning from HBaseTxClient:tryCommit, ts: EXCEPTION" + " txid: " + transactionId);
- throw new Exception("Exception " + e + "during tryCommit, unable to commit.");
+ LOG.error("Returning from HBaseTxClient:tryCommit, ts: EXCEPTION" + " txid: " + transactionId, e);
+ throw new IOException("Exception during tryCommit, unable to commit.", e);
}
synchronized(mapLock) {
@@ -664,10 +662,10 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public short callCreateTable(long transactionId, byte[] pv_htbldesc, Object[] beginEndKeys) throws Exception
+ public short callCreateTable(long transactionId, byte[] pv_htbldesc, Object[] beginEndKeys) throws IOException
{
TransactionState ts;
- HTableDescriptor htdesc;
+ HTableDescriptor htdesc = null;
if (LOG.isTraceEnabled()) LOG.trace("Enter callCreateTable, txid: [" + transactionId + "], htbldesc bytearray: " + pv_htbldesc + "desc in hex: " + Hex.encodeHexString(pv_htbldesc));
@@ -676,40 +674,17 @@ public class HBaseTxClient {
LOG.error("Returning from HBaseTxClient:callCreateTable, (null tx) retval: " + TransReturnCode.RET_NOTX.getShort() + " txid: " + transactionId);
return TransReturnCode.RET_NOTX.getShort();
}
-
try {
htdesc = HTableDescriptor.parseFrom(pv_htbldesc);
+ } catch (DeserializationException de) {
+ LOG.error("Error while getting HTableDescriptor caused by : ", de);
+ throw new IOException("Error while getting HTableDescriptor caused by : ", de);
}
- catch(Exception e) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callCreateTable exception in htdesc parseFrom, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() +
- " txid: " + transactionId +
- " DeserializationException: " + e);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- e.printStackTrace(pw);
- LOG.error(sw.toString());
-
- throw new Exception("DeserializationException in callCreateTable parseFrom, unable to send callCreateTable");
- }
-
- try {
- trxManager.createTable(ts, htdesc, beginEndKeys);
- }
- catch (Exception cte) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callCreateTable exception trxManager.createTable, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() +" txid: " + transactionId +" Exception: " + cte);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- cte.printStackTrace(pw);
- LOG.error("HBaseTxClient createTable call error: " + sw.toString());
-
- throw new Exception("createTable call error");
- }
+ trxManager.createTable(ts, htdesc, beginEndKeys);
return TransReturnCode.RET_OK.getShort();
}
- public short callAlterTable(long transactionId, byte[] pv_tblname, Object[] tableOptions) throws Exception
+ public short callAlterTable(long transactionId, byte[] pv_tblname, Object[] tableOptions) throws IOException
{
TransactionState ts;
String strTblName = new String(pv_tblname, "UTF-8");
@@ -722,23 +697,11 @@ public class HBaseTxClient {
return TransReturnCode.RET_NOTX.getShort();
}
- try {
- trxManager.alterTable(ts, strTblName, tableOptions);
- }
- catch (Exception cte) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callAlterTable exception trxManager.alterTable, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() +" txid: " + transactionId +" Exception: " + cte);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- cte.printStackTrace(pw);
- LOG.error("HBaseTxClient alterTable call error: " + sw.toString());
-
- throw new Exception("alterTable call error");
- }
+ trxManager.alterTable(ts, strTblName, tableOptions);
return TransReturnCode.RET_OK.getShort();
}
- public short callRegisterTruncateOnAbort(long transactionId, byte[] pv_tblname) throws Exception
+ public short callRegisterTruncateOnAbort(long transactionId, byte[] pv_tblname) throws IOException
{
TransactionState ts;
String strTblName = new String(pv_tblname, "UTF-8");
@@ -751,23 +714,11 @@ public class HBaseTxClient {
return TransReturnCode.RET_NOTX.getShort();
}
- try {
- trxManager.registerTruncateOnAbort(ts, strTblName);
- }
- catch (Exception e) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callRegisterTruncateOnAbort exception trxManager.registerTruncateOnAbort, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() +" txid: " + transactionId +" Exception: " + e);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- e.printStackTrace(pw);
- String msg = "HBaseTxClient registerTruncateOnAbort call error ";
- LOG.error(msg + " : " + sw.toString());
- throw new Exception(msg);
- }
+ trxManager.registerTruncateOnAbort(ts, strTblName);
return TransReturnCode.RET_OK.getShort();
}
- public short callDropTable(long transactionId, byte[] pv_tblname) throws Exception
+ public short callDropTable(long transactionId, byte[] pv_tblname) throws IOException
{
TransactionState ts;
String strTblName = new String(pv_tblname, "UTF-8");
@@ -780,17 +731,7 @@ public class HBaseTxClient {
return TransReturnCode.RET_NOTX.getShort();
}
- try {
- trxManager.dropTable(ts, strTblName);
- }
- catch (Exception cte) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callDropTable exception trxManager.dropTable, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() +" txid: " + transactionId +" Exception: " + cte);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- cte.printStackTrace(pw);
- LOG.error("HBaseTxClient dropTable call error: " + sw.toString());
- }
+ trxManager.dropTable(ts, strTblName);
return TransReturnCode.RET_OK.getShort();
}
@@ -799,7 +740,7 @@ public class HBaseTxClient {
int pv_port,
byte[] pv_hostname,
long pv_startcode,
- byte[] pv_regionInfo) throws Exception {
+ byte[] pv_regionInfo) throws IOException {
String hostname = new String(pv_hostname);
if (LOG.isTraceEnabled()) LOG.trace("Enter callRegisterRegion, txid: [" + transactionId + "], startId: " + startId + ", port: "
+ pv_port + ", hostname: " + hostname + ", reg info len: " + pv_regionInfo.length + " " + new String(pv_regionInfo, "UTF-8"));
@@ -807,16 +748,9 @@ public class HBaseTxClient {
HRegionInfo lv_regionInfo;
try {
lv_regionInfo = HRegionInfo.parseFrom(pv_regionInfo);
- }
- catch (Exception de) {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient:callRegisterRegion exception in lv_regionInfo parseFrom, retval: " +
- TransReturnCode.RET_EXCEPTION.toString() + " txid: " + transactionId + " DeserializationException: " + de);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- de.printStackTrace(pw);
- LOG.error(sw.toString());
-
- throw new Exception("DeserializationException in lv_regionInfo parseFrom, unable to register region");
+ } catch (DeserializationException de) {
+ LOG.error("Error while getting regionInfo caused by : ", de);
+ throw new IOException("Error while getting regionInfo caused by : ", de);
}
// TODO Not in CDH 5.1 ServerName lv_servername = ServerName.valueOf(hostname, pv_port, pv_startcode);
@@ -832,10 +766,9 @@ public class HBaseTxClient {
") not found in mapTransactionStates of size: " + mapTransactionStates.size());
try {
ts = trxManager.beginTransaction(transactionId);
- }
- catch (IdTmException exc) {
- LOG.error("HBaseTxClient: beginTransaction for tx (" + transactionId + ") caught exception " + exc);
- throw new IdTmException("HBaseTxClient: beginTransaction for tx (" + transactionId + ") caught exception " + exc);
+ } catch (IdTmException ite) {
+ LOG.error("Begin Transaction Error caused by : ", ite);
+ throw new IOException("Begin Transaction Error caused by :", ite);
}
synchronized (mapLock) {
TransactionState ts2 = mapTransactionStates.get(transactionId);
@@ -863,7 +796,7 @@ public class HBaseTxClient {
trxManager.registerRegion(ts, regionLocation);
} catch (IOException e) {
LOG.error("HBaseTxClient:callRegisterRegion exception in registerRegion call, txid: " + transactionId +
- " retval: " + TransReturnCode.RET_EXCEPTION.toString() + " IOException " + e);
+ " retval: " + TransReturnCode.RET_EXCEPTION.toString() + " IOException " , e);
return TransReturnCode.RET_EXCEPTION.getShort();
}
@@ -878,7 +811,7 @@ public class HBaseTxClient {
return TransReturnCode.RET_OK.getShort();
}
- public int participatingRegions(long transactionId) throws Exception {
+ public int participatingRegions(long transactionId) throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("Enter participatingRegions, txid: " + transactionId);
TransactionState ts = mapTransactionStates.get(transactionId);
if(ts == null) {
@@ -900,17 +833,11 @@ public class HBaseTxClient {
return participants;
}
- public long addControlPoint() throws Exception {
+ public long addControlPoint() throws IOException {
if (LOG.isTraceEnabled()) LOG.trace("Enter addControlPoint");
long result = 0L;
- try {
- if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient calling tLog.addControlPoint with mapsize " + mapTransactionStates.size());
- result = tLog.addControlPoint(mapTransactionStates);
- }
- catch(IOException e){
- LOG.error("addControlPoint IOException " + e);
- throw e;
- }
+ if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient calling tLog.addControlPoint with mapsize " + mapTransactionStates.size());
+ result = tLog.addControlPoint(mapTransactionStates);
Long lowestStartId = Long.MAX_VALUE;
for(ConcurrentHashMap.Entry<Long, TransactionState> entry : mapTransactionStates.entrySet()){
TransactionState value;
@@ -987,7 +914,7 @@ public class HBaseTxClient {
this.continueThread = false;
}
- private void addRegionToTS(String hostnamePort, byte[] regionInfo, TransactionState ts) throws Exception{
+ private void addRegionToTS(String hostnamePort, byte[] regionInfo, TransactionState ts) throws IOException{
HRegionInfo regionInfoLoc; // = new HRegionInfo();
final byte [] delimiter = ",".getBytes();
String[] result = hostnamePort.split(new String(delimiter), 3);
@@ -998,21 +925,14 @@ public class HBaseTxClient {
String hostname = result[0];
int port = Integer.parseInt(result[1]);
try {
- regionInfoLoc = HRegionInfo.parseFrom(regionInfo);
- }
- catch(Exception e) {
- LOG.error("Unable to parse region byte array, " + e);
- throw e;
+ regionInfoLoc = HRegionInfo.parseFrom(regionInfo);
+ } catch (DeserializationException de) {
+ throw new IOException(de);
}
- /*
ByteArrayInputStream lv_bis = new ByteArrayInputStream(regionInfo);
DataInputStream lv_dis = new DataInputStream(lv_bis);
- try {
- regionInfoLoc.readFields(lv_dis);
- } catch (Exception e) {
- throw new Exception();
- }
- */
+ regionInfoLoc.readFields(lv_dis);
+
//HBase98 TODO: need to set the value of startcode correctly
//HBase98 TODO: Not in CDH 5.1: ServerName lv_servername = ServerName.valueOf(hostname, port, 0);
@@ -1033,17 +953,15 @@ public class HBaseTxClient {
Map<String, byte[]> regions = null;
Map<Long, TransactionState> transactionStates =
new HashMap<Long, TransactionState>();
+ boolean loopBack = false;
+ do {
try {
- regions = zookeeper.checkForRecovery();
- } catch (Exception e) {
- if (regions != null) { // ignore no object returned by zookeeper.checkForRecovery
- LOG.error("An ERROR occurred while checking for regions to recover. " + "TM: " + tmID);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- e.printStackTrace(pw);
- LOG.error(sw.toString());
- }
+ regions = zookeeper.checkForRecovery();
+ } catch(InterruptedException ie) {
+ loopBack = true;
+ } catch (KeeperException ze) {
}
+ } while (loopBack);
if(regions != null) {
skipSleep = true;
@@ -1090,77 +1008,39 @@ public class HBaseTxClient {
}catch (NotServingRegionException e) {
TxRecoverList = null;
LOG.error("TRAF RCOV THREAD:NotServingRegionException calling recoveryRequest. regionBytes: " + new String(regionBytes) +
- " TM: " + tmID + " hostnamePort: " + hostnamePort);
+ " TM: " + tmID + " hostnamePort: " + hostnamePort, e);
- try {
// First delete the zookeeper entry
LOG.error("TRAF RCOV THREAD:recoveryRequest. Deleting region entry Entry: " + regionEntry);
zookeeper.deleteRegionEntry(regionEntry);
- }
- catch (Exception e2) {
- LOG.error("TRAF RCOV THREAD:Error calling deleteRegionEntry. regionEntry key: " + regionEntry.getKey() + " regionEntry value: " +
- new String(regionEntry.getValue()) + " exception: " + e2);
- }
- try {
// Create a local HTable object using the regionInfo
HTable table = new HTable(config, HRegionInfo.parseFrom(regionBytes).getTable().getNameAsString());
- try {
- // Repost a zookeeper entry for all current regions in the table
- zookeeper.postAllRegionEntries(table);
- }
- catch (Exception e2) {
- LOG.error("TRAF RCOV THREAD:Error calling postAllRegionEntries. table: " + new String(table.getTableName()) + " exception: " + e2);
- }
- }// try
- catch (Exception e1) {
- LOG.error("TRAF RCOV THREAD:recoveryRequest exception in new HTable " + HRegionInfo.parseFrom(regionBytes).getTable().getNameAsString() + " Exception: " + e1);
- }
+ // Repost a zookeeper entry for all current regions in the table
+ zookeeper.postAllRegionEntries(table);
}// NotServingRegionException
catch (TableNotFoundException tnfe) {
// In this case there is nothing to recover. We just need to delete the region entry.
- try {
// First delete the zookeeper entry
LOG.warn("TRAF RCOV THREAD:TableNotFoundException calling txnManager.recoveryRequest. " + "TM: " +
tmID + " regionBytes: [" + regionBytes + "]. Deleting zookeeper region entry. \n exception: " + tnfe);
zookeeper.deleteRegionEntry(regionEntry);
- }
- catch (Exception e2) {
- LOG.error("TRAF RCOV THREAD:Error calling deleteRegionEntry. regionEntry key: " + regionEntry.getKey() + " regionEntry value: " +
- new String(regionEntry.getValue()) + " exception: " + e2);
- }
}// TableNotFoundException
catch (DeserializationException de) {
// We are unable to parse the region info from ZooKeeper We just need to delete the region entry.
- try {
// First delete the zookeeper entry
LOG.warn("TRAF RCOV THREAD:DeserializationException calling txnManager.recoveryRequest. " + "TM: " +
tmID + " regionBytes: [" + regionBytes + "]. Deleting zookeeper region entry. \n exception: " + de);
zookeeper.deleteRegionEntry(regionEntry);
- }
- catch (Exception e2) {
- LOG.error("TRAF RCOV THREAD:Error calling deleteRegionEntry. regionEntry key: " + regionEntry.getKey() + " regionEntry value: " +
- new String(regionEntry.getValue()) + " exception: " + e2);
- }
-
}// DeserializationException
- catch (Exception e) {
- LOG.error("TRAF RCOV THREAD:An ERROR occurred calling txnManager.recoveryRequest. " + "TM: " +
- tmID + " regionBytes: [" + regionBytes + "] exception: " + e);
- }
+
if (TxRecoverList != null) {
if (LOG.isDebugEnabled()) LOG.trace("TRAF RCOV THREAD:size of TxRecoverList " + TxRecoverList.size());
if (TxRecoverList.size() == 0) {
- try {
// First delete the zookeeper entry
LOG.warn("TRAF RCOV THREAD:Leftover Znode calling txnManager.recoveryRequest. " + "TM: " +
tmID + " regionBytes: [" + regionBytes + "]. Deleting zookeeper region entry. ");
zookeeper.deleteRegionEntry(regionEntry);
- }
- catch (Exception e2) {
- LOG.error("TRAF RCOV THREAD:Error calling deleteRegionEntry. regionEntry key: " + regionEntry.getKey() + " regionEntry value: " +
- new String(regionEntry.getValue()) + " exception: " + e2);
- }
}
for (Long txid : TxRecoverList) {
TransactionState ts = transactionStates.get(txid);
@@ -1171,22 +1051,12 @@ public class HBaseTxClient {
if(hbtx.useDDLTrans){
TmDDL tmDDL = hbtx.getTmDDL();
StringBuilder state = new StringBuilder ();
- try {
- tmDDL.getState(txid,state);
- }
- catch(Exception egetState){
- LOG.error("TRAF RCOV THREAD:Error calling TmDDL getState." + egetState);
- }
+ tmDDL.getState(txid,state);
if(state.toString().equals("VALID"))
ts.setDDLTx(true);
}
}
- try {
- this.addRegionToTS(hostnamePort, regionBytes, ts);
- } catch (Exception e) {
- LOG.error("TRAF RCOV THREAD:Unable to add region to TransactionState, region info: " + new String(regionBytes));
- e.printStackTrace();
- }
+ this.addRegionToTS(hostnamePort, regionBytes, ts);
transactionStates.put(txid, ts);
}
}
@@ -1219,24 +1089,20 @@ public class HBaseTxClient {
txnManager.abort(ts);
}
- }catch (UnsuccessfulDDLException ddle) {
- LOG.error("UnsuccessfulDDLException encountered by Recovery Thread. Registering for retry. txID: " + txID + "Exception " + ddle);
- ddle.printStackTrace();
+ } catch (UnsuccessfulDDLException ddle) {
+ LOG.error("UnsuccessfulDDLException encountered by Recovery Thread. Registering for retry. txID: " + txID + "Exception " , ddle);
//Note that there may not be anymore redrive triggers from region server point of view for DDL operation.
//Register this DDL transaction for subsequent redrive from Audit Control Event.
//TODO: Launch a new Redrive Thread out of auditControlPoint().
TmDDL tmDDL = hbtx.getTmDDL();
- try {
- tmDDL.setState(txID,"REDRIVE");
- }
- catch(Exception e){
- LOG.error("TRAF RCOV THREAD:Error calling TmDDL putRow Redrive" + e);
- }
- }
- catch (Exception e) {
- LOG.error("Unable to get audit record for tx: " + txID + ", audit is throwing exception.");
- e.printStackTrace();
+ tmDDL.setState(txID,"REDRIVE");
+ LOG.error("TRAF RCOV THREAD:Error calling TmDDL putRow Redrive");
+ } catch (CommitUnsuccessfulException cue) {
+ LOG.error("CommitUnsuccessfulException encountered by Recovery Thread. Registering for retry. txID: " + txID + "Exception " , cue);
+ TmDDL tmDDL = hbtx.getTmDDL();
+ tmDDL.setState(txID,"REDRIVE");
+ LOG.error("TRAF RCOV THREAD:Error calling TmDDL putRow Redrive");
}
}
@@ -1257,17 +1123,40 @@ public class HBaseTxClient {
}
}
retryCount = 0;
- } catch (Exception e) {
+ } catch (InterruptedException e) {
LOG.error("Error in recoveryThread: " + e);
}
+ } catch (IOException e) {
+ int possibleRetries = 4;
+ LOG.error("Caught recovery thread exception for tmid: " + tmID + " retries: " + retryCount, e);
+
+ retryCount++;
+ if(retryCount > possibleRetries) {
+ LOG.error("Recovery thread failure, aborting process");
+ System.exit(4);
+ }
+
+ try {
+ Thread.sleep(SLEEP_DELAY / possibleRetries);
+ } catch(InterruptedException se) {
+ }
+ } catch (KeeperException ze) {
+ int possibleRetries = 4;
+ LOG.error("Caught recovery thread exception for tmid: " + tmID + " retries: " + retryCount, ze);
- } catch (Exception e) {
+ retryCount++;
+ if(retryCount > possibleRetries) {
+ LOG.error("Recovery thread failure, aborting process");
+ System.exit(4);
+ }
+
+ try {
+ Thread.sleep(SLEEP_DELAY / possibleRetries);
+ } catch(InterruptedException se) {
+ }
+ } catch (DeserializationException de) {
int possibleRetries = 4;
- LOG.error("Caught recovery thread exception for tmid: " + tmID + " retries: " + retryCount);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- e.printStackTrace(pw);
- LOG.error(sw.toString());
+ LOG.error("Caught recovery thread exception for tmid: " + tmID + " retries: " + retryCount, de);
retryCount++;
if(retryCount > possibleRetries) {
@@ -1277,8 +1166,7 @@ public class HBaseTxClient {
try {
Thread.sleep(SLEEP_DELAY / possibleRetries);
- } catch(Exception se) {
- LOG.error(se);
+ } catch(InterruptedException se) {
}
}
}
@@ -1294,7 +1182,7 @@ public class HBaseTxClient {
// callRequestRegionInfo
// Purpose: Prepares HashMapArray class to get region information
//--------------------------------------------------------------------------------
- public HashMapArray callRequestRegionInfo() throws Exception {
+ public HashMapArray callRequestRegionInfo() throws IOException {
String tablename, encoded_region_name, region_name, is_offline, region_id, hostname, port, thn;
@@ -1308,7 +1196,6 @@ public class HBaseTxClient {
HashMapArray hm = new HashMapArray();
- try{
for(ConcurrentHashMap.Entry<Long, TransactionState> entry : mapTransactionStates.entrySet()){
key = entry.getKey();
value = entry.getValue();
@@ -1375,10 +1262,6 @@ public class HBaseTxClient {
tnum = tnum + 1;
}
- }catch(Exception e){
- if (LOG.isTraceEnabled()) LOG.trace("Error in getting region info. Map might be empty. Please ensure sqlci insert was done");
- }
-
if (LOG.isTraceEnabled()) LOG.trace("HBaseTxClient::callRequestRegionInfo:: end size: " + hm.getSize());
return hm;
}