byte[] compressed = gzip(assembleUrlList(list)); if (compressed.length <= maxSizePerPayload) { rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
/** * Creates a gzipped payload. * <p> * The last gzipped payload is retained and only recalculated if the list of cache peers * has changed. * * @return a gzipped byte[] */ private List createCachePeersPayload() { CacheManagerPeerListener cacheManagerPeerListener = cacheManager.getCachePeerListener("RMI"); if (cacheManagerPeerListener == null) { LOG.warn("The RMICacheManagerPeerListener is missing. You need to configure a cacheManagerPeerListenerFactory" + " with class=\"net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory\" in ehcache.xml."); return new ArrayList(); } List localCachePeers = cacheManagerPeerListener.getBoundCachePeers(); int newCachePeersHash = localCachePeers.hashCode(); if (cachePeersHash != newCachePeersHash) { cachePeersHash = newCachePeersHash; compressedUrlListList = PayloadUtil.createCompressedPayloadList(localCachePeers, MAXIMUM_PEERS_PER_SEND); } return compressedUrlListList; }
private void processPayload(byte[] compressedPayload) { byte[] payload = PayloadUtil.ungzip(compressedPayload); String rmiUrls = new String(payload); if (self(rmiUrls)) { return; } rmiUrls = rmiUrls.trim(); LOG.debug("rmiUrls received {}", rmiUrls); processRmiUrls(rmiUrls); }
/** * 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; }
byte[] compressed = gzip(assembleUrlList(list)); if (compressed.length <= maxSizePerPayload) { rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
private void processPayload(byte[] compressedPayload) { byte[] payload = PayloadUtil.ungzip(compressedPayload); String rmiUrls = new String(payload); if (self(rmiUrls)) { return; } rmiUrls = rmiUrls.trim(); LOG.debug("rmiUrls received {}", rmiUrls); processRmiUrls(rmiUrls); }
/** * 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 gzipped payload. * <p/> * The last gzipped payload is retained and only recalculated if the list of cache peers * has changed. * * @return a gzipped byte[] */ private List createCachePeersPayload() { CacheManagerPeerListener cacheManagerPeerListener = cacheManager.getCachePeerListener("RMI"); if (cacheManagerPeerListener == null) { LOG.warn("The RMICacheManagerPeerListener is missing. You need to configure a cacheManagerPeerListenerFactory" + " with class=\"net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory\" in ehcache.xml."); return new ArrayList(); } List localCachePeers = cacheManagerPeerListener.getBoundCachePeers(); int newCachePeersHash = localCachePeers.hashCode(); if (cachePeersHash != newCachePeersHash) { cachePeersHash = newCachePeersHash; compressedUrlListList = PayloadUtil.createCompressedPayloadList(localCachePeers, MAXIMUM_PEERS_PER_SEND); } return compressedUrlListList; }
byte[] compressed = gzip(assembleUrlList(list)); if (compressed.length <= maxSizePerPayload) { rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
private void processPayload(byte[] compressedPayload) { byte[] payload = PayloadUtil.ungzip(compressedPayload); String rmiUrls = new String(payload); if (self(rmiUrls)) { return; } rmiUrls = rmiUrls.trim(); LOG.debug("rmiUrls received {}", rmiUrls); processRmiUrls(rmiUrls); }
/** * 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 gzipped payload. * <p> * The last gzipped payload is retained and only recalculated if the list of cache peers * has changed. * * @return a gzipped byte[] */ private List createCachePeersPayload() { CacheManagerPeerListener cacheManagerPeerListener = cacheManager.getCachePeerListener("RMI"); if (cacheManagerPeerListener == null) { LOG.warn("The RMICacheManagerPeerListener is missing. You need to configure a cacheManagerPeerListenerFactory" + " with class=\"net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory\" in ehcache.xml."); return new ArrayList(); } List localCachePeers = cacheManagerPeerListener.getBoundCachePeers(); int newCachePeersHash = localCachePeers.hashCode(); if (cachePeersHash != newCachePeersHash) { cachePeersHash = newCachePeersHash; compressedUrlListList = PayloadUtil.createCompressedPayloadList(localCachePeers, MAXIMUM_PEERS_PER_SEND); } return compressedUrlListList; }
byte[] compressed = gzip(assembleUrlList(list)); if (compressed.length <= maxSizePerPayload) { rv.addAll(createCompressedPayload(list1, maxSizePerPayload)); rv.addAll(createCompressedPayload(list2, maxSizePerPayload));
private void processPayload(byte[] compressedPayload) { byte[] payload = PayloadUtil.ungzip(compressedPayload); String rmiUrls = new String(payload); if (self(rmiUrls)) { return; } rmiUrls = rmiUrls.trim(); LOG.debug("rmiUrls received {}", rmiUrls); processRmiUrls(rmiUrls); }
/** * Creates a gzipped payload. * <p/> * The last gzipped payload is retained and only recalculated if the list of cache peers * has changed. * * @return a gzipped byte[] */ private List createCachePeersPayload() { CacheManagerPeerListener cacheManagerPeerListener = cacheManager.getCachePeerListener("RMI"); if (cacheManagerPeerListener == null) { LOG.warn("The RMICacheManagerPeerListener is missing. You need to configure a cacheManagerPeerListenerFactory" + " with class=\"net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory\" in ehcache.xml."); return new ArrayList(); } List localCachePeers = cacheManagerPeerListener.getBoundCachePeers(); int newCachePeersHash = localCachePeers.hashCode(); if (cachePeersHash != newCachePeersHash) { cachePeersHash = newCachePeersHash; compressedUrlListList = PayloadUtil.createCompressedPayloadList(localCachePeers, MAXIMUM_PEERS_PER_SEND); } return compressedUrlListList; }