Database in work. Added connection pool, etc
This commit is contained in:
Generated
+10
@@ -0,0 +1,10 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Environment-dependent path to Maven home directory
|
||||
/mavenHomeManager.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+1
@@ -0,0 +1 @@
|
||||
Lab7
|
||||
Generated
+18
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="Prog7_db" uuid="5db54927-fd03-4a15-9a4b-e13a7ce66528">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<configured-by-url>true</configured-by-url>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://aklivtsov.tech:5430/prog7_db</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+19
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/client" />
|
||||
<option value="$PROJECT_DIR$/common" />
|
||||
<option value="$PROJECT_DIR$/server" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="VulnerableLibrariesLocal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="isIgnoringEnabled" value="true" />
|
||||
<option name="ignoredModules">
|
||||
<list>
|
||||
<option value="Lab7.server" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredPackages">
|
||||
<list>
|
||||
<option value="ch.qos.logback:logback-core:1.5.20" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredReasons">
|
||||
<list>
|
||||
<option value="Not exploitable" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="2.2.0" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/server/src/main/kotlin/database/tables/DDLVersion.sql" dialect="PostgreSQL" />
|
||||
<file url="PROJECT" dialect="PostgreSQL" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
id 'org.jetbrains.dokka' version '2.2.0'
|
||||
}
|
||||
|
||||
group = 'lab6.prog'
|
||||
group = 'lab7.prog'
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ plugins {
|
||||
id 'org.jetbrains.dokka' version '2.2.0'
|
||||
}
|
||||
|
||||
group = 'lab6.prog'
|
||||
group = 'lab7.prog'
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
@@ -13,7 +13,7 @@ repositories {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set('Lab6-client')
|
||||
archiveBaseName.set('Lab7-client')
|
||||
archiveVersion.set('1.0')
|
||||
manifest {
|
||||
attributes 'Main-Class': 'MainKt'
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
||||
id 'org.jetbrains.dokka' version '2.2.0'
|
||||
}
|
||||
|
||||
group = 'lab6.prog'
|
||||
group = 'lab7.prog'
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -42,6 +42,8 @@ data class HumanBeing(
|
||||
require(name.isNotBlank()) { "Имя не может быть пустым" }
|
||||
}
|
||||
|
||||
fun getFuckingCar(): Car = car
|
||||
|
||||
/**
|
||||
* Сравниваем по имени и id
|
||||
*/
|
||||
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
# Техническое задание к программе
|
||||
|
||||
**Необходимо выполнить следующие требования:**
|
||||
|
||||
- Операции обработки объектов коллекции должны быть реализованы с помощью Stream API с использованием лямбда-выражений.
|
||||
- Объекты между клиентом и сервером должны передаваться в сериализованном виде.
|
||||
- Объекты в коллекции, передаваемой клиенту, должны быть отсортированы по названию
|
||||
- Клиент должен корректно обрабатывать временную недоступность сервера.
|
||||
- Обмен данными между клиентом и сервером должен осуществляться по протоколу UDP
|
||||
- Для обмена данными на сервере необходимо использовать **датаграммы**
|
||||
- Для обмена данными на клиенте необходимо использовать **сетевой канал**
|
||||
- Сетевые каналы должны использоваться в неблокирующем режиме.
|
||||
|
||||
**Обязанности серверного приложения:**
|
||||
|
||||
- Работа с файлом, хранящим коллекцию.
|
||||
- Управление коллекцией объектов.
|
||||
- Назначение автоматически генерируемых полей объектов в коллекции.
|
||||
- Ожидание подключений и запросов от клиента.
|
||||
- Обработка полученных запросов (команд).
|
||||
- Сохранение коллекции в файл при завершении работы приложения.
|
||||
- Сохранение коллекции в файл при исполнении специальной команды, доступной только серверу (клиент такую команду отправить не может).
|
||||
|
||||
**Серверное приложение должно состоять из следующих модулей (реализованных в виде одного или нескольких классов):**
|
||||
|
||||
- Модуль приёма подключений.
|
||||
- Модуль чтения запроса.
|
||||
- Модуль обработки полученных команд.
|
||||
- Модуль отправки ответов клиенту.
|
||||
|
||||
Сервер должен работать в **однопоточном** режиме.
|
||||
|
||||
**Обязанности клиентского приложения:**
|
||||
|
||||
- Чтение команд из консоли.
|
||||
- Валидация вводимых данных.
|
||||
- Сериализация введённой команды и её аргументов.
|
||||
- Отправка полученной команды и её аргументов на сервер.
|
||||
- Обработка ответа от сервера (вывод результата исполнения команды в консоль).
|
||||
- Команду `save` из клиентского приложения необходимо убрать.
|
||||
- Команда `exit` завершает работу клиентского приложения.
|
||||
|
||||
**Важно!** Команды и их аргументы должны представлять из себя объекты классов. Недопустим обмен "простыми" строками. Так, для команды add или её аналога необходимо сформировать объект, содержащий тип команды и объект, который должен храниться в вашей коллекции.
|
||||
|
||||
**Принцип работы клиентской части**
|
||||
|
||||
1. ввод команды
|
||||
2. валидация команды (без запроса на сервер, у клиента должна быть информация о доступных командах)
|
||||
3. ввод аргументов
|
||||
4. запрос на сервер
|
||||
5. обработка ответа от сервера
|
||||
6. вывод информации
|
||||
|
||||
**Принцип работы серверного приложения**
|
||||
|
||||
1. подключение
|
||||
3. получение запроса
|
||||
4. выполнение команды
|
||||
5. отправка ответа
|
||||
|
||||
**Примечания**
|
||||
|
||||
1. сервер может работать сразу с несколькими клиентами, но не параллельно
|
||||
2. клиент продолжает работать даже если сервер -- нет (должно быть информирование пользователя о том, что сервер умер + попытки подключения раз в N секунд)
|
||||
3. Общение между клиентом и сервером должно быть в виде json строк
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
2026-05-12 14:05:57.738 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS coordinates (id uuid PRIMARY KEY, x BIGINT NULL, y INT NULL)
|
||||
2026-05-12 14:05:58.287 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS car (id uuid PRIMARY KEY, cool BOOLEAN NULL)
|
||||
2026-05-12 14:16:46.098 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS humanbeing (id uuid PRIMARY KEY, "name" TEXT NOT NULL, coordinates uuid NOT NULL, last_name TEXT NOT NULL, creation_date DATE NOT NULL, real_hero BOOLEAN NOT NULL, has_toothpick BOOLEAN NOT NULL, impact_speed DOUBLE PRECISION NOT NULL, soundtrack_name TEXT NOT NULL, minutes_of_waiting REAL NOT NULL, car uuid NOT NULL, weapon_type weapontype DEFAULT NULL NULL, CONSTRAINT fk_humanbeing_coordinates__id FOREIGN KEY (coordinates) REFERENCES coordinates(id) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT fk_humanbeing_car__id FOREIGN KEY (car) REFERENCES car(id) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
2026-05-12 14:16:47.666 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:21:34.382 [main] DEBUG Exposed - CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
2026-05-12 14:21:34.985 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS coordinates (id uuid PRIMARY KEY, x BIGINT NULL, y INT NULL)
|
||||
2026-05-12 14:21:35.347 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS car (id uuid PRIMARY KEY, cool BOOLEAN NULL)
|
||||
2026-05-12 14:21:36.019 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS humanbeing (id uuid PRIMARY KEY, "name" TEXT NOT NULL, coordinates uuid NOT NULL, last_name TEXT NOT NULL, creation_date DATE NOT NULL, real_hero BOOLEAN NOT NULL, has_toothpick BOOLEAN NOT NULL, impact_speed DOUBLE PRECISION NOT NULL, soundtrack_name TEXT NOT NULL, minutes_of_waiting REAL NOT NULL, car uuid NOT NULL, weapon_type weapontype DEFAULT NULL NULL, CONSTRAINT fk_humanbeing_coordinates__id FOREIGN KEY (coordinates) REFERENCES coordinates(id) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT fk_humanbeing_car__id FOREIGN KEY (car) REFERENCES car(id) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
2026-05-12 14:21:37.369 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:24:23.769 [main] DEBUG Exposed -
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
2026-05-12 14:24:24.681 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS coordinates (id uuid PRIMARY KEY, x BIGINT NULL, y INT NULL)
|
||||
2026-05-12 14:24:24.982 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS car (id uuid PRIMARY KEY, cool BOOLEAN NULL)
|
||||
2026-05-12 14:24:25.494 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS humanbeing (id uuid PRIMARY KEY, "name" TEXT NOT NULL, coordinates uuid NOT NULL, last_name TEXT NOT NULL, creation_date DATE NOT NULL, real_hero BOOLEAN NOT NULL, has_toothpick BOOLEAN NOT NULL, impact_speed DOUBLE PRECISION NOT NULL, soundtrack_name TEXT NOT NULL, minutes_of_waiting REAL NOT NULL, car uuid NOT NULL, weapon_type weapontype DEFAULT NULL NULL, CONSTRAINT fk_humanbeing_coordinates__id FOREIGN KEY (coordinates) REFERENCES coordinates(id) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT fk_humanbeing_car__id FOREIGN KEY (car) REFERENCES car(id) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
2026-05-12 14:24:27.035 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:24:33.803 [main] DEBUG Exposed -
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
2026-05-12 14:24:36.459 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:34:18.008 [main] DEBUG Exposed -
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
2026-05-12 14:34:20.947 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:42:52.429 [main] DEBUG com.zaxxer.hikari.HikariConfig - Driver class org.postgresql.Driver found in Thread context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@1dbd16a6
|
||||
2026-05-12 14:42:52.435 [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension................................false
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit................................false
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog................................none
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql................................none
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery................................none
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout................................30000
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource................................none
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName................................none
|
||||
2026-05-12 14:42:52.437 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI................................none
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties................................{password=<masked>}
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................................"org.postgresql.Driver"
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - exceptionOverrideClassName................................none
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties................................{}
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry................................none
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout................................600000
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout................................1
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries................................false
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl................................jdbc:postgresql://aklivtsov.tech:5430/prog7_db
|
||||
2026-05-12 14:42:52.438 [main] DEBUG com.zaxxer.hikari.HikariConfig - keepaliveTime................................0
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold................................0
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime................................1800000
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize................................10
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry................................none
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory................................none
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle................................10
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - password................................<masked>
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName................................"HikariPool-1"
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly................................false
|
||||
2026-05-12 14:42:52.439 [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans................................false
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor................................none
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - schema................................none
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory................................internal
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation................................"TRANSACTION_REPEATABLE_READ"
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - username................................"mainUser"
|
||||
2026-05-12 14:42:52.440 [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout................................5000
|
||||
2026-05-12 14:42:52.441 [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
|
||||
2026-05-12 14:42:52.441 [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension................................false
|
||||
2026-05-12 14:42:52.441 [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit................................false
|
||||
2026-05-12 14:42:52.441 [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout................................30000
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties................................{password=<masked>}
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................................"org.postgresql.Driver"
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - exceptionOverrideClassName................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties................................{}
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry................................none
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout................................600000
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout................................1
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries................................false
|
||||
2026-05-12 14:42:52.442 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl................................jdbc:postgresql://aklivtsov.tech:5430/prog7_db
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - keepaliveTime................................0
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold................................0
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime................................1800000
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize................................10
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry................................none
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory................................none
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle................................10
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - password................................<masked>
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName................................"HikariPool-1"
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly................................false
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans................................false
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor................................none
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - schema................................none
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory................................internal
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation................................"TRANSACTION_REPEATABLE_READ"
|
||||
2026-05-12 14:42:52.443 [main] DEBUG com.zaxxer.hikari.HikariConfig - username................................"mainUser"
|
||||
2026-05-12 14:42:52.444 [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout................................5000
|
||||
2026-05-12 14:42:52.445 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
|
||||
2026-05-12 14:42:53.357 [main] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Failed to create/setup connection: FATAL: password authentication failed for user "mainUser"
|
||||
2026-05-12 14:42:53.357 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Cannot acquire connection from data source
|
||||
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "mainUser"
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:778)
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:234)
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:289)
|
||||
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:57)
|
||||
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:279)
|
||||
at org.postgresql.Driver.makeConnection(Driver.java:448)
|
||||
at org.postgresql.Driver.connect(Driver.java:298)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
|
||||
at database.DatabaseManager.start(DatabaseManager.kt:23)
|
||||
at database.DatabaseManagerKt.main(DatabaseManager.kt:57)
|
||||
2026-05-12 14:42:54.364 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
|
||||
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "mainUser"
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:778)
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:234)
|
||||
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:289)
|
||||
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:57)
|
||||
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:279)
|
||||
at org.postgresql.Driver.makeConnection(Driver.java:448)
|
||||
at org.postgresql.Driver.connect(Driver.java:298)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
|
||||
at database.DatabaseManager.start(DatabaseManager.kt:23)
|
||||
at database.DatabaseManagerKt.main(DatabaseManager.kt:57)
|
||||
2026-05-12 14:43:09.160 [main] DEBUG com.zaxxer.hikari.HikariConfig - Driver class org.postgresql.Driver found in Thread context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@1dbd16a6
|
||||
2026-05-12 14:43:09.165 [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
|
||||
2026-05-12 14:43:09.166 [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension................................false
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit................................false
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout................................30000
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI................................none
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties................................{password=<masked>}
|
||||
2026-05-12 14:43:09.167 [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................................"org.postgresql.Driver"
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - exceptionOverrideClassName................................none
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties................................{}
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry................................none
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout................................600000
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout................................1
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries................................false
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl................................jdbc:postgresql://aklivtsov.tech:5430/prog7_db
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - keepaliveTime................................0
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold................................0
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime................................1800000
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize................................10
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry................................none
|
||||
2026-05-12 14:43:09.168 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory................................none
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle................................10
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - password................................<masked>
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName................................"HikariPool-1"
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly................................false
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans................................false
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor................................none
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - schema................................none
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory................................internal
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation................................"TRANSACTION_REPEATABLE_READ"
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - username................................"mainUser"
|
||||
2026-05-12 14:43:09.169 [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout................................5000
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension................................false
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit................................false
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog................................none
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql................................none
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery................................none
|
||||
2026-05-12 14:43:09.170 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout................................30000
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties................................{password=<masked>}
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................................"org.postgresql.Driver"
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - exceptionOverrideClassName................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties................................{}
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout................................600000
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout................................1
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries................................false
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl................................jdbc:postgresql://aklivtsov.tech:5430/prog7_db
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - keepaliveTime................................0
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold................................0
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime................................1800000
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize................................10
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory................................none
|
||||
2026-05-12 14:43:09.171 [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle................................10
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - password................................<masked>
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName................................"HikariPool-1"
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly................................false
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans................................false
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor................................none
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - schema................................none
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory................................internal
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation................................"TRANSACTION_REPEATABLE_READ"
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - username................................"mainUser"
|
||||
2026-05-12 14:43:09.172 [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout................................5000
|
||||
2026-05-12 14:43:09.172 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
|
||||
2026-05-12 14:43:10.946 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@5552768b
|
||||
2026-05-12 14:43:10.949 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
|
||||
2026-05-12 14:43:11.054 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)
|
||||
2026-05-12 14:43:11.900 [main] DEBUG c.zaxxer.hikari.pool.ProxyConnection - HikariPool-1 - Executed rollback on connection org.postgresql.jdbc.PgConnection@5552768b due to dirty commit state on close().
|
||||
2026-05-12 14:43:12.231 [main] DEBUG Exposed -
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
2026-05-12 14:43:12.999 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@163b6851
|
||||
2026-05-12 14:43:14.034 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@59c18edd
|
||||
2026-05-12 14:43:14.370 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
2026-05-12 14:45:46.071 [main] DEBUG Exposed -
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
2026-05-12 14:45:47.694 [main] DEBUG Exposed - SELECT humanbeing.id, humanbeing."name", humanbeing.coordinates, humanbeing.last_name, humanbeing.creation_date, humanbeing.real_hero, humanbeing.has_toothpick, humanbeing.impact_speed, humanbeing.soundtrack_name, humanbeing.minutes_of_waiting, humanbeing.car, humanbeing.weapon_type FROM humanbeing
|
||||
+12
-3
@@ -5,7 +5,7 @@ plugins {
|
||||
id 'org.jetbrains.dokka' version '2.2.0'
|
||||
}
|
||||
|
||||
group = 'lab6.prog'
|
||||
group = 'lab7.prog'
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
@@ -13,7 +13,7 @@ repositories {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set('Lab6-server')
|
||||
archiveBaseName.set('Lab7-server')
|
||||
archiveVersion.set('1.0')
|
||||
manifest {
|
||||
attributes 'Main-Class': 'MainKt'
|
||||
@@ -27,7 +27,16 @@ dependencies {
|
||||
implementation "io.ktor:ktor-network:3.4.2"
|
||||
implementation "io.github.oshai:kotlin-logging-jvm:7.0.3"
|
||||
implementation "org.slf4j:slf4j-api:2.0.13"
|
||||
implementation "ch.qos.logback:logback-classic:1.5.6"
|
||||
implementation "ch.qos.logback:logback-classic:1.5.20"
|
||||
|
||||
// oh my gawd
|
||||
implementation "org.jetbrains.exposed:exposed-core:1.2.0"
|
||||
implementation "org.jetbrains.exposed:exposed-jdbc:1.2.0"
|
||||
implementation "org.jetbrains.exposed:exposed-dao:1.2.0"
|
||||
implementation "org.jetbrains.exposed:exposed-java-time:1.2.0"
|
||||
implementation "org.postgresql:postgresql:42.7.8"
|
||||
implementation "com.zaxxer:HikariCP:4.0.3"
|
||||
|
||||
implementation project(':common')
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import commands.*
|
||||
import file.FileManager
|
||||
import mu.KotlinLogging
|
||||
@@ -17,7 +17,7 @@ fun main(args: Array<String>) {
|
||||
logger.info{ "[startup] Starting server on port $port with $args args" }
|
||||
|
||||
val fileManager = FileManager(filePath)
|
||||
val manager = CollectionManager()
|
||||
val manager = Repository()
|
||||
val invoker = CommandInvoker()
|
||||
|
||||
// Загружаем коллекцию из файла
|
||||
@@ -58,7 +58,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
fun registerServerCommands(
|
||||
invoker: CommandInvoker,
|
||||
manager: CollectionManager,
|
||||
manager: Repository,
|
||||
fileManager: FileManager
|
||||
) {
|
||||
listOf(
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package auth
|
||||
|
||||
class AuthentificationManager {
|
||||
|
||||
fun register(username: String, password: String) {
|
||||
// go-to db
|
||||
|
||||
// return token or error
|
||||
}
|
||||
fun login(username: String, password: String) {
|
||||
// go-to db
|
||||
|
||||
// return token or error
|
||||
}
|
||||
|
||||
fun grantToken() {}
|
||||
fun validateToken(token: String) {}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class AddCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class AddCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "add"
|
||||
override val description = "добавить новый элемент в коллекцию"
|
||||
override val args = listOf(CommandArgType.NONE)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
class AddIfMaxCommand(private val manager: CollectionManager) : Command {
|
||||
class AddIfMaxCommand(private val manager: Repository) : Command {
|
||||
override val name = "add_if_max"
|
||||
override val description = "добавить элемент, если он больше максимального"
|
||||
override val type = CommandType.MODEL
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import models.HumanBeing
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Contextual
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class AddIfMinCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class AddIfMinCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "add_if_min"
|
||||
override val description = "добавить элемент, если он меньше минимального"
|
||||
override val type = CommandType.MODEL
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class ClearCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class ClearCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "clear"
|
||||
override val description = "очистить коллекцию"
|
||||
override val args = listOf(CommandArgType.NONE)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class InfoCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class InfoCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "info"
|
||||
override val description = "вывести информацию о коллекции"
|
||||
override val type = CommandType.SIMPLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
@@ -10,7 +10,7 @@ import network.Response
|
||||
* Выводит любой элемент с минимальным значением поля [HumanBeing.name].
|
||||
*/
|
||||
@Serializable
|
||||
class MinByNameCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class MinByNameCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "min_by_name"
|
||||
override val description = "вывести элемент с минимальным именем"
|
||||
override val type = CommandType.SIMPLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
@@ -10,7 +10,7 @@ import network.Response
|
||||
* Выводит значения поля [models.HumanBeing.minutesOfWaiting] в порядке убывания.
|
||||
*/
|
||||
@Serializable
|
||||
class PrintDescendingMinutesCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class PrintDescendingMinutesCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "print_field_descending_minutes_of_waiting"
|
||||
override val description = "вывести minutesOfWaiting в порядке убывания"
|
||||
override val type = CommandType.SIMPLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.UUID
|
||||
@@ -8,7 +8,7 @@ import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class RemoveByIdCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class RemoveByIdCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "remove_by_id"
|
||||
override val description = "удалить элемент по id: remove_by_id <uuid>"
|
||||
override val type = CommandType.MODEL
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import file.FileManager
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -9,7 +9,7 @@ import network.Response
|
||||
|
||||
@Serializable
|
||||
class SaveCommand(
|
||||
@Contextual private val manager: CollectionManager,
|
||||
@Contextual private val manager: Repository,
|
||||
@Contextual private val fileManager: FileManager
|
||||
) : Command {
|
||||
override val name = "save"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
import network.Response
|
||||
|
||||
@Serializable
|
||||
class ShowCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class ShowCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "show"
|
||||
override val description = "вывести все элементы коллекции"
|
||||
override val type = CommandType.SIMPLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
@@ -10,7 +10,7 @@ import network.Response
|
||||
* Выводит сумму значений поля [models.HumanBeing.minutesOfWaiting].
|
||||
*/
|
||||
@Serializable
|
||||
class SumOfMinutesCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class SumOfMinutesCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "sum_of_minutes_of_waiting"
|
||||
override val description = "вывести сумму minutesOfWaiting всех элементов"
|
||||
override val type = CommandType.SIMPLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package commands
|
||||
|
||||
import collection.CollectionManager
|
||||
import database.Repository
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import models.HumanBeing
|
||||
@@ -8,7 +8,7 @@ import network.Response
|
||||
import java.util.UUID
|
||||
|
||||
@Serializable
|
||||
class UpdateCommand(@Contextual private val manager: CollectionManager) : Command {
|
||||
class UpdateCommand(@Contextual private val manager: Repository) : Command {
|
||||
override val name = "update"
|
||||
override val description = "обновить элемент по id: update <uuid>"
|
||||
override val type = CommandType.MODEL
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package database
|
||||
import com.zaxxer.hikari.*
|
||||
import database.tables.CarTable
|
||||
import database.tables.CoordinatesTable
|
||||
import database.tables.HumanBeingTable
|
||||
import models.Coordinates
|
||||
import org.jetbrains.exposed.v1.jdbc.*
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
|
||||
class DatabaseManager {
|
||||
|
||||
fun start() {
|
||||
val config = HikariConfig().apply {
|
||||
jdbcUrl = "jdbc:postgresql://aklivtsov.tech:5430/prog7_db"
|
||||
driverClassName = "org.postgresql.Driver"
|
||||
username = "mainUser"
|
||||
password = "superDuperPassword"
|
||||
maximumPoolSize = 10 // Set according to your needs
|
||||
isAutoCommit = false // Exposed handles transactions manually
|
||||
transactionIsolation = "TRANSACTION_REPEATABLE_READ"
|
||||
validate()
|
||||
}
|
||||
val dataSource = HikariDataSource(config)
|
||||
Database.connect(dataSource)
|
||||
|
||||
transaction {
|
||||
exec("""
|
||||
DO ${'$'}${'$'} BEGIN
|
||||
CREATE TYPE weapontype AS ENUM ('hammer', 'shotgun', 'bat');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END ${'$'}${'$'};
|
||||
""")
|
||||
SchemaUtils.create(CoordinatesTable)
|
||||
SchemaUtils.create(CarTable)
|
||||
SchemaUtils.create(HumanBeingTable)
|
||||
}
|
||||
}
|
||||
|
||||
fun test(): List<String> {
|
||||
val smth = mutableListOf<String>()
|
||||
|
||||
transaction {
|
||||
val rows = HumanBeingTable.selectAll().toList()
|
||||
rows.forEach { row ->
|
||||
smth.add(row[HumanBeingTable.name])
|
||||
}
|
||||
}
|
||||
|
||||
return smth
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val manager = DatabaseManager()
|
||||
print("here we go!")
|
||||
manager.start()
|
||||
print(manager.test())
|
||||
print("here we don't go!")
|
||||
}
|
||||
+41
-4
@@ -1,7 +1,13 @@
|
||||
package collection
|
||||
package database
|
||||
|
||||
import database.tables.CarTable
|
||||
import database.tables.CoordinatesTable
|
||||
import models.HumanBeing
|
||||
import models.Car
|
||||
import database.tables.HumanBeingTable
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import org.jetbrains.exposed.v1.jdbc.insert
|
||||
import java.time.LocalDate
|
||||
import java.util.TreeSet
|
||||
import java.util.UUID
|
||||
@@ -9,14 +15,45 @@ import java.util.UUID
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
|
||||
class CollectionManager {
|
||||
class Repository {
|
||||
|
||||
private val collection: TreeSet<HumanBeing> = TreeSet()
|
||||
val initDate: LocalDate = LocalDate.now()
|
||||
|
||||
fun add(humanBeing: HumanBeing): Boolean {
|
||||
logger.info { "[ADD] Element created ${humanBeing.id}" }
|
||||
return collection.add(humanBeing)
|
||||
var allGood = true
|
||||
transaction {
|
||||
try {
|
||||
val cords = CoordinatesTable.insert {
|
||||
it[x] = humanBeing.coordinates.x
|
||||
it[y] = humanBeing.coordinates.y
|
||||
} get CoordinatesTable.id
|
||||
|
||||
val theCar = CarTable.insert {
|
||||
it[cool] = humanBeing.car.cool
|
||||
} get CarTable.id
|
||||
|
||||
HumanBeingTable.insert {
|
||||
it[name] = humanBeing.name
|
||||
it[coordinates] = cords
|
||||
it[creationDate] = humanBeing.creationDate
|
||||
it[realHero] = humanBeing.realHero
|
||||
it[hasToothpick] = humanBeing.hasToothpick
|
||||
it[impactSpeed] = humanBeing.impactSpeed
|
||||
it[soundtrackName] = humanBeing.soundtrackName
|
||||
it[minutesOfWaiting] = humanBeing.minutesOfWaiting
|
||||
it[car] = theCar
|
||||
it[weaponType] = humanBeing.weaponType
|
||||
}
|
||||
|
||||
logger.info { "[ADD] Element created ${humanBeing.id}" }
|
||||
allGood = true
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "[ADD] Error during inserting: $e" }
|
||||
allGood = false
|
||||
}
|
||||
}
|
||||
return allGood
|
||||
}
|
||||
|
||||
fun update(id: UUID, updated: HumanBeing): Boolean {
|
||||
@@ -0,0 +1,7 @@
|
||||
package database.tables
|
||||
|
||||
import org.jetbrains.exposed.v1.core.dao.id.java.UUIDTable
|
||||
|
||||
object CarTable : UUIDTable("car") {
|
||||
val cool = bool("cool").nullable()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package database.tables
|
||||
import org.jetbrains.exposed.v1.core.dao.id.java.UUIDTable
|
||||
|
||||
object CoordinatesTable : UUIDTable("coordinates") {
|
||||
val x = long("x").nullable()
|
||||
val y = integer("y").nullable()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
CREATE TYPE WeaponType AS ENUM ('hammer', 'shotgun', 'bat', 'hands'); -- last one is default
|
||||
CREATE DOMAIN auto_uuid as UUID DEFAULT gen_random_uuid();
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Coordinates(
|
||||
id auto_uuid PRIMARY KEY,
|
||||
x BIGINT,
|
||||
y INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Car(
|
||||
id auto_uuid PRIMARY KEY,
|
||||
cool BOOLEAN
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS HumanBeing(
|
||||
id auto_uuid PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
coordinates UUID references Coordinates(id),
|
||||
last_name TEXT,
|
||||
creation_date DATE,
|
||||
real_hero BOOLEAN,
|
||||
has_toothpick BOOLEAN,
|
||||
impact_speed DOUBLE PRECISION,
|
||||
soundtrack_name TEXT,
|
||||
minutes_of_waiting FLOAT,
|
||||
weapon_type WeaponType,
|
||||
car UUID references Car(id)
|
||||
);
|
||||
@@ -0,0 +1,34 @@
|
||||
package database.tables
|
||||
|
||||
import models.WeaponType
|
||||
import org.jetbrains.exposed.v1.core.dao.id.java.UUIDTable
|
||||
import org.jetbrains.exposed.v1.javatime.date
|
||||
import org.postgresql.util.PGobject
|
||||
|
||||
|
||||
object HumanBeingTable : UUIDTable("humanBeing") {
|
||||
val name = text("name")
|
||||
val coordinates = reference("coordinates", CoordinatesTable.id)
|
||||
val creationDate = date("creation_date")
|
||||
val realHero = bool("real_hero")
|
||||
val hasToothpick = bool("has_toothpick")
|
||||
val impactSpeed = double("impact_speed")
|
||||
val soundtrackName = text("soundtrack_name")
|
||||
val minutesOfWaiting = float("minutes_of_waiting")
|
||||
val car = reference("car", CarTable.id)
|
||||
val weaponType = customEnumeration(
|
||||
name = "weapon_type",
|
||||
sql = "weapontype",
|
||||
fromDb = { value ->
|
||||
WeaponType.valueOf(
|
||||
(value as PGobject).value!!
|
||||
)
|
||||
},
|
||||
toDb = { value ->
|
||||
PGobject().apply {
|
||||
type = "weapontype"
|
||||
this.value = value.name
|
||||
}
|
||||
}
|
||||
).nullable().default(null)
|
||||
}
|
||||
@@ -17,4 +17,6 @@
|
||||
<appender-ref ref="server_log" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<logger name="com.zaxxer.hikari" level="WARN"/>
|
||||
</configuration>
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||
}
|
||||
rootProject.name = 'Lab6'
|
||||
rootProject.name = 'Lab7'
|
||||
include 'client'
|
||||
include 'server'
|
||||
include 'common'
|
||||
Reference in New Issue
Block a user