public static StringBuilder getAuthString(List<ByteBuffer> authorizations) { StringBuilder auths = new StringBuilder(); for (ByteBuffer bb : authorizations) { auths.append(ByteBufferUtil.toString(bb)).append(","); } return auths; }
@Override public void splitTablet(TInfo tinfo, TCredentials credentials, TKeyExtent tkeyExtent, ByteBuffer splitPoint) throws NotServingTabletException, ThriftSecurityException { Table.ID tableId = Table.ID.of(new String(ByteBufferUtil.toBytes(tkeyExtent.table))); Namespace.ID namespaceId = getNamespaceId(credentials, tableId); if (!security.canSplitTablet(credentials, tableId, namespaceId)) throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); KeyExtent keyExtent = new KeyExtent(tkeyExtent); Tablet tablet = onlineTablets.get(keyExtent); if (tablet == null) { throw new NotServingTabletException(tkeyExtent); } if (keyExtent.getEndRow() == null || !keyExtent.getEndRow().equals(ByteBufferUtil.toText(splitPoint))) { try { if (TabletServer.this.splitTablet(tablet, ByteBufferUtil.toBytes(splitPoint)) == null) { throw new NotServingTabletException(tkeyExtent); } } catch (IOException e) { log.warn("Failed to split " + keyExtent, e); throw new RuntimeException(e); } } }
/** * Creates a new mutation from a Thrift mutation. * * @param tmutation * Thrift mutation */ public Mutation(TMutation tmutation) { this.row = ByteBufferUtil.toBytes(tmutation.row); this.data = ByteBufferUtil.toBytes(tmutation.data); this.entries = tmutation.entries; this.values = ByteBufferUtil.toBytesList(tmutation.values); if (tmutation.isSetSources()) { this.replicationSources = new HashSet<>(tmutation.sources); } if (this.row == null) { throw new IllegalArgumentException("null row"); } if (this.data == null) { throw new IllegalArgumentException("null serialized data"); } }
TableOperation tableOp = TableOperation.CREATE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); TimeType timeType = TimeType.valueOf(ByteBufferUtil.toString(arguments.get(1))); InitialTableState initialTableState = InitialTableState .valueOf(ByteBufferUtil.toString(arguments.get(2))); int splitCount = Integer.parseInt(ByteBufferUtil.toString(arguments.get(3))); String splitFile = null; String splitDirsFile = null; TableOperation tableOp = TableOperation.MERGE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, null); Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); TableOperation tableOp = TableOperation.DELETE_RANGE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_METADATA); Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); TableOperation tableOp = TableOperation.BULK_IMPORT; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); String dir = ByteBufferUtil.toString(arguments.get(1)); String failDir = ByteBufferUtil.toString(arguments.get(2)); boolean setTime = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(3))); TableOperation tableOp = TableOperation.COMPACT; Table.ID tableId = validateTableIdArgument(arguments.get(0), tableOp, null); byte[] startRow = ByteBufferUtil.toBytes(arguments.get(1)); byte[] endRow = ByteBufferUtil.toBytes(arguments.get(2));
@Override public void write(DataOutput out) throws IOException { if (impl != null) { ThriftMessageUtil msgUtil = new ThriftMessageUtil(); ByteBuffer serialized = msgUtil.serialize(impl); out.writeInt(serialized.limit()); ByteBufferUtil.write(out, serialized); } else { out.writeInt(0); } }
try { for (ByteBuffer edit : data.getEdits()) { DataInputStream dis = new DataInputStream(ByteBufferUtil.toByteArrayInputStream(edit)); try { key.readFields(dis);
String tableName = ByteBufferUtil.toString(arguments.get(0)); if (!security.canCreateTable(c, tableName)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); org.apache.accumulo.core.client.admin.TimeType timeType = org.apache.accumulo.core.client.admin.TimeType.valueOf(ByteBufferUtil.toString(arguments .get(1))); String oldTableName = ByteBufferUtil.toString(arguments.get(0)); String newTableName = ByteBufferUtil.toString(arguments.get(1)); String srcTableId = ByteBufferUtil.toString(arguments.get(0)); String tableName = ByteBufferUtil.toString(arguments.get(1)); String tableName = ByteBufferUtil.toString(arguments.get(0)); final String tableId = checkTableId(tableName, TableOperation.DELETE); checkNotMetadataTable(tableName, TableOperation.DELETE); String tableName = ByteBufferUtil.toString(arguments.get(0)); final String tableId = checkTableId(tableName, TableOperation.ONLINE); checkNotMetadataTable(tableName, TableOperation.ONLINE); String tableName = ByteBufferUtil.toString(arguments.get(0)); final String tableId = checkTableId(tableName, TableOperation.OFFLINE); checkNotMetadataTable(tableName, TableOperation.OFFLINE); String tableName = ByteBufferUtil.toString(arguments.get(0)); Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); final String tableId = checkTableId(tableName, TableOperation.MERGE);
public Gatherer(ClientContext context, TSummaryRequest request, AccumuloConfiguration tableConfig, CryptoService cryptoService) { this.ctx = context; this.tableId = Table.ID.of(request.tableId); this.startRow = ByteBufferUtil.toText(request.bounds.startRow); this.endRow = ByteBufferUtil.toText(request.bounds.endRow); this.clipRange = new Range(startRow, false, endRow, true); this.summaries = request.getSummarizers().stream().map(SummarizerConfigurationUtil::fromThrift) .collect(Collectors.toSet()); this.request = request; this.cryptoService = cryptoService; this.summarizerPattern = request.getSummarizerPattern(); if (summarizerPattern != null) { Pattern pattern = Pattern.compile(summarizerPattern); // The way conf is converted to string below is documented in the API, so consider this when // making changes! summarySelector = conf -> pattern .matcher(conf.getClassName() + " " + new TreeMap<>(conf.getOptions())).matches(); if (!summaries.isEmpty()) { summarySelector = summarySelector.or(conf -> summaries.contains(conf)); } } else if (!summaries.isEmpty()) { summarySelector = conf -> summaries.contains(conf); } else { summarySelector = conf -> true; } this.factory = new SummarizerFactory(tableConfig); }
/** * Creates a new mutation from a Thrift mutation. * * @param tmutation * Thrift mutation */ public Mutation(TMutation tmutation) { this.row = ByteBufferUtil.toBytes(tmutation.row); this.data = ByteBufferUtil.toBytes(tmutation.data); this.entries = tmutation.entries; this.values = ByteBufferUtil.toBytesList(tmutation.values); if (tmutation.isSetSources()) { this.replicationSources = new HashSet<>(tmutation.sources); } if (this.row == null) { throw new IllegalArgumentException("null row"); } if (this.data == null) { throw new IllegalArgumentException("null serialized data"); } }
@Override public void write(DataOutput out) throws IOException { if (authKey == null) { WritableUtils.writeVInt(out, 0); return; } ThriftMessageUtil util = new ThriftMessageUtil(); ByteBuffer serialized = util.serialize(authKey); WritableUtils.writeVInt(out, serialized.limit() - serialized.arrayOffset()); ByteBufferUtil.write(out, serialized); }
try { for (ByteBuffer edit : data.getEdits()) { DataInputStream dis = new DataInputStream(ByteBufferUtil.toByteArrayInputStream(edit)); try { key.readFields(dis);
/** * Creates a Value using the bytes in a buffer as the initial value. Makes a defensive copy. * * @param bytes * May not be null */ public Value(ByteBuffer bytes) { /* TODO ACCUMULO-2509 right now this uses the entire backing array, which must be accessible. */ this(toBytes(bytes), false); }
TableOperation tableOp = TableOperation.CREATE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); TimeType timeType = TimeType.valueOf(ByteBufferUtil.toString(arguments.get(1))); TableOperation tableOp = TableOperation.MERGE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, null); Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); TableOperation tableOp = TableOperation.DELETE_RANGE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_METADATA); Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); TableOperation tableOp = TableOperation.BULK_IMPORT; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); String dir = ByteBufferUtil.toString(arguments.get(1)); String failDir = ByteBufferUtil.toString(arguments.get(2)); boolean setTime = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(3))); TableOperation tableOp = TableOperation.COMPACT; String tableId = validateTableIdArgument(arguments.get(0), tableOp, null); byte[] startRow = ByteBufferUtil.toBytes(arguments.get(1)); byte[] endRow = ByteBufferUtil.toBytes(arguments.get(2)); List<IteratorSetting> iterators = IteratorUtil .decodeIteratorSettings(ByteBufferUtil.toBytes(arguments.get(3))); CompactionStrategyConfig compactionStrategy = CompactionStrategyConfigUtil .decode(ByteBufferUtil.toBytes(arguments.get(4))); String namespaceId = getNamespaceIdFromTableId(tableOp, tableId);
master.security.canFlush(c, tableId, namespaceId); Text startRow = ByteBufferUtil.toText(startRowBB); Text endRow = ByteBufferUtil.toText(endRowBB); final TServerConnection server = master.tserverSet.getConnection(instance); if (server != null) server.flush(master.masterLock, tableId, ByteBufferUtil.toBytes(startRowBB), ByteBufferUtil.toBytes(endRowBB)); } catch (TException ex) { Master.log.error(ex.toString());
public static Table.ID toTableId(ByteBuffer bytes) { return Table.ID.of(toString(bytes)); }
@Override public void write(DataOutput out) throws IOException { if (null != impl) { ThriftMessageUtil msgUtil = new ThriftMessageUtil(); ByteBuffer serialized = msgUtil.serialize(impl); out.writeInt(serialized.limit()); ByteBufferUtil.write(out, serialized); } else { out.writeInt(0); } }
/** * Constructs a token from a copy of the password. Destroying the argument after construction will * not destroy the copy in this token, and destroying this token will only destroy the copy held * inside this token, not the argument. */ public PasswordToken(ByteBuffer password) { this.password = ByteBufferUtil.toBytes(password); }