@Test public void testWriteRequest() { StripingPolicy sp = SetupUtils.getStripingPolicy(3, 7); List<String> s = new ArrayList(3); s.add("1"); s.add("2"); s.add("3"); org.xtreemfs.pbrpc.generatedinterfaces.GlobalTypes.Replica tmpR = org.xtreemfs.pbrpc.generatedinterfaces.GlobalTypes.Replica.newBuilder(). addAllOsdUuids(s).setStripingPolicy(sp).setReplicationFlags(0).build(); Replica r = new Replica(tmpR,null); RAID0ObjectMapper instance = new RAID0ObjectMapper(sp); byte[] bytes = new byte[14*1024]; for (int i = 0; i < bytes.length; i++) bytes[i] = 'a'; ReusableBuffer data = ReusableBuffer.wrap(bytes); data.position(0); List<ObjectRequest> result = instance.writeRequest(data, 2*1024, r); assertEquals(3, result.size()); assertEquals(0, result.get(0).getObjNo()); assertEquals(2*1024, result.get(0).getOffset()); assertEquals(5*1024, result.get(0).getLength()); assertEquals("1", result.get(0).getOsdUUID().toString()); assertEquals(5*1024, result.get(0).getData().capacity()); assertEquals(1, result.get(1).getObjNo()); assertEquals(0, result.get(1).getOffset()); assertEquals(7*1024, result.get(1).getLength()); assertEquals("2", result.get(1).getOsdUUID().toString()); assertEquals(7*1024, result.get(1).getData().capacity()); assertEquals(7*1024, result.get(1).getData().remaining()); assertEquals(2, result.get(2).getObjNo()); assertEquals(0, result.get(2).getOffset()); assertEquals(2*1024, result.get(2).getLength()); assertEquals("3", result.get(2).getOsdUUID().toString()); assertEquals(2*1024, result.get(2).getData().capacity()); }
@Override public List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica) { List<ObjectRequest> reqs = readRequest(data.remaining(), fileOffset, replica); int pCnt = 0; for (ObjectRequest rq : reqs) { ReusableBuffer viewBuf = data.createViewBuffer(); viewBuf.range(pCnt, rq.getLength()); pCnt += rq.getLength(); rq.setData(viewBuf); } return reqs; }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica) { List<ObjectRequest> reqs = readRequest(data.remaining(), fileOffset, replica); int pCnt = 0; for (ObjectRequest rq : reqs) { ReusableBuffer viewBuf = data.createViewBuffer(); viewBuf.range(pCnt, rq.getLength()); pCnt += rq.getLength(); rq.setData(viewBuf); } return reqs; } }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica) { List<ObjectRequest> reqs = readRequest(data.remaining(), fileOffset, replica); int pCnt = 0; for (ObjectRequest rq : reqs) { ReusableBuffer viewBuf = data.createViewBuffer(); viewBuf.range(pCnt, rq.getLength()); pCnt += rq.getLength(); rq.setData(viewBuf); } return reqs; } protected  RAID0ObjectMapper(StripingPolicy fileSP); }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica) { List<ObjectRequest> reqs = readRequest(data.remaining(), fileOffset, replica); int pCnt = 0; for (ObjectRequest rq : reqs) { ReusableBuffer viewBuf = data.createViewBuffer(); viewBuf.range(pCnt, rq.getLength()); pCnt += rq.getLength(); rq.setData(viewBuf); } return reqs; } protected  RAID0ObjectMapper(StripingPolicy fileSP); @Override List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica); @Override List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica); }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica) { List<ObjectRequest> reqs = readRequest(data.remaining(), fileOffset, replica); int pCnt = 0; for (ObjectRequest rq : reqs) { ReusableBuffer viewBuf = data.createViewBuffer(); viewBuf.range(pCnt, rq.getLength()); pCnt += rq.getLength(); rq.setData(viewBuf); } return reqs; } protected  RAID0ObjectMapper(StripingPolicy fileSP); @Override List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica); @Override List<ObjectRequest> writeRequest(ReusableBuffer data, long fileOffset, Replica replica);  }