use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.
the class IteratorUtilTest method testInvalidIteratorFormats.
/**
* Iterators should not contain dots in the name. Also, if the split size on "." is greater than one, it should be 3, i.e., itername.opt.optname
*/
@Test
public void testInvalidIteratorFormats() {
Map<String, String> data = new HashMap<>();
List<IterInfo> iterators = new ArrayList<>();
Map<String, Map<String, String>> options = new HashMap<>();
AccumuloConfiguration conf;
// create iterator with 'dot' in name
try {
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar", "50," + SummingCombiner.class.getName());
conf = new ConfigurationCopy(data);
IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
} catch (IllegalArgumentException ex) {
log.debug("caught expected exception: " + ex.getMessage());
}
data.clear();
iterators.clear();
options.clear();
// second part must be 'opt'.
try {
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar.baz", "49," + SummingCombiner.class.getName());
conf = new ConfigurationCopy(data);
IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
} catch (IllegalArgumentException ex) {
log.debug("caught expected exception: " + ex.getMessage());
}
data.clear();
iterators.clear();
options.clear();
// create iterator with invalid option format
try {
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar", "48," + SummingCombiner.class.getName());
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar.opt", "fakevalue");
conf = new ConfigurationCopy(data);
IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
Assert.assertEquals(1, iterators.size());
IterInfo ii = iterators.get(0);
Assert.assertEquals(new IterInfo(48, SummingCombiner.class.getName(), "foobar"), ii);
} catch (IllegalArgumentException ex) {
log.debug("caught expected exception: " + ex.getMessage());
}
data.clear();
iterators.clear();
options.clear();
// create iterator with 'opt' in incorrect position
try {
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz", "47," + SummingCombiner.class.getName());
data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz.fake.opt", "fakevalue");
conf = new ConfigurationCopy(data);
IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
Assert.assertEquals(1, iterators.size());
IterInfo ii = iterators.get(0);
Assert.assertEquals(new IterInfo(47, SummingCombiner.class.getName(), "foobaz"), ii);
} catch (IllegalArgumentException ex) {
log.debug("caught expected exception: " + ex.getMessage());
}
}
use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.
the class VerifyTabletAssignments method checkTabletServer.
private static void checkTabletServer(ClientContext context, Entry<HostAndPort, List<KeyExtent>> entry, HashSet<KeyExtent> failures) throws ThriftSecurityException, TException, NoSuchScanIDException {
TabletClientService.Iface client = ThriftUtil.getTServerClient(entry.getKey(), context);
Map<TKeyExtent, List<TRange>> batch = new TreeMap<>();
for (KeyExtent keyExtent : entry.getValue()) {
Text row = keyExtent.getEndRow();
Text row2 = null;
if (row == null) {
row = keyExtent.getPrevEndRow();
if (row != null) {
row = new Text(row);
row.append(new byte[] { 'a' }, 0, 1);
} else {
row = new Text("1234567890");
}
row2 = new Text(row);
row2.append(new byte[] { '!' }, 0, 1);
} else {
row = new Text(row);
row2 = new Text(row);
row.getBytes()[row.getLength() - 1] = (byte) (row.getBytes()[row.getLength() - 1] - 1);
}
Range r = new Range(row, true, row2, false);
batch.put(keyExtent.toThrift(), Collections.singletonList(r.toThrift()));
}
TInfo tinfo = Tracer.traceInfo();
Map<String, Map<String, String>> emptyMapSMapSS = Collections.emptyMap();
List<IterInfo> emptyListIterInfo = Collections.emptyList();
List<TColumn> emptyListColumn = Collections.emptyList();
InitialMultiScan is = client.startMultiScan(tinfo, context.rpcCreds(), batch, emptyListColumn, emptyListIterInfo, emptyMapSMapSS, Authorizations.EMPTY.getAuthorizationsBB(), false, null, 0L, null);
if (is.result.more) {
MultiScanResult result = client.continueMultiScan(tinfo, is.scanID);
checkFailures(entry.getKey(), failures, result);
while (result.more) {
result = client.continueMultiScan(tinfo, is.scanID);
checkFailures(entry.getKey(), failures, result);
}
}
client.closeMultiScan(tinfo, is.scanID);
ThriftUtil.returnClient((TServiceClient) client);
}
use of org.apache.accumulo.core.data.thrift.IterInfo 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;
}
use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.
the class ActiveCompactionImpl method getIterators.
@Override
public List<IteratorSetting> getIterators() {
ArrayList<IteratorSetting> ret = new ArrayList<>();
for (IterInfo ii : tac.getSsiList()) {
IteratorSetting settings = new IteratorSetting(ii.getPriority(), ii.getIterName(), ii.getClassName());
Map<String, String> options = tac.getSsio().get(ii.getIterName());
settings.addOptions(options);
ret.add(settings);
}
return ret;
}
use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.
the class CompressedIterators method decompress.
public IterConfig decompress(ByteBuffer iterators) {
IterConfig config = new IterConfig();
UnsynchronizedBuffer.Reader in = new UnsynchronizedBuffer.Reader(iterators);
int num = in.readVInt();
for (int i = 0; i < num; i++) {
String name = symbolTable.get(in.readVInt());
String iterClass = symbolTable.get(in.readVInt());
int prio = in.readVInt();
config.ssiList.add(new IterInfo(prio, iterClass, name));
int numOpts = in.readVInt();
HashMap<String, String> opts = new HashMap<>();
for (int j = 0; j < numOpts; j++) {
String key = symbolTable.get(in.readVInt());
String val = symbolTable.get(in.readVInt());
opts.put(key, val);
}
config.ssio.put(name, opts);
}
return config;
}
Aggregations