use of org.apache.accumulo.core.client.impl.AccumuloServerException in project accumulo by apache.
the class LargeSplitRowIT method userAddedSplit.
// User added split
@Test(timeout = 60 * 1000)
public void userAddedSplit() throws Exception {
log.info("User added split");
// make a table and lower the TABLE_END_ROW_MAX_SIZE property
final String tableName = getUniqueNames(1)[0];
final Connector conn = getConnector();
conn.tableOperations().create(tableName);
conn.tableOperations().setProperty(tableName, Property.TABLE_MAX_END_ROW_SIZE.getKey(), "1000");
// Create a BatchWriter and add a mutation to the table
BatchWriter batchWriter = conn.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation("Row");
m.put("cf", "cq", "value");
batchWriter.addMutation(m);
batchWriter.close();
// Create a split point that is too large to be an end row and fill it with all 'm'
SortedSet<Text> partitionKeys = new TreeSet<>();
byte[] data = new byte[(int) (ConfigurationTypeHelper.getFixedMemoryAsBytes(Property.TABLE_MAX_END_ROW_SIZE.getDefaultValue()) + 2)];
for (int i = 0; i < data.length; i++) {
data[i] = 'm';
}
partitionKeys.add(new Text(data));
// try to add the split point that is too large, if the split point is created the test fails.
try {
conn.tableOperations().addSplits(tableName, partitionKeys);
Assert.fail();
} catch (AccumuloServerException e) {
}
// Make sure that the information that was written to the table before we tried to add the split point is still correct
int counter = 0;
try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
for (Entry<Key, Value> entry : scanner) {
counter++;
Key k = entry.getKey();
Assert.assertEquals("Row", k.getRow().toString());
Assert.assertEquals("cf", k.getColumnFamily().toString());
Assert.assertEquals("cq", k.getColumnQualifier().toString());
Assert.assertEquals("value", entry.getValue().toString());
}
}
// Make sure there is only one line in the table
Assert.assertEquals(1, counter);
}
use of org.apache.accumulo.core.client.impl.AccumuloServerException in project accumulo by apache.
the class MetadataLocationObtainer method lookupTablets.
@Override
public List<TabletLocation> lookupTablets(ClientContext context, String tserver, Map<KeyExtent, List<Range>> tabletsRanges, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
final TreeMap<Key, Value> results = new TreeMap<>();
ResultReceiver rr = new ResultReceiver() {
@Override
public void receive(List<Entry<Key, Value>> entries) {
for (Entry<Key, Value> entry : entries) {
try {
results.putAll(WholeRowIterator.decodeRow(entry.getKey(), entry.getValue()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
};
ScannerOptions opts = null;
try (SettableScannerOptions unsetOpts = new SettableScannerOptions()) {
opts = unsetOpts.setColumns(locCols);
}
Map<KeyExtent, List<Range>> unscanned = new HashMap<>();
Map<KeyExtent, List<Range>> failures = new HashMap<>();
try {
TabletServerBatchReaderIterator.doLookup(context, tserver, tabletsRanges, failures, unscanned, rr, columns, opts, Authorizations.EMPTY);
if (failures.size() > 0) {
// invalidate extents in parents cache
if (log.isTraceEnabled())
log.trace("lookupTablets failed for {} extents", failures.size());
parent.invalidateCache(failures.keySet());
}
} catch (IOException e) {
log.trace("lookupTablets failed server={}", tserver, e);
parent.invalidateCache(context.getInstance(), tserver);
} catch (AccumuloServerException e) {
log.trace("lookupTablets failed server={}", tserver, e);
throw e;
}
return MetadataLocationObtainer.getMetadataLocationEntries(results).getLocations();
}
use of org.apache.accumulo.core.client.impl.AccumuloServerException in project accumulo by apache.
the class SummaryIT method testBuggySummarizer.
@Test
public void testBuggySummarizer() throws Exception {
final String table = getUniqueNames(1)[0];
Connector c = getConnector();
NewTableConfiguration ntc = new NewTableConfiguration();
SummarizerConfiguration sc1 = SummarizerConfiguration.builder(BuggySummarizer.class).build();
ntc.enableSummarization(sc1);
c.tableOperations().create(table, ntc);
// add a single split so that summary stats merge is forced
c.tableOperations().addSplits(table, new TreeSet<>(Collections.singleton(new Text("g"))));
try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
write(bw, "bar1", "f1", "q1", "v1");
write(bw, "bar2", "f1", "q1", "v2");
write(bw, "foo1", "f1", "q1", "v3");
}
c.tableOperations().flush(table, null, null, true);
try {
c.tableOperations().summaries(table).retrieve();
Assert.fail("Expected server side failure and did not see it");
} catch (AccumuloServerException ase) {
}
}
use of org.apache.accumulo.core.client.impl.AccumuloServerException in project accumulo by apache.
the class MetadataLocationObtainer method lookupTablet.
@Override
public TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
try {
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up in {} row={} extent={} tserver={}", Thread.currentThread().getId(), src.tablet_extent.getTableId(), TextUtil.truncate(row), src.tablet_extent, src.tablet_location);
timer = new OpTimer().start();
}
Range range = new Range(row, true, stopRow, true);
TreeMap<Key, Value> encodedResults = new TreeMap<>();
TreeMap<Key, Value> results = new TreeMap<>();
// Use the whole row iterator so that a partial mutations is not read. The code that extracts locations for tablets does a sanity check to ensure there is
// only one location. Reading a partial mutation could make it appear there are multiple locations when there are not.
List<IterInfo> serverSideIteratorList = new ArrayList<>();
serverSideIteratorList.add(new IterInfo(10000, WholeRowIterator.class.getName(), "WRI"));
Map<String, Map<String, String>> serverSideIteratorOptions = Collections.emptyMap();
boolean more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, false, 0L, null);
decodeRows(encodedResults, results);
if (more && results.size() == 1) {
range = new Range(results.lastKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME), true, new Key(stopRow).followingKey(PartialKey.ROW), false);
encodedResults.clear();
more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, false, 0L, null);
decodeRows(encodedResults, results);
}
if (timer != null) {
timer.stop();
log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(), results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
return MetadataLocationObtainer.getMetadataLocationEntries(results);
} catch (AccumuloServerException ase) {
if (log.isTraceEnabled())
log.trace("{} lookup failed, {} server side exception", src.tablet_extent.getTableId(), src.tablet_location);
throw ase;
} catch (NotServingTabletException e) {
if (log.isTraceEnabled())
log.trace("{} lookup failed, {} not serving {}", src.tablet_extent.getTableId(), src.tablet_location, src.tablet_extent);
parent.invalidateCache(src.tablet_extent);
} catch (AccumuloException e) {
if (log.isTraceEnabled())
log.trace("{} lookup failed", src.tablet_extent.getTableId(), e);
parent.invalidateCache(context.getInstance(), src.tablet_location);
}
return null;
}
Aggregations