Requirements
-------------------------------------
1. JDK 11 suitable for your platform.
2. Supported browsers: Chrome, Firefox, Safari, Edge.

How to run
-------------------------------------
1. Unpack gridgain-control-center-on-premise-<version>.zip to some folder.
2. Change work directory to folder where GridGain Control Center was unpacked.
3. Start control-center.{bat|sh} executable for your platform.

4. Open URL `http://localhost:3000` in browser to sign up as a regular user
	OR
   Open the link `http://localhost:3000/auth/signup?adminToken=<token>` to sign up as an Administrator.
   This link can be found in application's log.
5. Sign up to create a user.

Technical details
-------------------------------------
1. Package content:
    `libs` - this folder contains GridGain Control Center dependencies.
    `work` - this folder contains all GridGain Control Center data (registered users, created objects, ...) and
     should be preserved in case of update to new version.
2. Gridgain Control Center will start on default HTTP port `3000` and bind to all interfaces `0.0.0.0`.


You can use properties files, YAML files, environment variables to externalize configuration.

Properties are considered in the following order:
1. Java System properties (System.getProperties()).
2. OS environment variables.
3. Properties in /config subdirectory of the work directory or in work directory (application.properties and YAML variants).
   YAML format description can be found here: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-yaml


Various properties can be specified inside your application.properties file, inside your application.yml file, or Java System properties.
This appendix provides a list of common Spring Boot properties and references to the underlying classes that consume them:

# Initial Admin account.
account.admin.email=admin@example.com # Email of initial Admin
account.admin.password=123456 # Password of initial Admin

# Sign up configuration.
account.signup.enabled=true # Enable self-registration
account.activation.enabled=false # Enable account activation
account.activation.timeout=1800000 # Activation timeout(milliseconds)
account.activation.send-timeout=180000 # Activation email sending throttle (milliseconds)

# Sign in configuration.
account.authentication.max-attempts=Infinity # Specifies the maximum number of failed attempts allowed before preventing login.
account.authentication.interval=100 # Specifies the interval between login attempts, which increases exponentially based on the number of failed attempts (milliseconds).
account.authentication.max-interval=300000 # Specifies the maximum time that account can be locked for (milliseconds).

account.global-team.enabled=false # Enable global team, includes all users.
account.global-team.attach-cluster=false # Automatic cluster attachment to the global team after a successful handshake.

control.agent.secret-validation.enabled=true # Enable cluster secret validation on handshake.

# Embedded server configuration.
server.address=0.0.0.0 # Network address to which the GridGain Control Center should bind.
server.port=3000 # GridGain Control Center port.
spring.session.timeout=604800000 # The user session lifetime (milliseconds, 7 days by default).

control.repositories.auto-migrate-enabled=false # Enable auto-migration of internal storage.
control.base-url= # Control Center URL for links in notifications. If frontend and backend have different hosts/ports,
    please set frontend’s URI as a value (e.g. https://example.com:1234).
control.browsers.allowed-origins= # A comma-separated allowed origins for the WebSocket browsers endpoint.
control.web-socket.send-buffer-size-limit=Maximum amount of data to buffer when sending messages to a WebSocket session (in bytes).

# Repositories configuration
control.repositories.configurations.{cacheName}.data-region-name= # Custom data region for the cache. The property can be used for storing browser sessions (GccSessionCache) in the in-memory data region.
control.cache.backups= # Number of backups for all partitioned caches, configured with control.repositories.configurations.* properties.

# Metrics configuration.
control.metric.ttl= # Metrics TTL after that they will be removed. Set 0 for infinite TTL (in days, default: 1 day).
control.metric.limit=0 # By default is 0 which means no limit. If >0 allowed number of metrics per cluster will be stored. The oldest metrics will be deleted.
control.metric.bufRatio=1.1 # Coefficient which is applied to the "control.metric.limit". If it is 1.1 and the limit is 100, that means that when metric count reaches 110, delete job will clean outdated metrics(110-100=10 oldest metrics will be deleted).
control.metric-collector.limit-enabled=true # Metrics limit enabled flag. If false, all the metrics will be collected from a cluster. Otherwise, metrics will be collected on demand.
control.metric-collector.limit-file-path=classpath:metrics.yml # The path to yaml file with metric templates that must always be collected. Has no effect if limit-enabled is false.

# Email (MailProperties)
spring.mail.default-encoding=UTF-8 # Default MimeMessage encoding.
spring.mail.host= # SMTP server host. For instance, `smtp.example.com`.
spring.mail.jndi-name= # Session JNDI name. When set, takes precedence over other Session settings.
spring.mail.port= # SMTP server port.
spring.mail.properties.*= # Additional JavaMail Session properties.
spring.mail.protocol=smtp # Protocol used by the SMTP server.
spring.mail.username= # Login user of the SMTP server.
spring.mail.password= # Login password of the SMTP server.

# SMS (SmsProperties) - currently Control Center supports "vonage.com" only.
nexmo.creds.api-key= # API key from account.
nexmo.creds.api-secret= # API secret from account.
nexmo.creds.from= # The name or number the message should be sent from.

# SSL options.
server.ssl.ciphers= # Supported SSL ciphers.
server.ssl.client-auth= # Client authentication mode.
server.ssl.enabled=true # Whether to enable SSL support.
server.ssl.enabled-protocols= # Enabled SSL protocols.
server.ssl.key-alias= # Alias that identifies the key in the key store.
server.ssl.key-password= # Password used to access the key in the key store.
server.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file).
server.ssl.key-store-password= # Password used to access the key store.
server.ssl.key-store-provider= # Provider for the key store.
server.ssl.key-store-type= # Type of the key store.
server.ssl.protocol=TLS # SSL protocol to use.
server.ssl.trust-store= # Trust store that holds SSL certificates.
server.ssl.trust-store-password= # Password used to access the trust store.
server.ssl.trust-store-provider= # Provider for the trust store.
server.ssl.trust-store-type= # Type of the trust store.

