当前位置: 首页>>代码示例>>Java>>正文


Java KuduException类代码示例

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


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


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