public OfflineScanner(ClientContext context, Table.ID tableId, Authorizations authorizations) { checkArgument(context != null, "context is null"); checkArgument(tableId != null, "tableId is null"); checkArgument(authorizations != null, "authorizations is null"); this.context = context; this.tableId = new Text(tableId.getUtf8()); this.range = new Range((Key) null, (Key) null); this.authorizations = authorizations; this.batchSize = Constants.SCAN_BATCH_SIZE; }
@Override public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException { checkArgument(srcTableName != null, "srcTableName is null"); checkArgument(newTableName != null, "newTableName is null"); Table.ID srcTableId = Tables.getTableId(context, srcTableName); if (flush) _flush(srcTableId, null, null, true); if (propertiesToExclude == null) propertiesToExclude = Collections.emptySet(); if (propertiesToSet == null) propertiesToSet = Collections.emptyMap(); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(srcTableId.getUtf8()), ByteBuffer.wrap(newTableName.getBytes(UTF_8))); Map<String,String> opts = new HashMap<>(); for (Entry<String,String> entry : propertiesToSet.entrySet()) { if (entry.getKey().startsWith(CLONE_EXCLUDE_PREFIX)) throw new IllegalArgumentException("Property can not start with " + CLONE_EXCLUDE_PREFIX); opts.put(entry.getKey(), entry.getValue()); } for (String prop : propertiesToExclude) { opts.put(CLONE_EXCLUDE_PREFIX + prop, ""); } doTableFateOperation(newTableName, AccumuloException.class, FateOperation.TABLE_CLONE, args, opts); }
@Override public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException { Table.ID tableId = Tables.getTableId(context, tableName); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_CANCEL_COMPACT, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } }
entry.getValue(), row); Mutation orderMutation = OrderSection.createMutation(row.toString(), entry.getValue()); orderMutation.putDelete(OrderSection.NAME, new Text(entry.getKey().getUtf8())); mutations.add(orderMutation);
private void lookupTabletLocation(ClientContext context, Text row, boolean retry, LockCheckerSession lcSession) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { Text metadataRow = new Text(tableId.getUtf8()); metadataRow.append(new byte[] {';'}, 0, 1); metadataRow.append(row.getBytes(), 0, row.getLength());
_flush(tableId, start, end, true); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY : TextUtil.getByteBuffer(end),
AccumuloClient client = master.getContext(); final Text tableId = new Text(getTableId(master.getContext(), tableName).getUtf8());
@Override public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); /** * ACCUMULO-4574 if table is already online return without executing fate operation. */ TableState expectedState = Tables.getTableState(context, tableId, true); if (expectedState == TableState.ONLINE) { if (wait) waitForTableStateTransition(tableId, TableState.ONLINE); return; } List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_ONLINE, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } if (wait) waitForTableStateTransition(tableId, TableState.ONLINE); }
/** * Create a status record in the replication table */ protected boolean addStatusRecord(Text file, Table.ID tableId, Value v) { try { Mutation m = new Mutation(file); m.put(StatusSection.NAME, new Text(tableId.getUtf8()), v); try { replicationWriter.addMutation(m); } catch (MutationsRejectedException e) { log.warn("Failed to write work mutations for replication, will retry", e); return false; } } finally { try { replicationWriter.flush(); } catch (MutationsRejectedException e) { log.warn("Failed to write work mutations for replication, will retry", e); return false; } } return true; }
@Override public void load() throws TableNotFoundException, IOException, AccumuloException, AccumuloSecurityException { Table.ID tableId = Tables.getTableId(context, tableName); Map<String,String> props = context.instanceOperations().getSystemConfiguration(); AccumuloConfiguration conf = new ConfigurationCopy(props); FileSystem fs = VolumeConfiguration.getVolume(dir, context.getHadoopConf(), conf) .getFileSystem(); Path srcPath = checkPath(fs, dir); SortedMap<KeyExtent,Bulk.Files> mappings; if (plan == null) { mappings = computeMappingFromFiles(fs, tableId, srcPath); } else { mappings = computeMappingFromPlan(fs, tableId, srcPath); } BulkSerialize.writeLoadMapping(mappings, srcPath.toString(), fs::create); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8()), ByteBuffer.wrap(srcPath.toString().getBytes(UTF_8)), ByteBuffer.wrap((setTime + "").getBytes(UTF_8))); new TableOperationsImpl(context).doBulkFateOperation(args, tableName); }
@Override public void write(DataOutput out) throws IOException { new Text(getTableId().getUtf8()).write(out); if (getEndRow() != null) { out.writeBoolean(true); getEndRow().write(out); } else { out.writeBoolean(false); } if (getPrevEndRow() != null) { out.writeBoolean(true); getPrevEndRow().write(out); } else { out.writeBoolean(false); } }
@Override public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_OFFLINE, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } if (wait) waitForTableStateTransition(tableId, TableState.OFFLINE); }
/** * Add a column update to the given mutation with the provided tableId and value * * @param m * Mutation for OrderSection * @param tableId * Source table id * @param v * Serialized Status msg * @return The original Mutation */ public static Mutation add(Mutation m, Table.ID tableId, Value v) { m.put(NAME, new Text(tableId.getUtf8()), v); return m; }
@Override public Text getTableId() { return new Text(ke.getTableId().getUtf8()); }
public TKeyExtent toThrift() { return new TKeyExtent(ByteBuffer.wrap(tableId.getUtf8()), textEndRow == null ? null : TextUtil.getByteBuffer(textEndRow), textPrevEndRow == null ? null : TextUtil.getByteBuffer(textPrevEndRow)); }
public static Text getRow(Table.ID tableId, Text endRow) { Text entry = new Text(tableId.getUtf8()); if (endRow == null) { // append delimiter for default tablet entry.append(new byte[] {'<'}, 0, 1); } else { // append delimiter for regular tablets entry.append(new byte[] {';'}, 0, 1); entry.append(endRow.getBytes(), 0, endRow.getLength()); } return entry; }
public static Mutation add(Mutation m, Table.ID tableId, Value v) { m.put(NAME, new Text(tableId.getUtf8()), v); return m; } }
public TabletLocatorImpl(Table.ID tableId, TabletLocator parent, TabletLocationObtainer tlo, TabletServerLockChecker tslc) { this.tableId = tableId; this.parent = parent; this.locationObtainer = tlo; this.lockChecker = tslc; this.lastTabletRow = new Text(tableId.getUtf8()); lastTabletRow.append(new byte[] {'<'}, 0, 1); }
public static byte[] tableOfMetadataRow(Text row) { KeyExtent ke = new KeyExtent(); ke.decodeMetadataRow(row); return ke.getTableId().getUtf8(); }
private static Mutation createUpdateMutation(Text row, Value v, KeyExtent extent) { Mutation m = new Mutation(row); m.put(MetadataSchema.ReplicationSection.COLF, new Text(extent.getTableId().getUtf8()), v); return m; } }