本文整理匯總了Java中com.google.common.base.Throwables.propagateIfInstanceOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Throwables.propagateIfInstanceOf方法的具體用法?Java Throwables.propagateIfInstanceOf怎麽用?Java Throwables.propagateIfInstanceOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.base.Throwables
的用法示例。
在下文中一共展示了Throwables.propagateIfInstanceOf方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rebuffer
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public Buffer rebuffer(long position)
{
try
{
metrics.requests.mark();
long pageAlignedPos = position & alignmentMask;
Buffer buf;
do
buf = cache.get(new Key(source, pageAlignedPos)).reference();
while (buf == null);
return buf;
}
catch (Throwable t)
{
Throwables.propagateIfInstanceOf(t.getCause(), CorruptSSTableException.class);
throw Throwables.propagate(t);
}
}
示例2: remaining
import com.google.common.base.Throwables; //導入方法依賴的package包/類
public static int remaining(Channel ch) throws EventDeliveryException {
Transaction t = ch.getTransaction();
try {
t.begin();
int count = 0;
while (ch.take() != null) {
count += 1;
}
t.commit();
return count;
} catch (Throwable th) {
t.rollback();
Throwables.propagateIfInstanceOf(th, Error.class);
Throwables.propagateIfInstanceOf(th, EventDeliveryException.class);
throw new EventDeliveryException(th);
} finally {
t.close();
}
}
示例3: putToChannel
import com.google.common.base.Throwables; //導入方法依賴的package包/類
public static void putToChannel(Channel in, Iterable<Event> records)
throws EventDeliveryException {
Transaction t = in.getTransaction();
try {
t.begin();
for (Event record : records) {
in.put(record);
}
t.commit();
} catch (Throwable th) {
t.rollback();
Throwables.propagateIfInstanceOf(th, Error.class);
Throwables.propagateIfInstanceOf(th, EventDeliveryException.class);
throw new EventDeliveryException(th);
} finally {
t.close();
}
}
示例4: newDataset
import com.google.common.base.Throwables; //導入方法依賴的package包/類
private VirtualDatasetUI newDataset(DatasetPath datasetPath, DatasetVersion version,
From from, List<String> sqlContext) {
final VirtualDatasetUI ds = com.dremio.dac.explore.DatasetTool.newDatasetBeforeQueryMetadata(datasetPath, version, from, sqlContext, username);
final SqlQuery query = new SqlQuery(ds.getSql(), ds.getState().getContextList(), username);
ds.setLastTransform(new Transform(TransformType.createFromParent).setTransformCreateFromParent(new TransformCreateFromParent(from)));
final QueryMetadata metadata;
try {
Stopwatch sw = Stopwatch.createStarted();
metadata = QueryParser.extract(query, context);
long t = sw.elapsed(MILLISECONDS);
if (t > 100) {
logger.warn(String.format("parsing sql took %dms for %s:\n%s", t, ds.getName(), ds.getSql()));
}
} catch (RuntimeException e) {
Throwables.propagateIfInstanceOf(e, UserException.class);
throw new ServerErrorException("Produced invalid SQL:\n" + ds.getSql() + "\n" + e.getMessage(), e);
}
QuerySemantics.populateSemanticFields(metadata.getRowType(), ds.getState());
DatasetTool.applyQueryMetadata(ds, metadata);
return ds;
}
示例5: map
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
protected void map(ImmutableBytesWritable key, Result value, Context context)
throws IOException, InterruptedException {
try {
// first, finish any hash batches that end before the scanned row
while (nextSourceKey != null && key.compareTo(nextSourceKey) >= 0) {
moveToNextBatch(context);
}
// next, add the scanned row (as long as we've reached the first batch)
if (targetHasher.isBatchStarted()) {
targetHasher.hashResult(value);
}
} catch (Throwable t) {
mapperException = t;
Throwables.propagateIfInstanceOf(t, IOException.class);
Throwables.propagateIfInstanceOf(t, InterruptedException.class);
Throwables.propagate(t);
}
}
示例6: compactKeyValues
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void compactKeyValues() throws IOException {
try {
compact();
}catch(RocksDBException ex) {
Throwables.propagateIfInstanceOf(ex, IOException.class);
throw new IOException(ex);
}
}
示例7: checkedGet
import com.google.common.base.Throwables; //導入方法依賴的package包/類
private StoreWithId checkedGet(StoreBuilderConfig key) throws DatastoreException {
try{
return stores.get(key);
} catch (ExecutionException ex){
Throwables.propagateIfInstanceOf(ex.getCause(), DatastoreException.class);
throw new DatastoreException(ex);
}
}
示例8: getTables
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types) throws SQLException {
throwIfClosed();
try {
return super.getTables(catalog, schemaPattern,tableNamePattern, types);
} catch(SQLExecutionError e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例9: getSchemas
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public ResultSet getSchemas() throws SQLException {
throwIfClosed();
try {
return super.getSchemas();
} catch(SQLExecutionError e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例10: getCatalogs
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public ResultSet getCatalogs() throws SQLException {
throwIfClosed();
try {
return super.getCatalogs();
} catch(SQLExecutionError e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例11: getColumns
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public ResultSet getColumns(String catalog, String schema, String table,
String columnNamePattern) throws SQLException {
try {
throwIfClosed();
return super.getColumns(catalog, schema, table, columnNamePattern);
} catch(SQLExecutionError e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例12: prepareAndExecuteInternal
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
protected ExecuteResult prepareAndExecuteInternal(AvaticaStatement statement, String sql, long maxRowCount)
throws SQLException, NoSuchStatementException {
try {
return super.prepareAndExecuteInternal(statement, sql, maxRowCount);
} catch(RuntimeException e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例13: process
import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public Status process() throws EventDeliveryException {
long processedEvents = 0;
try {
if (shouldRoll()) {
closeWriter();
commitTransaction();
createWriter();
}
// The writer shouldn't be null at this point
Preconditions.checkNotNull(writer,
"Can't process events with a null writer. This is likely a bug.");
Channel channel = getChannel();
// Enter the transaction boundary if we haven't already
enterTransaction(channel);
for (; processedEvents < batchSize; processedEvents += 1) {
Event event = channel.take();
if (event == null) {
// no events available in the channel
break;
}
write(event);
}
// commit transaction
if (commitOnBatch) {
// Flush/sync before commiting. A failure here will result in rolling back
// the transaction
if (syncOnBatch && writer instanceof Syncable) {
((Syncable) writer).sync();
} else if (writer instanceof Flushable) {
((Flushable) writer).flush();
}
boolean committed = commitTransaction();
Preconditions.checkState(committed,
"Tried to commit a batch when there was no transaction");
committedBatch |= committed;
}
} catch (Throwable th) {
// catch-all for any unhandled Throwable so that the transaction is
// correctly rolled back.
rollbackTransaction();
if (commitOnBatch && committedBatch) {
try {
closeWriter();
} catch (EventDeliveryException ex) {
LOG.warn("Error closing writer there may be temp files that need to"
+ " be manually recovered: " + ex.getLocalizedMessage());
LOG.debug("Exception follows.", ex);
}
} else {
this.writer = null;
}
// handle the exception
Throwables.propagateIfInstanceOf(th, Error.class);
Throwables.propagateIfInstanceOf(th, EventDeliveryException.class);
throw new EventDeliveryException(th);
}
if (processedEvents == 0) {
counter.incrementBatchEmptyCount();
return Status.BACKOFF;
} else if (processedEvents < batchSize) {
counter.incrementBatchUnderflowCount();
} else {
counter.incrementBatchCompleteCount();
}
counter.addToEventDrainSuccessCount(processedEvents);
return Status.READY;
}