diff --git a/savenkov_alexander_lab_2/README.md b/savenkov_alexander_lab_2/README.md
new file mode 100644
index 0000000..e5f5434
--- /dev/null
+++ b/savenkov_alexander_lab_2/README.md
@@ -0,0 +1,105 @@
+# Лабораторная работа №2 - Разработка простейшего распределенного приложения
+
+Цель: изучение техники создания простого распределенного приложения.
+
+Задачи:
+
+- Согласно вышему варианту (выбирайте любой) разработать два приложения такие, что результат первого является исходными данными для второго.
+- Изучить файлы сборки образов docker и разработать их для созданных приложений.
+- Собрать файл docker-compose.yml для запуска приложений. Разобраться с монтированием каталогов из хост-системы.
+- Правильно закоммитить результат без лишних файлов.
+- Оформить pull request по правилам и отправить его на проверку.
+
+# Разработка двух приложений
+
+Вариант первого приложения(worker-1): 5 - Ищет в каталоге /var/data файл с самым коротким названием и перекладывает его в /var/result/data.txt
+Вариант второго приложения(worker_2) 1 - Ищет набольшее число из файла /var/data/data.txt и сохраняет его вторую степень в /var/result/result.txt
+
+Приложения выполнены на языке Java
+
+
+
Worker-1
+
+
+
+
Worker-2
+
+
+
+# Запуск
+
+Запуск контейнеров производится командой "docker-compose up -d"
+
+# Работа программы
+
+- Создание двух деррикторий: worker-1 и worker-2 для реализаций двух программ.
+- Описание Dockerfile для создания образов для обоих программ.
+
+
Worker-1 Dockerfile
+
+
+
+
Worker-2 Dockerfile
+
+
+- Создание двух репозиториев: data, result, для монтирования их в контейнеры.
+
+
data
+
+
+
+
result
+
+
+
+
f3.txt
+
+
+
+
file_with_a_very_long_name_that_is_often_used_in_programming.txt
+
+
+
+
file1.txt
+
+
+- Описание docker-compose: запускает контейнеры, реализует build для создания образов на основе dockerfile и у второго контейнера описавыется зависимость depends_on от первого контейнера, чтобы сначала запустился первый контейнер, а за ним запустился второй. Также описываются volumes, для монтирование папок data и result в контейнеры.
+
+
docker-compose
+
+
+
+
Сборка и запуска контейнеров
+
+
+
+
Проверка в Docker Desktop контейнеров и образов
+
+
+
+
+
+
+
Смотрим, что выдает нам первый воркер в консоль
+
+
+
+
Смотрим, что выдает нам второй воркер в консоль
+
+
+
+
Смотрим, что при запуске контейнеров действительно в папке result создалось два файла data.txt и result.txt
+
+
+
+
Смотрим, что лежит в файле data.txt
+
+
+
+
Смотрим, что лежит в файле result.txt
+
+
+
+# Видео
+
+Видео с разбором лабораторной работы - https://youtu.be/o_sTok7W22s
diff --git a/savenkov_alexander_lab_2/data/f3.txt b/savenkov_alexander_lab_2/data/f3.txt
new file mode 100644
index 0000000..12ad3dd
--- /dev/null
+++ b/savenkov_alexander_lab_2/data/f3.txt
@@ -0,0 +1,9 @@
+987
+654
+321
+876
+543
+210
+765
+432
+100
diff --git a/savenkov_alexander_lab_2/data/file1.txt b/savenkov_alexander_lab_2/data/file1.txt
new file mode 100644
index 0000000..1a157a2
--- /dev/null
+++ b/savenkov_alexander_lab_2/data/file1.txt
@@ -0,0 +1,9 @@
+456
+789
+123
+987
+345
+678
+234
+567
+890
diff --git a/savenkov_alexander_lab_2/data/file_with_a_very_long_name_that_is_often_used_in_programming.txt b/savenkov_alexander_lab_2/data/file_with_a_very_long_name_that_is_often_used_in_programming.txt
new file mode 100644
index 0000000..1003912
--- /dev/null
+++ b/savenkov_alexander_lab_2/data/file_with_a_very_long_name_that_is_often_used_in_programming.txt
@@ -0,0 +1,9 @@
+123
+456
+789
+234
+567
+890
+345
+678
+901
diff --git a/savenkov_alexander_lab_2/docker-compose.yml b/savenkov_alexander_lab_2/docker-compose.yml
new file mode 100644
index 0000000..d2817bf
--- /dev/null
+++ b/savenkov_alexander_lab_2/docker-compose.yml
@@ -0,0 +1,17 @@
+services:
+ worker-1:
+ build:
+ context: /worker-1
+ dockerfile: Dockerfile
+ volumes:
+ - D:\Git-RViP\savenkov_alexander_lab_2\data:/var/data
+ - D:\Git-RViP\savenkov_alexander_lab_2\result:/var/result
+ worker-2:
+ build:
+ context: /worker-2
+ dockerfile: Dockerfile
+ volumes:
+ - D:\Git-RViP\savenkov_alexander_lab_2\data:/var/data
+ - D:\Git-RViP\savenkov_alexander_lab_2\result:/var/result
+ depends_on:
+ - worker-1
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/result/data.txt b/savenkov_alexander_lab_2/result/data.txt
new file mode 100644
index 0000000..12ad3dd
--- /dev/null
+++ b/savenkov_alexander_lab_2/result/data.txt
@@ -0,0 +1,9 @@
+987
+654
+321
+876
+543
+210
+765
+432
+100
diff --git a/savenkov_alexander_lab_2/result/result.txt b/savenkov_alexander_lab_2/result/result.txt
new file mode 100644
index 0000000..543e9fa
--- /dev/null
+++ b/savenkov_alexander_lab_2/result/result.txt
@@ -0,0 +1 @@
+974169.0
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/screens/img1.png b/savenkov_alexander_lab_2/screens/img1.png
new file mode 100644
index 0000000..1b22e38
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img1.png differ
diff --git a/savenkov_alexander_lab_2/screens/img10.png b/savenkov_alexander_lab_2/screens/img10.png
new file mode 100644
index 0000000..142ea61
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img10.png differ
diff --git a/savenkov_alexander_lab_2/screens/img11.png b/savenkov_alexander_lab_2/screens/img11.png
new file mode 100644
index 0000000..7a85e9e
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img11.png differ
diff --git a/savenkov_alexander_lab_2/screens/img12.png b/savenkov_alexander_lab_2/screens/img12.png
new file mode 100644
index 0000000..f82db2d
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img12.png differ
diff --git a/savenkov_alexander_lab_2/screens/img13.png b/savenkov_alexander_lab_2/screens/img13.png
new file mode 100644
index 0000000..d1239ed
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img13.png differ
diff --git a/savenkov_alexander_lab_2/screens/img14.png b/savenkov_alexander_lab_2/screens/img14.png
new file mode 100644
index 0000000..32b00f1
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img14.png differ
diff --git a/savenkov_alexander_lab_2/screens/img15.png b/savenkov_alexander_lab_2/screens/img15.png
new file mode 100644
index 0000000..4ffa02c
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img15.png differ
diff --git a/savenkov_alexander_lab_2/screens/img16.png b/savenkov_alexander_lab_2/screens/img16.png
new file mode 100644
index 0000000..a1b0fff
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img16.png differ
diff --git a/savenkov_alexander_lab_2/screens/img17.png b/savenkov_alexander_lab_2/screens/img17.png
new file mode 100644
index 0000000..1936d1f
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img17.png differ
diff --git a/savenkov_alexander_lab_2/screens/img18.png b/savenkov_alexander_lab_2/screens/img18.png
new file mode 100644
index 0000000..c62f2bf
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img18.png differ
diff --git a/savenkov_alexander_lab_2/screens/img2.png b/savenkov_alexander_lab_2/screens/img2.png
new file mode 100644
index 0000000..1b8eb70
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img2.png differ
diff --git a/savenkov_alexander_lab_2/screens/img3.png b/savenkov_alexander_lab_2/screens/img3.png
new file mode 100644
index 0000000..a1fc648
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img3.png differ
diff --git a/savenkov_alexander_lab_2/screens/img4.png b/savenkov_alexander_lab_2/screens/img4.png
new file mode 100644
index 0000000..20d63d1
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img4.png differ
diff --git a/savenkov_alexander_lab_2/screens/img5.png b/savenkov_alexander_lab_2/screens/img5.png
new file mode 100644
index 0000000..a199adb
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img5.png differ
diff --git a/savenkov_alexander_lab_2/screens/img6.png b/savenkov_alexander_lab_2/screens/img6.png
new file mode 100644
index 0000000..e0c67df
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img6.png differ
diff --git a/savenkov_alexander_lab_2/screens/img7.png b/savenkov_alexander_lab_2/screens/img7.png
new file mode 100644
index 0000000..115fe90
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img7.png differ
diff --git a/savenkov_alexander_lab_2/screens/img8.png b/savenkov_alexander_lab_2/screens/img8.png
new file mode 100644
index 0000000..c01d451
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img8.png differ
diff --git a/savenkov_alexander_lab_2/screens/img9.png b/savenkov_alexander_lab_2/screens/img9.png
new file mode 100644
index 0000000..335ceca
Binary files /dev/null and b/savenkov_alexander_lab_2/screens/img9.png differ
diff --git a/savenkov_alexander_lab_2/worker-1/.gitignore b/savenkov_alexander_lab_2/worker-1/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-1/.idea/.gitignore b/savenkov_alexander_lab_2/worker-1/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/savenkov_alexander_lab_2/worker-1/.idea/misc.xml b/savenkov_alexander_lab_2/worker-1/.idea/misc.xml
new file mode 100644
index 0000000..07115cd
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-1/.idea/modules.xml b/savenkov_alexander_lab_2/worker-1/.idea/modules.xml
new file mode 100644
index 0000000..98d26e9
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-1/Dockerfile b/savenkov_alexander_lab_2/worker-1/Dockerfile
new file mode 100644
index 0000000..37758ff
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/Dockerfile
@@ -0,0 +1,18 @@
+# Используем образ с Java
+FROM openjdk:21
+
+# Создаем директории для данных и результата внутри контейнера
+RUN mkdir /var/data
+RUN mkdir /var/result
+
+# Создаем директорию приложения внутри контейнера
+WORKDIR /app
+
+# Копируем исходные файлы вашего Java-приложения внутрь контейнера
+COPY src /app/src
+
+# Компилируем Java-код
+RUN javac /app/src/FileMover.java
+
+# Запускаем Java-приложение
+CMD ["java", "-cp", "/app/src", "FileMover"]
diff --git a/savenkov_alexander_lab_2/worker-1/src/FileMover.java b/savenkov_alexander_lab_2/worker-1/src/FileMover.java
new file mode 100644
index 0000000..4447eee
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/src/FileMover.java
@@ -0,0 +1,50 @@
+import java.io.IOException;
+import java.nio.file.*;
+import java.util.List;
+
+public class FileMover {
+ public static void main(String[] args) {
+ String sourceDirectory = "/var/data";
+ String destinationDirectory = "/var/result";
+ String resultFile = destinationDirectory + "/data.txt";
+
+ try {
+ // Получаем список файлов в исходной директории
+ List files = getFilesInDirectory(sourceDirectory);
+
+ if (!files.isEmpty()) {
+ // Находим файл с самым коротким именем
+ Path shortestFileName = findShortestFileName(files);
+
+ // Копируем найденный файл в целевую директорию
+ Files.copy(shortestFileName, Paths.get(resultFile), StandardCopyOption.REPLACE_EXISTING);
+
+ System.out.println("Файл " + shortestFileName.getFileName() + " был скопирован в " + resultFile);
+ } else {
+ System.out.println("В исходной директории нет файлов для копирования.");
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static List getFilesInDirectory(String directory) throws IOException {
+ try (DirectoryStream stream = Files.newDirectoryStream(Paths.get(directory))) {
+ List fileList = new java.util.ArrayList<>();
+ for (Path entry : stream) {
+ fileList.add(entry);
+ }
+ return fileList;
+ }
+ }
+
+ private static Path findShortestFileName(List files) {
+ Path shortestFile = files.get(0);
+ for (Path file : files) {
+ if (file.getFileName().toString().length() < shortestFile.getFileName().toString().length()) {
+ shortestFile = file;
+ }
+ }
+ return shortestFile;
+ }
+}
diff --git a/savenkov_alexander_lab_2/worker-1/worker-1.iml b/savenkov_alexander_lab_2/worker-1/worker-1.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-1/worker-1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-2/.gitignore b/savenkov_alexander_lab_2/worker-2/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-2/.idea/.gitignore b/savenkov_alexander_lab_2/worker-2/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/savenkov_alexander_lab_2/worker-2/.idea/misc.xml b/savenkov_alexander_lab_2/worker-2/.idea/misc.xml
new file mode 100644
index 0000000..07115cd
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-2/.idea/modules.xml b/savenkov_alexander_lab_2/worker-2/.idea/modules.xml
new file mode 100644
index 0000000..ba047c4
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/savenkov_alexander_lab_2/worker-2/Dockerfile b/savenkov_alexander_lab_2/worker-2/Dockerfile
new file mode 100644
index 0000000..6f0e037
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/Dockerfile
@@ -0,0 +1,18 @@
+# Используем образ с Java
+FROM openjdk:21
+
+# Создаем директории для данных и результата внутри контейнера
+RUN mkdir /var/data
+RUN mkdir /var/result
+
+# Создаем директорию приложения внутри контейнера
+WORKDIR /app
+
+# Копируем исходные файлы вашего Java-приложения внутрь контейнера
+COPY src /app/src
+
+# Компилируем Java-код
+RUN javac /app/src/LargestNumberSquare.java
+
+# Запускаем Java-приложение
+CMD ["java", "-cp", "/app/src", "LargestNumberSquare"]
diff --git a/savenkov_alexander_lab_2/worker-2/src/LargestNumberSquare.java b/savenkov_alexander_lab_2/worker-2/src/LargestNumberSquare.java
new file mode 100644
index 0000000..bb4c53c
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/src/LargestNumberSquare.java
@@ -0,0 +1,44 @@
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+
+public class LargestNumberSquare {
+ public static void main(String[] args) {
+ String sourceFilePath = "/var/result/data.txt";
+ String resultFilePath = "/var/result/result.txt";
+
+ try (BufferedReader reader = new BufferedReader(new FileReader(sourceFilePath))) {
+ String line;
+ double largestNumber = Double.MIN_VALUE;
+
+ while ((line = reader.readLine()) != null) {
+ try {
+ double number = Double.parseDouble(line);
+ if (number > largestNumber) {
+ largestNumber = number;
+ }
+ } catch (NumberFormatException e) {
+ // Пропускаем строки, которые не могут быть преобразованы в числа
+ }
+ }
+
+ if (largestNumber != Double.MIN_VALUE) {
+ double square = Math.pow(largestNumber, 2);
+
+ try (FileWriter writer = new FileWriter(resultFilePath)) {
+ writer.write(Double.toString(square));
+ }
+
+ System.out.println("Наибольшее число в файле: " + largestNumber);
+ System.out.println("Вторая степень наибольшего числа: " + square);
+ System.out.println("Результат сохранен в " + resultFilePath);
+ } else {
+ System.out.println("Файл не содержит чисел.");
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/savenkov_alexander_lab_2/worker-2/worker-2.iml b/savenkov_alexander_lab_2/worker-2/worker-2.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/savenkov_alexander_lab_2/worker-2/worker-2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file