本文整理匯總了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);
}
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
}