logo
25.1
search
No matching documents found.
list
search
No matching documents found.
logo

Cluster Server

Cluster Server is similar to Webswing Server with the difference that it is not able to start an application instance itself. Therefore it is a lightweight module, which basically resends messages between application instance and browser. It also decides on which Session Pool the instance will be started, holds session statistics and metrics for Admin Console Server and does some other necessary communication with Session Pools.

Cluster Server is a stateless web server, which means that if you have multiple Cluster Servers it doesn't matter which server you connect to from the browser, even on refresh, the browser connection will always find the way to its application instance. If you have multiple Cluster Servers deployed and one of the Cluster Servers terminate, all the browser connections to this server can be reconnected through the other running Cluster Server without terminating the application instance.

Inside Cluster Server is a built-in mechanism - a Session Pool load balancer. This mechanism is responsible for finding a free Session Pool where a new instance will be started. By default the load balancer uses a simple round-robin algorithm. You can change the load balancing algorithm to Active Sessions Count by adding following to webswing.properties in the Webswing Server for the activeSessions load balancing:

org.webswing.server.api.service.sessionpool.loadbalance.LoadBalanceResolver = org.webswing.server.core.services.sessionpool.loadbalance.ActiveSessionsCountLoadBalanceResolver

Everything in your application that is related to web is configured and provided through the Cluster Server. This includes security (SSL, authentication, logout), translations, fonts or custom web resource handling. On the other hand, everything related to your application binary is configured and handled in Session Pool. Because of this the webswing.config file needs to be divided into 2 separate configuration files - webswing-server.config which is used by Cluster Server and webswing-app.config which is used by Session Pool. You can read more about this in next sections.

Cluster Server installation includes:

  • webswing.war
  • webswing-server.config
  • jetty.properties
  • webswing.properties
  • webswing.bat / webswing.sh
  • ssl configuration
  • security module configuration / libs
  • lang
  • web related files for apps, e.g. custom index.html

Here is an example of a webswing-server.config file:

{
  "/" : {
    "path" : "/",
    "security" : {
      "module" : "EMBEDED",
      "config" : {
        "users" : [ {
          "username" : "admin",
          "password" : "pwd",
          "roles" : [ "admin" ]
        }, {
          "username" : "support",
          "password" : "pwd",
          "roles" : [ "support" ]
        }, {
          "username" : "user",
          "password" : "pwd"
        } ]
      },
      "classPath" : [ ]
    },
    "langFolder" : "${webswing.configDir}/lang",
    "homeDir" : "${user.dir}",
    "allowedCorsOrigins" : [ "*" ],
    "dataStore": {
        "module": "FILESYSTEM",
        "config": {
            "transferFolder": "C:/work/dataStore/transfer"
        }
    }
  },
  "/webswing-demo" : {
    "path" : "/webswing-demo",
    "name" : "Webswing Demo",
    "webFolder" : "${webswing.rootDir}/apps/WebswingDemo/webroot",
    "security" : {
      "module" : "INHERITED",
      "config" : null,
      "classPath" : [ ]
    },
    "icon" : "${webswing.rootDir}/apps/WebswingDemo/icon.png",
    "webHomeDir" : "${webswing.rootDir}/apps/WebswingDemo",
    "langFolder" : "${webswing.configDir}/lang",
    "uploadMaxSize" : 5,
    "maxClients" : 100,
    "sessionMode" : "CONTINUE_FOR_BROWSER",
    "allowStealSession" : true,
    "autoLogout" : true
  }
}

Configuration of a Cluster Server is similar to the configuration of Webswing Server, please refer to this section for configuration options in webswing.properties.

Cluster with embedded Session Pool

Cluster Server can be also started/deployed with Session Pool included in the same java process. The embedded session pool is exactly the same as standalone Session Pool. You can also start another Cluster Server or even other standalone Session Pools to connect within a single cluster. To start a Cluster Server with Session Pool create a startup script where you use -clustersessionpool switch:

java -jar server/webswing-jetty-launcher.jar -j jetty.properties -clustersessionpool

The embedded Session Pool will look for configuration files in the root directory, but you can also provide the path to the files in startup script:

java -jar server/webswing-jetty-launcher.jar -j jetty.properties -clustersessionpool -pfsp C:\cluster\webswing-sessionpool.properties -csp C:\cluster\webswing-app.config

When deploying to Tomcat you can define these additional system properties:

webswing.clusterWithSessionPool=true
# optional
webswing.propertiesFile.sessionPool = C:\cluster\webswing-sessionpool.properties
#optional
webswing.configFile.sessionPool = C:\cluster\webswing-app.config