Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performing tasks on a remote worker with Docker. #24

Open
wants to merge 290 commits into
base: scheduler
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
290 commits
Select commit Hold shift + click to select a range
d1d3516
Updated arrebol.json and fixed WorkerDockerRequestHelper
wesleymonte Jun 17, 2019
aa5d3db
Fixed conflicts
wesleymonte Jun 17, 2019
2e9e19e
Adds some checks to make sure that the application does not start wit…
joivo Jun 17, 2019
3263936
Merge pull request #33 from ufcg-lsd/hotfix/fixed-pull-image
paulofelipefeitosa Jun 17, 2019
4ffca6b
Fixes configuration properties checking
joivo Jun 18, 2019
8ff2ba0
Fixes wrong comparison
joivo Jun 18, 2019
9995d6e
Added system exit to configuration error
wesleymonte Jun 18, 2019
04980f5
Init check of commands state
wesleymonte Jun 18, 2019
d674dd7
Updated sync of task
wesleymonte Jun 19, 2019
4a227ab
Fixed executeCommand method
wesleymonte Jun 19, 2019
4108561
Fix set task state
paulofelipefeitosa Jun 19, 2019
9dbcad8
Merge branch 'feature/check-commands-state' of https://github.com/ufc…
paulofelipefeitosa Jun 19, 2019
c9df93e
Fix commands state evaluation
paulofelipefeitosa Jun 19, 2019
257d7a2
Fix exit codes array size
paulofelipefeitosa Jun 19, 2019
2778e1b
Add attach stdout json body attribute
paulofelipefeitosa Jun 19, 2019
a1160ce
Separate methods into two new classes for both testing and cohesion p…
joivo Jun 19, 2019
7ddbd80
Fixes wrong string of commands
joivo Jun 19, 2019
ba307c5
Merge pull request #34 from ufcg-lsd/feature/check-commands-state
wesleymonte Jun 19, 2019
cc7b190
Adds task scripts examples for tests purposes
joivo Jun 19, 2019
4acc5aa
Merge pull request #35 from ufcg-lsd/feature/check-commands-tests
wesleymonte Jun 19, 2019
299ee0d
Added stderr to exec instance
wesleymonte Jun 19, 2019
c0be175
Set not finished commands on error to failed
paulofelipefeitosa Jun 19, 2019
d145f83
Merge pull request #36 from ufcg-lsd/feature/add-stderr
paulofelipefeitosa Jun 19, 2019
7f66f3a
Improve initial tests
paulofelipefeitosa Jun 19, 2019
4ac36ea
Resolve merge between send-commands and remote worker feature
paulofelipefeitosa Jun 21, 2019
423cae0
Merge pull request #37 from ufcg-lsd/merge-send-commands
wesleymonte Jun 21, 2019
41b33d3
Created jobStateMonitor
wesleymonte Jun 21, 2019
5a339a1
Refactored updateJobState
wesleymonte Jun 21, 2019
31902ac
Added failed value to update job state
wesleymonte Jun 21, 2019
1e7fc3e
Renamed id to value and fixed tab size
wesleymonte Jun 21, 2019
31e2500
Fixes verification always true
joivo Jun 21, 2019
7a1ff81
Merge pull request #38 from ufcg-lsd/feature/update-job-state
paulofelipefeitosa Jun 21, 2019
590cec3
Fixes infinite loop on command execution
joivo Jun 21, 2019
f7eee51
Change Docker Task Executor Command State semantic
paulofelipefeitosa Jun 21, 2019
6bc32f7
Merge pull request #42 from ufcg-lsd/docker-exec-command-state-semantics
joivo Jun 21, 2019
eb11112
Removed setTaskState from executor
wesleymonte Jun 21, 2019
6155c9e
Refactored DockerTaskExecutor
wesleymonte Jun 21, 2019
b0130ce
Removed try catch's
wesleymonte Jun 25, 2019
0c16a4f
Merge pull request #44 from ufcg-lsd/refactor-docker-executor
joivo Jun 25, 2019
b960213
Merge pull request #45 from ufcg-lsd/docker-exec-command-state-semantics
wesleymonte Jun 25, 2019
6a54d18
Merge branch 'feature/remote-worker' into send-commands
wesleymonte Jun 25, 2019
e5bb4e1
Merge pull request #32 from ufcg-lsd/send-commands
wesleymonte Jun 25, 2019
03c6524
Merge pull request #46 from ufcg-lsd/feature/send-commands-tests
joivo Jun 25, 2019
4cb4eb9
Adds shutdown.pid file to the gitignore
joivo Jul 1, 2019
029998e
Added verification of empty ec content
wesleymonte Jul 8, 2019
331e7c3
Package of changes requested in the review
wesleymonte Jul 10, 2019
5b3c49d
Refactored configuration
wesleymonte Jul 11, 2019
d07aaee
Fixed error messages
wesleymonte Jul 11, 2019
30ee95e
Refactored defaultImageId from docker worker
wesleymonte Jul 11, 2019
0e7e072
Fixed RawConfiguration and Updated arrebol.json
wesleymonte Jul 11, 2019
a5e2b1e
Merge pull request #47 from ufcg-lsd/hotfix/refactor-configuration
joivo Jul 11, 2019
9777525
Started adding bd
wesleymonte Jul 12, 2019
e843eeb
Fixed command/specification id and updated psql properties
wesleymonte Jul 15, 2019
5b14f76
Merge pull request #48 from ufcg-lsd/feature/db-psql
joivo Jul 15, 2019
72f0d5b
Added h2 config to default app properties
wesleymonte Jul 18, 2019
7cf7612
Added unit tests for DockerTaskExecutor
wesleymonte Jul 19, 2019
a4d2410
Added test for successful execution
wesleymonte Jul 22, 2019
6613e61
Added enum to worker types
wesleymonte Jul 22, 2019
edc5fb8
Removed taskId from executeCommand method
wesleymonte Jul 22, 2019
6beadbb
Refactored executeCommand method
wesleymonte Jul 22, 2019
8927983
Added javadoc to methods from DockerCommandExecutor
wesleymonte Jul 22, 2019
fa457db
Added doc to DockerTaskExecutor
wesleymonte Jul 22, 2019
94cff19
Formatted ArrebolController
wesleymonte Jul 22, 2019
fa29733
Refactored logs, renamed methods and added docs to DockerTaskExecutor
wesleymonte Jul 23, 2019
d384761
Refactored some methods from DockeTaskExecutor
wesleymonte Jul 23, 2019
678898d
Changed commands to exitcodes in TaskExecutionResult
wesleymonte Jul 23, 2019
605a80d
Removed not used attributes
wesleymonte Jul 23, 2019
18916a5
Changed to construct the TaskExecutionResult inside method execute
wesleymonte Jul 23, 2019
3254339
Refactored method setupAndRun from DockerTaskExecutor
wesleymonte Jul 23, 2019
57fb84c
Removed unnecessary taskId from some methods and added ec file path a…
wesleymonte Jul 23, 2019
fa6a286
renamed and refactored checkTask
wesleymonte Jul 23, 2019
2ae275c
Renamed setNotFinishedCommands
wesleymonte Jul 23, 2019
669715d
Formatted exceptions and renamed exception of not found docker image
wesleymonte Jul 23, 2019
29bfd18
Formatted some classes
wesleymonte Jul 23, 2019
1e3b5a4
Updated doc from DockerTaskExecutor
wesleymonte Jul 23, 2019
47d6ba7
Renamed some methods and renamed pooling constants
wesleymonte Jul 24, 2019
d735683
Removed FIXME
wesleymonte Jul 24, 2019
307b2b2
Renamed pooling time constants
wesleymonte Jul 24, 2019
0de5f5d
Merge pull request #49 from ufcg-lsd/changes-from-review-remote-worker
joivo Jul 24, 2019
d84689f
Added comments to task-script-executor
wesleymonte Jul 24, 2019
8ab7b00
Formatted some classes
wesleymonte Jul 24, 2019
3b55797
Added comment about set +e
wesleymonte Jul 24, 2019
c3b1d11
Added configuration validator
wesleymonte Jul 24, 2019
1841dee
Added new test for DockerExecutorHelper and created DockerUnitTestUtil
wesleymonte Jul 24, 2019
cf004dc
Added test for parse ec content to array
wesleymonte Jul 25, 2019
98a3c53
Merge branch 'feature/remote-worker' into feature/docker-unit-tests
wesleymonte Jul 25, 2019
6f6a25f
Fixed errors from merge
wesleymonte Jul 25, 2019
69e8d76
Fixed file path pattern
wesleymonte Jul 25, 2019
17adb4e
Added setup to DockerExecutorHelperTest and refactored
wesleymonte Jul 25, 2019
8933f15
Merge pull request #50 from ufcg-lsd/feature/docker-unit-tests
joivo Jul 25, 2019
5fdd5b7
Refactored validation process
wesleymonte Jul 25, 2019
59bdd83
Deleted NotFoundDockerImageException
wesleymonte Jul 25, 2019
f614d69
Added doc for method syncUntilTheLastCmdFinished
wesleymonte Jul 25, 2019
f2b8bd6
Refactored DockerTaskExecutorTest
wesleymonte Jul 26, 2019
0f88363
change doc and visibility
thiagomanel Jul 26, 2019
1dfc5b9
Moved get resource path command to inside try catch block
wesleymonte Jul 26, 2019
60bedda
Added comment to method all and fixed log
wesleymonte Jul 31, 2019
b0aec4f
Refactored DockerTaskExecutor constructor
wesleymonte Jul 31, 2019
1894f66
Moved commands list var
wesleymonte Jul 31, 2019
bf5824c
Started refactored docker task executor
wesleymonte Aug 1, 2019
9bf18eb
Moved apiAddress and containerId to TaskletHelper
wesleymonte Aug 2, 2019
29ae51d
Fixed testSuccessfulExecution
wesleymonte Aug 2, 2019
c66c791
Added TaskletHelperTest
wesleymonte Aug 2, 2019
f2a6877
Added testFailMaxSizeJobSpec
wesleymonte Aug 2, 2019
255fede
Made HttpWrapper methods static
wesleymonte Aug 2, 2019
c66ac7f
Replaced destroy by destroyed
wesleymonte Aug 2, 2019
0183f29
Added doc to DockerContainerResource
wesleymonte Aug 2, 2019
c2bd0c7
Changed constants to uppercase
wesleymonte Aug 2, 2019
c8c0d5b
Added doc to DefaultTasklet
wesleymonte Aug 2, 2019
fce90ec
Added white space before braces
wesleymonte Aug 2, 2019
e6bc370
Removed commented code
wesleymonte Aug 2, 2019
72ca41e
Added test for DefaultDockerContainerResource and for DefaultTaskletTest
wesleymonte Aug 2, 2019
2f21187
Merge pull request #51 from ufcg-lsd/feature/refactored-docker-task-e…
joivo Aug 2, 2019
976cb1d
Removed JobControllerTest
wesleymonte Aug 6, 2019
fb4fc3f
Added verification to null specification
wesleymonte Aug 6, 2019
7c004d3
Added validateTaskSpec
wesleymonte Aug 6, 2019
4cda575
Fixed messages log from DockerCommandExecutor and DockerTaskExecutor
wesleymonte Aug 7, 2019
aa1520e
Added Tasklet to constructor from DockerTaskExecutor
wesleymonte Aug 7, 2019
a462d98
Renamed containerName to containerId
wesleymonte Aug 7, 2019
cd8cae8
Fixed DockerTaskExecutorTest
wesleymonte Aug 7, 2019
d45509c
Moved default image id to DockerTaskExecutor
wesleymonte Aug 7, 2019
cdbb1a4
Added state to DockerContainerResource
wesleymonte Aug 7, 2019
33eeba6
Added ContainerRequestHelper to DefaultDockerContainerResource constr…
wesleymonte Aug 8, 2019
39d1527
Renamed containerId to resourceId
wesleymonte Aug 8, 2019
13f2b85
Created DockerFileHandlerHelper
wesleymonte Aug 8, 2019
a1823dc
Removed specification from task spec
wesleymonte Aug 8, 2019
ad5c91a
Created DockerRequestHelper and renamed ContainerRequestHelper to Doc…
wesleymonte Aug 8, 2019
c58615b
Renamed DockerRequestHelper to DockerImageRequestHelper, Removed apiA…
wesleymonte Aug 8, 2019
1fe1575
Fixed Docker Tests and removed PowerMock
wesleymonte Aug 8, 2019
e1b1ee6
Removed unnecessary DockerCommandExecutor from DockerImageRequestHelper
wesleymonte Aug 8, 2019
b0635d6
Added test for verify changes of state from docker resource
wesleymonte Aug 8, 2019
f151bfb
Renamed Docker Constants and added doc to getDockerContainerRequirements
wesleymonte Aug 8, 2019
bae5c91
Merge pull request #52 from ufcg-lsd/hotfix/remove-specification
joivo Aug 9, 2019
d2ee2cb
Fixed createContainerSpecification
wesleymonte Aug 12, 2019
b4f5f65
Changed fields from json to snake case
wesleymonte Aug 12, 2019
7dc0bb0
Moved JsonProperty to property fields
wesleymonte Aug 12, 2019
81d2a13
Merge pull request #53 from ufcg-lsd/hotfix/api_snake_case
joivo Aug 12, 2019
3e18487
Created QueueController and QueueService
wesleymonte Oct 21, 2019
0449dc7
Added addJobToQueue method to QueueService
wesleymonte Oct 21, 2019
39c7bfe
Created QueueManager and Default Queue
wesleymonte Oct 21, 2019
1980a41
Added getJobByIdFromQueue
wesleymonte Oct 21, 2019
ff43c53
Created queue package within models and moved queue class
wesleymonte Oct 21, 2019
68a69c3
Changed task param to job on Queue
wesleymonte Oct 22, 2019
0a8c908
Added function to save jobs from queue to db
wesleymonte Oct 22, 2019
8c25681
Created QueueDBManager
wesleymonte Oct 22, 2019
365877d
Removed legacy code
wesleymonte Oct 22, 2019
7b960ff
Removed queue package from models
wesleymonte Oct 22, 2019
133f6b7
Created JobDBManager and deleted JobDAO
wesleymonte Oct 22, 2019
46db737
Refactoring system communication with the database
wesleymonte Oct 24, 2019
b49aaf2
Added create Queue
wesleymonte Oct 24, 2019
c73bdfd
Created getQueuesNames
wesleymonte Oct 24, 2019
225c5cb
Created endpoint to add workers to a queue
wesleymonte Oct 29, 2019
eb47684
Renamed Queue to Job Processor
wesleymonte Oct 29, 2019
474d17d
Added persistence to workers
wesleymonte Oct 31, 2019
83eac19
Refactored get queues
wesleymonte Oct 31, 2019
8c73e71
Added queue id check
wesleymonte Oct 31, 2019
93a3f8f
Updated response body from addQueue
wesleymonte Nov 4, 2019
cfff7c6
Changed jobs field from queue to waiting jobs and Renamed json fields
wesleymonte Nov 4, 2019
fd34ee9
Added get queue by id
wesleymonte Nov 5, 2019
77d5e37
Renamed fields from DefaultJobProcessorDTO
wesleymonte Nov 5, 2019
5588a3d
Default queue name modified and code formatted
joivo Nov 12, 2019
6abb416
Removed mandatory workers in queues creation
joivo Nov 13, 2019
9119f89
Added jar creation
wesleymonte Nov 14, 2019
db7475d
Added parameter to configuration file path
wesleymonte Nov 14, 2019
0ab583c
Updated Dockerfile
wesleymonte Nov 14, 2019
8449b86
Refactored build and push scripts
wesleymonte Nov 18, 2019
176a291
Fixed jar path from Dockerfile
wesleymonte Nov 18, 2019
5cf1755
Fixed tag name from push script
wesleymonte Nov 19, 2019
439c9dd
Added maven plugin dependency to pom
wesleymonte Nov 19, 2019
11faca6
Added lib dir and jar file to gitignore
wesleymonte Nov 19, 2019
05bc87f
Added lib folder to Dockerfile
wesleymonte Nov 19, 2019
f2860e5
Set taskSpec id fixed
joivo Nov 20, 2019
3db7660
Run formatter
joivo Nov 20, 2019
f2b93c1
Sync methods
joivo Nov 20, 2019
017b5ff
Add logs
joivo Nov 20, 2019
4217f60
Fix save first job state bug
joivo Nov 20, 2019
fecc577
Run formatter
joivo Nov 20, 2019
bc5da7b
Merged with feature/queues
wesleymonte Nov 20, 2019
bf44af5
Merge pull request #56 from ufcg-lsd/feature/deploy
joivo Nov 21, 2019
949b9d2
Added workernode json properties
wesleymonte Nov 21, 2019
e46085c
Renamed worker pool to pool size
wesleymonte Nov 22, 2019
43cb281
Fix default queue name
joivo Nov 22, 2019
eb93f7d
Merge branch 'hotfix/worker-json-fields' of github.com:ufcg-lsd/arreb…
joivo Nov 22, 2019
5f612fb
Merge branch 'feature/queues' into hotfix/worker-json-fields
wesleymonte Nov 22, 2019
adce0e4
Merge pull request #57 from ufcg-lsd/hotfix/worker-json-fields
joivo Nov 23, 2019
ace9b70
Added entities fields from docker executor
wesleymonte Dec 10, 2019
18e4855
Added queueName to job processor constructor
wesleymonte Dec 10, 2019
c54bd8e
Removed latest from docker image name
wesleymonte Dec 19, 2019
1719aa2
Added label to task spec
wesleymonte Dec 19, 2019
a3ac715
Fixed RawWorkerIntegrationTest
wesleymonte Dec 20, 2019
5881060
Added json ignore to task spec id field
wesleymonte Jan 9, 2020
57b1ca8
Added synchronized to save job processor method from db manager
wesleymonte Jan 20, 2020
98511bb
Changed job processor hashmap to concurrent hashmap
wesleymonte Jan 20, 2020
e06f6c0
Added try/catch on job submmit routine and update job state routine
wesleymonte Jan 20, 2020
a99a21d
Fixed null on RawWorkerIntegrationTest
wesleymonte Jan 20, 2020
e23f5d8
Merge pull request #65 from ufcg-lsd/hotfix/task-label
wesleymonte Jan 20, 2020
5bdff1b
Merge pull request #64 from ufcg-lsd/hotfix/latest-tag
wesleymonte Jan 20, 2020
4f976f7
Fixed database reset bug
wesleymonte Jan 22, 2020
acd3da8
Added rollback of jobs that were not finished
wesleymonte Feb 10, 2020
4bf2f97
Merge pull request #67 from ufcg-lsd/hotfix/persist-queue
wesleymonte Feb 27, 2020
a4778af
Merge pull request #68 from ufcg-lsd/feature/queues
wesleymonte Feb 27, 2020
9d0d7d9
Added deploy scripts
wesleymonte Feb 27, 2020
5c4f22d
Added default database user on application properties
wesleymonte Feb 27, 2020
0efed76
Added deploy docs
wesleymonte Feb 27, 2020
2c4e452
Replaced was by is.
wesleymonte Feb 27, 2020
e04b234
Fixed pgadmin.env
wesleymonte Feb 27, 2020
225d195
Update deploy.md
thiagomanel Feb 28, 2020
0c86843
Merge pull request #69 from ufcg-lsd/deploy
wesleymonte Feb 28, 2020
2037525
fix misspell
gabrielfelipeg Mar 3, 2020
ffc32ad
Merge pull request #72 from gabrielfelipeg/patch-1
joivo Mar 3, 2020
8474423
Added useful docker script
wesleymonte Apr 16, 2020
1448947
Deleted legacy docker scripts
wesleymonte Apr 16, 2020
2dc12b1
Removed 'esac' unecessary
wesleymonte Apr 29, 2020
40c287f
Updated define params function from docker script
wesleymonte Apr 29, 2020
eebeebd
Added bind mount to application properties for docker script
wesleymonte Apr 29, 2020
d1d1af6
Added stop function to docker script
wesleymonte Apr 29, 2020
71171c4
Moved fogbow scripts to fogbow dir
wesleymonte Apr 29, 2020
2bf2a28
Renamed workers dir to worker
wesleymonte Apr 29, 2020
2dfe64e
Added ansible worker deploy scripts
wesleymonte Apr 29, 2020
107b6c8
Renamed deploy.md to README.md
wesleymonte Apr 29, 2020
48e3dfc
Added info about worker deployment on deploy readme
wesleymonte Apr 29, 2020
e1fc276
Added info about where run install script
wesleymonte Apr 29, 2020
871e522
Updated comment about requirements of worker setup script
wesleymonte Apr 29, 2020
72347da
Fixed variable assignment when null on docker script
wesleymonte Apr 29, 2020
c88aa22
Added comment explaining ':-' from docker script
wesleymonte Apr 29, 2020
5bfe1b9
Added comments explaning default variables values on docker script
wesleymonte Apr 29, 2020
8cccfbd
Added comments explaning default variables values on docker script
wesleymonte Apr 29, 2020
845cd7a
Merge pull request #75 from ufcg-lsd/feature/docker-script
thiagomanel Apr 29, 2020
22df4ce
Update README.md
thiagomanel Apr 29, 2020
a6e7803
Update setup.sh
thiagomanel Apr 29, 2020
45ab8e0
Merge pull request #76 from ufcg-lsd/feature/worker-deployment
thiagomanel Apr 29, 2020
4711aa0
Added commands in the docuemntation to install Ansible
wesleymonte May 11, 2020
a714d43
Replaced 'warning' by 'note' in the worker deployment readme'
wesleymonte May 11, 2020
d61014d
Renamed deployed_worker_ip field from /worker/deploy/hosts.conf to wo…
wesleymonte May 11, 2020
772ccc2
Updated the example configuration file shown in the README of the wor…
wesleymonte May 11, 2020
5344864
Added note about firewall rule in the README.md from worker deployment
wesleymonte May 11, 2020
082c510
Updated README of arrebol deployment
wesleymonte May 11, 2020
9b6af8b
Made improvements to the README text of the deploy
wesleymonte May 12, 2020
263d226
Made improvements to the README text of the worker deploy
wesleymonte May 12, 2020
58636d1
Update README.md
thiagomanel May 12, 2020
ebec0d7
Update README.md
thiagomanel May 12, 2020
359ec42
Update README.md
thiagomanel May 12, 2020
4a64329
Merge pull request #81 from ufcg-lsd/enhancement/deploy-doc
thiagomanel May 12, 2020
08a175d
Updated deploy doc
wesleymonte May 14, 2020
78650ff
Batch of fix in the arrebol deployment doc
wesleymonte May 15, 2020
35ebd5e
Added explanation about arrebol.json in the arrebol deploy doc
wesleymonte May 15, 2020
a4503f6
Fixed typing error in the arrebol deploy doc
wesleymonte May 15, 2020
8dcff9a
Added new sections about k8s
thiagoyeds Oct 30, 2020
10004fe
Merge pull request #83 from ufcg-lsd/hotfix/arrebol-doc
thiagomanel Nov 16, 2020
a81e0c2
Merge pull request #93 from ufcg-lsd/hotfix/arrebol-k8s-doc
thiagomanel Nov 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@
@SpringBootApplication
public class ArrebolApplication {

@Bean
public Properties properties() {
return new Properties();
}

@Autowired
private ArrebolController arrebolController;

@Bean
@Lazy
public ArrebolFacade arrebolFacade(Properties properties) {
//ArrebolController arrebolController = new ArrebolController(properties);
public ArrebolFacade arrebolFacade() {
ArrebolFacade arrebolFacade = new ArrebolFacade(arrebolController);
try {
arrebolFacade.start();
Expand Down
96 changes: 60 additions & 36 deletions src/main/java/org/fogbowcloud/arrebol/ArrebolController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.fogbowcloud.arrebol;

import com.google.gson.Gson;
import org.apache.log4j.Logger;
import org.fogbowcloud.arrebol.execution.DockerTaskExecutor;
import org.fogbowcloud.arrebol.execution.RawTaskExecutor;
import org.fogbowcloud.arrebol.execution.TaskExecutor;
import org.fogbowcloud.arrebol.execution.Worker;
import org.fogbowcloud.arrebol.execution.*;
import org.fogbowcloud.arrebol.models.job.Job;
import org.fogbowcloud.arrebol.models.job.JobState;
import org.fogbowcloud.arrebol.models.specification.Specification;
Expand All @@ -20,18 +18,15 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.util.*;

@Component
public class ArrebolController {

private final Logger LOGGER = Logger.getLogger(ArrebolController.class);

private final Properties properties;
private Configuration configuration;
private final DefaultScheduler scheduler;
private final Map<String, Job> jobPool;
private final TaskQueue queue;
Expand All @@ -43,16 +38,17 @@ public class ArrebolController {
@Autowired
private JobRepository jobRepository;

public ArrebolController(Properties properties) {
this.properties = properties;
public ArrebolController() {

String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
Properties arrebolProperties = new Properties();

try (InputStream input = new FileInputStream(path + File.separator + "arrebol.conf")) {
arrebolProperties.load(input);
} catch (IOException ex) {
LOGGER.error("Error on loading properties file path=" + path, ex);
//Configuration arrebolConfiguration
try {
Gson gson = new Gson();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gson gson = new Gson(); could be moved to before the try

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to inside loadConfigurationFile method.

BufferedReader bufferedReader = new BufferedReader(new FileReader(path + File.separator + "arrebol.json"));
this.configuration = gson.fromJson(bufferedReader, Configuration.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the util certifyConfigurationProperties method you guys added. maybe, refactor lines 62-64 to a loadConfigurationFile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

DockerVariable.DEFAULT_IMAGE = this.configuration.getImageId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ins't this DockerStuff related to an specific worker type? shouldn't be moved to worker specific loading code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to inside new method called loadGlobalVariables.

} catch (FileNotFoundException e) {
LOGGER.error("Error on loading properties file path=" + path, e);
System.exit(1);
}

Expand All @@ -62,7 +58,7 @@ public ArrebolController(Properties properties) {
this.queue = new TaskQueue(queueId, queueName);

int poolId = 1;
WorkerPool pool = createPool(arrebolProperties, poolId);
WorkerPool pool = createPool(configuration, poolId);

//create the scheduler bind the pieces together
FifoSchedulerPolicy policy = new FifoSchedulerPolicy();
Expand All @@ -75,39 +71,65 @@ public ArrebolController(Properties properties) {
private static final String RAW_TYPE = "raw";
private static final String DOCKER_TYPE = "docker";

private WorkerPool createPool(Properties properties, int poolId) {
private WorkerPool createPool(Configuration configuration, int poolId) {

//we need to deal with missing/wrong properties
thiagomanel marked this conversation as resolved.
Show resolved Hide resolved

Collection<Worker> workers = new LinkedList<>();
String poolType = properties.getProperty("pool.type");

int poolSize = new Integer(properties.getProperty("pool.size"));
for (int i = 0; i < poolSize; i++) {
TaskExecutor executor = createTaskExecutor(poolType, properties);
Specification resourceSpec = null;
Worker worker = new MatchAnyWorker(resourceSpec, "resourceId-"+i, poolId, executor);
workers.add(worker);
}
populatePool(workers, poolId, configuration);

WorkerPool pool = new StaticPool(poolId, workers);
LOGGER.info("pool={" + pool + "} created with workers={" + workers + "}");

return pool;
}

private TaskExecutor createTaskExecutor(String type, Properties properties) {
private void populatePool(Collection<Worker> workers, int poolId, Configuration configuration){
String poolType = configuration.getPoolType();
if(poolType.equals(DOCKER_TYPE)){
joivo marked this conversation as resolved.
Show resolved Hide resolved
workers.addAll(createDockerWorkers(poolId, configuration));
} else if(poolType.equals(RAW_TYPE)){
workers.addAll(createRawWorkers(poolId, configuration));
}
}

private Collection<Worker> createDockerWorkers(Integer poolId, Configuration configuration){
Collection<Worker> workers = new LinkedList<>();
int poolSize = new Integer(configuration.getPoolSize());
String imageId = configuration.getImageId();
for(String address : configuration.getWorkers()){
for (int i = 0; i < poolSize; i++) {
joivo marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info("Creating docker worker with address=" + address);
joivo marked this conversation as resolved.
Show resolved Hide resolved
Worker worker = createDockerWorker(poolId, i, imageId, address);
workers.add(worker);
}
}
return workers;
}

TaskExecutor executor = null;
private Worker createDockerWorker(Integer poolId, int resourceId, String imageId, String address){
TaskExecutor executor = new DockerTaskExecutor(imageId, "docker-executor-" + UUID.randomUUID().toString(), address);
Specification resourceSpec = null;
Worker worker = new MatchAnyWorker(resourceSpec, "resourceId-"+resourceId, poolId, executor);
return worker;
}

if (type.equals(RAW_TYPE)) {
executor = new RawTaskExecutor();
} else if (type.equals(DOCKER_TYPE)) {
String imageId = properties.getProperty("pool.image_id");
executor = new DockerTaskExecutor(imageId, "docker-executor-" + UUID.randomUUID().toString());
private Collection<Worker> createRawWorkers(Integer poolId, Configuration configuration){
Collection<Worker> workers = new LinkedList<>();
int poolSize = new Integer(configuration.getPoolSize());
for (int i = 0; i < poolSize; i++) {
LOGGER.info("Creating raw worker[" + i + "]");
joivo marked this conversation as resolved.
Show resolved Hide resolved
Worker worker = createRawWorker(poolId, i);
workers.add(worker);
}
return workers;
}

return executor;
private Worker createRawWorker(Integer poolId, int resourceId){
TaskExecutor executor = new RawTaskExecutor();
Specification resourceSpec = null;
Worker worker = new MatchAnyWorker(resourceSpec, "resourceId-"+resourceId, poolId, executor);
return worker;
}

public void start() {
Expand Down Expand Up @@ -158,4 +180,6 @@ public TaskState getTaskState(String taskId) {
//FIXME:
return null;
}


}
34 changes: 34 additions & 0 deletions src/main/java/org/fogbowcloud/arrebol/Configuration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.fogbowcloud.arrebol;

import java.util.List;

public class Configuration {

private String poolType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make them final

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

private Integer poolSize;
private String imageId;
private List<String> workers;

public Configuration(String poolType, Integer poolSize, String imageId, List<String> workers) {
joivo marked this conversation as resolved.
Show resolved Hide resolved
this.poolType = poolType;
this.poolSize = poolSize;
this.imageId = imageId;
this.workers = workers;
}

public String getPoolType() {
return poolType;
}

public Integer getPoolSize() {
return poolSize;
}

public String getImageId() {
return imageId;
}

public List<String> getWorkers() {
return workers;
}
}
Loading