private static void assertKeyValuePair(Entry<Key, Value> e, byte[] row, String cf, String cq, String value) { assertEquals(row, e.getKey().getRow().copyBytes()); assertEquals(cf, e.getKey().getColumnFamily().toString()); assertEquals(cq, e.getKey().getColumnQualifier().toString()); assertEquals(value, e.getValue().toString()); }
private static void assertKeyValuePair(Entry<Key, Value> e, byte[] row, String cf, String cq, String cv, String value) { assertEquals(row, e.getKey().getRow().copyBytes()); assertEquals(cf, e.getKey().getColumnFamily().toString()); assertEquals(cq, e.getKey().getColumnQualifier().toString()); assertEquals(cv, e.getKey().getColumnVisibility().toString()); assertEquals(value, e.getValue().toString()); }
private long getNumRowsInTable(String metricsTable, Authorizations auths) throws TableNotFoundException { // Create scanner against the metrics table, pulling the special column and the rows column Scanner scanner = connector.createScanner(metricsTable, auths); scanner.setRange(METRICS_TABLE_ROWID_RANGE); scanner.fetchColumn(METRICS_TABLE_ROWS_CF_AS_TEXT, CARDINALITY_CQ_AS_TEXT); // Scan the entry and get the number of rows long numRows = -1; for (Entry<Key, Value> entry : scanner) { if (numRows > 0) { throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Should have received only one entry when scanning for number of rows in metrics table"); } numRows = Long.parseLong(entry.getValue().toString()); } scanner.close(); LOG.debug("Number of rows in table is %d", numRows); return numRows; }
private Optional<String> getDefaultTabletLocation(String fulltable) { try { String tableId = connector.tableOperations().tableIdMap().get(fulltable); // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username)); scan.fetchColumnFamily(new Text("loc")); scan.setRange(new Range(tableId + '<')); // scan the entry Optional<String> location = Optional.empty(); for (Entry<Key, Value> entry : scan) { if (location.isPresent()) { throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry"); } location = Optional.of(entry.getValue().toString()); } scan.close(); return location; } catch (Exception e) { // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet. // This is purely an optimization, but we will want to log the error. LOG.error("Failed to get tablet location, returning dummy location", e); return Optional.empty(); } }
rangeValues.put(rangeToKey.get(Range.exact(entry.getKey().getRow())), parseLong(entry.getValue().toString()));
public static LogEntry fromKeyValue(Key key, Value value) { return fromKeyValue(key, value.toString()); }
public static SuspendingTServer fromValue(Value value) { String valStr = value.toString(); String[] parts = valStr.split("[|]", 2); return new SuspendingTServer(HostAndPort.fromString(parts[0]), Long.parseLong(parts[1])); }
@Override protected void aggregateStats(Entry<Key,Value> entry) { if (entry.getKey().getColumnFamily().toString().equals("~tab") && entry.getKey().getColumnQualifier().toString().equals("loc")) { // The row for the sharded table should look like: <tableId>;yyyyMMhh_N String row = entry.getKey().getRow().toString(); // Parse the day out of the row int semicolon = row.indexOf(";"); String day = null; if (semicolon != -1) { semicolon++; day = row.substring(semicolon, semicolon + 8); } else day = "NULL "; String server = entry.getValue().toString(); if (countsByDay.get(day) == null) countsByDay.put(day, new HashSet<>()); countsByDay.get(day).add(server); } }
@Override public boolean accept(Key k, Value v) { if (!k.isDeleted() && k.compareColumnFamily(TabletsSection.BulkFileColumnFamily.NAME) == 0) { long txid = Long.parseLong(v.toString()); Status status = bulkTxStatusCache.get(txid); if (status == null) { try { if (arbitrator.transactionComplete(Constants.BULK_ARBITRATOR_TYPE, txid)) { status = Status.INACTIVE; } else { status = Status.ACTIVE; } } catch (Exception e) { status = Status.ACTIVE; log.error("{}", e.getMessage(), e); } bulkTxStatusCache.put(txid, status); } return status == Status.ACTIVE; } return true; }
public static Map<Long,? extends Collection<FileRef>> getBulkFilesLoaded(ServerContext context, KeyExtent extent) { Text metadataRow = extent.getMetadataEntry(); Map<Long,List<FileRef>> result = new HashMap<>(); VolumeManager fs = context.getVolumeManager(); try (Scanner scanner = new ScannerImpl(context, extent.isMeta() ? RootTable.ID : MetadataTable.ID, Authorizations.EMPTY)) { scanner.setRange(new Range(metadataRow)); scanner.fetchColumnFamily(TabletsSection.BulkFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Long tid = Long.parseLong(entry.getValue().toString()); List<FileRef> lst = result.get(tid); if (lst == null) { result.put(tid, lst = new ArrayList<>()); } lst.add(new FileRef(fs, entry.getKey())); } } return result; }
public static List<FileRef> getBulkFilesLoaded(ServerContext context, AccumuloClient client, KeyExtent extent, long tid) { List<FileRef> result = new ArrayList<>(); try (Scanner mscanner = new IsolatedScanner(client.createScanner( extent.isMeta() ? RootTable.NAME : MetadataTable.NAME, Authorizations.EMPTY))) { VolumeManager fs = context.getVolumeManager(); mscanner.setRange(extent.toMetadataRange()); mscanner.fetchColumnFamily(TabletsSection.BulkFileColumnFamily.NAME); for (Entry<Key,Value> entry : mscanner) { if (Long.parseLong(entry.getValue().toString()) == tid) { result.add(new FileRef(fs, entry.getKey())); } } return result; } catch (TableNotFoundException ex) { // unlikely throw new RuntimeException("Onos! teh metadata table has vanished!!"); } }
throw new IllegalStateException("Tablet has multiple locations : " + lastRowFromKey); location = new Text(val.toString()); session = new Text(colq); } else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) {
time = value.toString(); dataFiles.put(ref, new DataFileValue(entry.getValue().get())); } else if (DIRECTORY_COLUMN.hasColumns(key)) { directory = value.toString(); } else if (family.equals(LogColumnFamily.NAME)) { logEntries.add(LogEntry.fromKeyValue(key, entry.getValue())); scanFiles.add(new FileRef(fs, key)); } else if (FLUSH_COLUMN.hasColumns(key)) { flushID = Long.parseLong(value.toString()); } else if (COMPACT_COLUMN.hasColumns(key)) { compactID = Long.parseLong(entry.getValue().toString()); } else if (family.equals(LastLocationColumnFamily.NAME)) { lastLocation = new TServerInstance(value, key.getColumnQualifier()); } else if (family.equals(BulkFileColumnFamily.NAME)) { Long id = Long.decode(value.toString()); List<FileRef> lst = bulkImported.get(id); if (lst == null) {
Key key = entry.getKey(); if (key.compareColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) { String location = entry.getValue().toString(); String[] parts = location.split(":"); String host = parts[0];
while (iter.hasNext()) { Entry<Key,Value> entry = iter.next(); TServerInstance alive = master.tserverSet.find(entry.getValue().toString()); if (alive == null) { Master.log.info("Removing entry {}", entry);
} else if (MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN .hasColumns(entry.getKey())) { volumes.add(getTableURI(entry.getValue().toString()));
location = null; } else if (colf.equals(TabletsSection.CurrentLocationColumnFamily.NAME)) { location = entry.getValue().toString();
String[] split = entry.getValue().toString().split("\\|")[0].split(";"); walogs.add(Arrays.asList(split)); } else if (cf.compareTo(TabletsSection.LastLocationColumnFamily.NAME) == 0) {
bw.addMutation(createDeleteMutation(context, tableId, cell.getValue().toString()));