@Override public Response statfs(Map<Byte, Long> instanceMap) throws TException { // TODO: don't care about this for now Response r = new Response(replica.getInstanceMap()); r.setStatfs( new FileSystemStats(32 * 1024, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, 0, 0, 1024)); return r; }
@Override public Response open(String path, int flags, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); Set<Byte> parts = oracle.partitionsOf(path); Command cmd = newCommand(CommandType.OPEN, parts, instanceMap); OpenCmd open = new OpenCmd(path, flags, parts); cmd.setOpen(open); FileHandle fh = (FileHandle) replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); r.setOpen(fh); return r; }
@Override public Response getattr(String path, Map<Byte, Long> instanceMap) throws TException { // can be sent to ANY partition that replicates the path - we send it to the first returned by // the oracle path = makePathAbsolute(path); Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition)); Command cmd = newCommand(CommandType.ATTR, parts, instanceMap); AttrCmd attr = new AttrCmd(path, parts); cmd.setAttr(attr); Attr result = (Attr) replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); r.setGetattr(result); return r; }
@Override public Response readlink(String path, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); // can be sent to ANY partition that replicates the path - we send it to the first returned by // the oracle Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition)); Command cmd = newCommand(CommandType.READLINK, parts, instanceMap); ReadlinkCmd readlink = new ReadlinkCmd(path, parts); cmd.setReadlink(readlink); String result = (String) replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); r.setReadlink(result); return r; }
@Override public Response getdir(String path, Map<Byte, Long> instanceMap) throws TException { // can be sent to ANY partition that replicates the path - we send it to the first returned by // the oracle path = makePathAbsolute(path); Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition)); Command cmd = newCommand(CommandType.GETDIR, parts, instanceMap); GetdirCmd getdir = new GetdirCmd(path, parts); cmd.setGetdir(getdir); @SuppressWarnings("unchecked") List<DirEntry> entries = (List<DirEntry>) replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); r.setGetdir(entries); return r; }
@Override public Response readBlocks( String path, FileHandle fh, long offset, long bytes, Map<Byte, Long> instanceMap) throws TException { path = makePathAbsolute(path); // assuming this replica replicates the file, send to own partition Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition)); Command cmd = newCommand(CommandType.READ_BLOCKS, parts, instanceMap); ReadBlocksCmd read = new ReadBlocksCmd(path, fh, offset, bytes, parts); cmd.setRead(read); ReadResult readResult = (ReadResult) replica.submitCommand(cmd); Response r = new Response(replica.getInstanceMap()); r.setReadBlocks(readResult); return r; }