[id='server_readme']
= Infinispan Server

Infinispan server provides fast, reliable, and secure access to your data. This
release of the server improves on previous versions and offers:

* Small code-base with minimal duplication of existing functionality (e.g. configuration).
* Embeddable: the server should allow for easy testability in both single and clustered configurations.
* RESTful administration capabilities.
* Logging with link:https://logging.apache.org/log4j/2.x/[Apache Log4j 2].
* Security with link:https://github.com/wildfly-security/wildfly-elytron[WildFly Elytron] SPIs.

== Directory Structure
Server distributions have the following directory structure:

* `/bin`: scripts to start the server and create/modify users.
* `/boot`: `JAR` files to boot the server.
* `/docs`: examples and component licenses.
* `/lib`: server `JAR` files.
* `/server`: default server instance folder.
- `/server/conf`: configuration files.
- `/server/data`: data files organized by container name.
- `/server/lib`: extension `JAR` files for custom filters, listeners, and so on.
- `/server/log`: server log files.

== Server Paths
Servers use the following _paths_:

* `infinispan.server.home` defaults to the directory that contains the server
distribution.
* `infinispan.server.root` contains configuration and data for Infinispan
servers and defaults to the `server` directory under `infinispan.server.home`. +
Multiple roots can exist in the same or different directories. To start
multiple server instances you can specify the path to `infinispan.server.root`
with a command line argument.
+
[NOTE]
====
When the server starts it locks `infinispan.server.root` to avoid
concurrent use by multiple server instances.
====
* `infinispan.server.configuration` defaults to `infinispan.xml`, which resides in the `conf` folder under `infinispan.server.root`.

== Command Arguments
The `server.sh|bat` startup script includes arguments that you can use to get
information and configure the server runtime environment.

To view the available command arguments, include the `--help` or `-h` option as follows:

----
$ bin/server.sh -h
----

== Logging Configuration
You configure logging with `log4j2.xml` in the `server/conf` directory.

== Configuration
The server configuration extends the standard Infinispan configuration with the
following server-specific elements:

* `security` configures the available security realms for the endpoints.
* `cache-container` multiple containers may be configured, distinguished by name.
* `endpoints` lists the enabled endpoint connectors (hotrod, rest, and so on).
* `socket-bindings` lists the socket bindings.

The following is an example server configuration:

[source,xml,options="nowrap",subs=attributes+]
----
<infinispan
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:infinispan:config:10.1 https://infinispan.org/schemas/infinispan-config-10.1.xsd
                            urn:infinispan:server:10.1 https://infinispan.org/schemas/infinispan-server-10.1.xsd"
        xmlns="urn:infinispan:config:10.1"
        xmlns:server="urn:infinispan:server:10.1">

   <cache-container default-cache="default" statistics="false">
      <transport cluster="${infinispan.cluster.name}" stack="udp"/>
      <global-state/>
      <distributed-cache name="default"/>
   </cache-container>

   <server xmlns="urn:infinispan:server:10.1">
      <interfaces>
         <interface name="public">
            <loopback/>
         </interface>
         <interface name="admin">
            <loopback/>
         </interface>
      </interfaces>

      <socket-bindings default-interface="public" port-offset="${infinispan.socket.binding.port-offset:0}">
         <socket-binding name="hotrod" port="11222"/>
         <socket-binding name="rest" port="8080"/>
         <socket-binding name="memcached" port="11221"/>
         <socket-binding name="admin" port="9990" interface="admin"/>
      </socket-bindings>

      <security>
         <security-realms>
            <security-realm name="ManagementRealm">
               <properties-realm groups-attribute="Roles">
                  <user-properties path="mgmt-users.properties" relative-to="infinispan.server.config.dir" plain-text="true"/>
                  <group-properties path="mgmt-groups.properties" relative-to="infinispan.server.config.dir" />
               </properties-realm>
            </security-realm>
            <security-realm name="PublicRealm">
               <properties-realm groups-attribute="Roles">
                  <user-properties path="public-users.properties" relative-to="infinispan.server.config.dir" plain-text="true"/>
                  <group-properties path="public-groups.properties" relative-to="infinispan.server.config.dir" />
               </properties-realm>
               <server-identities>
                  <ssl>
                     <keystore path="application.keystore" relative-to="infinispan.server.config.dir"
                               keystore-password="password" alias="server" key-password="password"
                               generate-self-signed-certificate-host="localhost"/>
                  </ssl>
               </server-identities>
            </security-realm>
         </security-realms>
      </security>

      <endpoints>
         <hotrod-connector socket-binding="hotrod"/>
         <memcached-connector socket-binding="memcached"/>
         <rest-connector socket-binding="rest"/>
      </endpoints>
   </server>
</infinispan>
----

== Additional Details
The following is a list of additional details about the server, in no particular order:

* All containers handled by the same server share the same thread pools and transport.
