@Test public void testReadRequest() { 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); List<ObjectRequest> result = instance.readRequest(7*1024, 0, r); assertEquals(1, result.size()); assertEquals(0, result.get(0).getObjNo()); assertEquals(0, result.get(0).getOffset()); assertEquals(7*1024, result.get(0).getLength()); assertEquals("1", result.get(0).getOsdUUID().toString()); result = instance.readRequest(5*1024, 2*1024, r); assertEquals(1, 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()); result = instance.readRequest(8*1024, 0, r); assertEquals(2, result.size()); assertEquals(0, result.get(0).getObjNo()); assertEquals(0, result.get(0).getOffset()); assertEquals(7*1024, result.get(0).getLength()); assertEquals("1", result.get(0).getOsdUUID().toString()); assertEquals(1, result.get(1).getObjNo()); assertEquals(0, result.get(1).getOffset()); assertEquals(1*1024, result.get(1).getLength()); assertEquals("2", result.get(1).getOsdUUID().toString()); result = instance.readRequest(14*1024, 0, r); assertEquals(2, result.size()); assertEquals(0, result.get(0).getObjNo()); assertEquals(0, result.get(0).getOffset()); assertEquals(7*1024, result.get(0).getLength()); assertEquals("1", result.get(0).getOsdUUID().toString()); 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()); result = instance.readRequest(14*1024, 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(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(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()); }
@Override public List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica) { List<ObjectRequest> reqs = new LinkedList(); final long firstObj = fileOffset / stripeSize; final long lastObj = (fileOffset+length-1) / stripeSize; final int firstOffset = (int)fileOffset%stripeSize; if (firstObj == lastObj) { ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, length, getOSDForObject(replica, firstObj), null); reqs.add(rq); return reqs; } ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, stripeSize-firstOffset, getOSDForObject(replica, firstObj),null); reqs.add(rq); for (long o = firstObj+1; o < lastObj; o++) { rq = new ObjectRequest(o, 0, stripeSize, getOSDForObject(replica, o), null); reqs.add(rq); } final int lastSize = ((length+fileOffset)%stripeSize == 0) ? stripeSize : (int) (length+fileOffset)%stripeSize; if (lastSize > 0) { rq = new ObjectRequest(lastObj, 0, lastSize, getOSDForObject(replica, lastObj), null); reqs.add(rq); } return reqs; }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica) { List<ObjectRequest> reqs = new LinkedList(); final long firstObj = fileOffset / stripeSize; final long lastObj = (fileOffset+length-1) / stripeSize; final int firstOffset = (int)fileOffset%stripeSize; if (firstObj == lastObj) { ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, length, getOSDForObject(replica, firstObj), null); reqs.add(rq); return reqs; } ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, stripeSize-firstOffset, getOSDForObject(replica, firstObj),null); reqs.add(rq); for (long o = firstObj+1; o < lastObj; o++) { rq = new ObjectRequest(o, 0, stripeSize, getOSDForObject(replica, o), null); reqs.add(rq); } final int lastSize = ((length+fileOffset)%stripeSize == 0) ? stripeSize : (int) (length+fileOffset)%stripeSize; if (lastSize > 0) { rq = new ObjectRequest(lastObj, 0, lastSize, getOSDForObject(replica, lastObj), null); reqs.add(rq); } return reqs; } }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica) { List<ObjectRequest> reqs = new LinkedList(); final long firstObj = fileOffset / stripeSize; final long lastObj = (fileOffset+length-1) / stripeSize; final int firstOffset = (int)fileOffset%stripeSize; if (firstObj == lastObj) { ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, length, getOSDForObject(replica, firstObj), null); reqs.add(rq); return reqs; } ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, stripeSize-firstOffset, getOSDForObject(replica, firstObj),null); reqs.add(rq); for (long o = firstObj+1; o < lastObj; o++) { rq = new ObjectRequest(o, 0, stripeSize, getOSDForObject(replica, o), null); reqs.add(rq); } final int lastSize = ((length+fileOffset)%stripeSize == 0) ? stripeSize : (int) (length+fileOffset)%stripeSize; if (lastSize > 0) { rq = new ObjectRequest(lastObj, 0, lastSize, getOSDForObject(replica, lastObj), null); reqs.add(rq); } return reqs; } protected  RAID0ObjectMapper(StripingPolicy fileSP); }
RAID0ObjectMapper extends ObjectMapper { @Override public List<ObjectRequest> readRequest(int length, long fileOffset, Replica replica) { List<ObjectRequest> reqs = new LinkedList(); final long firstObj = fileOffset / stripeSize; final long lastObj = (fileOffset+length-1) / stripeSize; final int firstOffset = (int)fileOffset%stripeSize; if (firstObj == lastObj) { ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, length, getOSDForObject(replica, firstObj), null); reqs.add(rq); return reqs; } ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, stripeSize-firstOffset, getOSDForObject(replica, firstObj),null); reqs.add(rq); for (long o = firstObj+1; o < lastObj; o++) { rq = new ObjectRequest(o, 0, stripeSize, getOSDForObject(replica, o), null); reqs.add(rq); } final int lastSize = ((length+fileOffset)%stripeSize == 0) ? stripeSize : (int) (length+fileOffset)%stripeSize; if (lastSize > 0) { rq = new ObjectRequest(lastObj, 0, lastSize, getOSDForObject(replica, lastObj), null); reqs.add(rq); } 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> readRequest(int length, long fileOffset, Replica replica) { List<ObjectRequest> reqs = new LinkedList(); final long firstObj = fileOffset / stripeSize; final long lastObj = (fileOffset+length-1) / stripeSize; final int firstOffset = (int)fileOffset%stripeSize; if (firstObj == lastObj) { ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, length, getOSDForObject(replica, firstObj), null); reqs.add(rq); return reqs; } ObjectRequest rq = new ObjectRequest(firstObj, firstOffset, stripeSize-firstOffset, getOSDForObject(replica, firstObj),null); reqs.add(rq); for (long o = firstObj+1; o < lastObj; o++) { rq = new ObjectRequest(o, 0, stripeSize, getOSDForObject(replica, o), null); reqs.add(rq); } final int lastSize = ((length+fileOffset)%stripeSize == 0) ? stripeSize : (int) (length+fileOffset)%stripeSize; if (lastSize > 0) { rq = new ObjectRequest(lastObj, 0, lastSize, getOSDForObject(replica, lastObj), null); reqs.add(rq); } 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);  }