public static Message getRequest(Service service, Descriptors.MethodDescriptor methodDesc, org.apache.hbase.thirdparty.com.google.protobuf.ByteString shadedRequest) throws IOException { Message.Builder builderForType = service.getRequestPrototype(methodDesc).newBuilderForType(); org.apache.hadoop.hbase.protobuf.ProtobufUtil.mergeFrom(builderForType, // TODO: COPY FROM SHADED TO NON_SHADED. DO I HAVE TOO? shadedRequest.toByteArray()); return builderForType.build(); }
@Override public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { TableList.Builder builder = TableList.newBuilder(); ProtobufUtil.mergeFrom(builder, message); for (String table: builder.getNameList()) { this.add(new TableModel(table)); } return this; } }
@Override public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { Cell.Builder builder = Cell.newBuilder(); ProtobufUtil.mergeFrom(builder, message); setColumn(builder.getColumn().toByteArray()); setValue(builder.getData().toByteArray()); if (builder.hasTimestamp()) { setTimestamp(builder.getTimestamp()); } return this; }
/** * Convert a protocol buffer CellVisibility bytes to a client CellVisibility * * @param protoBytes * @return the converted client CellVisibility * @throws DeserializationException */ private static CellVisibility toCellVisibility(byte[] protoBytes) throws DeserializationException { if (protoBytes == null) return null; ClientProtos.CellVisibility.Builder builder = ClientProtos.CellVisibility.newBuilder(); ClientProtos.CellVisibility proto = null; try { ProtobufUtil.mergeFrom(builder, protoBytes); proto = builder.build(); } catch (IOException e) { throw new DeserializationException(e); } return toCellVisibility(proto); }
/** * Reads back User auth data written to zookeeper. * @param data * @return User auth details * @throws DeserializationException */ public static MultiUserAuthorizations readUserAuthsFromZKData(byte[] data) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(data)) { int pblen = ProtobufUtil.lengthOfPBMagic(); try { MultiUserAuthorizations.Builder builder = MultiUserAuthorizations.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return builder.build(); } catch (IOException e) { throw new DeserializationException(e); } } return null; }
public static ListMultimap<String, Permission> readPermissions(byte[] data, Configuration conf) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(data)) { int pblen = ProtobufUtil.lengthOfPBMagic(); try { AccessControlProtos.UsersAndPermissions.Builder builder = AccessControlProtos.UsersAndPermissions.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return AccessControlUtil.toPermission(builder.build()); } catch (IOException e) { throw new DeserializationException(e); } } else { // TODO: We have to re-write non-PB data as PB encoded. Otherwise we will carry old Writables // forever (here and a couple of other places). ListMultimap<String, Permission> perms = ArrayListMultimap.create(); try { DataInput in = new DataInputStream(new ByteArrayInputStream(data)); int length = in.readInt(); for (int i = 0; i < length; i++) { String user = Text.readString(in); perms.putAll(user, readWritableUserPermission(in, conf)); } } catch (IOException | ClassNotFoundException e) { throw new DeserializationException(e); } return perms; } }
/** * Reads back from the zookeeper. The data read here is of the form written by * writeToZooKeeper(Map<byte[], Integer> entries). * * @param data * @return Labels and their ordinal details * @throws DeserializationException */ public static List<VisibilityLabel> readLabelsFromZKData(byte[] data) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(data)) { int pblen = ProtobufUtil.lengthOfPBMagic(); try { VisibilityLabelsRequest.Builder builder = VisibilityLabelsRequest.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return builder.getVisLabelList(); } catch (IOException e) { throw new DeserializationException(e); } } return null; }
@Override public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { TableInfo.Builder builder = TableInfo.newBuilder(); ProtobufUtil.mergeFrom(builder, message); setName(builder.getName()); for (TableInfo.Region region: builder.getRegionsList()) { add(new TableRegionModel(builder.getName(), region.getId(), region.getStartKey().toByteArray(), region.getEndKey().toByteArray(), region.getLocation())); } return this; } }
@Override public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { CellSet.Builder builder = CellSet.newBuilder(); ProtobufUtil.mergeFrom(builder, message); for (CellSet.Row row: builder.getRowsList()) { RowModel rowModel = new RowModel(row.getKey().toByteArray()); for (Cell cell: row.getValuesList()) { long timestamp = HConstants.LATEST_TIMESTAMP; if (cell.hasTimestamp()) { timestamp = cell.getTimestamp(); } rowModel.addCell( new CellModel(cell.getColumn().toByteArray(), timestamp, cell.getData().toByteArray())); } addRow(rowModel); } return this; } }
AccessControlProtos.UsersAndPermissions.Builder builder = AccessControlProtos.UsersAndPermissions.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return AccessControlUtil.toUserPermission(builder.build()); } catch (IOException e) {
org.apache.hadoop.hbase.protobuf.ProtobufUtil.mergeFrom(builder, serviceResult.getValue().getValue().toByteArray()); callback.update(region, row, (R) builder.build());
AuthenticationProtos.TokenIdentifier.Builder builder = AuthenticationProtos.TokenIdentifier.newBuilder(); ProtobufUtil.mergeFrom(builder, inBytes); AuthenticationProtos.TokenIdentifier identifier = builder.build();
@Override public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { Version.Builder builder = Version.newBuilder(); ProtobufUtil.mergeFrom(builder, message); if (builder.hasRestVersion()) { restVersion = builder.getRestVersion(); } if (builder.hasJvmVersion()) { jvmVersion = builder.getJvmVersion(); } if (builder.hasOsVersion()) { osVersion = builder.getOsVersion(); } if (builder.hasServerVersion()) { serverVersion = builder.getServerVersion(); } if (builder.hasJerseyVersion()) { jerseyVersion = builder.getJerseyVersion(); } return this; } }
throws IOException { Scanner.Builder builder = Scanner.newBuilder(); ProtobufUtil.mergeFrom(builder, message); if (builder.hasStartRow()) { startRow = builder.getStartRow().toByteArray();
service.getRequestPrototype(methodDesc).newBuilderForType(); org.apache.hadoop.hbase.protobuf.ProtobufUtil.mergeFrom(builder, call.getRequest().toByteArray()); com.google.protobuf.Message request =
throws IOException { StorageClusterStatus.Builder builder = StorageClusterStatus.newBuilder(); ProtobufUtil.mergeFrom(builder, message); if (builder.hasRegions()) { regions = builder.getRegions();
throws IOException { TableSchema.Builder builder = TableSchema.newBuilder(); ProtobufUtil.mergeFrom(builder, message); this.setName(builder.getName()); for (TableSchema.Attribute attr: builder.getAttrsList()) {
public static Message getRequest(Service service, Descriptors.MethodDescriptor methodDesc, org.apache.hbase.thirdparty.com.google.protobuf.ByteString shadedRequest) throws IOException { Message.Builder builderForType = service.getRequestPrototype(methodDesc).newBuilderForType(); org.apache.hadoop.hbase.protobuf.ProtobufUtil.mergeFrom(builderForType, // TODO: COPY FROM SHADED TO NON_SHADED. DO I HAVE TOO? shadedRequest.toByteArray()); return builderForType.build(); }
/** * Convert a protocol buffer CellVisibility bytes to a client CellVisibility * * @param protoBytes * @return the converted client CellVisibility * @throws DeserializationException */ private static CellVisibility toCellVisibility(byte[] protoBytes) throws DeserializationException { if (protoBytes == null) return null; ClientProtos.CellVisibility.Builder builder = ClientProtos.CellVisibility.newBuilder(); ClientProtos.CellVisibility proto = null; try { ProtobufUtil.mergeFrom(builder, protoBytes); proto = builder.build(); } catch (IOException e) { throw new DeserializationException(e); } return toCellVisibility(proto); }