Small HTTP server with DB. This is a test job.
You should use Apache Ant to build project. Build.xml placed in /ant.
You can just run ant in this directory to build and run project - or - see command list:
ant compile-- To compile only.ant build.jar-- To compile and create a jar-file.antorant run-- compile, build jar and run the program with default settings. Notice that folder/buildwill be overwritten.
Edit default settings right in build.xml. Default settings for ant build project:- [Port = 3000] - See line
<property name="port" value="3000"/>
To build project without Ant
Summary:
- JRE1.6
- libraries:
../lib/*.jar - sources:
../src/nettyserver - Main-class:
nettyserver/NettyServer
See Implementation details below.
To run program without Ant, run it from command line.
java -jar NettyServer.jar [port]
If everything ok, program will type:
Web server started at port 3000
type "stop" to stop server
Default port is 3000. So, to check server, enter to address line in your browser http://localhost:3000/status.
According to the test job features list, there is 3 pages:
/status-- shows the statistic page/hello-- after 10 seconds says "Hello page"/redirect?url=<url>-- redirects to the specified in GET request URL.
Project uses Netty framework. Number of threads by default = 2 * Cores.
+---ant
| build.xml
|
+---benchmark
| *.txt
|
+---build
| | NettyServer.jar
| +---classes
| | *.class
| \---localdb
| *
|
+---lib
| hsqldb.jar
| netty-all-4.0.10.Final.jar
|
+---screens
| *.png;*.jpg
|
\---src
\---nettyserver
Database.java
HttpServerHandler.java
HttpServerInitializer.java
ManualDBForm.java
NettyServer.java
StatDAO.java
StatusHolder.java
- ant -- contains build script for Apache Ant
- benchmark -- Apache benchmark results
- build -- destination folder for build project
- build/localdb -- will be created automatically
- lib -- used libraries
- screens -- screenshots
- src -- source code
Main-class: NettyServer
NettyServer-- Starts and stops server.Database-- provides access to DatabaseHttpServerInitializer-- specify pipeline factory, means how we will handle connectionsHttpServerHandler-- Http handler. Accepts http requests and responds to them.ManualDBForm-- Debug tool.StatDAO-- implements methods to work with Database.StatusHolder-- synchronized counter
See JavaDoc for more details.
This project uses embedded HSQL DB. It's fast and thread-safe.
Database files placed in folder /localdb in build directory.
To change DBMS edit Database class.
Besides see StatDAO class, that contains all SQL code, to use your specific DBMS features.
Database contains only two tables. Connections for each accepted request
and URI for storing text strings and aggregated data.
Benchmark details: CPU: Athlon x64 631 @2.6Ghz 4 Cores. RAM: 8 GB. Max heap size: 512Mb.
Description: Apache benchmark compare the size of each response to the first received.
Status page generated dynamically, so obviously there is a lot of failed requests by lengths.



