jersey.repackaged.com.google.common.collect.ImmutableMap Java Examples

The following examples show how to use jersey.repackaged.com.google.common.collect.ImmutableMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 6 votes vote down vote up
@DELETE
@Path("/keep/last/{numPartitions}")
public APIResponse<Map<String, Integer>> keepLastN(
    @PathParam("numPartitions") Integer numPartitions, @Context UriInfo info) {
  long startTs = System.currentTimeMillis();
  int numDeletedPartitions = cube.deleteCube(numPartitions);
  int numOptimizedPartitions = cube.optimize();
  long t0 = System.currentTimeMillis();
  System.gc();
  log.debug("GC took {}ms", System.currentTimeMillis() - t0);
  return new APIResponse<>(
      ImmutableMap.of(
          "numDeletedPartitions", numDeletedPartitions,
          "numOptimizedPartitions", numOptimizedPartitions,
          "gcTimeMs", (int) (System.currentTimeMillis() - t0)),
      info,
      startTs);
}
 
Example #2
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 6 votes vote down vote up
@DELETE
@Path("/{cubeName}")
public APIResponse<Map<String, Integer>> deleteCube(
    @PathParam("cubeName") String cubeName, @Context UriInfo info) {
  if (!cube.hasCube(cubeName)) {
    log.warn("Could not find cube {}", cubeName);
    throw new NotFoundException(String.format("Could not find cube %s", cubeName));
  }

  long startTs = System.currentTimeMillis();
  int numDeletedPartitions = cube.deleteCube(cubeName, 0);
  int numOptimizedPartitions = cube.optimize();
  long t0 = System.currentTimeMillis();
  System.gc();
  log.debug("GC took {}ms", System.currentTimeMillis() - t0);
  return new APIResponse<>(
      ImmutableMap.of(
          "numDeletedPartitions", numDeletedPartitions,
          "numOptimizedPartitions", numOptimizedPartitions,
          "gcTimeMs", (int) (System.currentTimeMillis() - t0)),
      info,
      startTs);
}
 
Example #3
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 6 votes vote down vote up
@DELETE
@Path("/all/from/{fromPartition}/to/{toPartition}")
public APIResponse<Map<String, Integer>> deletePartitions(
    @PathParam("fromPartition") String fromPartition,
    @PathParam("toPartition") String toPartition,
    @Context UriInfo info) {
  long startTs = System.currentTimeMillis();
  int numDeletedPartitions = cube.deleteCube(fromPartition, toPartition);
  int numOptimizedPartitions = cube.optimize();
  long t0 = System.currentTimeMillis();
  System.gc();
  log.debug("GC took {}ms", System.currentTimeMillis() - t0);
  return new APIResponse<>(
      ImmutableMap.of(
          "numDeletedPartitions", numDeletedPartitions,
          "numOptimizedPartitions", numOptimizedPartitions,
          "gcTimeMs", (int) (System.currentTimeMillis() - t0)),
      info,
      startTs);
}
 
Example #4
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 6 votes vote down vote up
@DELETE
@Path("/{cubeName}/from/{fromPartition}/to/{toPartition}")
public APIResponse<Map<String, Integer>> deletePartitionsOfCube(
    @PathParam("cubeName") String cubeName,
    @PathParam("fromPartition") String fromPartition,
    @PathParam("toPartition") String toPartition,
    @Context UriInfo info) {
  if (!cube.hasCube(cubeName)) {
    log.warn("Could not find cube {}", cubeName);
    throw new NotFoundException(String.format("Could not find cube %s", cubeName));
  }

  long startTs = System.currentTimeMillis();
  int numDeletedPartitions = cube.deleteCube(cubeName, fromPartition, toPartition);
  int numOptimizedPartitions = cube.optimize();
  long t0 = System.currentTimeMillis();
  System.gc();
  log.debug("GC took {}ms", System.currentTimeMillis() - t0);
  return new APIResponse<>(
      ImmutableMap.of(
          "numDeletedPartitions", numDeletedPartitions,
          "numOptimizedPartitions", numOptimizedPartitions,
          "gcTimeMs", (int) (System.currentTimeMillis() - t0)),
      info,
      startTs);
}
 
