• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KuduException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.kudu.client.KuduException的典型用法代码示例。如果您正苦于以下问题:Java KuduException类的具体用法?Java KuduException怎么用?Java KuduException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KuduException类属于org.apache.kudu.client包,在下文中一共展示了KuduException类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTables

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
public Map<SchemaTableName, KuduTableHandle> getTables(KuduClient kuduClient)
    {
        Map<SchemaTableName, KuduTableHandle> tables = null;
        ImmutableMap.Builder<SchemaTableName, KuduTableHandle> tablesBuilder = ImmutableMap.builder();
//        ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> tableColumnsBuilder = ImmutableMap.builder();
        List<String> listTable = null;
        try {
            listTable = kuduClient.getTablesList().getTablesList();
        }
        catch (KuduException e) {
            e.printStackTrace();
        }

        for (String table : listTable) {
            SchemaTableName schemaTableName = new SchemaTableName(PRESTO_KUDU_SCHEMA, table);
            tablesBuilder.put(schemaTableName, new KuduTableHandle(schemaTableName));
        }

        tables = tablesBuilder.build();

        return tables;
    }
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:23,代码来源:KuduTables.java


示例2: advanceNextPosition

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Override
public boolean advanceNextPosition()
{
    try {
        if (results != null && results.hasNext()) {
            result = results.next();
            return true;
        }
        else {
            if (kuduScanner.hasMoreRows()) {
                results = kuduScanner.nextRows();
                if (results.hasNext()) {
                    result = results.next();
                    return true;
                }
            }
        }
    }
    catch (KuduException e) {
        logger.error(e, e.getMessage());
    }
    return false;
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:24,代码来源:KuduRecordCursor.java


示例3: connectToTable

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
private synchronized KuduTable connectToTable() throws KuduException {
  if (client == null) {
    LOG.info("Connecting to Kudu");

    String masterAddresses = config.getString(CONNECTION_CONFIG_NAME);

    client = new KuduClient.KuduClientBuilder(masterAddresses).build();
    session = client.newSession();
    session.setFlushMode(FlushMode.AUTO_FLUSH_BACKGROUND);
    session.setMutationBufferSpace(10000);
    session.setIgnoreAllDuplicateRows(isInsertIgnore());

    LOG.info("Connection to Kudu established");
  }

  String tableName = config.getString(TABLE_CONFIG_NAME);
  KuduTable table = getTable(tableName);

  return table;
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:21,代码来源:KuduOutput.java


示例4: testConnectionFailure

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Test
public void testConnectionFailure() throws Exception{
  // Mock connection refused
  PowerMockito.stub(
      PowerMockito.method(AsyncKuduClient.class, "getTablesList"))
      .toThrow(PowerMockito.mock(KuduException.class));

  ProcessorRunner runner = setProcessorRunner(tableName);

  try {
    List<Stage.ConfigIssue> issues = runner.runValidateConfigs();
    Assert.assertEquals(1, issues.size());
  } catch (StageException e) {
    Assert.fail("should not throw StageException");
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:TestKuduLookup.java


示例5: testTableDoesNotExistNoEL

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
/**
 * If table name template is not EL, we access Kudu and check if the table exists.
 * This test checks when Kudu's tableExists() method returns false.
 * @throws Exception
 */
@Test
public void testTableDoesNotExistNoEL() throws Exception{
  // Mock table doesn't exist in Kudu.
  PowerMockito.stub(
      PowerMockito.method(AsyncKuduClient.class, "tableExists"))
      .toThrow(PowerMockito.mock(KuduException.class));
  ProcessorRunner runner = setProcessorRunner(tableName);

  try {
    List<Stage.ConfigIssue> issues = runner.runValidateConfigs();
    Assert.assertEquals(1, issues.size());
  } catch (StageException e){
    Assert.fail();
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:21,代码来源:TestKuduLookup.java


示例6: testConnectionFailure

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Test
public void testConnectionFailure() throws Exception{
  // Mock connection refused
  PowerMockito.stub(
      PowerMockito.method(KuduClient.class, "getTablesList"))
      .toThrow(PowerMockito.mock(KuduException.class));

  TargetRunner targetRunner = setTargetRunner(tableName, KuduOperationType.INSERT, UnsupportedOperationAction.DISCARD);

  try {
    List<Stage.ConfigIssue> issues = targetRunner.runValidateConfigs();
    Assert.assertEquals(1, issues.size());
  } catch (StageException e) {
    Assert.fail("should not throw StageException");
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:TestKuduTarget.java


示例7: validateObject

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Override
public boolean validateObject(PooledObject<KuduClient> pooledKuduClient)
{
    final KuduClient kuduClient = pooledKuduClient.getObject();
    try {
        kuduClient.listTabletServers();
        return true;
    }
    catch (KuduException e) {
        return false;
    }
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:13,代码来源:KuduClientFactory.java


示例8: openTable

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
public KuduTable openTable(KuduClient client, final String name)

    {
        KuduTable kuduTable = null;
        try {
            kuduTable = client.openTable(name);
        }
        catch (KuduException e) {
            log.error(e, e.getMessage());
        }
        return kuduTable;
    }
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:13,代码来源:KuduClientManager.java


示例9: dropTable

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
public void dropTable(KuduClient kuduClient, String tableName)
{
    try {
        kuduClient.deleteTable(tableName);
    }
    catch (KuduException e) {
        log.error(e, e.getMessage());
    }
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:10,代码来源:KuduClientManager.java


示例10: close

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Override
public void close()
{
    // TODO: 18/04/2017 如果有资源申请,在这个地方需要关闭
    try {
        if (kuduScanner != null) {
            kuduScanner.close();
        }
        kuduClientManager.close(this.kuduClient);
    }
    catch (KuduException e) {
        logger.error(e, e.getMessage());
    }
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:15,代码来源:KuduRecordCursor.java


示例11: resultAsRow

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
private Row resultAsRow(RowResult result, KuduTable table) throws KuduException {
  List<Object> values = Lists.newArrayList();

  for (ColumnSchema columnSchema : table.getSchema().getColumns()) {
    String columnName = columnSchema.getName();

    if (result.isNull(columnName)) {
      values.add(null);
      continue;
    }

    switch (columnSchema.getType()) {
      case DOUBLE:
        values.add(result.getDouble(columnName));
        break;
      case FLOAT:
        values.add(result.getFloat(columnName));
        break;
      case INT32:
        values.add(result.getInt(columnName));
        break;
      case INT64:
        values.add(result.getLong(columnName));
        break;
      case STRING:
        values.add(result.getString(columnName));
        break;
      case BOOL:
        values.add(result.getBoolean(columnName));
        break;
      default:
        throw new RuntimeException("Unsupported Kudu column type: " + columnSchema.getType());
    }
  }

  Row row = new RowWithSchema(getTableSchema(table), values.toArray());

  return row;
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:40,代码来源:KuduOutput.java


示例12: getTable

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
private synchronized KuduTable getTable(String tableName) throws KuduException {
  if (tables == null) {
    tables = Maps.newHashMap();
  }

  if (tables.containsKey(tableName)) {
    return tables.get(tableName);
  }
  else {
    KuduTable table = client.openTable(tableName);
    tables.put(tableName, table);
    return table;
  }
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:15,代码来源:KuduOutput.java


示例13: getTableSchema

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
private synchronized StructType getTableSchema(KuduTable table) throws KuduException {
  if (tableSchemas == null) {
    tableSchemas = Maps.newHashMap();
  }

  if (tableSchemas.containsKey(table.getName())) {
    return tableSchemas.get(table.getName());
  }
  else {
    StructType tableSchema = schemaFor(table);
    tableSchemas.put(table.getName(), tableSchema);
    return tableSchema;
  }
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:15,代码来源:KuduOutput.java


示例14: insertTagset

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
/**
 * Attempts to insert the provided tagset and ID. Returns {@code true} if the
 * write was successful, or {@code false} if the write failed due to a tagset
 * with the same ID already existing in the table.
 *
 * @param tagset the tagset to insert
 * @param id     the ID to insert the tagset with
 * @return whether the write succeeded
 */
private Deferred<Boolean> insertTagset(final SerializedTagset tagset, final int id) throws KuduException {
  final class InsertTagsetCB implements Callback<Deferred<Boolean>, OperationResponse> {
    @Override
    public Deferred<Boolean> call(OperationResponse response) {
      if (response.hasRowError()) {
        if (response.getRowError().getErrorStatus().isAlreadyPresent()) {
          LOG.info("Attempted to insert duplicate tagset; id: {}, tagset: {}", id, tagset);
          // TODO: Consider adding a backoff with jitter before attempting
          //       the insert again (if the lookup fails).
          return Deferred.fromResult(false);
        }
        return Deferred.fromError(new RuntimeException(
            String.format("Unable to insert tagset; id: %s, tagset: %s, error: %s",
                          id, tagset, response.getRowError())));
      } else {
        return Deferred.fromResult(true);
      }
    }
    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this).toString();
    }
  }

  LOG.debug("Inserting tagset; id: {}, tags: {}", id, tagset);
  final AsyncKuduSession session = client.newSession();
  try {
    // We don't have to handle PleaseThrottleException because we are only
    // inserting a single row.
    final Insert insert = tagsetsTable.newInsert();
    insert.getRow().addInt(Tables.TAGSETS_ID_INDEX, id);
    insert.getRow().addBinary(Tables.TAGSETS_TAGSET_INDEX, tagset.getBytes());
    return session.apply(insert).addCallbackDeferring(new InsertTagsetCB());
  } finally {
    session.close();
  }
}
 
开发者ID:danburkert,项目名称:kudu-ts,代码行数:47,代码来源:Tagsets.java


示例15: createTestTable

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
public static void createTestTable(String tableName, KuduClient client) throws Exception
{
  List<String> rangeKeys = new ArrayList<>();
  rangeKeys.add("introwkey");
  List<String> hashPartitions = new ArrayList<>();
  hashPartitions.add("stringrowkey");
  hashPartitions.add("timestamprowkey");
  CreateTableOptions thisTableOptions = new CreateTableOptions()
      .setNumReplicas(1)
      .addHashPartitions(hashPartitions,HASH_BUCKETS_SIZE_FOR_ALL_HASH_COL)
      .setRangePartitionColumns(rangeKeys);
  int stepsize = Integer.MAX_VALUE / SPLIT_COUNT_FOR_INT_ROW_KEY;
  int splitBoundary = stepsize;
  Schema schema = buildSchemaForUnitTestsTable();
  for ( int i = 0; i < SPLIT_COUNT_FOR_INT_ROW_KEY; i++) {
    PartialRow splitRowBoundary = schema.newPartialRow();
    splitRowBoundary.addInt("introwkey",splitBoundary);
    thisTableOptions = thisTableOptions.addSplitRow(splitRowBoundary);
    splitBoundary += stepsize;
  }
  try {
    client.createTable(tableName, schema,thisTableOptions);
  } catch (KuduException e) {
    LOG.error("Error while creating table for unit tests " + e.getMessage(), e);
    throw e;
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:29,代码来源:KuduClientTestCommons.java


示例16: KuduTarget

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
public KuduTarget(KuduConfigBean configBean) {
  this.configBean = configBean;
  this.kuduMaster = Strings.nullToEmpty(configBean.kuduMaster).trim();
  this.tableNameTemplate = Strings.nullToEmpty(configBean.tableNameTemplate).trim();
  this.fieldMappingConfigs = configBean.fieldMappingConfigs == null
      ? Collections.<KuduFieldMappingConfig>emptyList()
      : configBean.fieldMappingConfigs;
  this.defaultOperation = configBean.defaultOperation;

  CacheBuilder cacheBuilder = CacheBuilder.newBuilder()
      .maximumSize(tableCacheSize)
      .expireAfterAccess(1, TimeUnit.HOURS);

  if(LOG.isDebugEnabled()) {
    cacheBuilder.recordStats();
  }

  kuduTables = cacheBuilder.build(new CacheLoader<String, KuduTable>() {
        @Override
        public KuduTable load(String tableName) throws KuduException {
          return kuduClient.openTable(tableName);
        }
      });

  cacheCleaner = new CacheCleaner(kuduTables, "KuduTarget", 10 * 60 * 1000);

  recordConverters = cacheBuilder.build(new CacheLoader<KuduTable, KuduRecordConverter>() {
    @Override
    public KuduRecordConverter load(KuduTable table) throws KuduException {
      return createKuduRecordConverter(table);
    }
  });
  recordBuilderCacheCleaner = new CacheCleaner(recordConverters, "KuduTarget KuduRecordConverter", 10 * 60 * 1000);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:35,代码来源:KuduTarget.java


示例17: testCheckConnection

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
@Test
public void testCheckConnection() throws Exception{
  PowerMockito.stub(
      PowerMockito.method(AsyncKuduClient.class, "getTablesList"))
      .toThrow(PowerMockito.mock(KuduException.class));

  List<Stage.ConfigIssue> issues = new ArrayList<>();
  Context context = getContext();
  KuduUtils.checkConnection(client, context, KUDU_MASTER, issues);
  Assert.assertEquals(1, issues.size());
  Stage.ConfigIssue issue = issues.get(0);
  Assert.assertTrue(issues.get(0).toString().contains(Errors.KUDU_00.name()));
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:14,代码来源:TestKuduUtils.java


示例18: testTableDoesNotExistWithEL

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
/**
 * When tableNameTemplate contains EL, it checks if the table exists in Kudu
 * for every single records. This test checks error records when the table
 * does not exist in Kudu.
 * @throws Exception
 */
@Test
public void testTableDoesNotExistWithEL() throws Exception{
  // Mock KuduClient.openTable() to throw KuduException
  PowerMockito.stub(PowerMockito.method(KuduClient.class, "openTable")).toThrow(PowerMockito.mock(KuduException.class));

  TargetRunner targetRunner = setTargetRunner(
      "${record:attribute('tableName')}",
      KuduOperationType.INSERT,
      UnsupportedOperationAction.DISCARD
  );

  Record record =  RecordCreator.create();
  LinkedHashMap<String, Field> field = new LinkedHashMap<>();
  field.put("key", Field.create(1));
  record.set(Field.createListMap(field));
  record.getHeader().setAttribute("tableName", "do_not_exist");
  targetRunner.runInit();

  try {
    targetRunner.runWrite(Collections.singletonList(record));
    Assert.assertEquals(1, targetRunner.getErrorRecords().size());
  } catch (StageException e){
    Assert.fail();
  }
  targetRunner.runDestroy();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:33,代码来源:TestKuduTarget.java


示例19: insertTagset

import org.apache.kudu.client.KuduException; //导入依赖的package包/类
/**
 * Insert a tagset into the {@code tags} table.
 * @param id the tagset ID.
 * @param tagset the tagset.
 * @return The tagset ID.
 */
public Deferred<Integer> insertTagset(final int id, final SortedMap<String, String> tagset)
    throws KuduException {
  if (tagset.isEmpty()) { return Deferred.fromResult(id); }
  LOG.debug("Inserting tags; tagsetID: {}, tags: {}", id, tagset);
  final AsyncKuduSession session = client.newSession();

  class InsertTagsetCB implements Callback<Deferred<Integer>, List<OperationResponse>> {
    @Override
    public Deferred<Integer> call(List<OperationResponse> responses) {
      try {
        for (OperationResponse response : responses) {
          if (response.hasRowError()) {
            return Deferred.fromError(new RuntimeException(
                String.format("Unable to insert tag: %s", response.getRowError())));
          }
        }
        return Deferred.fromResult(id);
      } finally {
        session.close();
      }
    }
    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this)
                        .add("id", id)
                        .add("tags", tagset)
                        .toString();
    }
  }

  if (tagset.size() > 1000) {
    session.setMutationBufferSpace(tagset.size());
  }
  session.setMutationBufferLowWatermark(1.0f);

  // buffer all of the tags into the session, and ensure that we don't get
  // a PleaseThrottleException. In practice the number of tags should be
  // small.
  session.setMutationBufferSpace(tagset.size());
  session.setMutationBufferLowWatermark(1.0f);
  session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
  for (Map.Entry<String, String> tag : tagset.entrySet()) {
    Insert insert = table.newInsert();
    // TODO: check with JD that if the inserts below fail, the error will
    // also be returned in the flush call.
    insert.getRow().addString(Tables.TAGS_KEY_INDEX, tag.getKey());
    insert.getRow().addString(Tables.TAGS_VALUE_INDEX, tag.getValue());
    insert.getRow().addInt(Tables.TAGS_TAGSET_ID_INDEX, id);
    session.apply(insert);
  }
  return session.flush().addCallbackDeferring(new InsertTagsetCB());
}
 
开发者ID:danburkert,项目名称:kudu-ts,代码行数:59,代码来源:Tags.java



注:本文中的org.apache.kudu.client.KuduException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OperationMetrics类代码示例发布时间:2022-05-22
下一篇:
Java DependencyCollectionContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap