cloudstore-developers
Changes
generate.sh 32(+32 -0)
pom.xml 15(+12 -3)
README.md 155(+112 -43)
src/main/resources/app-context.xml 3(+1 -2)
src/main/resources/hibernate.xml 6(+3 -3)
src/main/resources/mongodb.xml 2(+1 -1)
Details
generate.sh 32(+32 -0)
diff --git a/generate.sh b/generate.sh
new file mode 100644
index 0000000..0b870d6
--- /dev/null
+++ b/generate.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]
+then
+ echo "Illegal number of parameters"
+ echo "Usage: generate.sh <sql|mongodb>"
+ exit 1
+fi
+
+DB_TYPE=$1
+
+echo "########################"
+echo "# Compiling CloudStore #"
+echo "########################"
+
+mvn install
+
+echo "#######################"
+echo "# Generating database #"
+echo "#######################"
+
+cd src/main/java
+
+if [ $DB_TYPE == "sql" ]
+then
+ java -cp ../../../target/dependency/*:../../../target/classes/ -Deu.cloudscale.datasource=hibernate eu/cloudscale/showcase/generate/Generate sql
+fi
+
+if [ $DB_TYPE == "mongodb" ]
+then
+ java -cp ../../../target/dependency/*:../../../target/classes/ -Deu.cloudscale.datasource=mongodb eu/cloudscale/showcase/generate/Generate mongodb
+fi
pom.xml 15(+12 -3)
diff --git a/pom.xml b/pom.xml
index 8d1dc72..b38ed67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -182,6 +182,7 @@
</dependencies>
<build>
<plugins>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
@@ -311,6 +312,14 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
+ <!-- <dependencies>
+ <dependency>
+ <groupId>eu.cloudscale</groupId>
+ <artifactId>showcase</artifactId>
+ <version>1.0.0-BUILD-SNAPSHOT</version>
+ <type>war</type>
+ </dependency>
+ </dependencies> -->
<configuration>
<executable>java</executable>
<arguments>
@@ -395,15 +404,15 @@
</build>
<profiles>
<profile>
- <id>amazon-hibernate</id>
+ <id>hibernate</id>
<properties>
<eu.cloudscale.environment>aws</eu.cloudscale.environment>
<eu.cloudscale.datasource>hibernate</eu.cloudscale.datasource>
- <eu.cloudscale.showcase.generate.properties>classpath:database/database.aws.hibernate.properties</eu.cloudscale.showcase.generate.properties>
+ <eu.cloudscale.showcase.generate.properties>classpath:database/database.hibernate.properties</eu.cloudscale.showcase.generate.properties>
</properties>
</profile>
<profile>
- <id>amazon-mongodb</id>
+ <id>mongodb</id>
<properties>
<eu.cloudscale.environment>aws</eu.cloudscale.environment>
<eu.cloudscale.datasource>mongodb</eu.cloudscale.datasource>
README.md 155(+112 -43)
diff --git a/README.md b/README.md
index 117bf51..111cebf 100644
--- a/README.md
+++ b/README.md
@@ -21,55 +21,13 @@ To deploy CloudStore on public or private cloud you can use our [deployment scri
Otherwise, you can hand-install CloudStore in your computer or virtual machines, and generate load with Gatling, or manually by connecting your browser to the deployed site.
-## Installing
-
-**NOTICE**: The following installation instructions were tested on Ubuntu 14.04 Linux. For other platforms you may use different commands.
-
-1. Download source code from GitHub:
-
- ```bash
- $ wget https://github.com/CloudScale-Project/CloudStore/archive/v1.zip -O cloudstore.zip
- ```
-
-2. Unpack ```cloudstore.zip```:
-
- ```bash
- $ unzip cloudstore.zip
- ```
-
-3. Change directory to ```CloudStore-1```:
-
- ```bash
- $ cd CloudStore-1
- ```
-
-4. Configure the CloudStore application. See **Configuration** section of this page.
-
-4. Compile source code with Maven from directory where ```pom.xml``` file is located:
-
- ```bash
- $ mvn clean install
- ```
-
-5. Copy ```target/showcase-1.0.0-BUILD-SNAPSHOT.war``` to Tomcat:
-
- ```bash
- $ cp target/showcase-1.0.0-BUILD-SNAPSHOT.war /var/lib/tomcat7/webapps
- ```
-
-6. Restart Tomcat
-
- ```bash
- $ sudo service tomcat7 restart
- ```
-
## Configuration
Before you can use and deploy CloudStore you need to tell CloudStore where the database is and how to connect to it. Since we are using Hibernate ORM to interact with database, CloudStore support multiple SQL databases (tested only with MySQL). We have also implemented support for MongoDB.
#### MySQL configuration
-Edit file ```src/main/resources/database/database.aws.hibernate.properties``` and set:
+Edit file ```src/main/resources/database/database.hibernate.properties``` and set:
1. Configure JDBC driver
@@ -105,6 +63,12 @@ Edit file ```src/main/resources/database/database.aws.hibernate.properties``` an
> jdbc.url=jdbc:mysql:replication://master.example.com,replica1.example.com,replica2.example.com/tpcw?autoReconnect=true
> ```
+3. Configure connection pool size
+
+ ```
+ jdbc.pool_size=150
+ ```
+
3. Configure JDBC credentials
```
@@ -116,8 +80,113 @@ Edit file ```src/main/resources/database/database.aws.hibernate.properties``` an
#### MongoDB configuration
+Edit file ```src/main/resources/database/database.mongodb.properties``` and set:
+
+1. Set database name:
+
+ ```
+ mongodb.dbname=tpcw
+ ```
+
+2. Set database hostname or IP
+
+ ```
+ mongodb.host=127.0.0.1
+ ```
+
+3. Set database port
+
+ ```
+ mongodb.port=27017
+ ```
+
+4. Set database username
+
+ ```
+ mongodb.username=test
+ ```
+
+4. Set connection pool size
+
+ ```
+ mongodb.pool_size=150
+ ```
+
+5. Set database password
+
+ ```
+ mongodb.password=test123
+ ```
+
+## Installing
+
+**NOTICE**: The following installation instructions were tested on Ubuntu 14.04 Linux. For other platforms you may use different commands.
+
+1. Download source code from GitHub:
+
+ ```bash
+ $ wget https://github.com/CloudScale-Project/CloudStore/archive/v1.zip -O cloudstore.zip
+ ```
+
+2. Unpack ```cloudstore.zip```:
+
+ ```bash
+ $ unzip cloudstore.zip
+ ```
+
+3. Change directory to ```CloudStore-1```:
+
+ ```bash
+ $ cd CloudStore-1
+ ```
+
+4. Configure the CloudStore application. See **Configuration** section of this page.
+
+4. Compile source code with Maven from directory where ```pom.xml``` file is located:
+
+ **NOTE**: You must choose for which database provider you want to compile CloudStore. There are two maven profiles ```amazon-hibernate``` and ```amazon-mongodb```.
+
+ Example for MySQL:
+
+ ```bash
+ $ mvn clean install -Phibernate
+ ```
+
+ Example for MongoDB:
+
+ ```bash
+ $ mvn clean install -Pmongodb
+ ```
+
+5. Copy ```target/showcase-1.0.0-BUILD-SNAPSHOT.war``` to Tomcat:
+
+ ```bash
+ $ cp target/showcase-1.0.0-BUILD-SNAPSHOT.war /var/lib/tomcat7/webapps
+ ```
+
+6. Restart Tomcat
+
+ ```bash
+ $ sudo service tomcat7 restart
+ ```
+
## Database
+Database can be generated for both SQL and MongoDB databases or you can use existing dumps that you import into choosen database.
+
+#### Generate database for SQL databases
+
+1. In ```hibernate.xml``` file make sure you have uncommented next line:
+
+ ```
+ <prop key="hibernate.hbm2ddl.auto">update</prop>
+ ```
+
+2. Make sure you have edited the configuration file for database ```src/main/resources/database/database.aws.hibernate.properties```. For more information see **Configuration** section.
+
+3.
+
+
CloudStore uses a MySQL database, which can be generated by running ```Generate.java``` file:
```
diff --git a/src/main/java/eu/cloudscale/showcase/generate/Generate.java b/src/main/java/eu/cloudscale/showcase/generate/Generate.java
index 514235e..622f303 100755
--- a/src/main/java/eu/cloudscale/showcase/generate/Generate.java
+++ b/src/main/java/eu/cloudscale/showcase/generate/Generate.java
@@ -42,7 +42,7 @@ public class Generate
{
if( args.length < 1 )
{
- System.out.println("Usage: $ java Generate <mysql|mongodb>");
+ System.out.println("Usage: $ java Generate <sql|mongodb>");
System.exit(0);
}
@@ -52,9 +52,9 @@ public class Generate
IGenerate db = (IGenerate) context.getBean("generateMongo");
String db_str = "Generating for MongoDB";
- if(args[0].equals("mysql"))
+ if(args[0].equals("sql"))
{
- db_str = "Generating for MySQL";
+ db_str = "Generating for SQL";
db = (IGenerate) context.getBean("generateHibernate");
}
System.out.println(db_str);
src/main/resources/app-context.xml 3(+1 -2)
diff --git a/src/main/resources/app-context.xml b/src/main/resources/app-context.xml
index c3e9893..0c5cafc 100755
--- a/src/main/resources/app-context.xml
+++ b/src/main/resources/app-context.xml
@@ -11,8 +11,7 @@
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<import resource="classpath:cache.xml" />
- <import resource="classpath:hibernate.xml" />
-<!-- <import resource="classpath:hibernate.xml" /> -->
+ <import resource="classpath:${eu.cloudscale.datasource}.xml" />
<import resource="classpath:servlet-context.xml" />
<context:annotation-config />
src/main/resources/hibernate.xml 6(+3 -3)
diff --git a/src/main/resources/hibernate.xml b/src/main/resources/hibernate.xml
index 9e08600..913c418 100755
--- a/src/main/resources/hibernate.xml
+++ b/src/main/resources/hibernate.xml
@@ -18,7 +18,7 @@
http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:property-placeholder
- location="classpath:database/database.aws.hibernate.properties" />
+ location="classpath:database/database.hibernate.properties" />
<context:component-scan base-package="eu.cloudscale.showcase.db.dao.hibernate" />
<bean id="service" class="eu.cloudscale.showcase.db.services.HibernateService" />
@@ -33,7 +33,7 @@
<!-- these are C3P0 properties -->
<property name="acquireIncrement" value="1" />
<property name="minPoolSize" value="4" />
- <property name="maxPoolSize" value="${connection_pool_size}" />
+ <property name="maxPoolSize" value="${jdbc.pool_size}" />
<!-- <property name="maxPoolSize" value="500"/> -->
<!-- <property name="maxIdleTime" value="30" /> -->
<!-- <property name="maxConnectionAge" value="180" /> -->
@@ -59,7 +59,7 @@
<property name="packagesToScan" value="eu.cloudscale.showcase.db.dao" />
<property name="hibernateProperties">
<props>
-<!-- <prop key="hibernate.hbm2ddl.auto">create-drop</prop> -->
+<!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
<!-- <prop key="hibernate.jdbc.batch_size">1000</prop> -->
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
src/main/resources/mongodb.xml 2(+1 -1)
diff --git a/src/main/resources/mongodb.xml b/src/main/resources/mongodb.xml
index 30cd791..5effc5b 100755
--- a/src/main/resources/mongodb.xml
+++ b/src/main/resources/mongodb.xml
@@ -23,7 +23,7 @@
<mongo:mongo host="${mongodb.host}" port="${mongodb.port}" >
- <mongo:options connections-per-host="${connection_pool_size}"
+ <mongo:options connections-per-host="${mongodb.pool_size}"
connect-timeout="30000"
/>
</mongo:mongo>