Class FIXServer

java.lang.Object
com.epam.fixengine.FIXServer
All Implemented Interfaces:
com.epam.fixengine.manager.ConfiguredSessionListener
Direct Known Subclasses:
ScheduledFIXServer, SSLFIXServer

public class FIXServer extends Object implements com.epam.fixengine.manager.ConfiguredSessionListener
Generic FIXServer implementation.
  • Field Details

    • servers

      protected Map<Integer,com.epam.fixengine.FIXServer.ServerMeta> servers
    • configuration

      protected final com.epam.fixengine.session.util.ConfigurationAdaptor configuration
  • Constructor Details

    • FIXServer

      public FIXServer()
    • FIXServer

      public FIXServer(int... ports)
    • FIXServer

      public FIXServer(com.epam.fixengine.configuration.Configuration conf)
      Creates the fix server.
    • FIXServer

      public FIXServer(com.epam.fixengine.configuration.Configuration conf, int... ports)
  • Method Details

    • getTransportFactory

      protected SessionTransportFactory getTransportFactory(com.epam.fixengine.configuration.Configuration configuration)
    • getAcceptorStrategy

      protected SessionAcceptorStrategyHandler getAcceptorStrategy(com.epam.fixengine.session.util.ConfigurationAdaptor configuration, com.epam.fixengine.manager.ConfiguredSessionRegister configuredSessionRegister)
    • setServer

      public void setServer(@NotNull @NotNull Server server)
      Replaces default TCPServer implementation with custom Server implementation.
      Parameters:
      server - implementation specified by user
      See Also:
    • setListener

      public void setListener(FIXServerListener listener)
      Sets listener.
      Parameters:
      listener - - user specified listener
    • setConnectionValidator

      public void setConnectionValidator(ConnectionValidator connectionValidator)
    • setLoginWaitTimeout

      public void setLoginWaitTimeout(int loginWaitTimeout)
      Sets login timeout.
      Parameters:
      loginWaitTimeout - the login timeout in mils
    • setPorts

      public void setPorts(int... ports)
      Sets ports to listen on.
      Parameters:
      ports - ports to listen on
    • setPorts

      public void setPorts(com.epam.fixengine.session.util.ConfigurationAdaptor config, int... ports)
    • addServer

      protected Server addServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, Integer port, Server server, com.epam.fixengine.acceptor.ConnectionHandler handler)
    • deleteServer

      protected Server deleteServer(Integer port)
    • clearServers

      protected void clearServers()
    • createServer

      protected Server createServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose)
    • getServer

      protected Server getServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose)
    • getPorts

      public int[] getPorts()
      Listening ports
      Returns:
      listening ports
    • setPort

      public void setPort(int port)
      Sets port to listen on.
      Parameters:
      port - port to listen on
    • setNic

      public void setNic(String nic)
    • getNic

      public String getNic()
    • start

      public boolean start() throws IOException
      Actually starts the servers.
      Returns:
      true if all servers started succesfully false - otherwise (server will add WARN messages with description of each problem to LOG)
      Throws:
      IOException - if unable to start the server at least on one port. In this case the first received exception will be thrown.
    • registerConfiguredSessions

      protected void registerConfiguredSessions()
    • stop

      public void stop() throws IOException
      Stops the server.
      Throws:
      IOException - if stop was unsuccessful
    • getOpenPorts

      public Set<Integer> getOpenPorts()
      Provides with port numbers which added and actually started in this FIX Server.
      Returns:
      set of port numbers
    • openPort

      public boolean openPort(int portNum) throws IOException
      Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).
      Parameters:
      portNum - the socket port number
      Returns:
      true if opened, false - otherwise (was already open etc)
      Throws:
      IOException - if was failed to open
    • openPort

      public boolean openPort(com.epam.fixengine.configuration.Configuration config, int portNum) throws IOException
      Throws:
      IOException
    • openPort

      public boolean openPort(int portNum, boolean autoClose) throws IOException
      Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).
      Parameters:
      portNum - the socket port number
      autoClose - flag to switch on/off auto close of port listening on removing from registry of last session with the given port
      Returns:
      true if opened, false - otherwise (was already open etc)
      Throws:
      IOException - if was failed to open
    • openPort

      public boolean openPort(com.epam.fixengine.configuration.Configuration config, int portNum, boolean autoClose) throws IOException
      Throws:
      IOException
    • closePort

      public boolean closePort(int portNum)
      Closes port for listening of incoming FIX sessions on the given port.
      Parameters:
      portNum - the socket port number
      Returns:
      true if port was open and closed, false - otherwise (was not open etc)
    • stopAndDeleteServer

      protected boolean stopAndDeleteServer(int portNum)
    • handleAutoClose

      protected boolean handleAutoClose(Integer portNum, Server server)
    • registerAcceptorSession

      public void registerAcceptorSession(SessionParameters sessionParameters)
      Register the session parameters of acceptor.

      Parameters:
      sessionParameters - the sessionParameters
    • unregisterAcceptorSession

      public void unregisterAcceptorSession(SessionParameters sessionParameters)
      Remove registered acceptor session. Note: To remove registered acceptor session it's enough to pass SessionParameters with right SenderComId and TargetCompId for a moment.
      Parameters:
      sessionParameters -
    • getRegisterAcceptorSession

      public List<SessionParameters> getRegisterAcceptorSession()
    • getConfigPath

      public String getConfigPath()
      Path to config file
      Returns:
      path to config file
    • setConfigPath

      public void setConfigPath(String configPath)
      Set path to config file
      Parameters:
      configPath - path to config file
    • setIncomingConnectionExecutor

      public void setIncomingConnectionExecutor(ExecutorService executorService)
      Set custom executor service.
      Parameters:
      executorService - the executor will be used for working with incoming connections.
    • getConfiguredServerSocketFactory

      protected ServerSocketFactory getConfiguredServerSocketFactory(@NotNull @NotNull com.epam.fixengine.configuration.Configuration configuration)
    • isStarted

      public boolean isStarted()
    • addServerStatusListener

      public void addServerStatusListener(FIXServerStatusListener statusListener)
    • removeServerStatusListener

      public void removeServerStatusListener(FIXServerStatusListener statusListener)
    • onAddSession

      public void onAddSession(SessionParameters params)
      Specified by:
      onAddSession in interface com.epam.fixengine.manager.ConfiguredSessionListener
    • onRemoveSession

      public void onRemoveSession(SessionParameters params)
      Specified by:
      onRemoveSession in interface com.epam.fixengine.manager.ConfiguredSessionListener
    • validateBeforeRegistration

      protected void validateBeforeRegistration(SessionParameters sessionParameters)