# Rate limit
control.rate-limit.ban-duration-seconds= # Duration of ban.
control.rate-limit.candidates= # Number of candidates with top statistics that would be banned.
control.rate-limit.hard-limit= # Number of messages in the queue.
control.rate-limit.soft-limit= # Number of messages in the queue.
control.rate-limit.disconnected-lifetime-seconds= # Lifetime of the rate limit session without connection.
control.rate-limit.update-interval-millis= # Scheduled interval for alert check.
control.rate-limit.remove-session-interval-millis= # Scheduled interval for session removing check.

# License configuration
control.license.filestorage= # Flag that enables file watcher for license updates. (default: false)
control.license.path= # License monitoring path for file watcher. (default: license/control-center-license.xml)

# OpenID Connect configuration. Replace XXXXX with your provider name.
spring.security.oauth2.client.registration.XXXXX.client-id= # Registered client ID in provider.
spring.security.oauth2.client.registration.XXXXX.client-secret= # Secret for registered client ID.
spring.security.oauth2.client.provider.XXXXX.authorization-uri= # Authorization URI for the provider.
spring.security.oauth2.client.provider.XXXXX.token-uri= # Token URI for the provider.
spring.security.oauth2.client.provider.XXXXX.jwk-set-uri= # JWK set URI for the provider.

# Active Directory configuration.
Control Center can be configured to use Active Directory as a source of user information.

Active Directory integration uses "BIND" operation to authenticate users.

NOTE: Active Directory integration cannot be used together with native or OpenID-Connect-based authentication.

spring.activedirectory.urls= # URLs of the server, comma-separated. (Example: ldap://localhost:389,ldap://localhost:8389)
spring.activedirectory.domain= # Default domain name, which can be added to the user login, if the domain is not specified. (Example: gridgain.org)
spring.activedirectory.rootDn= # Base path from which all operations should originate. (Example: dc=gridgain,dc=org)
spring.activedirectory.adminRole="Domain Admins" # The name of the user group with admin permissions.

# Uploaded artifact properties.
spring.servlet.multipart.max-file-size= # Limit of uploaded artifact file size. (default: 100 MB)

# LDAP configuration.
Control Center can be configured to use LDAP as a source of user information.

By default, LDAP integration uses password comparison authenticator which compares the login password with the value
stored in the directory using a remote LDAP "compare" operation.

NOTE: LDAP integration cannot be used together with native or OpenID-Connect-based authentication.

spring.ldap.urls= # LDAP URLs of the server, comma-separated. (Example: ldap://localhost:389,ldap://localhost:8389)
spring.ldap.base= # Base path from which all operations should originate. (Example: dc=gridgain,dc=org)
spring.ldap.admin-role=admin # The name of the user group with admin permissions.
spring.ldap.bind-authenticator.enabled=false # Enable authenticator which binds as a user.
spring.ldap.password-comparison-authenticator.password-attribute-name=userPassword # The field name where the password is stored.
spring.ldap.user-details.group-role-attribute=cn # The ID of the attribute which contains the role name for a group.
spring.ldap.user-details.group-member-attributeName=uniquemember # Name of the multi-valued attribute which holds the DNs of users who are members of a group.
spring.ldap.user-details.group-search-base=ou=groups # The Distinguished Name under which groups are stored.
spring.ldap.user-details.user-search-base=ou=people # The Distinguished Name under which users are stored.
spring.ldap.user-details.user-search-filter=uid={0} # The filter expression used in the user search. This is an LDAP search filter (as defined in 'RFC 2254') with optional arguments.


HTTPS setup (with self-signed certificate) between cluster and GridGain Control Center
-------------------------------------
1. Generate self-signed certificate.
2. Configure GridGain Control Center to use SSL port: 443 and key-store with generated certificate.
3. Configure your cluster to use SSL with help of management.sh utility.
For more information execute: management.sh --help

