@Override public TabletMetadata next() { if (sawLast) { throw new NoSuchElementException(); } TabletMetadata next = iter.next(); // impossible to construct a range that stops at the first tablet that contains endRow. That // is why this specialized code exists. if (next.getExtent().contains(endRow)) { sawLast = true; } return next; } }
static boolean goodTransition(TabletMetadata prev, TabletMetadata curr) { if (!curr.sawPrevEndRow()) { log.warn("Tablet {} had no prev end row.", curr.getExtent()); return false; } if (!curr.getTableId().equals(prev.getTableId())) { if (prev.getEndRow() != null) { log.debug("Non-null end row for last tablet in table: " + prev.getExtent() + " " + curr.getExtent()); return false; } if (curr.getPrevEndRow() != null) { log.debug("First tablet for table had prev end row {} {} ", prev.getExtent(), curr.getExtent()); return false; } } else { if (prev.getEndRow() == null) { throw new IllegalStateException("Null end row for tablet in middle of table: " + prev.getExtent() + " " + curr.getExtent()); } if (curr.getPrevEndRow() == null || !prev.getEndRow().equals(curr.getPrevEndRow())) { log.debug("Tablets end row and prev end row not equals {} {} ", prev.getExtent(), curr.getExtent()); return false; } } return true; }
.mergeOverlapping(Lists.transform(entry.getValue(), tm -> tm.getExtent().toDataRange())); List<TRowRange> ranges = merged.stream().map(r -> toClippedExtent(r).toThrift())
@Override void load(List<TabletMetadata> tablets, Files files) { for (TabletMetadata tablet : tablets) { // send files to tablet sever // ideally there should only be one tablet location to send all the files TabletMetadata.Location location = tablet.getLocation(); HostAndPort server = null; if (location == null) { locationLess++; continue; } else { server = location.getHostAndPort(); } Set<String> loadedFiles = tablet.getLoaded(); Map<String,MapFileInfo> thriftImports = new HashMap<>(); for (final Bulk.FileInfo fileInfo : files) { String fullPath = new Path(bulkDir, fileInfo.getFileName()).toString(); if (!loadedFiles.contains(fullPath)) { thriftImports.put(fileInfo.getFileName(), new MapFileInfo(fileInfo.getEstFileSize())); } } addToQueue(server, tablet.getExtent(), thriftImports); } sendQueued(4 * 1024 * 1024); }
protected Iterator<Size> getSizeIterator(AccumuloClient client, String tablename, Text start, Text end) throws MergeException { // open up metadata, walk through the tablets. Table.ID tableId; TabletsMetadata tablets; try { ClientContext context = (ClientContext) client; tableId = Tables.getTableId(context, tablename); tablets = TabletsMetadata.builder().scanMetadataTable() .overRange(new KeyExtent(tableId, end, start).toMetadataRange()).fetchFiles().fetchPrev() .build(context); } catch (Exception e) { throw new MergeException(e); } return tablets.stream().map(tm -> { long size = tm.getFilesMap().values().stream().mapToLong(DataFileValue::getSize).sum(); return new Size(tm.getExtent(), size); }).iterator(); }
if (Tables.getTableState(context, tableId) != TableState.OFFLINE) { throw new AccumuloException("Table is online " + tableId + " cannot scan tablet in offline mode " + tablet.getExtent()); if (!tablet.getExtent().getTableId().equals(tableId)) { throw new AccumuloException( " did not find tablets for table " + tableId + " " + tablet.getExtent()); if (currentExtent != null && !tablet.getExtent().isPreviousExtent(currentExtent)) throw new AccumuloException( " " + currentExtent + " is not previous extent " + tablet.getExtent()); iter = createIterator(tablet.getExtent(), absFiles); iter.seek(range, LocalityGroupUtil.families(options.fetchedColumns), options.fetchedColumns.size() != 0); currentExtent = tablet.getExtent();
protected Iterable<Pair<KeyExtent,Location>> getLocationProvider() { return () -> { try { return TabletsMetadata.builder().forTable(tableId).fetchLocation().fetchPrev() .build(context).stream().map(tm -> { Location loc = Location.NONE; if (tm.hasCurrent()) { loc = new Location(new TServerInstance(tm.getLocation())); } return new Pair<>(tm.getExtent(), loc); }).iterator(); } catch (Exception e) { throw new RuntimeException(e); } }; }
@Override void load(List<TabletMetadata> tablets, Files files) throws MutationsRejectedException { byte[] fam = TextUtil.getBytes(DataFileColumnFamily.NAME); for (TabletMetadata tablet : tablets) { if (tablet.getLocation() != null) { unloadingTablets.increment(tablet.getLocation().getHostAndPort(), 1L); continue; } Mutation mutation = new Mutation(tablet.getExtent().getMetadataEntry()); for (final Bulk.FileInfo fileInfo : files) { String fullPath = new Path(bulkDir, fileInfo.getFileName()).toString(); byte[] val = new DataFileValue(fileInfo.getEstFileSize(), fileInfo.getEstNumEntries()) .encode(); mutation.put(fam, fullPath.getBytes(UTF_8), val); } bw.addMutation(mutation); } }
|| (expectedState == TableState.OFFLINE && loc != null)) { if (continueRow == null) continueRow = tablet.getExtent().getMetadataEntry(); waitFor++; lastRow = tablet.getExtent().getMetadataEntry(); if (!tablet.getExtent().getTableId().equals(tableId)) { throw new AccumuloException( "Saw unexpected table Id " + tableId + " " + tablet.getExtent()); if (lastExtent != null && !tablet.getExtent().isPreviousExtent(lastExtent)) { holes++; lastExtent = tablet.getExtent();