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


Java RowError類代碼示例

本文整理匯總了Java中org.apache.kudu.client.RowError的典型用法代碼示例。如果您正苦於以下問題:Java RowError類的具體用法?Java RowError怎麽用?Java RowError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: applyRandomMutations

import org.apache.kudu.client.RowError; //導入依賴的package包/類
@Override
public void applyRandomMutations(List<PlannedRow> planned) throws Exception {
  KuduTable table = connectToTable();

  List<Operation> operations = extractOperations(planned, table);

  for (Operation operation : operations) {
    session.apply(operation);
  }

  // Wait until all operations have completed before checking for errors.
  while (session.hasPendingOperations()) {
    Thread.sleep(1);
  }

  // Fail fast on any error applying mutations
  if (session.countPendingErrors() > 0) {
    RowError firstError = session.getPendingErrors().getRowErrors()[0];
    String errorMessage = String.format("Kudu output error '%s' during operation '%s' at tablet server '%s'",
        firstError.getErrorStatus(), firstError.getOperation(), firstError.getTsUUID());

    throw new RuntimeException(errorMessage);
  }
}
 
開發者ID:cloudera-labs,項目名稱:envelope,代碼行數:25,代碼來源:KuduOutput.java

示例2: stop

import org.apache.kudu.client.RowError; //導入依賴的package包/類
@Override
public void stop() throws Exception {
  batch.close();
  RowErrorsAndOverflowStatus batchErrors = batch.getPendingErrors();
  for (RowError rowError : batchErrors.getRowErrors()) {
    LOG.error("failed to write datapoint: {}", rowError.getErrorStatus());
  }
}
 
開發者ID:danburkert,項目名稱:kudu-ts,代碼行數:9,代碼來源:PutResource.java

示例3: put

import org.apache.kudu.client.RowError; //導入依賴的package包/類
@POST
@Timed
public Response put(@QueryParam("summary") @DefaultValue("false") BooleanFlag summary,
                    @QueryParam("details") @DefaultValue("false") BooleanFlag details,
                    @QueryParam("sync") @DefaultValue("false") BooleanFlag sync,
                    @QueryParam("sync_timeout") @DefaultValue("120000") IntParam sync_timeout,
                    JsonNode body) throws Exception {
  LOG.trace("put; summary: {}, details: {}, sync: {}, sync_timeout: {}, body: {}",
            summary, details, sync, sync_timeout, body);

  WriteBatch batch = ts.writeBatch();
  try {
    batch.setFlushMode(SessionConfiguration.FlushMode.AUTO_FLUSH_BACKGROUND);
    if (sync_timeout.get() > 0) batch.setTimeoutMillis(sync_timeout.get());

    int datapoints = 0;
    List<Error> errors = new ArrayList<>();
    Iterator<JsonNode> nodes;
    if (body.isArray()) {
      nodes = body.elements();
    } else {
      nodes = Iterators.singletonIterator(body);
    }

    while (nodes.hasNext()) {
      datapoints++;
      JsonNode node = nodes.next();
      try {
        Datapoint datapoint = mapper.treeToValue(node, Datapoint.class);
        batch.writeDatapoint(datapoint.getMetric(),
                             datapoint.getTags(),
                             datapoint.getTimestamp(),
                             datapoint.getValue());
      } catch (JsonProcessingException e) {
        errors.add(new Error(node, e.getMessage()));
      }
    }

    batch.flush();
    RowErrorsAndOverflowStatus batchErrors = batch.getPendingErrors();
    for (RowError rowError : batchErrors.getRowErrors()) {
      errors.add(new Error(null, rowError.getErrorStatus().toString()
       + " (op " + rowError.getOperation().toString() + ")"));
    }

    if (errors.isEmpty()) {
      LOG.debug("put {} datapoints: {}", datapoints, body);
      return Response.noContent().build();
    } else {
      LOG.error("failed to write {} of {} body: {}", errors.size(), datapoints, errors);
      if (details.get()) {
        Detail detail = new Detail(errors, errors.size(), datapoints - errors.size());
        return Response.status(Response.Status.BAD_REQUEST).entity(detail).build();
      } else if (summary.get()) {
        Summary s = new Summary(errors.size(), datapoints - errors.size());
        return Response.status(Response.Status.BAD_REQUEST).entity(s).build();
      } else {
        return Response.status(Response.Status.BAD_REQUEST).build();
      }
    }

  } finally {
    batch.close();
  }
}
 