Example #5
Source File: PersistEntityMutation.java    From timbuctoo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Object executeAction(DataFetchingEnvironment env) {
  User user = MutationHelpers.getUser(env);
  String entityUri = env.getArgument("entityUri");
  URI uri;
  try {
    uri = GetEntity.makeUrl(ownerId, dataSetName, entityUri);
  } catch (UnsupportedEncodingException e) {
    return ImmutableMap.of("message", "Request for presistent Uri failed.");
  }
  URI fullUri = uriHelper.fromResourceUri(uri);

  EntityLookup entityLookup = ImmutableEntityLookup.builder().dataSetId(dataSetId).uri(entityUri).user(user).build();
  redirectionService.add(fullUri, entityLookup);

  return ImmutableMap.of("message", "Request for presistent Uri accepted");
}
 
Example #6
Source File: TaskApiTest.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Test
public void testList() {
    int taskId = this.rebuild();

    Response r = client().get(path, ImmutableMap.of("limit", -1));
    String content = assertResponseStatus(200, r);
    List<Map<?, ?>> tasks = assertJsonContains(content, "tasks");
    assertArrayContains(tasks, "id", taskId);

    this.waitTaskSuccess(taskId);
    r = client().get(path, ImmutableMap.of("status", "RUNNING"));
    content = assertResponseStatus(200, r);
    tasks = assertJsonContains(content, "tasks");
    Assert.assertTrue(tasks.isEmpty());
}
 
Example #7
Source File: TaskApiTest.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
private int rebuild() {
    String rebuildPath = "/graphs/hugegraph/jobs/rebuild/indexlabels";
    String personByCity = "personByCity";
    Map<String, Object> params = ImmutableMap.of();
    Response r = client().put(rebuildPath, personByCity, "",  params);
    String content = assertResponseStatus(202, r);
    return assertJsonContains(content, "task_id");
}
 
Example #8
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 5 votes vote down vote up
@POST
@Path("/insert")
public APIResponse<Map<String, Integer>> insert(List<DataRow> rows, @Context UriInfo info) {
  long startTs = System.currentTimeMillis();
  cube.insert(rows);
  log.info("Inserted {} rows", rows.size());
  return new APIResponse<>(ImmutableMap.of("numInsertedRows", rows.size()), info, startTs);
}
 
Example #9
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 5 votes vote down vote up
@POST
@Path("/save")
public APIResponse<Map<String, String>> save(@Context UriInfo info) throws IOException {
  final long startTs = System.currentTimeMillis();
  log.info("Saving to {}", cube.getPath());
  cube.save(cube.getPath());
  log.info("Saving finished");
  return new APIResponse<>(ImmutableMap.of("savePath", cube.getPath()), info, startTs);
}
 
Example #10
Source File: CubeResource.java    From cubedb with GNU General Public License v3.0 5 votes vote down vote up
@POST
@Path("/saveJSON")
public APIResponse<Map<String, String>> dump(@Context UriInfo info) throws IOException {
  final long startTs = System.currentTimeMillis();
  String path = cube.getPath() + "/json";
  log.info("Saving to {}", path);
  cube.saveAsJson(path);
  log.info("Saving finished");
  return new APIResponse<>(ImmutableMap.of("savePath", path), info, startTs);
}
 
Example #11
Source File: VisNode.java    From hugegraph-studio with Apache License 2.0 4 votes vote down vote up
public VisNode(NodeColorOption colorOption) {
    this(ImmutableMap.of(), colorOption);
}
 
Example #12
Source File: Predicate.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
public Map<String, Long> getReferenceTypes() {
  return ImmutableMap.copyOf(referenceTypes);
}
 
Example #13
Source File: Predicate.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
public Map<String, Long> getValueTypes() {
  return ImmutableMap.copyOf(valueTypes);
}