@Test public void testBigPayload() throws RemoteException { List<CachePeer> bigPayloadList = new ArrayList<CachePeer>(); int peers = 5000; int minCacheNameSize = 50; int maxCacheNameSize = 500; for (int i = 0; i < peers; i++) { bigPayloadList.add(new PayloadUtilTestCachePeer(getRandomName(minCacheNameSize, maxCacheNameSize))); } doTestBigPayLoad(bigPayloadList, 5); doTestBigPayLoad(bigPayloadList, 10); doTestBigPayLoad(bigPayloadList, 50); doTestBigPayLoad(bigPayloadList, 100); doTestBigPayLoad(bigPayloadList, 150); doTestBigPayLoad(bigPayloadList, 300); doTestBigPayLoad(bigPayloadList, 500); doTestBigPayLoad(bigPayloadList, 1000000); bigPayloadList.clear(); bigPayloadList.add(new PayloadUtilTestCachePeer(getRandomName(3000, 3001))); List<byte[]> compressedList = PayloadUtil.createCompressedPayloadList(bigPayloadList, 150); assertEquals(0, compressedList.size()); }
public static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend) { List<byte[]> rv = new ArrayList<byte[]>(); int iters = (int) Math.ceil((double) localCachePeers.size() / maximumPeersPerSend); for (int i = 0; i < iters; i++) { int fromIndex = maximumPeersPerSend * i; int toIndex = Math.min(maximumPeersPerSend * (i + 1), localCachePeers.size()); List<CachePeer> subList = localCachePeers.subList(fromIndex, toIndex); rv.addAll(createCompressedPayload(subList, MTU)); } return rv; }
PayloadUtil { public static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend) { List<byte[]> rv = new ArrayList<byte[]>(); int iters = (int) Math.ceil((double) localCachePeers.size() / maximumPeersPerSend); for (int i = 0; i < iters; i++) { int fromIndex = maximumPeersPerSend * i; int toIndex = Math.min(maximumPeersPerSend * (i + 1), localCachePeers.size()); List<CachePeer> subList = localCachePeers.subList(fromIndex, toIndex); rv.addAll(createCompressedPayload(subList, MTU)); } return rv; } }
PayloadUtil { public static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend) { List<byte[]> rv = new ArrayList<byte[]>(); int iters = (int) Math.ceil((double) localCachePeers.size() / maximumPeersPerSend); for (int i = 0; i < iters; i++) { int fromIndex = maximumPeersPerSend * i; int toIndex = Math.min(maximumPeersPerSend * (i + 1), localCachePeers.size()); List<CachePeer> subList = localCachePeers.subList(fromIndex, toIndex); rv.addAll(createCompressedPayload(subList, MTU)); } return rv; } private  PayloadUtil(); }
PayloadUtil { public static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend) { List<byte[]> rv = new ArrayList<byte[]>(); int iters = (int) Math.ceil((double) localCachePeers.size() / maximumPeersPerSend); for (int i = 0; i < iters; i++) { int fromIndex = maximumPeersPerSend * i; int toIndex = Math.min(maximumPeersPerSend * (i + 1), localCachePeers.size()); List<CachePeer> subList = localCachePeers.subList(fromIndex, toIndex); rv.addAll(createCompressedPayload(subList, MTU)); } return rv; } private  PayloadUtil(); static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend); static byte[] assembleUrlList(List localCachePeers); static byte[] gzip(byte[] ungzipped); static byte[] ungzip(final byte[] gzipped); }
PayloadUtil { public static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend) { List<byte[]> rv = new ArrayList<byte[]>(); int iters = (int) Math.ceil((double) localCachePeers.size() / maximumPeersPerSend); for (int i = 0; i < iters; i++) { int fromIndex = maximumPeersPerSend * i; int toIndex = Math.min(maximumPeersPerSend * (i + 1), localCachePeers.size()); List<CachePeer> subList = localCachePeers.subList(fromIndex, toIndex); rv.addAll(createCompressedPayload(subList, MTU)); } return rv; } private  PayloadUtil(); static List<byte[]> createCompressedPayloadList(final List<CachePeer> localCachePeers, final int maximumPeersPerSend); static byte[] assembleUrlList(List localCachePeers); static byte[] gzip(byte[] ungzipped); static byte[] ungzip(final byte[] gzipped); static final int MTU; static final String URL_DELIMITER; }