public void incrementConnectionFailures(String address) { Integer count = addressBlacklist.get(address); if (count == null) { count = 1; } else { count += 1; } addressBlacklist.put(address, count); }
@SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> map) { for (Entry<? extends K, ? extends V> entry : map.entrySet()) { V value = entry.getValue(); // If the map is another DefaultCache instance than the // entry values will be CacheObject instances that need // to be converted to the normal object form. if (value instanceof CacheObject) { //noinspection unchecked value = ((CacheObject<V>) value).object; } put(entry.getKey(), value); } }
/** * Returns the address of the multiple recipients service. To obtain such address service * discovery is going to be used on the connected server and if none was found then another * attempt will be tried on the server items. The discovered information is going to be cached for * 24 hours. * * @param connection the connection to use for disco. The connected server is going to be queried. * @return the address of the multiple recipients service or <tt>null</tt> if none was found. */ private static String getMultipleRecipienServiceAddress(Connection connection) { String serviceName = connection.getServiceName(); String serviceAddress = (String) services.get(serviceName); if (serviceAddress == null) { synchronized (services) { serviceAddress = (String) services.get(serviceName); if (serviceAddress == null) { // Send the disco packet to the server itself try { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(serviceName); // Check if the server supports JEP-33 if (info.containsFeature("http://jabber.org/protocol/address")) { serviceAddress = serviceName; } else { // Get the disco items and send the disco packet to each server item DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(serviceName); for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); ) { DiscoverItems.Item item = it.next(); info = ServiceDiscoveryManager.getInstanceFor(connection) .discoverInfo(item.getEntityID(), item.getNode()); if (info.containsFeature("http://jabber.org/protocol/address")) { serviceAddress = serviceName; break; } } } // Cache the discovered information services.put(serviceName, serviceAddress == null ? "" : serviceAddress); } catch (XMPPException e) { LOGGER.log(Level.SEVERE, "Error occurred retrieving multiple recipients service", e); } } } } return "".equals(serviceAddress) ? null : serviceAddress; }
/** * Increments the connection failure counter by one for the given address. * * @param address the address the connection failure counter should be increased */ private void incrementConnectionFailures(String address) { Integer count = ADDRESS_BLACKLIST.get(address); ADDRESS_BLACKLIST.put(address, count == null ? 1 : count + 1); }