Class PortsManager


  • public class PortsManager
    extends java.lang.Object
    Maintains a list of ports used on this host, associated with time stamps. The ports are persistet into the temp file system.
    Version:
    $Id: PortsManager.java,v 1.4.2.3 2009/01/05 07:41:00 belaban Exp $
    Author:
    Bela Ban
    • Constructor Summary

      Constructors 
      Constructor Description
      PortsManager()  
      PortsManager​(long expiry_time)  
      PortsManager​(long expiry_time, java.lang.String ports_file)  
      PortsManager​(long expiry_time, java.lang.String filename, java.lang.String temp_dir)  
      PortsManager​(java.lang.String ports_file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deleteFile()
      Deletes the underlying file.
      long getExpiryTime()  
      int getNextAvailablePort​(int start_port)
      Loads the file, weeds out expired ports, returns the next available port and saves the new port in the file
      void removePort​(int port)
      Loads the file, removes the port (if existent) and closes the file again
      void setExpiryTime​(long expiry_time)  
      void updatePort​(int port)
      Updates the timestamp for the given port
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PortsManager

        public PortsManager()
      • PortsManager

        public PortsManager​(long expiry_time)
      • PortsManager

        public PortsManager​(java.lang.String ports_file)
      • PortsManager

        public PortsManager​(long expiry_time,
                            java.lang.String ports_file)
      • PortsManager

        public PortsManager​(long expiry_time,
                            java.lang.String filename,
                            java.lang.String temp_dir)
    • Method Detail

      • getExpiryTime

        public long getExpiryTime()
      • setExpiryTime

        public void setExpiryTime​(long expiry_time)
      • getNextAvailablePort

        public int getNextAvailablePort​(int start_port)
        Loads the file, weeds out expired ports, returns the next available port and saves the new port in the file
      • removePort

        public void removePort​(int port)
        Loads the file, removes the port (if existent) and closes the file again
      • updatePort

        public void updatePort​(int port)
        Updates the timestamp for the given port
        Parameters:
        port -
      • deleteFile

        public void deleteFile()
        Deletes the underlying file. Used for unit testing, not recommended for regular use !