Search in sources :

Example 1 with AccumuloServerException

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);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) Text(org.apache.hadoop.io.Text) AccumuloServerException(org.apache.accumulo.core.client.impl.AccumuloServerException) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 2 with AccumuloServerException

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();
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) TreeMap(java.util.TreeMap) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) AccumuloServerException(org.apache.accumulo.core.client.impl.AccumuloServerException) Value(org.apache.accumulo.core.data.Value) ArrayList(java.util.ArrayList) List(java.util.List) ScannerOptions(org.apache.accumulo.core.client.impl.ScannerOptions) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) ResultReceiver(org.apache.accumulo.core.client.impl.TabletServerBatchReaderIterator.ResultReceiver)

Example 3 with AccumuloServerException

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) {
    }
}
Also used : AccumuloServerException(org.apache.accumulo.core.client.impl.AccumuloServerException) Connector(org.apache.accumulo.core.client.Connector) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) Text(org.apache.hadoop.io.Text) BatchWriter(org.apache.accumulo.core.client.BatchWriter) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Test(org.junit.Test)

Example 4 with AccumuloServerException

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;
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) ArrayList(java.util.ArrayList) Range(org.apache.accumulo.core.data.Range) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) AccumuloServerException(org.apache.accumulo.core.client.impl.AccumuloServerException) OpTimer(org.apache.accumulo.core.util.OpTimer) Value(org.apache.accumulo.core.data.Value) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Aggregations

AccumuloServerException (org.apache.accumulo.core.client.impl.AccumuloServerException)4 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 BatchWriter (org.apache.accumulo.core.client.BatchWriter)2 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)2 Connector (org.apache.accumulo.core.client.Connector)2 PartialKey (org.apache.accumulo.core.data.PartialKey)2 Text (org.apache.hadoop.io.Text)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeSet (java.util.TreeSet)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 Scanner (org.apache.accumulo.core.client.Scanner)1 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)1