The requirements to install a working copy of the sla core are:
- Oracle JDK >=1.6
- Database to install the database schema for the service: Mysql>=5.0
- Maven >= 3.0
All commands shown here are ready to be executed from the root directory of the project (i.e., the one with the configuration.properties file)
###1. Download the project ###
Download the project using a git client from sla core repository
$ git clone https://github.com/modaclouds/modaclouds-sla-core.git
It is recommended to use the master branch as it is always the latest released version.
###2. Creating the mysql database ###
From mysql command tool, create a database (with a user with sufficient privileges, as root):
$ mysql -p -u root
mysql> CREATE DATABASE atossla;
Create a user:
mysql> CREATE USER atossla@localhost IDENTIFIED BY '_atossla_';
mysql> GRANT ALL PRIVILEGES ON atossla.* TO atossla@localhost; -- * optional WITH GRANT OPTION;
From command prompt, create needed tables:
$ mvn test exec:java -f sla-repository/pom.xml
Another option to create the database is execute a sql file from the project root directory:
$ bin/restoreDatabase.sh
The names used here are the default values of the sla core. See configuration to know how to change the values.
###3. Importing the code into eclipse ###
The core of the ATOSSLA has been developed using the Eclipse Java IDE, although others Java editors could be used, here we only provide the instructions about how to import the code into Eclipse.
The first step is to tell Maven to create the necessary Eclipse project files executing this:
$ mvn eclipse:eclipse
The previous command is going to generate the eclipse project files: .settings, .classpath, and .project. Again, please never upload those files to the repository, it is going to deconfigure the eclipse of other developers (it is easy to fix, just an annoying waste of time).
After it, from your eclipse you can import the project. Go to "import project from file", go to the trunk folder, and you should see the "ATOSSLA" project ready to be imported in your Eclipse.
The project is made up of five main modules:
- SLA Repository
- SLA Enforcement
- SLA Service
- SLA Tools
- SLA Personalization
A configuration.properties.sample that is placed in the parent directory has to be copied to configuration.properties.
Several parameters can be configured through this file.
- tomcat.directory when building, war will be automatically copied to this directory,
- db.* allows to configure the database username, password and name in case it has been changed from the proposed one in the section Creating the mysql database. It can be selected if queries from hibernate must be shown or not. These parameters can be overriden at deployment time through the use of environment variables (see section Running),
- log.* allows to configure the log files to be generated and the level of information,
- enforcement.* several parameters from the enforcement can be customized,
- service.basicsecurity.* basic security is enabled These parameters can be used to set the user name and password to access to the rest services.
- ''parser.*'' different parsers can be implemented for the agreement and template. By default, wsag standard parsers are have been implemented and configured in the file. Also dateformat can be configured.
If you're creating the database using the command mvn test exec:java -f sla-repository/pom.xml please make sure that you configure properly sla-repository\src\main\resources\META-INF\persistence.xml. Make sure you're setting the username, password and connection url with the proper parameters.
<property name="hibernate.connection.username" value="atossla" />
<property name="hibernate.connection.password" value="_atossla_" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/atossla" />
$ mvn install
If you want to skip tests:
$ mvn install -Dmaven.test.skip=true
The result of the command is a war in sla-service/target. The war is also copied to the directory pointed by tomcat.directory in the configuration.properties file.
If the war was successfully copied to tomcat.directory, then start your tomcat to run the server.
Alternatively, you can run an embedded tomcat:
$ bin/runserver.sh
that is just a shortcut for:
$ mvn tomcat:run -f sla-service/pom.xml
Some configuration parameters can be overriden using environment variables or jdk variables. The list of parameters overridable is:
DB_DRIVER
; default value iscom.mysql.jdbc.Driver
DB_URL
; default value isjdbc:mysql://${db.host}:${db.port}/${db.name}
DB_USERNAME
; default value is${db.username}
DB_PASSWORD
; default value is${db.password}
DB_SHOWSQL
; default value is${db.showSQL}
F.e., to use a different database configuration:
$ export DB_URL=jdbc:mysql://localhost:3306/sla
$ export DB_USERNAME=sla
$ export DB_PASSWORD=<secret>
$ bin/runserver.sh
Check that everything is working:
$ curl http://localhost:8080/sla-service/providers
The actual address depends on the tomcat configuration. The embedded tomcat uses http://localhost:8080/sla-service/ as service root url.
Time to check the User Guide!