├── .gitattributes
├── .idea
├── .gitignore
├── libraries
│ └── End_of_module.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
└── vcs.xml
├── CODE_OF_CONDUCT.md
├── Java_Task_Scheduling.iml
├── LICENSE
├── README.md
├── Xtra
├── Classes.lnk
├── GUI.exe
├── JAVAC.c
├── Matrix.c
├── Matrix.exe
├── Readme.PNG
├── Somme Matricielle.lnk
├── TSServer.c
├── TSServer.exe
├── Task Management Project GUI.lnk
├── Task management.lnk
├── TaskManagement_Process.c
├── TaskManagement_Process.lnk
├── TaskManagements.c
├── TaskManagements.exe
├── config.txt
├── config0.txt
├── config1.txt
├── config2.txt
├── config3.txt
├── kernel.txt
├── rmiregistry.c
├── rmiregistry.exe
├── ship.jpg
├── slave0.c
├── slave0.exe
├── slave1.c
├── slave1.exe
├── slave2.c
├── slave2.exe
├── slave3.c
└── slave3.exe
├── build.xml
├── build
├── built-jar.properties
└── classes
│ ├── .netbeans_automatic_build
│ ├── .netbeans_update_resources
│ └── Classes
│ ├── 3558
│ ├── 6612
│ ├── 7715
│ ├── 9607
│ ├── CovolutionTask.class
│ ├── FilterTask.class
│ ├── MatrixTask.class
│ ├── SlaveTask.class
│ ├── Task.class
│ ├── TaskResult.class
│ ├── TaskScheduler.class
│ ├── TaskSchedulerClient.class
│ ├── TaskSchedulerInterface.class
│ ├── TaskSchedulerServer.class
│ ├── Taskqueue.class
│ ├── Tasks$1.class
│ ├── Tasks$2.class
│ ├── Tasks$3.class
│ ├── Tasks$4.class
│ ├── Tasks$5.class
│ ├── Tasks$6.class
│ ├── Tasks$7.class
│ ├── Tasks.class
│ ├── Tasks.form
│ ├── WorkerThread.class
│ ├── convolutionresult.jpg
│ └── filterresult.jpg
├── dist
└── End_of_module.jar
├── imageResult
├── nbproject
├── build-impl.xml
├── genfiles.properties
├── private
│ ├── private.properties
│ └── private.xml
├── project.properties
└── project.xml
└── src
└── Classes
├── CovolutionTask.class
├── CovolutionTask.java
├── FilterTask.class
├── FilterTask.java
├── MatrixTask.class
├── MatrixTask.java
├── SlaveTask.class
├── SlaveTask.java
├── Task.class
├── Task.java
├── TaskResult.class
├── TaskResult.java
├── TaskScheduler.class
├── TaskScheduler.java
├── TaskSchedulerClient.class
├── TaskSchedulerClient.java
├── TaskSchedulerInterface.class
├── TaskSchedulerInterface.java
├── TaskSchedulerServer.class
├── TaskSchedulerServer.java
├── Taskqueue.class
├── Taskqueue.java
├── Tasks$1.class
├── Tasks$2.class
├── Tasks$3.class
├── Tasks$4.class
├── Tasks$5.class
├── Tasks$6.class
├── Tasks$7.class
├── Tasks.class
├── Tasks.form
├── Tasks.java
├── WorkerThread.class
├── WorkerThread.java
└── filterresult.jpg
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.zip export-ignore
2 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/libraries/End_of_module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | https://github.com/walidbosso.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/Java_Task_Scheduling.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | [](https://github.com/walidbosso/Java_Task_Scheduling)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | # Java Task Scheduling System
26 |
27 |
28 |
29 |
30 |
31 |
32 | ## Presentation:
33 | - This project introduces a Java-based Distributed Task Scheduling System for parallel data(Image & Matrix) processing using `Threads`.
34 | - Efficient task scheduling optimizes resource allocation and timeframes.
35 |
36 |
37 | ## What does my project do exactly:
38 | - Clients can easily submit various tasks like *Filter, Convolution, and Matrix*, executed via `RMI` on the server. All will be executed in parallel.
39 | - Server and its workers further breaks down tasks to pieces and send them through `TCP` to slaves, then compiles outcomes when they are ready again, and then sends the result back to the client.
40 | - Slaves play a pivotal role by executing assigned sub-tasks.
41 |
42 |
43 |
44 | ## Instructions:
45 | - Fork & Clone the repository.
46 |
47 | - Install JDK if its not installed yet, when done, go to your system environement variables, Edit Path, and add "C:\Path\To\Your\JDK\bin" at the end of it.
48 |
49 | - Put all 5 config.txt files+ image+ kernel.txt in Desktop
50 |
51 | **Inside folder "src" open 8 of Git-Bash in each 1 of type these lines:**
52 |
53 |
54 | ```bash
55 | # Compile Java files
56 | javac Classes/*.java
57 |
58 | # Starts the slaves listening TCP
59 | java Classes.SlaveTask config0.txt
60 | java Classes.SlaveTask config1.txt
61 | java Classes.SlaveTask config2.txt
62 | java Classes.SlaveTask config3.txt
63 |
64 | # Open the RMI port
65 | rmiregistry 13190
66 |
67 | # Start the server, creates multiple workers which works in parallel
68 | java Classes.TaskSchedulerServer config.txt
69 |
70 | # Open the GUI
71 | java Classes.Tasks
72 | ```
73 |
74 |
75 | ## Extra
76 | ### A port open error:
77 | ```bash
78 | jps #To see all javaprocess along with PID
79 | ```
80 | ```bash
81 | taskkill /PID 5032 /F #To terminate in case it was needed, 5032 is just an example.
82 | ```
83 |
84 |
85 | ### More ressources:
86 |
87 | - In case you didn't want to do this manually and felt lazy, check the folder called `Xtra`, I included C codes where it can automatize this work, just fix the Path to each C file in each C code, compile each one of them. When you finish, run **TaskManagement_Process.exe**, this will run all the 8 commands I mentioned above automatically.
88 | - Now whenever you feel like trying the project again just run **TaskManagement_Process.exe**, no need to run 8 commands every single time, consider creating a link to the .exe file instead and add an icon.
89 | - Contact me in [LinkedIn](https://www.linkedin.com/in/walidbosso) for questions.
90 |
91 |
92 |
93 |
94 |
95 | ----------------------
96 | > >
© *by Walid BOUSSOU* 🇲🇦 😄
97 | ----------------------
98 |
99 |
100 |
101 | 👏 Thanks for the support
102 |
103 | ## Stargazers
104 |
105 |
106 |
107 |
108 | [](https://github.com/walidbosso/Java_Task_Scheduling/stargazers)
109 |
110 |
111 |
112 |
113 |
114 | ## Forkers
115 |
116 |
117 |
118 | [](https://github.com/walidbosso/Java_Task_Scheduling/network/members)
119 |
120 |
121 |
122 | ## Contributors
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | 
135 |
136 |
137 |
138 |
139 | 
140 |
141 |
142 |

143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 | 𝚂𝚑𝚘𝚠 𝚜𝚘𝚖𝚎 💙 𝚋𝚢 𝚜𝚝𝚊𝚛𝚛𝚒𝚗𝚐 ⭐ 𝚝𝚑𝚎 𝚛𝚎𝚙𝚘𝚜𝚒𝚝𝚘𝚛𝚢!
159 |
160 |
161 |
162 |
163 |

164 |
165 |
166 |
171 |
--------------------------------------------------------------------------------
/Xtra/Classes.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Classes.lnk
--------------------------------------------------------------------------------
/Xtra/GUI.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/GUI.exe
--------------------------------------------------------------------------------
/Xtra/JAVAC.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | // Replace the path with the path to your Java source files
6 | system("javac -cp PATH_TO\\src\\Classes\\*.java");
7 |
8 |
9 | return 0;
10 | }
11 |
--------------------------------------------------------------------------------
/Xtra/Matrix.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | int main() {
7 |
8 | while(true){
9 | system("java -cp PATH_TO\\src Classes.TaskSchedulerClient");
10 | system("pause");
11 | system("cls");
12 | };
13 |
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/Xtra/Matrix.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Matrix.exe
--------------------------------------------------------------------------------
/Xtra/Readme.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Readme.PNG
--------------------------------------------------------------------------------
/Xtra/Somme Matricielle.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Somme Matricielle.lnk
--------------------------------------------------------------------------------
/Xtra/TSServer.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 |
7 | system("java -cp PATH_TO Classes.TaskSchedulerServer config.txt");
8 |
9 | return 0;
10 | }
11 |
--------------------------------------------------------------------------------
/Xtra/TSServer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/TSServer.exe
--------------------------------------------------------------------------------
/Xtra/Task Management Project GUI.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Task Management Project GUI.lnk
--------------------------------------------------------------------------------
/Xtra/Task management.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/Task management.lnk
--------------------------------------------------------------------------------
/Xtra/TaskManagement_Process.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | system("start \"\" \"PATH_TO\\slave0.exe\"");
7 | system("start \"\" \"PATH_TO\\slave1.exe\"");
8 | system("start \"\" \"PATH_TO\\slave2.exe\"");
9 | system("start \"\" \"PATH_TO\\slave3.exe\"");
10 | system("start \"\" \"PATH_TO\\rmiregistry.exe\"");
11 | system("start \"\" \"PATH_TO\\TSServer.exe\"");
12 | system("start \"\" \"PATH_TO\\TaskManagements.exe\"");
13 |
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/Xtra/TaskManagement_Process.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/TaskManagement_Process.lnk
--------------------------------------------------------------------------------
/Xtra/TaskManagements.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 |
7 | system("java -cp PATH_TO Classes.Tasks");
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Xtra/TaskManagements.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/TaskManagements.exe
--------------------------------------------------------------------------------
/Xtra/config.txt:
--------------------------------------------------------------------------------
1 | SlaveIp;127.0.0.1
2 | SlavePort;9000
3 | SlaveIp;127.0.0.1
4 | SlavePort;9001
5 | SlaveIp;127.0.0.1
6 | SlavePort;9002
7 | SlaveIp;127.0.0.1
8 | SlavePort;9003
--------------------------------------------------------------------------------
/Xtra/config0.txt:
--------------------------------------------------------------------------------
1 | port;9000
--------------------------------------------------------------------------------
/Xtra/config1.txt:
--------------------------------------------------------------------------------
1 | port;9001
2 |
--------------------------------------------------------------------------------
/Xtra/config2.txt:
--------------------------------------------------------------------------------
1 | port;9002
--------------------------------------------------------------------------------
/Xtra/config3.txt:
--------------------------------------------------------------------------------
1 | port;9003
--------------------------------------------------------------------------------
/Xtra/kernel.txt:
--------------------------------------------------------------------------------
1 | -1 0 -1 0 8 0 -1 0 -1
--------------------------------------------------------------------------------
/Xtra/rmiregistry.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 |
7 | if (chdir("PATH_TO\\src") != 0) {
8 | perror("chdir failed");
9 | exit(EXIT_FAILURE);
10 | }
11 |
12 | system("rmiregistry 13190");
13 |
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/Xtra/rmiregistry.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/rmiregistry.exe
--------------------------------------------------------------------------------
/Xtra/ship.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/ship.jpg
--------------------------------------------------------------------------------
/Xtra/slave0.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | system("java -cp PATH_TO\\src Classes.SlaveTask config0.txt");
7 |
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Xtra/slave0.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/slave0.exe
--------------------------------------------------------------------------------
/Xtra/slave1.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | system("java -cp PATH_TO\\src Classes.SlaveTask config1.txt");
7 |
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Xtra/slave1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/slave1.exe
--------------------------------------------------------------------------------
/Xtra/slave2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | system("java -cp PATH_TO\\src Classes.SlaveTask config2.txt");
7 |
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Xtra/slave2.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/slave2.exe
--------------------------------------------------------------------------------
/Xtra/slave3.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | system("java -cp PATH_TO\\src Classes.SlaveTask config3.txt");
7 |
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Xtra/slave3.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/Xtra/slave3.exe
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project End_of_module.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/build/built-jar.properties:
--------------------------------------------------------------------------------
1 | #Sun, 29 Jan 2023 19:24:59 +0100
2 |
3 |
4 | C\:\\Users\\USER\\Documents\\NetBeansProjects\\End_of_module=
5 |
--------------------------------------------------------------------------------
/build/classes/.netbeans_automatic_build:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/.netbeans_automatic_build
--------------------------------------------------------------------------------
/build/classes/.netbeans_update_resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/.netbeans_update_resources
--------------------------------------------------------------------------------
/build/classes/Classes/3558:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/3558
--------------------------------------------------------------------------------
/build/classes/Classes/6612:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/6612
--------------------------------------------------------------------------------
/build/classes/Classes/7715:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/7715
--------------------------------------------------------------------------------
/build/classes/Classes/9607:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/9607
--------------------------------------------------------------------------------
/build/classes/Classes/CovolutionTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/CovolutionTask.class
--------------------------------------------------------------------------------
/build/classes/Classes/FilterTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/FilterTask.class
--------------------------------------------------------------------------------
/build/classes/Classes/MatrixTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/MatrixTask.class
--------------------------------------------------------------------------------
/build/classes/Classes/SlaveTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/SlaveTask.class
--------------------------------------------------------------------------------
/build/classes/Classes/Task.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Task.class
--------------------------------------------------------------------------------
/build/classes/Classes/TaskResult.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/TaskResult.class
--------------------------------------------------------------------------------
/build/classes/Classes/TaskScheduler.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/TaskScheduler.class
--------------------------------------------------------------------------------
/build/classes/Classes/TaskSchedulerClient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/TaskSchedulerClient.class
--------------------------------------------------------------------------------
/build/classes/Classes/TaskSchedulerInterface.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/TaskSchedulerInterface.class
--------------------------------------------------------------------------------
/build/classes/Classes/TaskSchedulerServer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/TaskSchedulerServer.class
--------------------------------------------------------------------------------
/build/classes/Classes/Taskqueue.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Taskqueue.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$1.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$2.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$3.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$4.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$5.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$6.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks$7.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/Tasks.class
--------------------------------------------------------------------------------
/build/classes/Classes/Tasks.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
180 |
--------------------------------------------------------------------------------
/build/classes/Classes/WorkerThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/WorkerThread.class
--------------------------------------------------------------------------------
/build/classes/Classes/convolutionresult.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/convolutionresult.jpg
--------------------------------------------------------------------------------
/build/classes/Classes/filterresult.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/build/classes/Classes/filterresult.jpg
--------------------------------------------------------------------------------
/dist/End_of_module.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/dist/End_of_module.jar
--------------------------------------------------------------------------------
/imageResult:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/imageResult
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=5d314871
2 | build.xml.script.CRC32=32c5cab9
3 | build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=5d314871
7 | nbproject/build-impl.xml.script.CRC32=211db6ee
8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48
9 |
--------------------------------------------------------------------------------
/nbproject/private/private.properties:
--------------------------------------------------------------------------------
1 | compile.on.save=true
2 | user.properties.file=C:\\Users\\USER\\AppData\\Roaming\\NetBeans\\15\\build.properties
3 |
--------------------------------------------------------------------------------
/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/TaskSchedulerInterface.java
7 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/TaskResult.java
8 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/FilterTask.java
9 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/WorkerThread.java
10 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/Taskqueue.java
11 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/convolutionresult.jpg
12 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/Task.java
13 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/TaskSchedulerClient.java
14 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/TaskScheduler.java
15 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/TaskSchedulerServer.java
16 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/filterresult.jpg
17 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/SlaveTask.java
18 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/CovolutionTask.java
19 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/MatrixTask.java
20 | file:/C:/Users/USER/Documents/NetBeansProjects/End_of_module/src/Classes/Tasks.java
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.modulepath=\
22 | ${run.modulepath}
23 | debug.test.classpath=\
24 | ${run.test.classpath}
25 | debug.test.modulepath=\
26 | ${run.test.modulepath}
27 | # Files in build.classes.dir which should be excluded from distribution jar
28 | dist.archive.excludes=
29 | # This directory is removed when the project is cleaned:
30 | dist.dir=dist
31 | dist.jar=${dist.dir}/End_of_module.jar
32 | dist.javadoc.dir=${dist.dir}/javadoc
33 | dist.jlink.dir=${dist.dir}/jlink
34 | dist.jlink.output=${dist.jlink.dir}/End_of_module
35 | excludes=
36 | includes=**
37 | jar.compress=false
38 | javac.classpath=
39 | # Space-separated list of extra javac options
40 | javac.compilerargs=
41 | javac.deprecation=false
42 | javac.external.vm=true
43 | javac.modulepath=
44 | javac.processormodulepath=
45 | javac.processorpath=\
46 | ${javac.classpath}
47 | javac.source=19
48 | javac.target=19
49 | javac.test.classpath=\
50 | ${javac.classpath}:\
51 | ${build.classes.dir}
52 | javac.test.modulepath=\
53 | ${javac.modulepath}
54 | javac.test.processorpath=\
55 | ${javac.test.classpath}
56 | javadoc.additionalparam=
57 | javadoc.author=false
58 | javadoc.encoding=${source.encoding}
59 | javadoc.html5=false
60 | javadoc.noindex=false
61 | javadoc.nonavbar=false
62 | javadoc.notree=false
63 | javadoc.private=false
64 | javadoc.splitindex=true
65 | javadoc.use=true
66 | javadoc.version=false
67 | javadoc.windowtitle=
68 | # The jlink additional root modules to resolve
69 | jlink.additionalmodules=
70 | # The jlink additional command line parameters
71 | jlink.additionalparam=
72 | jlink.launcher=true
73 | jlink.launcher.name=End_of_module
74 | main.class=Classes.Tasks
75 | meta.inf.dir=${src.dir}/META-INF
76 | mkdist.disabled=true
77 | platform.active=default_platform
78 | run.classpath=\
79 | ${javac.classpath}:\
80 | ${build.classes.dir}
81 | # Space-separated list of JVM arguments used when running the project.
82 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
83 | # To set system properties for unit tests define test-sys-prop.name=value:
84 | run.jvmargs=
85 | run.modulepath=\
86 | ${javac.modulepath}
87 | run.test.classpath=\
88 | ${javac.test.classpath}:\
89 | ${build.test.classes.dir}
90 | run.test.modulepath=\
91 | ${javac.test.modulepath}
92 | source.encoding=UTF-8
93 | src.dir=src
94 | test.src.dir=test
95 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | End_of_module
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Classes/CovolutionTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/CovolutionTask.class
--------------------------------------------------------------------------------
/src/Classes/CovolutionTask.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 |
4 | import java.awt.Graphics;
5 | import java.awt.image.BufferedImage;
6 | import java.io.ByteArrayInputStream;
7 | import java.io.ByteArrayOutputStream;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.OutputStream;
11 | import java.io.Serializable;
12 | import java.net.Socket;
13 | import java.nio.ByteBuffer;
14 | import java.util.logging.Level;
15 | import java.util.logging.Logger;
16 | import javax.imageio.ImageIO;
17 | import static Classes.TaskSchedulerServer.sockets;
18 | import java.io.DataOutputStream;
19 | import java.io.PrintWriter;
20 | import java.nio.FloatBuffer;
21 |
22 | public class CovolutionTask implements Task, Serializable, Runnable {
23 |
24 | int ID;
25 | static float[] kernel;
26 | byte[] kernelB;
27 | BufferedImage outputimage1;
28 | BufferedImage outputimage2;
29 | BufferedImage outputimage3;
30 | BufferedImage outputimage4;
31 | byte[] inputImage;
32 | BufferedImage image;
33 | Object result;
34 |
35 | static String Convolution = "Convolution";
36 |
37 | //static Socket socket ;
38 | public CovolutionTask(int ID, byte[] inputImage, byte[] kernelB) {
39 | this.ID = ID;
40 | this.inputImage = inputImage;
41 | this.kernelB = kernelB;
42 | }
43 |
44 | static float[] Tofloat(byte[] kernelB) {
45 | FloatBuffer floatBuffer = ByteBuffer.wrap(kernelB).asFloatBuffer();
46 | float[] floatArray = new float[kernelB.length / 4];
47 | floatBuffer.get(floatArray);
48 | kernel = floatArray;
49 | return kernel;
50 | }
51 |
52 | public static float[] byteToFloat(byte[] input) {
53 | float[] ret = new float[input.length / 4];
54 | for (int x = 0; x < input.length; x += 4) {
55 | ret[x / 4] = ByteBuffer.wrap(input, x, 4).getFloat();
56 | }
57 | return ret;
58 | }
59 |
60 | static void send_Image(BufferedImage image, Socket socket) throws IOException {
61 | // send String
62 | PrintWriter out1 = new PrintWriter(socket.getOutputStream(), true);
63 | out1.println(Convolution);
64 |
65 | OutputStream output = socket.getOutputStream();
66 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
67 | ImageIO.write(image, "jpg", byteArrayOutputStream);
68 | byte[] size = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
69 | output.write(size);
70 | output.write(byteArrayOutputStream.toByteArray());
71 |
72 | // send kernel
73 | DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
74 | dos.writeInt(kernel.length);
75 | for (float f : kernel) {
76 | dos.writeFloat(f);
77 | }
78 |
79 | System.out.println("sending ....");
80 | }
81 |
82 | static BufferedImage receive_Image(Socket socket) throws IOException {
83 | InputStream inputStream = socket.getInputStream();
84 | System.out.println("Reading: " + System.currentTimeMillis());
85 | byte[] sizeAr = new byte[8];
86 | inputStream.read(sizeAr);
87 | int size1 = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
88 | byte[] imageAr = new byte[size1];
89 | inputStream.read(imageAr);
90 | BufferedImage image3 = ImageIO.read(new ByteArrayInputStream(imageAr));
91 | System.out.println("Received ");
92 | return image3;
93 | }
94 |
95 | //---------------- split image ------------//
96 | static BufferedImage splitImage(BufferedImage im, int square) {
97 | BufferedImage image = null;
98 | if (im == null) {
99 | return null;
100 | }
101 | switch (square) {
102 | case 1:
103 | image = im.getSubimage(1, 1, im.getWidth() / 2, im.getHeight() / 2);
104 | return image;
105 | case 2:
106 | image = im.getSubimage(im.getWidth() / 2, 0, im.getWidth() / 2, im.getHeight() / 2);
107 | return image;
108 | case 3:
109 | image = im.getSubimage(0, im.getHeight() / 2, im.getWidth() / 2, im.getHeight() / 2);
110 | return image;
111 | case 4:
112 | image = im.getSubimage(im.getWidth() / 2, im.getHeight() / 2, im.getWidth() / 2, im.getHeight() / 2);
113 | return image;
114 | }
115 | return image;
116 | }
117 |
118 | ////-------------- merger images ----------------//
119 | static BufferedImage mergeImages(BufferedImage topLeft, BufferedImage topRight, BufferedImage bottomLeft, BufferedImage bottomRight) throws IOException {
120 | int width = topLeft.getWidth() + topRight.getWidth();
121 | int height = topLeft.getHeight() + topRight.getHeight();
122 | BufferedImage mergedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
123 | Graphics graphics = mergedImage.getGraphics();
124 | graphics.drawImage(topLeft, 1, 1, null);
125 | graphics.drawImage(topRight, width / 2, 1, null);
126 | graphics.drawImage(bottomLeft, 1, height / 2, null);
127 | graphics.drawImage(bottomRight, width / 2, height / 2, null);
128 |
129 | return mergedImage;
130 | }
131 |
132 | @Override
133 | public void run() {
134 |
135 | }
136 |
137 | @Override
138 | public void execute() {
139 | try {
140 |
141 | System.out.println(" start execute");
142 |
143 | InputStream in = new ByteArrayInputStream(inputImage);
144 | image = ImageIO.read(in);
145 | kernel = byteToFloat(kernelB);
146 |
147 | BufferedImage image1 = splitImage(image, 1);
148 | send_Image(image1, sockets.get(0));
149 | outputimage1 = receive_Image(sockets.get(0));
150 |
151 | BufferedImage image2 = splitImage(image, 2);
152 | send_Image(image2, sockets.get(1));
153 | outputimage2 = receive_Image(sockets.get(1));
154 |
155 | BufferedImage image3 = splitImage(image, 3);
156 | send_Image(image3, sockets.get(2));
157 | outputimage3 = receive_Image(sockets.get(2));
158 |
159 | BufferedImage image4 = splitImage(image, 4);
160 | send_Image(image4, sockets.get(3));
161 | outputimage4 = receive_Image(sockets.get(3));
162 |
163 | result = mergeImages(outputimage1, outputimage2, outputimage3, outputimage4);
164 |
165 | } catch (IOException ex) {
166 | Logger.getLogger(CovolutionTask.class.getName()).log(Level.SEVERE, null, ex);
167 | }
168 |
169 | }
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/src/Classes/FilterTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/FilterTask.class
--------------------------------------------------------------------------------
/src/Classes/FilterTask.java:
--------------------------------------------------------------------------------
1 |
2 | package Classes;
3 |
4 |
5 | import static Classes.CovolutionTask.splitImage;
6 | import static Classes.CovolutionTask.mergeImages;
7 | import static Classes.TaskSchedulerServer.sockets;
8 | import java.awt.image.BufferedImage;
9 | import java.io.ByteArrayInputStream;
10 | import java.io.ByteArrayOutputStream;
11 | import java.io.IOException;
12 | import java.io.InputStream;
13 | import java.io.OutputStream;
14 | import java.io.PrintWriter;
15 | import java.io.Serializable;
16 | import java.net.Socket;
17 | import java.nio.ByteBuffer;
18 | import java.nio.charset.StandardCharsets;
19 | import java.util.logging.Level;
20 | import java.util.logging.Logger;
21 | import javax.imageio.ImageIO;
22 |
23 |
24 | public class FilterTask implements Task, Serializable {
25 |
26 | int ID;
27 | Object result;
28 | byte[] inputImage;
29 | BufferedImage image;
30 | byte[] filter ;
31 |
32 | BufferedImage outputimage1, outputimage2, outputimage3, outputimage4;
33 |
34 | public FilterTask(int ID, byte[] inputImage , byte[] filter1) {
35 | this.ID = ID;
36 | this.inputImage = inputImage;
37 | this.filter = filter1;
38 | }
39 |
40 | static void send_Image(BufferedImage image, Socket socket, String filter) throws IOException {
41 | // send filter name
42 | PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
43 | out.println(filter);
44 | out.flush();
45 | // send image
46 | OutputStream output = socket.getOutputStream();
47 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
48 | ImageIO.write(image, "jpg", byteArrayOutputStream);
49 | byte[] size = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
50 | output.write(size);
51 | output.write(byteArrayOutputStream.toByteArray());
52 | output.flush();
53 | System.out.println("sending ...."+filter);
54 | }
55 |
56 | //------------------receive-----------------//
57 | static BufferedImage receive_Image(Socket socket) throws IOException {
58 | InputStream inputStream = socket.getInputStream();
59 | System.out.println("Reading: " + System.currentTimeMillis());
60 | byte[] sizeAr = new byte[4];
61 | inputStream.read(sizeAr);
62 | int size1 = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
63 | byte[] imageAr = new byte[size1];
64 | inputStream.read(imageAr);
65 | BufferedImage outputImage = ImageIO.read(new ByteArrayInputStream(imageAr));
66 | System.out.println("Received from from slave ");
67 |
68 | return outputImage;
69 | }
70 |
71 | @Override
72 | public void execute() {
73 | System.out.println(" start execute");
74 |
75 | try {
76 | InputStream in = new ByteArrayInputStream(inputImage);
77 | image = ImageIO.read(in);
78 | String color = new String(filter, StandardCharsets.UTF_8);
79 |
80 | BufferedImage image1 = splitImage(image, 1);
81 | send_Image(image1, sockets.get(0),color);
82 | outputimage1 = receive_Image(sockets.get(0));
83 |
84 | BufferedImage image2 = splitImage(image, 2);
85 | send_Image(image2, sockets.get(1),color);
86 | outputimage2 = receive_Image(sockets.get(1));
87 |
88 | BufferedImage image3 = splitImage(image, 3);
89 | send_Image(image3, sockets.get(2),color);
90 | outputimage3 = receive_Image(sockets.get(2));
91 |
92 | BufferedImage image4 = splitImage(image, 4);
93 | send_Image(image4, sockets.get(3),color);
94 | outputimage4 = receive_Image(sockets.get(3));
95 |
96 | Thread.sleep(500);
97 | result = mergeImages(outputimage1, outputimage2, outputimage3, outputimage4);
98 |
99 | } catch (IOException ex) {
100 | Logger.getLogger(FilterTask.class.getName()).log(Level.SEVERE, null, ex);
101 | } catch (InterruptedException ex) {
102 | Logger.getLogger(FilterTask.class.getName()).log(Level.SEVERE, null, ex);
103 | }
104 |
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/Classes/MatrixTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/MatrixTask.class
--------------------------------------------------------------------------------
/src/Classes/MatrixTask.java:
--------------------------------------------------------------------------------
1 |
2 | package Classes;
3 |
4 | import java.io.Serializable;
5 | import java.rmi.RemoteException;
6 | import java.rmi.server.UnicastRemoteObject;
7 |
8 |
9 | public class MatrixTask implements Serializable,Task {
10 | int ID ;
11 | int[][] matrix1 ;
12 | int[][] matrix2 ;
13 | int[][] matrix3;
14 | Object Resultmatrix ;
15 | public MatrixTask(int ID , int[][] matrix1 , int[][] matrix2 ) throws RemoteException{
16 | this.matrix1 = matrix1 ;
17 | this.matrix2 = matrix2 ;
18 | this.ID = ID ;
19 | }
20 | @Override
21 | public void execute() {
22 | matrix3 = new int[matrix1.length][matrix1[0].length];
23 | for(int i=0 ; i> 24) & 0xff;
103 | int r = 0;
104 | int g = 0;
105 | int b = (p & 0xff);
106 | p = (a << 24) | (r << 16) | (g << 8) | b;
107 | image.setRGB(j, i, p);
108 | }
109 | }
110 | return image;
111 | }
112 |
113 | // green filter
114 | static BufferedImage GreenImage(BufferedImage image) {
115 | int width = image.getWidth();
116 | int height = image.getHeight();
117 |
118 | for (int x = 0; x < width; x++) {
119 | for (int y = 0; y < height; y++) {
120 | int rgb = image.getRGB(x, y);
121 |
122 | int red = (rgb >> 16) & 0xff;
123 | int green = (rgb >> 8) & 0xff;
124 | int blue = rgb & 0xff;
125 |
126 | // increase the green component and set the RGB value
127 | green = Math.min(255, green + 50);
128 | rgb = (red << 16) | (green << 8) | blue;
129 | image.setRGB(x, y, rgb);
130 | }
131 | }
132 |
133 | return image;
134 | }
135 |
136 | // red filter
137 | static BufferedImage RedImage(BufferedImage image) {
138 | int width = image.getWidth();
139 | int height = image.getHeight();
140 | WritableRaster raster = image.getRaster();
141 | int[] pixels = new int[width * height * 3];
142 | raster.getPixels(0, 0, width, height, pixels);
143 | for (int i = 0; i < pixels.length; i += 3) {
144 | pixels[i + 1] = 0;
145 | pixels[i + 2] = 0;
146 | }
147 | raster.setPixels(0, 0, width, height, pixels);
148 | return image;
149 | }
150 | //---------------apply convolution ------------//
151 |
152 | static BufferedImage Convole(BufferedImage inputimage, float[] kernel) {
153 | Kernel kernel1 = new Kernel(3, 3, kernel);
154 | ConvolveOp convolution = new ConvolveOp(kernel1);
155 | BufferedImage outputimage = convolution.filter(inputimage, null);
156 | System.out.println("convolution has been applied");
157 | return outputimage;
158 | }
159 | // ------------ read slave comfig file
160 |
161 | public static void readConfigFile_Slave() {
162 | BufferedReader bufferedReader = null;
163 | String line = "";
164 | if (file.exists()) {
165 | try {
166 | bufferedReader = new BufferedReader(new FileReader(file));
167 | System.out.println("start reading ");
168 | line = bufferedReader.readLine();
169 |
170 | String[] row = line.split(";");
171 |
172 | if ("port".equals(row[0])) {
173 | port_slave = Integer.parseInt(row[1]);
174 | } else {
175 | System.exit(-1);
176 | }
177 |
178 | } catch (Exception e) {
179 | e.printStackTrace();
180 | }
181 |
182 | } else {
183 | System.out.println("file doesn't exist");
184 | System.exit(-1);
185 | }
186 | }
187 |
188 | public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
189 | String path = "C:\\Users\\User\\Desktop\\";
190 |
191 | path += args[0];
192 | file = new File(path);
193 |
194 | readConfigFile_Slave();
195 |
196 | serverSocket = new ServerSocket(port_slave);
197 | socket = serverSocket.accept();
198 |
199 | while (true) {
200 | System.out.println("start slaves");
201 | socket = receive_Image();
202 |
203 | System.out.println(Task);
204 | if (Task.equals("Gray")) {
205 | System.out.println("start gray");
206 | outputimage = asGrayscaleImage(inputimage);
207 | resend(outputimage);
208 | }
209 | if (Task.equals("Blue")) {
210 | System.out.println("start blue");
211 | outputimage = BlueImage(inputimage);
212 | resend(outputimage);
213 | }
214 | if (Task.equals("Red")) {
215 | System.out.println("start Red");
216 | outputimage = RedImage(inputimage);
217 | resend(outputimage);
218 | }
219 | if (Task.equals("Convolution")) {
220 | outputimage = Convole(inputimage, kernel);
221 | resend(outputimage);
222 | }
223 | }
224 | }
225 |
226 | }
227 |
--------------------------------------------------------------------------------
/src/Classes/Task.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Task.class
--------------------------------------------------------------------------------
/src/Classes/Task.java:
--------------------------------------------------------------------------------
1 |
2 | package Classes;
3 |
4 | import java.io.Serializable;
5 |
6 | /* interface task */
7 | public interface Task extends Serializable {
8 |
9 | void execute() ;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/Classes/TaskResult.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/TaskResult.class
--------------------------------------------------------------------------------
/src/Classes/TaskResult.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.File;
5 |
6 | public class TaskResult {
7 |
8 | private int taskId;
9 | private Object result ;
10 | public TaskResult(int taskId, Object result) {
11 | this.taskId = taskId;
12 | this.result = result;
13 | }
14 |
15 | public int getTaskId() {
16 | return taskId;
17 | }
18 |
19 | public Object getResult() {
20 | return result;
21 | }
22 |
23 |
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/src/Classes/TaskScheduler.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/TaskScheduler.class
--------------------------------------------------------------------------------
/src/Classes/TaskScheduler.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.File;
5 | import java.rmi.RemoteException;
6 | import java.rmi.server.UnicastRemoteObject;
7 | import java.util.ArrayList;
8 | import java.util.logging.Level;
9 | import java.util.logging.Logger;
10 |
11 | public class TaskScheduler extends UnicastRemoteObject implements TaskSchedulerInterface {
12 |
13 | Object result ;
14 |
15 | Taskqueue taskQueue;
16 | int ID;
17 | MatrixTask matrixtask;
18 | FilterTask filtertask ;
19 | CovolutionTask covolutiontask;
20 | ArrayList BD;
21 |
22 | public TaskScheduler(Taskqueue taskQueue, ArrayList BD) throws RemoteException {
23 | this.taskQueue = taskQueue;
24 | this.BD = BD;
25 | }
26 |
27 | @Override
28 | public int submitTask(Task task) throws RemoteException {
29 |
30 | try {
31 |
32 | taskQueue.add(task);
33 | if ("Classes.CovolutionTask" == task.getClass().getName()) {
34 | covolutiontask = (CovolutionTask) task;
35 | ID = covolutiontask.ID;
36 |
37 | }
38 | if ("Classes.MatrixTask" == task.getClass().getName()) {
39 | matrixtask = (MatrixTask) task;
40 | ID = matrixtask.ID;
41 |
42 | }
43 | if ("Classes.FilterTask" == task.getClass().getName()) {
44 | filtertask = (FilterTask) task;
45 | ID = filtertask.ID;
46 |
47 | }
48 |
49 | } catch (InterruptedException ex) {
50 | Logger.getLogger(TaskScheduler.class.getName()).log(
51 | Level.SEVERE, null, ex);
52 | }
53 |
54 | return ID;
55 | }
56 |
57 | @Override
58 | public Object getResult(int taskId) throws RemoteException {
59 |
60 |
61 |
62 |
63 | for (int i = 0; i < BD.size(); i++) {
64 | if (taskId == BD.get(i).getTaskId()) {
65 | result = BD.get(i).getResult();
66 | System.out.println("show your result ");
67 | BD.remove(i);
68 |
69 | }
70 | }
71 |
72 |
73 | return result;
74 | }
75 |
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerClient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/TaskSchedulerClient.class
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerClient.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.BufferedReader;
5 | import java.io.ByteArrayInputStream;
6 | import java.io.ByteArrayOutputStream;
7 | import java.io.File;
8 | import java.io.FileReader;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 | import java.nio.ByteBuffer;
12 | import java.rmi.*;
13 | import java.util.Random;
14 | import javax.imageio.ImageIO;
15 | import javax.swing.ImageIcon;
16 | import javax.swing.JFrame;
17 | import javax.swing.JLabel;
18 | import javax.swing.JPanel;
19 |
20 | public class TaskSchedulerClient {
21 |
22 | static float[] kernel = new float[9];
23 |
24 | static int[][] matrix1 = {{10, 20, 30},
25 | {1, 2, 3},
26 | {1, 2, 3}};
27 |
28 | static int[][] matrix2 = {{10, 20, 30},
29 | {1, 2, 3},
30 | {1, 2, 3}};
31 |
32 | static int taskId;
33 | static int[][] matrixResult;
34 | static BufferedImage outputImage;
35 |
36 | static public void showImage(BufferedImage image, String sk_or_rmi) throws IOException {
37 | JLabel picLabel = new JLabel(new ImageIcon(image));
38 | JFrame frame = new JFrame(sk_or_rmi);
39 | frame.setSize(image.getWidth(), image.getHeight());
40 | frame.setVisible(true);
41 | JPanel panel = new JPanel();
42 | panel.setSize(image.getWidth(), image.getHeight());
43 | panel.setVisible(true);
44 | panel.add(picLabel);
45 | frame.add(panel);
46 |
47 | }
48 |
49 | public static void AfficherMtarix(int[][] matrix) {
50 | for (int i = 0; i < matrix.length; i++) {
51 | for (int j = 0; j < matrix[0].length; j++) {
52 | System.out.print(matrix[i][j] + " ");
53 | }
54 | System.out.print("\n");
55 | }
56 | }
57 |
58 | public static byte[] Tobyte(File file) throws IOException {
59 | BufferedImage image = ImageIO.read(file);
60 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
61 | ImageIO.write(image, "jpg", baos);
62 | byte[] imagebyte = baos.toByteArray();
63 | return imagebyte;
64 | }
65 | //--------- read kernel from file -----------//
66 |
67 | static float[] readKernel(File kernelfile) {
68 | BufferedReader reader = null;
69 | float[] table = new float[9];
70 | try {
71 | reader = new BufferedReader(new FileReader(kernelfile));
72 | String input = null;
73 |
74 | while ((input = reader.readLine()) != null) {
75 | String nums[] = input.trim().split("\\s+");
76 | for (int i = 0; i < 9; i++) {
77 | table[i] = Float.parseFloat(nums[i]);
78 | }
79 | break;
80 | }
81 |
82 | } catch (NumberFormatException | IOException e) {
83 | e.printStackTrace();
84 | }
85 | return table;
86 | }
87 |
88 | public static byte[] floatToByte(float[] input) {
89 | byte[] ret = new byte[input.length * 4];
90 | for (int x = 0; x < input.length; x++) {
91 | ByteBuffer.wrap(ret, x * 4, 4).putFloat(input[x]);
92 | }
93 | return ret;
94 | }
95 |
96 | public static void main(String[] args) throws IOException, NotBoundException {
97 | try {
98 | Random r = new Random();
99 |
100 | TaskSchedulerInterface task
101 | = (TaskSchedulerInterface) Naming.lookup("rmi://localhost:13190/task");
102 |
103 | // Submit a task to the server
104 | System.out.println("start client ...");
105 |
106 | /**
107 | * ************************ matrix example
108 | * *****************************
109 | */
110 | taskId = task.submitTask(new MatrixTask(r.nextInt(10000 - 1000) + 1000, matrix1, matrix2));
111 | System.out.println(" Submitted task with ID " + taskId);
112 | matrixResult = (int[][]) task.getResult(taskId);
113 | System.out.println("La somme des deux votre matrices est :");
114 | AfficherMtarix(matrixResult);
115 | /**
116 | * ************************ end example
117 | * *****************************
118 | */
119 |
120 | } catch (Exception e) {
121 | e.printStackTrace();
122 | }
123 |
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerInterface.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/TaskSchedulerInterface.class
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerInterface.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.File;
5 | import java.rmi.Remote;
6 | import java.rmi.RemoteException;
7 |
8 | // interface d RMI hiya contract bin client o server
9 | public interface TaskSchedulerInterface extends Remote {
10 |
11 | // had les deux methodes homa li ghaywsaom client ms mn baed maneamlolom override
12 | public int submitTask(Task task) throws RemoteException ;
13 | public Object getResult(int taskId) throws RemoteException ;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerServer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/TaskSchedulerServer.class
--------------------------------------------------------------------------------
/src/Classes/TaskSchedulerServer.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 |
4 | import java.io.BufferedReader;
5 | import java.io.File;
6 | import java.io.FileReader;
7 | import java.net.Socket;
8 | import java.rmi.Naming;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.concurrent.ExecutorService;
12 | import java.util.concurrent.Executors;
13 |
14 |
15 | public class TaskSchedulerServer {
16 |
17 | private static final int NUM_WORKER_THREADS = 8;
18 | private static ExecutorService threadPool = Executors.newFixedThreadPool(NUM_WORKER_THREADS);
19 | public static Taskqueue taskQueue = new Taskqueue();
20 | static ArrayList BD = new ArrayList<>();
21 |
22 | public static List slavesPorts = new ArrayList();
23 | public static List slavesIP = new ArrayList();
24 | public static List sockets = new ArrayList();
25 | public static File file;
26 | // Constuct
27 | public TaskSchedulerServer() {
28 | threadPool = Executors.newFixedThreadPool(NUM_WORKER_THREADS);
29 | taskQueue = new Taskqueue();
30 |
31 | }
32 |
33 | public static void start() throws InterruptedException {
34 |
35 | // Start worker threads to process tasks from the queue
36 | for (int i = 0; i < NUM_WORKER_THREADS; i++) {
37 | threadPool.submit(new WorkerThread(taskQueue, BD));
38 | }
39 |
40 | }
41 | // ------------ read master comfig file
42 |
43 | public static void readConfigFile() {
44 | BufferedReader bufferedReader = null;
45 | String line = "";
46 | if (file.exists()) {
47 | try {
48 | bufferedReader = new BufferedReader(new FileReader(file));
49 | System.out.println("start reading ");
50 | while ((line = bufferedReader.readLine()) != null) {
51 |
52 | String[] row = line.split(";");
53 | if ("SlaveIp".equals(row[0])) {
54 | slavesIP.add(row[1]);
55 |
56 | } else {
57 |
58 | System.exit(-1);
59 |
60 | }
61 | line = bufferedReader.readLine();
62 |
63 | row = line.split(";");
64 |
65 | if ("SlavePort".equals(row[0])) {
66 | slavesPorts.add(Integer.parseInt(row[1]));
67 | } else {
68 | System.exit(-1);
69 | }
70 | }
71 | } catch (Exception e) {
72 | e.printStackTrace();
73 | }
74 |
75 | } else {
76 | System.out.println("file doesn't exist");
77 | System.exit(-1);
78 | }
79 | }
80 |
81 | public static void main(String[] args) throws InterruptedException {
82 |
83 |
84 | try {
85 |
86 | TaskSchedulerInterface skeleton = new TaskScheduler(taskQueue, BD);
87 | Naming.rebind("rmi://localhost:13190/task", skeleton);
88 | System.out.println("Server is ready ...");
89 |
90 | String path = "C:\\Users\\User\\Desktop\\";
91 | path += args[0];
92 | file = new File(path);
93 | readConfigFile();
94 |
95 | for (int i = 0; i < slavesPorts.size(); i++) {
96 | sockets.add(new Socket(slavesIP.get(i) , slavesPorts.get(i)));
97 | System.out.println(slavesIP.get(i)+" "+slavesPorts.get(i));
98 | }
99 | start();
100 |
101 | } catch (Exception e) {
102 | System.out.println(e);
103 | }
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/Classes/Taskqueue.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Taskqueue.class
--------------------------------------------------------------------------------
/src/Classes/Taskqueue.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.util.concurrent.BlockingQueue;
4 | import java.util.concurrent.LinkedBlockingQueue;
5 |
6 |
7 | public class Taskqueue {
8 |
9 | BlockingQueue queue;
10 |
11 | public Taskqueue() {
12 | queue = new LinkedBlockingQueue<>();
13 | }
14 |
15 | public void add(Task task) throws InterruptedException {
16 | queue.add(task);
17 | if(!queue.isEmpty())
18 | System.out.println("task added to queue " + task.toString());
19 | }
20 |
21 | public Task take() throws InterruptedException {
22 |
23 | return queue.take();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/Classes/Tasks$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$1.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$2.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$3.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$4.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$5.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$6.class
--------------------------------------------------------------------------------
/src/Classes/Tasks$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks$7.class
--------------------------------------------------------------------------------
/src/Classes/Tasks.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/Tasks.class
--------------------------------------------------------------------------------
/src/Classes/Tasks.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
180 |
--------------------------------------------------------------------------------
/src/Classes/Tasks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package Classes;
6 |
7 | import java.awt.Image;
8 | import java.awt.image.BufferedImage;
9 | import java.io.File;
10 | import java.io.IOException;
11 | import java.util.logging.Level;
12 | import java.util.logging.Logger;
13 | import javax.imageio.ImageIO;
14 | import javax.swing.ImageIcon;
15 | import javax.swing.JFrame;
16 | import javax.swing.JLabel;
17 | import javax.swing.JPanel;
18 | import static Classes.TaskSchedulerClient.*;
19 |
20 | import java.awt.Graphics;
21 | import java.io.BufferedReader;
22 | import java.io.ByteArrayInputStream;
23 | import java.io.FileReader;
24 | import java.io.InputStream;
25 | import java.net.MalformedURLException;
26 | import java.nio.ByteBuffer;
27 | import java.rmi.Naming;
28 | import java.rmi.NotBoundException;
29 | import java.rmi.RemoteException;
30 | import java.util.Random;
31 |
32 | public class Tasks extends javax.swing.JFrame {
33 |
34 | static float[] kernel = new float[9];
35 |
36 | public Tasks() {
37 | initComponents();
38 | }
39 |
40 | @SuppressWarnings("unchecked")
41 | // //GEN-BEGIN:initComponents
42 | private void initComponents() {
43 |
44 | buttonGroup1 = new javax.swing.ButtonGroup();
45 | radio2 = new javax.swing.JRadioButton();
46 | radio1 = new javax.swing.JRadioButton();
47 | jLabel2 = new javax.swing.JLabel();
48 | F2 = new javax.swing.JTextField();
49 | jScrollPane1 = new javax.swing.JScrollPane();
50 | list1 = new javax.swing.JList<>();
51 | jLabel3 = new javax.swing.JLabel();
52 | jButton1 = new javax.swing.JButton();
53 | jLabel5 = new javax.swing.JLabel();
54 | F4 = new javax.swing.JTextField();
55 |
56 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
57 |
58 | buttonGroup1.add(radio2);
59 | radio2.setText("Convolution");
60 | radio2.addActionListener(new java.awt.event.ActionListener() {
61 | public void actionPerformed(java.awt.event.ActionEvent evt) {
62 | radio2ActionPerformed(evt);
63 | }
64 | });
65 |
66 | buttonGroup1.add(radio1);
67 | radio1.setText("Filters");
68 | radio1.addActionListener(new java.awt.event.ActionListener() {
69 | public void actionPerformed(java.awt.event.ActionEvent evt) {
70 | radio1ActionPerformed(evt);
71 | }
72 | });
73 |
74 | jLabel2.setText("kernel :");
75 |
76 | F2.setText("kernel.txt");
77 | F2.addActionListener(new java.awt.event.ActionListener() {
78 | public void actionPerformed(java.awt.event.ActionEvent evt) {
79 | F2ActionPerformed(evt);
80 | }
81 | });
82 |
83 | list1.setModel(new javax.swing.AbstractListModel() {
84 | String[] strings = { "Gray", "Blue", "Red", "Green" };
85 | public int getSize() { return strings.length; }
86 | public String getElementAt(int i) { return strings[i]; }
87 | });
88 | jScrollPane1.setViewportView(list1);
89 |
90 | jLabel3.setText("choose flter ;");
91 |
92 | jButton1.setBackground(new java.awt.Color(0, 51, 255));
93 | jButton1.setText("Display Result");
94 | jButton1.addActionListener(new java.awt.event.ActionListener() {
95 | public void actionPerformed(java.awt.event.ActionEvent evt) {
96 | jButton1ActionPerformed(evt);
97 | }
98 | });
99 |
100 | jLabel5.setText("Choose image :");
101 |
102 | F4.setText("ship.jpg");
103 | F4.addActionListener(new java.awt.event.ActionListener() {
104 | public void actionPerformed(java.awt.event.ActionEvent evt) {
105 | F4ActionPerformed(evt);
106 | }
107 | });
108 |
109 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
110 | getContentPane().setLayout(layout);
111 | layout.setHorizontalGroup(
112 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113 | .addGroup(layout.createSequentialGroup()
114 | .addGap(99, 99, 99)
115 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116 | .addComponent(jButton1)
117 | .addGroup(layout.createSequentialGroup()
118 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119 | .addComponent(jLabel3)
120 | .addComponent(radio1))
121 | .addGap(31, 31, 31)
122 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
123 | .addGroup(layout.createSequentialGroup()
124 | .addComponent(jLabel5)
125 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
126 | .addComponent(F4, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
127 | .addComponent(radio2)
128 | .addGroup(layout.createSequentialGroup()
129 | .addComponent(jLabel2)
130 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
131 | .addComponent(F2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
132 | .addContainerGap(486, Short.MAX_VALUE))
133 | );
134 | layout.setVerticalGroup(
135 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
136 | .addGroup(layout.createSequentialGroup()
137 | .addGap(23, 23, 23)
138 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
139 | .addComponent(jLabel5)
140 | .addComponent(F4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
141 | .addGap(23, 23, 23)
142 | .addComponent(radio2)
143 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
144 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
145 | .addComponent(jLabel2)
146 | .addComponent(F2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
147 | .addGap(28, 28, 28)
148 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
149 | .addGroup(layout.createSequentialGroup()
150 | .addComponent(radio1)
151 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
152 | .addComponent(jLabel3))
153 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
154 | .addGap(27, 27, 27)
155 | .addComponent(jButton1)
156 | .addContainerGap(91, Short.MAX_VALUE))
157 | );
158 |
159 | pack();
160 | }// //GEN-END:initComponents
161 |
162 | private void radio2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio2ActionPerformed
163 | // TODO add your handling code here:
164 | }//GEN-LAST:event_radio2ActionPerformed
165 |
166 | private void radio1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio1ActionPerformed
167 | // TODO add your handling code here:
168 | }//GEN-LAST:event_radio1ActionPerformed
169 |
170 | private void F2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_F2ActionPerformed
171 | // TODO add your handling code here:
172 | }//GEN-LAST:event_F2ActionPerformed
173 |
174 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
175 | try {
176 | Random r = new Random();
177 | // start RMI
178 | TaskSchedulerInterface task
179 | = (TaskSchedulerInterface) Naming.lookup("rmi://localhost:13190/task");
180 |
181 | if (radio2.isSelected()) { // Convolution part
182 | // read image file
183 | String pathimage = "C:\\Users\\User\\Desktop\\";
184 | pathimage += F4.getText();
185 | // read kernel file
186 | String pathkernel = "C:\\Users\\User\\Desktop\\";
187 | pathkernel += F2.getText();
188 | // read kernel
189 | kernel = readKernel(new File(pathkernel));
190 | File output = new File(pathimage);
191 | // image to byte
192 | byte[] imagebyte = Tobyte(output);
193 | // kernel to byte
194 | byte[] kernelbyte = floatToByte(kernel);
195 | // start filter task
196 | taskId = task.submitTask(new CovolutionTask(r.nextInt(10000 - 1000) + 1000, imagebyte, kernelbyte));
197 | System.out.println(" Submitted task with ID " + taskId);
198 | Thread.sleep(3000);
199 | // get result
200 | Object outputbyte = task.getResult(taskId);
201 | InputStream in = new ByteArrayInputStream((byte[]) outputbyte);
202 | BufferedImage outputImage = ImageIO.read(in);
203 | showImage(outputImage, "Convolution");
204 | }
205 | if (radio1.isSelected()) { // filter task
206 | String color = list1.getSelectedValue();
207 |
208 | System.out.println(color);
209 | // read image file
210 | String pathimage = "C:\\Users\\User\\Desktop\\";
211 | pathimage += F4.getText();
212 | File output = new File(pathimage);
213 | // image to byte
214 | byte[] imagebyte1 = Tobyte(output);
215 | // submit task
216 | FilterTask filter = new FilterTask(r.nextInt(10000 - 1000) + 1000, imagebyte1, color.getBytes());
217 | taskId = task.submitTask(filter);
218 | System.out.println(" Submitted task with ID " + taskId);
219 | Thread.sleep(3000);
220 | // get task result
221 | Object outputbyte1 = task.getResult(taskId);
222 | InputStream in1 = new ByteArrayInputStream((byte[]) outputbyte1);
223 | BufferedImage outputImage = ImageIO.read(in1);
224 | showImage(outputImage, color);
225 |
226 | }
227 | } catch (IOException ex) {
228 | Logger.getLogger(Tasks.class.getName()).log(Level.SEVERE, null, ex);
229 | } catch (NotBoundException ex) {
230 | Logger.getLogger(Tasks.class.getName()).log(Level.SEVERE, null, ex);
231 | } catch (InterruptedException ex) {
232 | Logger.getLogger(Tasks.class.getName()).log(Level.SEVERE, null, ex);
233 | }
234 |
235 | }//GEN-LAST:event_jButton1ActionPerformed
236 |
237 | private void F4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_F4ActionPerformed
238 | // TODO add your handling code here:
239 | }//GEN-LAST:event_F4ActionPerformed
240 |
241 | /**
242 | * @param args the command line arguments
243 | */
244 | public static void main(String args[]) {
245 | /* Set the Nimbus look and feel */
246 | //
247 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
248 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
249 | */
250 | try {
251 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
252 | if ("Nimbus".equals(info.getName())) {
253 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
254 | break;
255 | }
256 | }
257 | } catch (ClassNotFoundException ex) {
258 | java.util.logging.Logger.getLogger(Tasks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
259 | } catch (InstantiationException ex) {
260 | java.util.logging.Logger.getLogger(Tasks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
261 | } catch (IllegalAccessException ex) {
262 | java.util.logging.Logger.getLogger(Tasks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
263 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
264 | java.util.logging.Logger.getLogger(Tasks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
265 | }
266 | //
267 |
268 | /* Create and display the form */
269 | java.awt.EventQueue.invokeLater(new Runnable() {
270 | public void run() {
271 | new Tasks().setVisible(true);
272 | }
273 | });
274 | }
275 |
276 | // Variables declaration - do not modify//GEN-BEGIN:variables
277 | private javax.swing.JTextField F2;
278 | private javax.swing.JTextField F4;
279 | private javax.swing.ButtonGroup buttonGroup1;
280 | private javax.swing.JButton jButton1;
281 | private javax.swing.JLabel jLabel2;
282 | private javax.swing.JLabel jLabel3;
283 | private javax.swing.JLabel jLabel5;
284 | private javax.swing.JScrollPane jScrollPane1;
285 | private javax.swing.JList list1;
286 | private javax.swing.JRadioButton radio1;
287 | private javax.swing.JRadioButton radio2;
288 | // End of variables declaration//GEN-END:variables
289 | }
290 |
--------------------------------------------------------------------------------
/src/Classes/WorkerThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/WorkerThread.class
--------------------------------------------------------------------------------
/src/Classes/WorkerThread.java:
--------------------------------------------------------------------------------
1 | package Classes;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.util.ArrayList;
8 | import java.util.logging.Level;
9 | import java.util.logging.Logger;
10 | import javax.imageio.ImageIO;
11 |
12 | public class WorkerThread implements Runnable {
13 |
14 | Taskqueue taskQueue;
15 | ArrayList BD;
16 |
17 | public WorkerThread() {
18 |
19 | }
20 |
21 | public WorkerThread(Taskqueue taskqueue, ArrayList BD) {
22 | this.taskQueue = taskqueue;
23 | this.BD = BD;
24 | }
25 |
26 | @Override
27 | public synchronized void run() {
28 | while (true) {
29 |
30 | System.out.println(" start worker .....");
31 | try {
32 | Task task = taskQueue.take();
33 |
34 | if ("Classes.MatrixTask" == task.getClass().getName()) {
35 | MatrixTask task1 = (MatrixTask) task;
36 | task1.execute();
37 | System.out.println("done execute ");
38 | BD.add(new TaskResult(task1.ID, task1.Resultmatrix));
39 | System.out.println(" task added to BD matrix ");
40 | }
41 |
42 | if ("Classes.CovolutionTask" == task.getClass().getName()) {
43 |
44 | CovolutionTask task2 = (CovolutionTask) task;
45 | task2.execute();
46 | File output1 = new File("C:\\Users\\User\\Desktop\\convolutionresult.jpg");
47 | ImageIO.write((BufferedImage) task2.result, "jpg", output1);
48 | System.out.println("done execute ");
49 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
50 | ImageIO.write((BufferedImage) task2.result, "jpg", baos);
51 | task2.result = baos.toByteArray();
52 |
53 | BD.add(new TaskResult(task2.ID, task2.result));
54 | System.out.println(" task added to BD image " + task2.ID + " " + task2.result);
55 |
56 | }
57 | if ("Classes.FilterTask" == task.getClass().getName()) {
58 |
59 | FilterTask task3 = (FilterTask) task;
60 | task3.execute();
61 | File output1 = new File("C:\\Users\\User\\Desktop\\"+task3.ID+".jpg");
62 | ImageIO.write((BufferedImage) task3.result, "jpg", output1);
63 | System.out.println("done execute ");
64 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
65 | ImageIO.write((BufferedImage) task3.result, "jpg", baos);
66 | task3.result = baos.toByteArray();
67 |
68 | BD.add(new TaskResult(task3.ID, task3.result));
69 | System.out.println(" task added to BD image " + task3.ID + " " + task3.result);
70 |
71 | }
72 |
73 | } catch (InterruptedException ex) {
74 | System.err.println(ex.getMessage());
75 | Logger.getLogger(WorkerThread.class.getName()).log(Level.SEVERE, null, ex);
76 |
77 | } catch (IOException ex) {
78 | Logger.getLogger(WorkerThread.class.getName()).log(Level.SEVERE, null, ex);
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/Classes/filterresult.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walidbosso/Java_Task_Scheduling/8d4ac9bdd4ab602f0a1392dbfe615eae5fe123f9/src/Classes/filterresult.jpg
--------------------------------------------------------------------------------