開發者ID:danburkert,項目名稱:kudu-ts,代碼行數:66,代碼來源:PutResource.java

示例4: nonSyncPut

import org.apache.kudu.client.RowError; //導入依賴的package包/類
public Response nonSyncPut(boolean summary,
                           boolean details,
                           Iterator<JsonNode> datapointNodes) throws Exception {

  RowErrorsAndOverflowStatus batchErrors = batch.getPendingErrors();
  for (RowError rowError : batchErrors.getRowErrors()) {
    LOG.error("failed to write datapoint: {}", rowError.getErrorStatus());
  }

  List<Error> errors = new ArrayList<>();
  int datapoints = 0;
  while (datapointNodes.hasNext()) {
    datapoints++;
    JsonNode node = datapointNodes.next();
    try {
      Datapoint datapoint = mapper.treeToValue(node, Datapoint.class);
      batch.writeDatapoint(datapoint.getMetric(),
                           datapoint.getTags(),
                           datapoint.getTimestamp(),
                           datapoint.getValue());
    } catch (JsonProcessingException e) {
      errors.add(new Error(node, e.getMessage()));
    }
  }

  if (errors.isEmpty()) {
    LOG.debug("put {} datapoints: {}", datapoints, datapointNodes);
    return Response.noContent().build();
  } else {
    LOG.error("failed to write {} of {} body: {}", errors.size(), datapoints, errors);
    if (details) {
      Detail detail = new Detail(errors, errors.size(), datapoints - errors.size());
      return Response.status(Response.Status.BAD_REQUEST).entity(detail).build();
    } else if (summary) {
      Summary s = new Summary(errors.size(), datapoints - errors.size());
      return Response.status(Response.Status.BAD_REQUEST).entity(s).build();
    } else {
      return Response.status(Response.Status.BAD_REQUEST).build();
    }
  }
}
 
開發者ID:danburkert,項目名稱:kudu-ts,代碼行數:42,代碼來源:PutResource.java

示例5: syncPut

import org.apache.kudu.client.RowError; //導入依賴的package包/類
public Response syncPut(boolean summary,
                        boolean details,
                        int timeout,
                        JsonNode datapointNodes) throws Exception {
  WriteBatch batch = ts.writeBatch();
  if (timeout > 0) batch.setTimeoutMillis(timeout);

  int datapoints = 0;
  List<Error> errors = new ArrayList<>();
  Iterator<JsonNode> nodes;
  if (datapointNodes.isArray()) {
    nodes = datapointNodes.elements();
  } else {
    nodes = Iterators.singletonIterator(datapointNodes);
  }

  while (nodes.hasNext()) {
    datapoints++;
    JsonNode node = nodes.next();
    try {
      Datapoint datapoint = mapper.treeToValue(node, Datapoint.class);
      batch.writeDatapoint(datapoint.getMetric(),
                           datapoint.getTags(),
                           datapoint.getTimestamp(),
                           datapoint.getValue());
    } catch (JsonProcessingException e) {
      errors.add(new Error(node, e.getMessage()));
    }
  }

  batch.flush();
  RowErrorsAndOverflowStatus batchErrors = batch.getPendingErrors();
  for (RowError rowError : batchErrors.getRowErrors()) {
    errors.add(new Error(null, rowError.getErrorStatus().toString()));
  }

  if (errors.isEmpty()) {
    LOG.debug("put {} datapoints: {}", datapoints, datapointNodes);
    return Response.noContent().build();
  } else {
    LOG.error("failed to write {} of {} body: {}", errors.size(), datapoints, errors);
    if (details) {
      Detail detail = new Detail(errors, errors.size(), datapoints - errors.size());
      return Response.status(Response.Status.BAD_REQUEST).entity(detail).build();
    } else if (summary) {
      Summary s = new Summary(errors.size(), datapoints - errors.size());
      return Response.status(Response.Status.BAD_REQUEST).entity(s).build();
    } else {
      return Response.status(Response.Status.BAD_REQUEST).build();
    }
  }
}
 
開發者ID:danburkert,項目名稱:kudu-ts,代碼行數:53,代碼來源:PutResource.java


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