@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; }
@Override public Response rmdir(String path, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); Set<Byte> parts = oracle.partitionsOf(path); Set<Byte> parentParts = oracle.partitionsOf(Paths.dirname(path)); Set<Byte> involvedPartitions = Sets.union(parts, parentParts); Command cmd = newCommand(CommandType.RMDIR, involvedPartitions, instanceMap); RmdirCmd rmdir = new RmdirCmd(path, parentParts, parts); cmd.setRmdir(rmdir); replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); return r; }
@Override public Response mknod( String path, int mode, int rdev, int uid, int gid, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); Set<Byte> parts = oracle.partitionsOf(path); Set<Byte> parentParts = oracle.partitionsOf(Paths.dirname(path)); Set<Byte> involvedPartitions = Sets.union(parts, parentParts); Command cmd = newCommand(CommandType.MKNOD, involvedPartitions, instanceMap); MknodCmd mknod = new MknodCmd(path, mode, uid, gid, parentParts, parts); cmd.setMknod(mknod); replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); return r; }
@Override public Response symlink(String target, String path, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); target = makePathAbsolute(target); Set<Byte> parts = oracle.partitionsOf(path); Set<Byte> parentParts = oracle.partitionsOf(Paths.dirname(path)); Set<Byte> involvedPartitions = Sets.union(parts, parentParts); Command cmd = newCommand(CommandType.SYMLINK, involvedPartitions, instanceMap); SymlinkCmd symlink = new SymlinkCmd(target, path, parentParts, parts); cmd.setSymlink(symlink); replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); return r; }