public void incrementConnectionFailures(String address) {
   Integer count = addressBlacklist.get(address);
   if (count == null) {
     count = 1;
   } else {
     count += 1;
   }
   addressBlacklist.put(address, count);
 }
Ejemplo n.º 2
0
  /**
   * 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;
  }
 public int getConnectionFailures(String address) {
   Integer count = addressBlacklist.get(address);
   return count != null ? count : 0;
 }
 /**
  * Returns how often the connection to the given address failed.
  *
  * @param address the address
  * @return number of connection failures
  */
 private int getConnectionFailures(String address) {
   Integer count = ADDRESS_BLACKLIST.get(address);
   return count != null ? count : 0;
 }
 /**
  * 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);
 }