/** * Creates a list of compressed (using gzip) url list. Breaks up the list of urlList such that size of each compressed entry in the list * does not exceed the {@link #MTU} and the number of url's in each compressed entry does not exceed the maximumPeersPerSend parameter * * @param localCachePeers * List containing the peers * @param maximumPeersPerSend * The maximum number of peers that can be present in one compressed entry * @return List of compressed entries containing the peers urlList */ 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; }
rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
/** * Creates a list of compressed (using gzip) url list. Breaks up the list of urlList such that size of each compressed entry in the list * does not exceed the {@link #MTU} and the number of url's in each compressed entry does not exceed the maximumPeersPerSend parameter * * @param localCachePeers * List containing the peers * @param maximumPeersPerSend * The maximum number of peers that can be present in one compressed entry * @return List of compressed entries containing the peers urlList */ 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; }
/** * Creates a list of compressed (using gzip) url list. Breaks up the list of urlList such that size of each compressed entry in the list * does not exceed the {@link #MTU} and the number of url's in each compressed entry does not exceed the maximumPeersPerSend parameter * * @param localCachePeers * List containing the peers * @param maximumPeersPerSend * The maximum number of peers that can be present in one compressed entry * @return List of compressed entries containing the peers urlList */ 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; }
/** * Creates a list of compressed (using gzip) url list. Breaks up the list of urlList such that size of each compressed entry in the list * does not exceed the {@link #MTU} and the number of url's in each compressed entry does not exceed the maximumPeersPerSend parameter * * @param localCachePeers * List containing the peers * @param maximumPeersPerSend * The maximum number of peers that can be present in one compressed entry * @return List of compressed entries containing the peers urlList */ 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; }
rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));