Package tigase.server

Class ConnectionManager<IO extends XMPPIOService<?>>

All Implemented Interfaces:
ClusteredComponentIfc, Configurable, XMPPService, ConfigurationChangedAware, Initializable, RegistrarBean, IOServiceListener<IO>, MessageReceiver, PacketWriterWithTimeout, ServerComponent, StatisticsContainer, StatisticsContainerIfc, VHostListener, XMPPIOServiceListener<IO>
Direct Known Subclasses:
ClientConnectionManager, ClusterConnectionManager, ComponentConnectionManager, ComponentProtocol, S2SConnectionManager

public abstract class ConnectionManager<IO extends XMPPIOService<?>> extends AbstractMessageReceiver implements XMPPIOServiceListener<IO>, RegistrarBean
Describe class ConnectionManager here.
Created: Sun Jan 22 22:52:58 2006
Artur Hefczyc
  • Field Details

  • Constructor Details

    • ConnectionManager

      public ConnectionManager()
    • ConnectionManager

      protected ConnectionManager(int socketBufferSize)
  • Method Details

    • enableServiceConnectedTimeout

      protected boolean enableServiceConnectedTimeout(IO service)
    • beanConfigurationChanged

      public void beanConfigurationChanged(Collection<String> changedFields)
      Description copied from interface: ConfigurationChangedAware
      Method called when configuration was applied to bean.
      Specified by:
      beanConfigurationChanged in interface ConfigurationChangedAware
      beanConfigurationChanged in class AbstractMessageReceiver
      changedFields - collection of field names which were changed
    • checkTrafficLimits

      public boolean checkTrafficLimits(IO serv)
    • everyMinute

      public void everyMinute()
      Description copied from class: AbstractMessageReceiver
      Utility method executed precisely every minute. A component can overwrite the method to put own code to be executed at the regular intervals of time.
      Note, no extensive calculations should happen in this method nor long lasting operations. It is essential that the method processing does not exceed 1 minute. The overriding method must call the the super method first and only then run own code.
      everyMinute in class AbstractMessageReceiver
    • hashCodeForPacket

      public int hashCodeForPacket(Packet packet)
      Description copied from class: AbstractMessageReceiver
      This method decides how incoming packets are distributed among processing threads. Different components needs different distribution to efficient use all threads and avoid packets re-ordering.
      If there are N processing threads, packets are distributed among threads using following code:
       int threadNo = Math.abs(hashCodeForPacket(packet) % N);

      For a PubSub component, for example, a better packets distribution would be based on the PubSub channel name, for SM a better distribution is based on the destination address, etc....
      hashCodeForPacket in class AbstractMessageReceiver
      packet - is a Packet which needs to be processed by some thread.
      a hash code generated for the input thread.
    • initBindings

      public void initBindings(Bindings binds)
      Description copied from class: BasicComponent
      Initialize a mapping of key/value pairs which can be used in scripts loaded by the server
      initBindings in class BasicComponent
      binds - A mapping of key/value pairs, all of whose keys are Strings.
    • initializationCompleted

      public void initializationCompleted()
      Description copied from interface: ServerComponent
      Method is called by MessageRouter when all the startup components of the server have been loaded and configured through setProperties(...) call. At this point the whole server should be loaded and functional, except initializations taking place in this routine.
      Specified by:
      initializationCompleted in interface ServerComponent
      initializationCompleted in class BasicComponent
    • packetsReady

      public void packetsReady(IO serv) throws IOException
      Specified by:
      packetsReady in interface IOServiceListener<IO extends XMPPIOService<?>>
    • processingInThreads

      public int processingInThreads()
      Description copied from class: AbstractMessageReceiver
      Concurrency control method. Returns preferable number of threads set for this component.
      processingInThreads in class AbstractMessageReceiver
      preferable number of threads set for this component.
    • processingOutThreads

      public int processingOutThreads()
      Description copied from class: AbstractMessageReceiver
      Concurrency control method. Returns preferable number of threads set for this component.
      processingOutThreads in class AbstractMessageReceiver
      preferable number of threads set for this component.
    • processPacket

      public void processPacket(Packet packet)
      Description copied from class: AbstractMessageReceiver
      This is the main Packet processing method. It is called concurrently from many threads so implementing it in thread save manner is essential. The method is called for each packet addressed to the component.
      Please note, the Packet instance may be processed by different parts of the server, different components or plugins at the same time. Therefore this is very important to tread the Packet instance as unmodifiable object.
      Processing in this method is asynchronous, therefore there is no result value. If there are some 'result' packets generated during processing, they should be passed back using addOutPacket(Packet) method.
      Specified by:
      processPacket in class AbstractMessageReceiver
      packet - is an instance of the Packet class passed for processing.
    • processSocketData

      public abstract Queue<Packet> processSocketData(IO serv)
    • processUndeliveredPacket

      public abstract boolean processUndeliveredPacket(Packet packet, Long stamp, String errorMessage)
      Processes undelivered packets
      stamp - - timestamp when packet was received to be written to XMPPIOService
    • reconnectionFailed

      public abstract void reconnectionFailed(Map<String,Object> port_props)
    • getDefPorts

      public HashSet<Integer> getDefPorts()
    • register

      public void register(Kernel kernel)
      Description copied from interface: RegistrarBean
      Method called when bean is being registered allowing developer to programatically register other beans.
      Specified by:
      register in interface RegistrarBean
      kernel - - instance from local scope
    • unregister

      public void unregister(Kernel kernel)
      Description copied from interface: RegistrarBean
      Method called while bean is being unregistered.
      Specified by:
      unregister in interface RegistrarBean
      kernel - - instance from local scope
    • release

      public void release()
      Description copied from interface: ServerComponent
      Method called when component is being stopped and unloaded.
      Specified by:
      release in interface ServerComponent
      release in class AbstractMessageReceiver
    • serviceConnected

      protected void serviceConnected(IO service)
    • serviceStarted

      @TODO(note="Do something if service with the same unique ID is already started, possibly kill the old one...") public void serviceStarted(IO service)
    • serviceStopped

      public boolean serviceStopped(IO service)
      Specified by:
      serviceStopped in interface IOServiceListener<IO extends XMPPIOService<?>>
    • shouldRedeliverWaitingPackets

      protected boolean shouldRedeliverWaitingPackets(IO service)
    • redeliverWaitingPackets

      protected void redeliverWaitingPackets(IO service)
    • start

      public void start()
      Specified by:
      start in interface MessageReceiver
      start in class AbstractMessageReceiver
    • stop

      public void stop()
      stop in class AbstractMessageReceiver
    • updateConnectionDetails

      public void updateConnectionDetails(Map<String,Object> port_props)
    • writePacketsToSocket

      public void writePacketsToSocket(IO serv, Queue<Packet> packets)
    • writePacketToSocket

      public boolean writePacketToSocket(IO ios, Packet p)
    • xmppStreamError

      public String xmppStreamError(IO serv, List<Element> err_el)
      Specified by:
      xmppStreamError in interface XMPPIOServiceListener<IO extends XMPPIOService<?>>
    • getPortsConfigBean

      public ConnectionManager.PortsConfigBean getPortsConfigBean()
    • getStatistics

      public void getStatistics(StatisticsList list)
      Description copied from class: AbstractMessageReceiver
      Method returns component statistics. Please note, the method can be called every second by the server monitoring system therefore no extensive or lengthy calculations are allowed. If there are some statistics requiring lengthy operations like database access they must have Level.FINEST assigned and must be put inside the level guard to prevent generating them by the system monitor. The system monitor does not collect FINEST statistics.
      Level guard code looks like the example below:
       if (list.checkLevel(Level.FINEST)) {
         // Some CPU intensive calculations or lengthy operations
         list.add(getName(), "Statistic description", stat_value, Level.FINEST);
      This way you make sure your extensive operation is not executed every second by the monitoring system and does not affect the server performance.
      Specified by:
      getStatistics in interface StatisticsContainerIfc
      getStatistics in class AbstractMessageReceiver
      list - is a StatistcsList where all statistics are stored.
    • getXMPPIOService

      public IO getXMPPIOService(String serviceId)
    • setName

      public void setName(String name)
      Description copied from interface: ServerComponent
      Method used to assign component name (localpart of the component)
      Specified by:
      setName in interface ServerComponent
      setName in class AbstractMessageReceiver
      name - to be assigned
    • getFlashCrossDomainPolicy

      public String getFlashCrossDomainPolicy()
    • setFlashCrossDomainPolicyFile

      public void setFlashCrossDomainPolicyFile(String file)
    • getNet_buffer_limit

      public int getNet_buffer_limit()
    • setNet_buffer_limit

      public void setNet_buffer_limit(int value)
    • setProcessors

      public void setProcessors(XMPPIOProcessor[] processors)
    • getTrafficThrottling

      public String getTrafficThrottling()
    • setTrafficThrottling

      public void setTrafficThrottling(String trafficThrottling)
    • connectWaitingTasks

      protected void connectWaitingTasks()
    • setupWatchdogThread

      protected void setupWatchdogThread()
    • setWatchdogPingType

      public void setWatchdogPingType(ConnectionManager.WATCHDOG_PING_TYPE watchdogPingType)
    • newWatchdog

      protected ConnectionManager<IO>.Watchdog newWatchdog()
    • addWaitingTask

      protected void addWaitingTask(Map<String,Object> conn)
    • checkHighThroughputProperty

      protected <T> void checkHighThroughputProperty(String ht_def_key, T ht_dev_val, String st_def_key, T st_def_val, String prop_key, Class<T> prop_val_class, Map<String,Object> params, Map<String,Object> props)
    • countIOServices

      protected int countIOServices()
      Returns number of active network connections (IOServices).
      number of active network connections (IOServices).
    • doForAllServices

      protected void doForAllServices(ServiceChecker<IO> checker)
      Perform a given action defined by ServiceChecker for all active IOService objects (active network connections).
      checker - is a ServiceChecker instance defining an action to perform for all IOService objects.
    • writePacketToSocket

      protected boolean writePacketToSocket(Packet p)
    • writePacketToSocket

      protected boolean writePacketToSocket(Packet p, String serviceId)
    • writeRawData

      protected void writeRawData(IO ios, String data)
    • getDefPlainPorts

      protected int[] getDefPlainPorts()
    • getDefSSLPorts

      protected int[] getDefSSLPorts()
    • getDefTrafficThrottling

      protected String getDefTrafficThrottling()
    • getMaxInactiveTime

      protected abstract long getMaxInactiveTime()
    • getParamsForPort

      protected Map<String,Object> getParamsForPort(int port)
    • getServiceId

      protected String getServiceId(Packet packet)
    • getServiceId

      protected String getServiceId(JID jid)
    • getUniqueId

      protected String getUniqueId(IO serv)
    • getXMPPIOService

      protected IO getXMPPIOService(Packet p)
    • getXMPPIOServiceInstance

      protected abstract IO getXMPPIOServiceInstance()
    • isHighThroughput

      protected boolean isHighThroughput()
    • socketAccepted

      protected void socketAccepted(IO serv, SocketType type)
    • releaseListener

      protected void releaseListener(ConnectionOpenListener toStop)
    • startService

      protected ConnectionManager<IO>.tigase.server.ConnectionManager.ConnectionListenerImpl startService(Map<String,Object> port_props)