Esempio n. 1
0
  @Override
  public Response debug(Debug debug) throws TException {
    Set<Byte> partitions;
    if (debug.getType() == DebugCommands.POPULATE_FILE.getId()) {
      partitions = oracle.partitionsOf("/");
    } else {
      partitions = new HashSet<>();
      partitions.add(Byte.valueOf(Byte.parseByte(debug.getData().get("partition"))));
    }

    Command cmd = newCommand(CommandType.DEBUG, partitions, null);
    cmd.setDebug(debug);
    replica.submitCommand(cmd);
    Response r = new Response(replica.getInstanceMap());
    return r;
  }
Esempio n. 2
0
  @Override
  public Response rename(String from, String to, Map<Byte, Long> instanceMap) throws TException {
    from = makePathAbsolute(from);
    to = makePathAbsolute(to);
    Set<Byte> fromParts = oracle.partitionsOf(from);
    Set<Byte> fromParentParts = oracle.partitionsOf(Paths.dirname(from));
    Set<Byte> toParts = oracle.partitionsOf(to);
    Set<Byte> toParentParts = oracle.partitionsOf(Paths.dirname(to));
    Set<Byte> involvedPartitions = new HashSet<>();
    involvedPartitions.addAll(fromParts);
    involvedPartitions.addAll(fromParentParts);
    involvedPartitions.addAll(toParts);
    involvedPartitions.addAll(toParentParts);

    Command cmd = newCommand(CommandType.RENAME, involvedPartitions, instanceMap);
    RenameCmd rename = new RenameCmd(from, to, fromParentParts, fromParts, toParentParts, toParts);
    cmd.setRename(rename);
    replica.submitCommand(cmd);
    Response r = new Response(replica.getInstanceMap());
    return r;
  }