當前位置: 首頁>>代碼示例>>Java>>正文


Java Throwables.getStackTraceAsString方法代碼示例

本文整理匯總了Java中com.google.common.base.Throwables.getStackTraceAsString方法的典型用法代碼示例。如果您正苦於以下問題:Java Throwables.getStackTraceAsString方法的具體用法?Java Throwables.getStackTraceAsString怎麽用?Java Throwables.getStackTraceAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Throwables的用法示例。


在下文中一共展示了Throwables.getStackTraceAsString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteAllRowTs

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void deleteAllRowTs(
    ByteBuffer tableName, ByteBuffer row, long timestamp,
    Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
  Table table = null;
  try {
    table = getTable(tableName);
    Delete delete  = new Delete(getBytes(row), timestamp);
    addAttributes(delete, attributes);
    table.delete(delete);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally {
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:18,代碼來源:ThriftServerRunner.java

示例2: scannerGetList

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public List<TRowResult> scannerGetList(int id,int nbRows)
    throws IllegalArgument, IOError {
  LOG.debug("scannerGetList: id=" + id);
  ResultScannerWrapper resultScannerWrapper = getScanner(id);
  if (null == resultScannerWrapper) {
    String message = "scanner ID is invalid";
    LOG.warn(message);
    throw new IllegalArgument("scanner ID is invalid");
  }

  Result [] results = null;
  try {
    results = resultScannerWrapper.getScanner().next(nbRows);
    if (null == results) {
      return new ArrayList<TRowResult>();
    }
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
  return ThriftUtilities.rowResultFromHBase(results, resultScannerWrapper.isColumnSorted());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:ThriftServerRunner.java

示例3: increment

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void increment(TIncrement tincrement) throws IOError, TException {

  if (tincrement.getRow().length == 0 || tincrement.getTable().length == 0) {
    throw new TException("Must supply a table and a row key; can't increment");
  }

  if (conf.getBoolean(COALESCE_INC_KEY, false)) {
    this.coalescer.queueIncrement(tincrement);
    return;
  }

  Table table = null;
  try {
    table = getTable(tincrement.getTable());
    Increment inc = ThriftUtilities.incrementFromThrift(tincrement);
    table.increment(inc);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally{
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:25,代碼來源:ThriftServerRunner.java

示例4: getVer

import com.google.common.base.Throwables; //導入方法依賴的package包/類
/**
 * Note: this public interface is slightly different from public Java APIs in regard to
 * handling of the qualifier. Here we differ from the public Java API in that null != byte[0].
 * Rather, we respect qual == null as a request for the entire column family. If you want to
 * access the entire column family, use
 * {@link #getVer(ByteBuffer, ByteBuffer, ByteBuffer, int, Map)} with a {@code column} value
 * that lacks a {@code ':'}.
 */
public List<TCell> getVer(ByteBuffer tableName, ByteBuffer row, byte[] family,
    byte[] qualifier, int numVersions, Map<ByteBuffer, ByteBuffer> attributes) throws IOError {

  Table table = null;
  try {
    table = getTable(tableName);
    Get get = new Get(getBytes(row));
    addAttributes(get, attributes);
    if (null == qualifier) {
      get.addFamily(family);
    } else {
      get.addColumn(family, qualifier);
    }
    get.setMaxVersions(numVersions);
    Result result = table.get(get);
    return ThriftUtilities.cellFromHBase(result.rawCells());
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally{
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:ThriftServerRunner.java

示例5: deleteTable

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void deleteTable(ByteBuffer in_tableName) throws IOError {
  TableName tableName = getTableName(in_tableName);
  if (LOG.isDebugEnabled()) {
    LOG.debug("deleteTable: table=" + tableName);
  }
  try {
    if (!getAdmin().tableExists(tableName)) {
      throw new IOException("table does not exist");
    }
    getAdmin().deleteTable(tableName);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:ThriftServerRunner.java

示例6: toString

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public String toString() {
	try {
		return baos.toString(Charsets.UTF_8.name());
	} catch (UnsupportedEncodingException e) {
		return Throwables.getStackTraceAsString(e);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:9,代碼來源:OutputStreamPrinterThread.java

示例7: runTest

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
	SampleResult sampleResult = new SampleResult();
	long sampleStart = 0;
	long sampleEnd = 0;

	try {
		assertNotInterrupted();
		executing = true;
		setup();
		setSampleLabel(sampleResult);
		execute();
		assertSuccess();
		sampleResult.setSuccessful(true);
		sampleStart = martiniResult.getStartTimestamp();
		sampleEnd = martiniResult.getEndTimestamp();
		setResponse(sampleResult);
	}
	catch (Exception e) {
		super.getNewLogger().warn("unable to execute Martini", e);
		sampleResult.setSuccessful(false);
		String message = Throwables.getStackTraceAsString(e);
		sampleResult.setResponseMessage(message);
	}
	finally {
		sampleResult.setStampAndTime(sampleStart, sampleEnd);
		teardown();
		executing = false;
	}
	return sampleResult;
}
 
開發者ID:qas-guru,項目名稱:martini-jmeter-extension,代碼行數:32,代碼來源:MartiniSamplerClient.java

示例8: getRegionInfo

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    byte[] row = getBytes(searchRow);
    Result startRowResult =
        getRowOrBefore(TableName.META_TABLE_NAME.getName(), row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:ThriftServerRunner.java

示例9: scannerOpen

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public int scannerOpen(ByteBuffer tableName, ByteBuffer startRow,
    List<ByteBuffer> columns,
    Map<ByteBuffer, ByteBuffer> attributes) throws IOError {

  Table table = null;
  try {
    table = getTable(tableName);
    Scan scan = new Scan(getBytes(startRow));
    addAttributes(scan, attributes);
    if(columns != null && columns.size() != 0) {
      for(ByteBuffer column : columns) {
        byte [][] famQf = KeyValue.parseColumn(getBytes(column));
        if(famQf.length == 1) {
          scan.addFamily(famQf[0]);
        } else {
          scan.addColumn(famQf[0], famQf[1]);
        }
      }
    }
    return addScanner(table.getScanner(scan), false);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally{
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:ThriftServerRunner.java

示例10: testTransactionWithShardLeaderNotResponding

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Test
public void testTransactionWithShardLeaderNotResponding() throws Exception {
    followerDatastoreContextBuilder.frontendRequestTimeoutInSeconds(2);
    followerDatastoreContextBuilder.shardElectionTimeoutFactor(50);
    initDatastoresWithCars("testTransactionWithShardLeaderNotResponding");

    // Do an initial read to get the primary shard info cached.

    final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();
    readTx.read(CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);

    // Shutdown the leader and try to create a new tx.

    JavaTestKit.shutdownActorSystem(leaderSystem, null, true);

    followerDatastoreContextBuilder.operationTimeoutInMillis(50).shardElectionTimeoutFactor(1);
    sendDatastoreContextUpdate(followerDistributedDataStore, followerDatastoreContextBuilder);

    final DOMStoreReadWriteTransaction rwTx = followerDistributedDataStore.newReadWriteTransaction();

    rwTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());

    try {
        followerTestKit.doCommit(rwTx.ready());
        fail("Exception expected");
    } catch (final ExecutionException e) {
        final String msg = "Unexpected exception: " + Throwables.getStackTraceAsString(e.getCause());
        if (DistributedDataStore.class.equals(testParameter)) {
            assertTrue(msg, Throwables.getRootCause(e) instanceof NoShardLeaderException
                    || e.getCause() instanceof ShardLeaderNotRespondingException);
        } else {
            assertTrue(msg, Throwables.getRootCause(e) instanceof RequestTimeoutException);
        }
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:36,代碼來源:DistributedDataStoreRemotingIntegrationTest.java

示例11: enableTable

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void enableTable(ByteBuffer tableName) throws IOError {
  try{
    getAdmin().enableTable(getTableName(tableName));
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:ThriftServerRunner.java

示例12: disableTable

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void disableTable(ByteBuffer tableName) throws IOError{
  try{
    getAdmin().disableTable(getTableName(tableName));
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:ThriftServerRunner.java

示例13: scannerOpenTs

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public int scannerOpenTs(ByteBuffer tableName, ByteBuffer startRow,
    List<ByteBuffer> columns, long timestamp,
    Map<ByteBuffer, ByteBuffer> attributes) throws IOError, TException {

  Table table = null;
  try {
    table = getTable(tableName);
    Scan scan = new Scan(getBytes(startRow));
    addAttributes(scan, attributes);
    scan.setTimeRange(0, timestamp);
    if (columns != null && columns.size() != 0) {
      for (ByteBuffer column : columns) {
        byte [][] famQf = KeyValue.parseColumn(getBytes(column));
        if(famQf.length == 1) {
          scan.addFamily(famQf[0]);
        } else {
          scan.addColumn(famQf[0], famQf[1]);
        }
      }
    }
    return addScanner(table.getScanner(scan), false);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally{
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:30,代碼來源:ThriftServerRunner.java

示例14: compact

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void compact(ByteBuffer tableNameOrRegionName) throws IOError {
  try {
    // TODO: HBaseAdmin.compact(byte[]) deprecated and not trivial to replace here.
    // ThriftServerRunner.compact should be deprecated and replaced with methods specific to
    // table and region.
    ((HBaseAdmin) getAdmin()).compact(getBytes(tableNameOrRegionName));
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:ThriftServerRunner.java

示例15: scannerOpenWithStopTs

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public int scannerOpenWithStopTs(ByteBuffer tableName, ByteBuffer startRow,
    ByteBuffer stopRow, List<ByteBuffer> columns, long timestamp,
    Map<ByteBuffer, ByteBuffer> attributes)
    throws IOError, TException {

  Table table = null;
  try {
    table = getTable(tableName);
    Scan scan = new Scan(getBytes(startRow), getBytes(stopRow));
    addAttributes(scan, attributes);
    scan.setTimeRange(0, timestamp);
    if (columns != null && columns.size() != 0) {
      for (ByteBuffer column : columns) {
        byte [][] famQf = KeyValue.parseColumn(getBytes(column));
        if(famQf.length == 1) {
          scan.addFamily(famQf[0]);
        } else {
          scan.addColumn(famQf[0], famQf[1]);
        }
      }
    }
    scan.setTimeRange(0, timestamp);
    return addScanner(table.getScanner(scan), false);
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  } finally{
    closeTable(table);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:ThriftServerRunner.java


注:本文中的com.google.common.base.Throwables.getStackTraceAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。