Exemplo n.º 1
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;
  }