@Test public void testMultiCellGetJSON() throws IOException, JAXBException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; StringBuilder path = new StringBuilder(); path.append("/"); path.append(TABLE); path.append("/multiget/?row="); path.append(ROW_1); path.append("&row="); path.append(ROW_2); client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1)); client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2)); Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); assertEquals(response.getCode(), 200); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); client.delete(row_5_url); client.delete(row_6_url); }
@GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; RowModel rowModel = new RowModel(rk); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil .cloneQualifier(value), value.getTimestamp(), CellUtil.cloneValue(value))); } model.addRow(rowModel); } else { LOG.trace("The row : " + rk + " not found in the table."); } } if (model.getRows().size() == 0) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("No rows found." + CRLF) .build(); } else { servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } } catch (Exception e) { servlet.getMetrics().incrementFailedGetRequests(1); return processException(e); } }
MultiRowResource extends ResourceBase implements Constants { @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; RowModel rowModel = new RowModel(rk); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil .cloneQualifier(value), value.getTimestamp(), CellUtil.cloneValue(value))); } model.addRow(rowModel); } else { LOG.trace("The row : " + rk + " not found in the table."); } } if (model.getRows().size() == 0) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("No rows found." + CRLF) .build(); } else { servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } } catch (Exception e) { servlet.getMetrics().incrementFailedGetRequests(1); return processException(e); } } }
MultiRowResource extends ResourceBase implements Constants { @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; RowModel rowModel = new RowModel(rk); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil .cloneQualifier(value), value.getTimestamp(), CellUtil.cloneValue(value))); } model.addRow(rowModel); } else { LOG.trace("The row : " + rk + " not found in the table."); } } if (model.getRows().size() == 0) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("No rows found." + CRLF) .build(); } else { servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } } catch (Exception e) { servlet.getMetrics().incrementFailedGetRequests(1); return processException(e); } } MultiRowResource(TableResource tableResource, String versions); }
MultiRowResource extends ResourceBase implements Constants { @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; RowModel rowModel = new RowModel(rk); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil .cloneQualifier(value), value.getTimestamp(), CellUtil.cloneValue(value))); } model.addRow(rowModel); } else { LOG.trace("The row : " + rk + " not found in the table."); } } if (model.getRows().size() == 0) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("No rows found." + CRLF) .build(); } else { servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } } catch (Exception e) { servlet.getMetrics().incrementFailedGetRequests(1); return processException(e); } } MultiRowResource(TableResource tableResource, String versions); @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) Response get(final @Context UriInfo uriInfo); }
MultiRowResource extends ResourceBase implements Constants { @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; RowModel rowModel = new RowModel(rk); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil .cloneQualifier(value), value.getTimestamp(), CellUtil.cloneValue(value))); } model.addRow(rowModel); } else { LOG.trace("The row : " + rk + " not found in the table."); } } if (model.getRows().size() == 0) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("No rows found." + CRLF) .build(); } else { servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } } catch (Exception e) { servlet.getMetrics().incrementFailedGetRequests(1); return processException(e); } } MultiRowResource(TableResource tableResource, String versions); @GET @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF }) Response get(final @Context UriInfo uriInfo);  }