String location = entry.getValue().stream().filter(tm -> tm.getLocation() != null) // filter .map(tm -> tm.getLocation().getHostAndPort().toString()) // convert to host:port strings
@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); }
@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); } }
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); } }; }
while (tablet.getLocation() != null) { if (Tables.getTableState(context, tableId) != TableState.OFFLINE) { Tables.clearCache(context);
tabletsToWaitFor++; if (tablet.hasCurrent()) { serversToFlush.increment(new TServerInstance(tablet.getLocation()), 1);
tabletsToWaitFor++; if (tablet.hasCurrent()) serversToFlush.add(new TServerInstance(tablet.getLocation()));
total++; Location loc = tablet.getLocation();