Skip to content

Commit

Permalink
HBASE-13419 Thrift gateway should propagate text from exception cause…
Browse files Browse the repository at this point in the history
…s (Michael Muller)
  • Loading branch information
tedyu committed Apr 13, 2015
1 parent e75c620 commit 679e0e8
Showing 1 changed file with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
import org.mortbay.thread.QueuedThreadPool;

import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

/**
Expand Down Expand Up @@ -755,7 +756,7 @@ public void enableTable(ByteBuffer tableName) throws IOError {
getAdmin().enableTable(getTableName(tableName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -765,7 +766,7 @@ public void disableTable(ByteBuffer tableName) throws IOError{
getAdmin().disableTable(getTableName(tableName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -775,7 +776,7 @@ public boolean isTableEnabled(ByteBuffer tableName) throws IOError {
return this.connectionCache.getAdmin().isTableEnabled(getTableName(tableName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -788,7 +789,7 @@ public void compact(ByteBuffer tableNameOrRegionName) throws IOError {
((HBaseAdmin) getAdmin()).compact(getBytes(tableNameOrRegionName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -801,7 +802,7 @@ public void majorCompact(ByteBuffer tableNameOrRegionName) throws IOError {
((HBaseAdmin) getAdmin()).majorCompact(getBytes(tableNameOrRegionName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -816,7 +817,7 @@ public List<ByteBuffer> getTableNames() throws IOError {
return list;
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -849,7 +850,7 @@ public List<TRegionInfo> getTableRegions(ByteBuffer tableName)
return Collections.emptyList();
} catch (IOException e){
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -894,7 +895,7 @@ protected List<TCell> get(ByteBuffer tableName,
return ThriftUtilities.cellFromHBase(result.rawCells());
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -937,7 +938,7 @@ public List<TCell> getVer(ByteBuffer tableName, ByteBuffer row, byte[] family,
return ThriftUtilities.cellFromHBase(result.rawCells());
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -981,7 +982,7 @@ protected List<TCell> getVerTs(ByteBuffer tableName, ByteBuffer row, byte[] fami
return ThriftUtilities.cellFromHBase(result.rawCells());
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1038,7 +1039,7 @@ public List<TRowResult> getRowWithColumnsTs(
return ThriftUtilities.rowResultFromHBase(result);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1103,7 +1104,7 @@ public List<TRowResult> getRowsWithColumnsTs(ByteBuffer tableName,
return ThriftUtilities.rowResultFromHBase(result);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1135,7 +1136,7 @@ public void deleteAllTs(ByteBuffer tableName,

} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1157,7 +1158,7 @@ public void deleteAllRowTs(
table.delete(delete);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1178,10 +1179,10 @@ public void createTable(ByteBuffer in_tableName,
getAdmin().createTable(desc);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage(), e);
throw new IllegalArgument(e.getMessage());
throw new IllegalArgument(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1202,7 +1203,7 @@ public void deleteTable(ByteBuffer in_tableName) throws IOError {
getAdmin().deleteTable(tableName);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1260,10 +1261,10 @@ public void mutateRowTs(ByteBuffer tableName, ByteBuffer row,
table.put(put);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage(), e);
throw new IllegalArgument(e.getMessage());
throw new IllegalArgument(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1331,10 +1332,10 @@ public void mutateRowsTs(

} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage(), e);
throw new IllegalArgument(e.getMessage());
throw new IllegalArgument(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1360,7 +1361,7 @@ protected long atomicIncrement(ByteBuffer tableName, ByteBuffer row,
getBytes(row), family, qualifier, amount);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1396,7 +1397,7 @@ public List<TRowResult> scannerGetList(int id,int nbRows)
}
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
return ThriftUtilities.rowResultFromHBase(results, resultScannerWrapper.isColumnSorted());
}
Expand Down Expand Up @@ -1450,7 +1451,7 @@ public int scannerOpenWithScan(ByteBuffer tableName, TScan tScan,
return addScanner(table.getScanner(scan), tScan.sortColumns);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1475,7 +1476,7 @@ public int scannerOpen(ByteBuffer tableName, ByteBuffer startRow,
return addScanner(table.getScanner(scan), false);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1501,7 +1502,7 @@ public int scannerOpenWithStop(ByteBuffer tableName, ByteBuffer startRow,
return addScanner(table.getScanner(scan), false);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1531,7 +1532,7 @@ public int scannerOpenWithPrefix(ByteBuffer tableName,
return addScanner(table.getScanner(scan), false);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1557,7 +1558,7 @@ public int scannerOpenTs(ByteBuffer tableName, ByteBuffer startRow,
return addScanner(table.getScanner(scan), false);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1585,7 +1586,7 @@ public int scannerOpenWithStopTs(ByteBuffer tableName, ByteBuffer startRow,
return addScanner(table.getScanner(scan), false);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1606,7 +1607,7 @@ public Map<ByteBuffer, ColumnDescriptor> getColumnDescriptors(
return columns;
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1619,7 +1620,7 @@ public List<TCell> getRowOrBefore(ByteBuffer tableName, ByteBuffer row,
return ThriftUtilities.cellFromHBase(result.rawCells());
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1658,7 +1659,7 @@ public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
return region;
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1696,7 +1697,7 @@ public void increment(TIncrement tincrement) throws IOError, TException {
table.increment(inc);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand Down Expand Up @@ -1724,7 +1725,7 @@ public List<TCell> append(TAppend tappend) throws IOError, TException {
return ThriftUtilities.cellFromHBase(result.rawCells());
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
}
}

Expand All @@ -1745,7 +1746,7 @@ public boolean checkAndPut(ByteBuffer tableName, ByteBuffer row, ByteBuffer colu
put.setDurability(mput.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage(), e);
throw new IllegalArgument(e.getMessage());
throw new IllegalArgument(Throwables.getStackTraceAsString(e));
}

Table table = null;
Expand All @@ -1756,10 +1757,10 @@ public boolean checkAndPut(ByteBuffer tableName, ByteBuffer row, ByteBuffer colu
value != null ? getBytes(value) : HConstants.EMPTY_BYTE_ARRAY, put);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
throw new IOError(Throwables.getStackTraceAsString(e));
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage(), e);
throw new IllegalArgument(e.getMessage());
throw new IllegalArgument(Throwables.getStackTraceAsString(e));
}
}
}
Expand Down

0 comments on commit 679e0e8

Please sign in to comment.