1414import java .util .List ;
1515import java .util .Map ;
1616import java .util .Properties ;
17- import java .util .concurrent .Executors ;
1817
1918import javax .sql .DataSource ;
2019
2726
2827import httl .Engine ;
2928import httl .Template ;
29+ import io .netty .channel .nio .NioEventLoopGroup ;
3030
3131public class Server {
3232
@@ -54,10 +54,22 @@ private static List<Fortune> queryFortunes(DataSource ds) throws SQLException {
5454 private static DataSource createPostgresDataSource () throws ClassNotFoundException {
5555 Class .forName ("org.postgresql.Driver" );
5656 HikariConfig config = new HikariConfig ();
57+
5758 config .setJdbcUrl ("jdbc:postgresql://tfb-database:5432/hello_world" );
5859 config .setUsername ("benchmarkdbuser" );
5960 config .setPassword ("benchmarkdbpass" );
60- config .setMaximumPoolSize (512 );
61+
62+ config .setMaximumPoolSize (520 );
63+ config .setMinimumIdle (512 );
64+
65+ config .setConnectionTimeout (30000 );
66+ config .setIdleTimeout (600000 );
67+ config .setMaxLifetime (1800000 );
68+
69+ config .setAutoCommit (true );
70+
71+ config .setPoolName ("PostgreSQL-HikariCP-Pool" );
72+
6173 return new HikariDataSource (config );
6274 }
6375
@@ -135,7 +147,7 @@ static void main(String[] args) throws Exception {
135147 System .setProperty ("org.slf4j.simpleLogger.defaultLogLevel" , "DEBUG" );
136148 // create server
137149 HttpServer server = HttpServer .create (new InetSocketAddress (port ), 1024 * 8 );
138- server .setExecutor (Executors . newVirtualThreadPerTaskExecutor ( ));
150+ server .setExecutor (new NioEventLoopGroup ( 1 ));
139151 server .createContext ("/plaintext" , createPlaintextHandler ());
140152 server .createContext ("/json" , createJSONHandler ());
141153 if (settings .contains ("postgres" )) {
@@ -145,4 +157,4 @@ static void main(String[] args) throws Exception {
145157 // start server
146158 server .start ();
147159 }
148- }
160+ }
0 commit comments