For example, the properties for GridGain Control Center can be specified as:
server.port=443
server.ssl.key-store-type=JKS
server.ssl.key-store=certificates/server.jks
server.ssl.key-store-password=change_me


Database(s) configuration
-------------------------------------
The following property can be used to specify custom database(s) configuration in "application.properties":
ignite.configurations=<Path to configuration file or XML configuration>

Or using environment variable:
IGNITE_CONFIGURATIONS=<Path to configuration file or XML configuration>

Or using system properties:
-Dignite.configurations=<Path to configuration file or XML configuration>

For example:
ignite.configurations=classpath:ignite-config.xml
ignite.configurations=file:\some\path\custom-ignite-config.xml
ignite.configurations=<?xml version... XML content ...>

Configuration "classpath:ignite-config.xml" will be used as default and available out of the box.
It contains configuration for single-node isolated cluster and suitable for development or small production usages.

This is an example of default Control Center configuration that can be changed over ignite.configurations property:
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="consistentId" value="ggcc-db"/>
        <property name="metricsLogFrequency" value="0"/>

        <!-- Disable all clients. -->
        <property name="connectorConfiguration"><null/></property>
        <property name="clientConnectorConfiguration"><null/></property>

        <!-- Persistence required to store user data on disk. -->
        <property name="dataStorageConfiguration">
            <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                <property name="walSegmentSize" value="#{512L * 1024L * 1024L}"/>

                <property name="defaultDataRegionConfiguration">
                    <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                        <property name="persistenceEnabled" value="true"/>
                        <!-- Set region size, because default size is 20% of physical memory available on current machine. -->
                        <property name="maxSize" value="#{256 * 1024 * 1024}"/>
                    </bean>
                </property>

                <property name="dataRegionConfigurations">
                    <list>
                        <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                            <property name="name" value="in-memory"/>
                            <property name="maxSize" value="#{128 * 1024L * 1024L}"/>
                        </bean>
                    </list>
                </property>
            </bean>
        </property>

        <!-- Logging configuration. -->
        <property name="gridLogger">
            <bean class="org.apache.ignite.logger.log4j2.Log4J2Logger">
                <constructor-arg type="java.lang.String" value="log4j2.xml"/>
            </bean>
        </property>

        <property name="communicationSpi">
            <bean class="org.gridgain.gmc.discovery.IsolatedCommunicationSpi"/>
        </property>

        <property name="discoverySpi">
            <bean class="org.gridgain.gmc.discovery.IsolatedDiscoverySpi"/>
        </property>
    </bean>
</beans>

It is possible to setup separate data storage for users data, metrics and traces.
In this case GridGain Control Center will start three internal client nodes to connect to external clusters.
This will improve scalability and fault tolerance of GridGain Control Center.
To achieve this goal, define Spring XML configuration with three beans of IgniteConfiguration for three clients
that should connect to different clusters and pass it to GridGain Control Center via "ignite.configurations" property.

Beans should have the following predefined names: USERS_IGNITE_CONFIG, METRICS_IGNITE_CONFIG and TRACES_IGNITE_CONFIG, COMPUTE_IGNITE_CONFIG.

This is an example of how the Control Center can be configured to store its internal information in three different GridGain clusters:
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!-- Client node for connecting to database with users data. -->
    <bean class="org.apache.ignite.configuration.IgniteConfiguration" name="USERS_IGNITE_CONFIG">
        <property name="clientMode" value="true"/>

        <!-- Setup discovery to cluster with users data. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="localPort" value="47500"/>
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <!-- Other settings -->
    </bean>

    <!-- Client node for connecting to database with metrics. -->
    <bean class="org.apache.ignite.configuration.IgniteConfiguration" name="METRICS_IGNITE_CONFIG">
        <property name="clientMode" value="true"/>

        <!-- Setup discovery to cluster with metrics. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="localPort" value="47600"/>
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47600</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <!-- Other settings -->
    </bean>

    <!-- Client node for connecting to database with traces. -->
    <bean class="org.apache.ignite.configuration.IgniteConfiguration" name="TRACES_IGNITE_CONFIG">
        <property name="clientMode" value="true"/>

        <!-- Setup discovery to cluster with traces. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="localPort" value="47700"/>
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47700</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <!-- Other settings -->
    </bean>

    <!-- Client node for connecting to database with compute. -->
        <bean class="org.apache.ignite.configuration.IgniteConfiguration" name="COMPUTE_IGNITE_CONFIG">
            <property name="clientMode" value="true"/>

            <!-- Setup discovery to cluster with compute. -->
            <property name="discoverySpi">
                <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                    <property name="localPort" value="47800"/>
                    <property name="ipFinder">
                        <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                            <property name="addresses">
                                <list>
                                    <value>127.0.0.1:47800</value>
                                </list>
                            </property>
                        </bean>
                    </property>
                </bean>
            </property>

            <!-- Other settings -->
        </bean>
</beans>
