private void get(ChannelHandlerContext ctx, FullHttpRequest req) { Params params = parse(req); conn.getTable(TableName.valueOf(params.table)).get(new Get(Bytes.toBytes(params.row)) .addColumn(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier))) .whenComplete((r, e) -> { if (e != null) { exceptionCaught(ctx, e); } else { byte[] value = r.getValue(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier)); if (value != null) { write(ctx, HttpResponseStatus.OK, Optional.of(Bytes.toStringBinary(value))); } else { write(ctx, HttpResponseStatus.NOT_FOUND, Optional.empty()); } } }); }
private void put(ChannelHandlerContext ctx, FullHttpRequest req) { Params params = parse(req); byte[] value = new byte[req.content().readableBytes()]; req.content().readBytes(value); conn.getTable(TableName.valueOf(params.table)).put(new Put(Bytes.toBytes(params.row)) .addColumn(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier), value)) .whenComplete((r, e) -> { if (e != null) { exceptionCaught(ctx, e); } else { write(ctx, HttpResponseStatus.OK, Optional.empty()); } }); }
private void get(ChannelHandlerContext ctx, FullHttpRequest req) { Params params = parse(req); conn.getTable(TableName.valueOf(params.table)).get(new Get(Bytes.toBytes(params.row)) .addColumn(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier))) .whenComplete((r, e) -> { if (e != null) { exceptionCaught(ctx, e); } else { byte[] value = r.getValue(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier)); if (value != null) { write(ctx, HttpResponseStatus.OK, Optional.of(Bytes.toStringBinary(value))); } else { write(ctx, HttpResponseStatus.NOT_FOUND, Optional.empty()); } } }); }
private void put(ChannelHandlerContext ctx, FullHttpRequest req) { Params params = parse(req); byte[] value = new byte[req.content().readableBytes()]; req.content().readBytes(value); conn.getTable(TableName.valueOf(params.table)).put(new Put(Bytes.toBytes(params.row)) .addColumn(Bytes.toBytes(params.family), Bytes.toBytes(params.qualifier), value)) .whenComplete((r, e) -> { if (e != null) { exceptionCaught(ctx, e); } else { write(ctx, HttpResponseStatus.OK, Optional.empty()); } }); }