Compare commits
1 Commits
main
...
simonov_ni
Author | SHA1 | Date | |
---|---|---|---|
f7074a49d6 |
3
simonov_nikita_lab_2/.idea/.gitignore
vendored
Normal file
3
simonov_nikita_lab_2/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
6
simonov_nikita_lab_2/.idea/misc.xml
Normal file
6
simonov_nikita_lab_2/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
10
simonov_nikita_lab_2/.idea/modules.xml
Normal file
10
simonov_nikita_lab_2/.idea/modules.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/simonov_nikita_lab2.iml" filepath="$PROJECT_DIR$/.idea/simonov_nikita_lab2.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/worker-1/worker-1.iml" filepath="$PROJECT_DIR$/worker-1/worker-1.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/worker-2/worker-2.iml" filepath="$PROJECT_DIR$/worker-2/worker-2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
simonov_nikita_lab_2/.idea/simonov_nikita_lab2.iml
Normal file
12
simonov_nikita_lab_2/.idea/simonov_nikita_lab2.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="SonarLintModuleSettings">
|
||||
<option name="uniqueId" value="030f8d38-cf44-4d39-857b-c2917f42a268" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,11 @@
|
||||
|
||||
W
|
||||
java:S1141"5Extract this nested try block into a separate method.(¡»¢üùÿÿÿÿ8À®—ðÇ1
|
||||
c
|
||||
java:S1075"ARefactor your code to get this URI from a customizable parameter.(ŒÙž¿ùÿÿÿÿ8ê®—ðÇ1
|
||||
c
|
||||
java:S1075"ARefactor your code to get this URI from a customizable parameter.(ÿ¶„‚üÿÿÿÿ8ê®—ðÇ1
|
||||
@ java:S106-"+Replace this use of System.out by a logger.(öë°í
|
||||
@ java:S106."+Replace this use of System.out by a logger.(㆛ø
|
||||
E java:S106/"+Replace this use of System.out by a logger.(îùƒÜøÿÿÿÿ
|
||||
E java:S1061"+Replace this use of System.out by a logger.(ýŸðœûÿÿÿÿ
|
@ -0,0 +1,13 @@
|
||||
|
||||
W
|
||||
java:S1141"5Extract this nested try block into a separate method.(¡»¢üùÿÿÿÿ8ÅÔÉžÈ1
|
||||
c
|
||||
java:S1075"ARefactor your code to get this URI from a customizable parameter.(ŒÙž¿ùÿÿÿÿ8ÙÔÉžÈ1
|
||||
U
|
||||
java:S1481"3Remove this unused "sourceFilePath" local variable.(ŒÙž¿ùÿÿÿÿ8ÛÔÉžÈ1
|
||||
c
|
||||
java:S1075"ARefactor your code to get this URI from a customizable parameter.(ÿ¶„‚üÿÿÿÿ8ÛÔÉžÈ1
|
||||
c
|
||||
java:S1075"ARefactor your code to get this URI from a customizable parameter.(³’Úãÿÿÿÿÿ8ÛÔÉžÈ1
|
||||
G java:S106*"+Replace this use of System.out by a logger.(ø®ë¾8àÔÉžÈ1
|
||||
L java:S106+"+Replace this use of System.out by a logger.(힃¦ûÿÿÿÿ8àÔÉžÈ1
|
@ -0,0 +1,3 @@
|
||||
|
||||
L java:S106"+Replace this use of System.out by a logger.(‘Λ<C38E>øÿÿÿÿ8°<C2B0>ðÇ1
|
||||
L java:S106 "+Replace this use of System.out by a logger.(æ<>Éâùÿÿÿÿ8±<C2B1>ðÇ1
|
39
simonov_nikita_lab_2/.idea/sonarlint/issuestore/index.pb
Normal file
39
simonov_nikita_lab_2/.idea/sonarlint/issuestore/index.pb
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
Z
|
||||
*worker-2/src/FindingLargestNumberFile.java,0\3\03a92d5d92427ae83731739f82560657bd7e1d33
|
||||
C
|
||||
worker-1/Dockerfile,e\6\e69c92c782a7aaf8d0c509cb120e1ead92c1002a
|
||||
C
|
||||
worker-2/Dockerfile,8\3\83ed28ddb28df8a1891a8bb18462429f6bf9c67a
|
||||
F
|
||||
data/awdafgergssdf.txt,a\4\a44778d2018213866a7c7700d98e9b5a0c8bb0d7
|
||||
C
|
||||
data/sgeagfdsfh.txt,e\e\ee36fd8c882eeb7d494b394d46fbdb34cd105ba9
|
||||
?
|
||||
data/sdfwef.txt,e\c\ec82235829a15dc40a553c3fb4b789f1198f4425
|
||||
V
|
||||
&worker-1/src/FindShortestFileName.java,9\4\94c92b7b02fdd2531b355bac9c83b9f486abe86c
|
||||
9
|
||||
README.md,8\e\8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
|
||||
B
|
||||
docker-compose.yml,3\5\35b8c13cf2eb2a194eada000eb310d65aed53b2a
|
||||
S
|
||||
#worker-3/src/CheckingTheResult.java,9\2\92c4d1ca65baa16d74df9bf3d5b6393a87742c07
|
||||
C
|
||||
worker-3/Dockerfile,6\b\6b3c7820a55d6a07cc9d46efa42c98ebf1f45354
|
||||
E
|
||||
worker-3/worker-2.iml,5\0\502eff2775ccdc92a339926170a76685b0db195b
|
||||
=
|
||||
service1.yaml,d\e\de9026ba42f1709def40029bb15d3a5c09210226
|
||||
=
|
||||
service2.yaml,f\b\fbfd3efcc3c334f991162df3f9840f75dd4ac2b6
|
||||
=
|
||||
service3.yaml,d\1\d1d02446e29911114aa8461a6d339c8a9b233292
|
||||
C
|
||||
worker-3/.gitignore,e\d\ed0d20f6dbf0bbada896a9094ff70ec66340a7a2
|
||||
G
|
||||
result/check_result.txt,7\a\7a3b22c128c191dcaf132b29cd87547571c08e36
|
||||
A
|
||||
result/result.txt,f\4\f4cf0185d9befba3e1246fec6ecc3fb42d5b2f98
|
||||
?
|
||||
result/data.txt,a\d\adb97326bef634ca60e90d62c3e817831b0e62ad
|
@ -0,0 +1,39 @@
|
||||
|
||||
C
|
||||
worker-1/Dockerfile,e\6\e69c92c782a7aaf8d0c509cb120e1ead92c1002a
|
||||
C
|
||||
worker-2/Dockerfile,8\3\83ed28ddb28df8a1891a8bb18462429f6bf9c67a
|
||||
Z
|
||||
*worker-2/src/FindingLargestNumberFile.java,0\3\03a92d5d92427ae83731739f82560657bd7e1d33
|
||||
F
|
||||
data/awdafgergssdf.txt,a\4\a44778d2018213866a7c7700d98e9b5a0c8bb0d7
|
||||
?
|
||||
data/sdfwef.txt,e\c\ec82235829a15dc40a553c3fb4b789f1198f4425
|
||||
C
|
||||
data/sgeagfdsfh.txt,e\e\ee36fd8c882eeb7d494b394d46fbdb34cd105ba9
|
||||
B
|
||||
docker-compose.yml,3\5\35b8c13cf2eb2a194eada000eb310d65aed53b2a
|
||||
V
|
||||
&worker-1/src/FindShortestFileName.java,9\4\94c92b7b02fdd2531b355bac9c83b9f486abe86c
|
||||
9
|
||||
README.md,8\e\8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
|
||||
C
|
||||
worker-3/Dockerfile,6\b\6b3c7820a55d6a07cc9d46efa42c98ebf1f45354
|
||||
S
|
||||
#worker-3/src/CheckingTheResult.java,9\2\92c4d1ca65baa16d74df9bf3d5b6393a87742c07
|
||||
=
|
||||
service1.yaml,d\e\de9026ba42f1709def40029bb15d3a5c09210226
|
||||
=
|
||||
service2.yaml,f\b\fbfd3efcc3c334f991162df3f9840f75dd4ac2b6
|
||||
=
|
||||
service3.yaml,d\1\d1d02446e29911114aa8461a6d339c8a9b233292
|
||||
E
|
||||
worker-3/worker-2.iml,5\0\502eff2775ccdc92a339926170a76685b0db195b
|
||||
C
|
||||
worker-3/.gitignore,e\d\ed0d20f6dbf0bbada896a9094ff70ec66340a7a2
|
||||
G
|
||||
result/check_result.txt,7\a\7a3b22c128c191dcaf132b29cd87547571c08e36
|
||||
A
|
||||
result/result.txt,f\4\f4cf0185d9befba3e1246fec6ecc3fb42d5b2f98
|
||||
?
|
||||
result/data.txt,a\d\adb97326bef634ca60e90d62c3e817831b0e62ad
|
124
simonov_nikita_lab_2/.idea/uiDesigner.xml
Normal file
124
simonov_nikita_lab_2/.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
117
simonov_nikita_lab_2/README.md
Normal file
117
simonov_nikita_lab_2/README.md
Normal file
@ -0,0 +1,117 @@
|
||||
# Лабораторная работа №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
|
||||
|
||||
## Структура проекта
|
||||
|
||||
![](/screens/Screenshot_1.png)
|
||||
|
||||
# Работа программы
|
||||
|
||||
- Создание двух директорий: worker-1 и worker-2 для реализаций двух программ.
|
||||
- Описание Dockerfile для создания образов для обоих программ.
|
||||
|
||||
## Docker файл для первого сервиса
|
||||
|
||||
```yml
|
||||
# Используем образ с Java
|
||||
FROM openjdk:21
|
||||
|
||||
# Создаем директории для данных и результата внутри контейнера
|
||||
RUN mkdir /var/data
|
||||
RUN mkdir /var/result
|
||||
|
||||
# Создаем директорию приложения внутри контейнера
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем исходные файлы вашего Java-приложения внутрь контейнера
|
||||
COPY src /app/src
|
||||
|
||||
# Компилируем Java-код
|
||||
RUN javac /app/src/FindShortestFileName.java
|
||||
|
||||
# Запускаем Java-приложение
|
||||
CMD ["java", "-cp", "/app/src", "FindShortestFileName"]
|
||||
```
|
||||
|
||||
## Docker файл для второго сервиса
|
||||
|
||||
```yml
|
||||
# Используем образ с Java
|
||||
FROM openjdk:21
|
||||
|
||||
# Создаем директории для данных и результата внутри контейнера
|
||||
RUN mkdir /var/data
|
||||
RUN mkdir /var/result
|
||||
|
||||
# Создаем директорию приложения внутри контейнера
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем исходные файлы вашего Java-приложения внутрь контейнера
|
||||
COPY src /app/src
|
||||
|
||||
Компилируем Java-код
|
||||
RUN javac /app/src/FindingLargestNumberFile.java
|
||||
|
||||
# Запускаем Java-приложение
|
||||
CMD ["java", "-cp", "/app/src", "FindingLargestNumberFile"]
|
||||
```
|
||||
|
||||
## Docker-compose
|
||||
|
||||
```yml
|
||||
services:
|
||||
worker-1:
|
||||
build:
|
||||
context: /worker-1
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- D:\рил\simonov_nikita_lab_2\data:/var/data
|
||||
- D:\рил\simonov_nikita_lab_2\result:/var/result
|
||||
worker-2:
|
||||
build:
|
||||
context: /worker-2
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- D:\рил\simonov_nikita_lab_2\data:/var/data
|
||||
- D:\рил\simonov_nikita_lab_2\result:/var/result
|
||||
depends_on:
|
||||
- worker-1
|
||||
```
|
||||
|
||||
## Исходные файлы
|
||||
|
||||
![](/screens/Screenshot_5.png)
|
||||
|
||||
## После запуска контейнера создаются файлы `data.txt` и `result.txt`:
|
||||
|
||||
![](/screens/Screenshot_2.png)
|
||||
|
||||
- `data.txt`
|
||||
|
||||
![](/screens/Screenshot_3.png)
|
||||
|
||||
- `result.txt`
|
||||
|
||||
![](/screens/Screenshot_4.png)
|
||||
|
||||
# Запушенный контейнер
|
||||
|
||||
![](/screens/Screenshot_6.png)
|
||||
|
||||
# Ссылка на видео
|
||||
|
||||
https://drive.google.com/file/d/1kPXcYOX0bRmjzBbg8GBWp0JfFWb2rUGm/view?usp=sharing
|
9
simonov_nikita_lab_2/data/Shugar_Dady.txt
Normal file
9
simonov_nikita_lab_2/data/Shugar_Dady.txt
Normal file
@ -0,0 +1,9 @@
|
||||
44
|
||||
65
|
||||
23
|
||||
90
|
||||
98
|
||||
65
|
||||
32
|
||||
87
|
||||
|
8
simonov_nikita_lab_2/data/Uncle_Bob.txt
Normal file
8
simonov_nikita_lab_2/data/Uncle_Bob.txt
Normal file
@ -0,0 +1,8 @@
|
||||
12
|
||||
34
|
||||
56
|
||||
13
|
||||
11
|
||||
6
|
||||
4
|
||||
7
|
11
simonov_nikita_lab_2/data/other_mom.txt
Normal file
11
simonov_nikita_lab_2/data/other_mom.txt
Normal file
@ -0,0 +1,11 @@
|
||||
67
|
||||
23
|
||||
56
|
||||
89
|
||||
1
|
||||
48
|
||||
44
|
||||
90
|
||||
12
|
||||
32
|
||||
78
|
17
simonov_nikita_lab_2/docker-compose.yml
Normal file
17
simonov_nikita_lab_2/docker-compose.yml
Normal file
@ -0,0 +1,17 @@
|
||||
services:
|
||||
worker-1:
|
||||
build:
|
||||
context: /worker-1
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- D:\рил\simonov_nikita_lab_2\data:/var/data
|
||||
- D:\рил\simonov_nikita_lab_2\result:/var/result
|
||||
worker-2:
|
||||
build:
|
||||
context: /worker-2
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- D:\рил\simonov_nikita_lab_2\data:/var/data
|
||||
- D:\рил\simonov_nikita_lab_2\result:/var/result
|
||||
depends_on:
|
||||
- worker-1
|
11
simonov_nikita_lab_2/result/data.txt
Normal file
11
simonov_nikita_lab_2/result/data.txt
Normal file
@ -0,0 +1,11 @@
|
||||
67
|
||||
23
|
||||
56
|
||||
89
|
||||
1
|
||||
48
|
||||
44
|
||||
90
|
||||
12
|
||||
32
|
||||
78
|
1
simonov_nikita_lab_2/result/result.txt
Normal file
1
simonov_nikita_lab_2/result/result.txt
Normal file
@ -0,0 +1 @@
|
||||
8100.0
|
BIN
simonov_nikita_lab_2/screens/Screenshot_1.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
BIN
simonov_nikita_lab_2/screens/Screenshot_2.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
simonov_nikita_lab_2/screens/Screenshot_3.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
BIN
simonov_nikita_lab_2/screens/Screenshot_4.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
simonov_nikita_lab_2/screens/Screenshot_5.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
simonov_nikita_lab_2/screens/Screenshot_6.png
Normal file
BIN
simonov_nikita_lab_2/screens/Screenshot_6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
29
simonov_nikita_lab_2/worker-1/.gitignore
vendored
Normal file
29
simonov_nikita_lab_2/worker-1/.gitignore
vendored
Normal file
@ -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
|
8
simonov_nikita_lab_2/worker-1/.idea/.gitignore
vendored
Normal file
8
simonov_nikita_lab_2/worker-1/.idea/.gitignore
vendored
Normal file
@ -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
|
6
simonov_nikita_lab_2/worker-1/.idea/misc.xml
Normal file
6
simonov_nikita_lab_2/worker-1/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
simonov_nikita_lab_2/worker-1/.idea/modules.xml
Normal file
8
simonov_nikita_lab_2/worker-1/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/worker-1.iml" filepath="$PROJECT_DIR$/worker-1.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
18
simonov_nikita_lab_2/worker-1/Dockerfile
Normal file
18
simonov_nikita_lab_2/worker-1/Dockerfile
Normal file
@ -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/FindShortestFileName.java
|
||||
|
||||
# Запускаем Java-приложение
|
||||
CMD ["java", "-cp", "/app/src", "FindShortestFileName"]
|
71
simonov_nikita_lab_2/worker-1/src/FindShortestFileName.java
Normal file
71
simonov_nikita_lab_2/worker-1/src/FindShortestFileName.java
Normal file
@ -0,0 +1,71 @@
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Программа для перемещения файла с самым коротким именем из одной директории в другую.
|
||||
*/
|
||||
public class FindShortestFileName {
|
||||
|
||||
/**
|
||||
* Точка входа в программу.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// Указываем пути исходной и целевой директорий, а также путь результирующего файла
|
||||
String sourceDirectory = "/var/data";
|
||||
String destinationDirectory = "/var/result";
|
||||
String resultFile = destinationDirectory + "/data.txt";
|
||||
|
||||
try {
|
||||
// Получаем список файлов в исходной директории
|
||||
List<Path> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает список файлов в указанной директории.
|
||||
*
|
||||
* @param directory Путь к директории.
|
||||
* @return Список файлов в директории.
|
||||
* @throws IOException В случае ошибок при чтении директории.
|
||||
*/
|
||||
private static List<Path> getFilesInDirectory(String directory) throws IOException {
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(directory))) {
|
||||
List<Path> fileList = new java.util.ArrayList<>();
|
||||
for (Path entry : stream) {
|
||||
fileList.add(entry);
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Находит файл с самым коротким именем в списке.
|
||||
*
|
||||
* @param files Список файлов.
|
||||
* @return Путь к файлу с самым коротким именем.
|
||||
*/
|
||||
private static Path findShortestFileName(List<Path> files) {
|
||||
Path shortestFile = files.get(0);
|
||||
for (Path file : files) {
|
||||
if (file.getFileName().toString().length() < shortestFile.getFileName().toString().length()) {
|
||||
shortestFile = file;
|
||||
}
|
||||
}
|
||||
return shortestFile;
|
||||
}
|
||||
}
|
14
simonov_nikita_lab_2/worker-1/worker-1.iml
Normal file
14
simonov_nikita_lab_2/worker-1/worker-1.iml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="SonarLintModuleSettings">
|
||||
<option name="uniqueId" value="a8341579-2851-407d-ad6a-b2b7f768ee65" />
|
||||
</component>
|
||||
</module>
|
29
simonov_nikita_lab_2/worker-2/.gitignore
vendored
Normal file
29
simonov_nikita_lab_2/worker-2/.gitignore
vendored
Normal file
@ -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
|
8
simonov_nikita_lab_2/worker-2/.idea/.gitignore
vendored
Normal file
8
simonov_nikita_lab_2/worker-2/.idea/.gitignore
vendored
Normal file
@ -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
|
6
simonov_nikita_lab_2/worker-2/.idea/misc.xml
Normal file
6
simonov_nikita_lab_2/worker-2/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
simonov_nikita_lab_2/worker-2/.idea/modules.xml
Normal file
8
simonov_nikita_lab_2/worker-2/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/worker-2.iml" filepath="$PROJECT_DIR$/worker-2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
18
simonov_nikita_lab_2/worker-2/Dockerfile
Normal file
18
simonov_nikita_lab_2/worker-2/Dockerfile
Normal file
@ -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/FindingLargestNumberFile.java
|
||||
|
||||
# Запускаем Java-приложение
|
||||
CMD ["java", "-cp", "/app/src", "FindingLargestNumberFile"]
|
@ -0,0 +1,56 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Программа для поиска наибольшего числа в файле, вычисления его второй степени и сохранения результата в другом файле.
|
||||
*/
|
||||
public class FindingLargestNumberFile {
|
||||
|
||||
/**
|
||||
* Точка входа в программу.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
14
simonov_nikita_lab_2/worker-2/worker-2.iml
Normal file
14
simonov_nikita_lab_2/worker-2/worker-2.iml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="SonarLintModuleSettings">
|
||||
<option name="uniqueId" value="ca0d01ae-0c7f-4c2c-b85f-2442b28d754e" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue
Block a user