Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HW2 Task manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diana.alkateeb
HW2 Task manager
Commits
5b7d4e2f
Commit
5b7d4e2f
authored
Apr 27, 2019
by
Wagner Franchin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved the code and updated the README.md
parent
bccc6ece
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
29 deletions
+43
-29
README.md
README.md
+6
-2
TaskExecutor.java
src/singleton/TaskExecutor.java
+22
-17
TaskBitcoin.java
src/task/TaskBitcoin.java
+6
-3
TaskFiboRecursive.java
src/task/TaskFiboRecursive.java
+6
-4
TaskNotFound.java
src/task/TaskNotFound.java
+3
-3
No files found.
README.md
View file @
5b7d4e2f
...
@@ -66,6 +66,10 @@ Something like this should be expected as output:
...
@@ -66,6 +66,10 @@ Something like this should be expected as output:
wfranchi@computer:~$
curl
-d
TaskHello
-d
World http://localhost:8000
wfranchi@computer:~$
curl
-d
TaskHello
-d
World http://localhost:8000
Result: Hello World;
Executed
in
: 0,00s
Result: Hello World;
Executed
in
: 0,00s
```
```
Just two parameters are allowed:
`-d <task name> -d <parameter values>`
.
If you want to pass more parameter values one suggestion is to use key delimiter like comma
`,`
.
## Running the web servers in Docker containers
## Running the web servers in Docker containers
### 1. Download the project
### 1. Download the project
...
@@ -78,12 +82,12 @@ cd task-webserver-docker
...
@@ -78,12 +82,12 @@ cd task-webserver-docker
$ docker build -t taskwebserver:1.0 .
$ docker build -t taskwebserver:1.0 .
```
```
### 3. Running the web servers in different containers
### 3. Running the web servers in different containers
Let's start the
`WebServerSocket`
container that can be accessed through the port
`8000`
:
Let's
two containers. First
start the
`WebServerSocket`
container that can be accessed through the port
`8000`
:
```
```
$ docker run -d --rm --name webserversocket -e WEBSERVER=WebServerSocket -p 8000:8000 taskwebserver:1.0
$ docker run -d --rm --name webserversocket -e WEBSERVER=WebServerSocket -p 8000:8000 taskwebserver:1.0
```
```
Let's
start the
`WebServerHttp`
container that can be accessed through the port
`8001`
:
And then
start the
`WebServerHttp`
container that can be accessed through the port
`8001`
:
```
```
$ docker run -d --rm --name webserverhttp -e WEBSERVER=WebServerHttp -p 8001:8000 taskwebserver:1.0
$ docker run -d --rm --name webserverhttp -e WEBSERVER=WebServerHttp -p 8001:8000 taskwebserver:1.0
```
```
...
...
src/singleton/TaskExecutor.java
View file @
5b7d4e2f
...
@@ -13,28 +13,33 @@ public enum TaskExecutor {
...
@@ -13,28 +13,33 @@ public enum TaskExecutor {
INSTANCE
;
INSTANCE
;
public
String
run
(
String
parameters
)
{
public
String
run
(
String
parameters
)
{
Task
task
;
List
<
String
>
list
=
Arrays
.
stream
(
parameters
.
split
(
"&"
)).
collect
(
Collectors
.
toList
());
List
<
String
>
list
=
Arrays
.
stream
(
parameters
.
split
(
"&"
)).
collect
(
Collectors
.
toList
());
String
taskName
=
list
.
get
(
0
);
String
input
=
list
.
get
(
1
);
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
Task
task
;
if
(
list
.
size
()
!=
2
)
{
switch
(
taskName
)
{
task
=
new
TaskIncorrectParams
(
""
);
case
"TaskBubbleSort"
:
}
else
{
task
=
new
TaskBubbleSort
(
input
);
String
taskName
=
list
.
get
(
0
);
break
;
String
input
=
list
.
get
(
1
);
case
"TaskFiboRecursive"
:
task
=
new
TaskFiboRecursive
(
input
);
switch
(
taskName
)
{
break
;
case
"TaskBubbleSort"
:
case
"TaskBitcoin"
:
task
=
new
TaskBubbleSort
(
input
);
task
=
new
TaskBitcoin
(
input
);
break
;
break
;
case
"TaskFiboRecursive"
:
default
:
task
=
new
TaskFiboRecursive
(
input
);
task
=
new
NoTask
(
""
);
break
;
break
;
case
"TaskBitcoin"
:
task
=
new
TaskBitcoin
(
input
);
break
;
default
:
task
=
new
TaskNotFound
(
""
);
break
;
}
task
.
execute
();
}
}
task
.
execute
();
TasksList
.
INSTANCE
.
add
(
task
);
TasksList
.
INSTANCE
.
add
(
task
);
long
end
=
System
.
currentTimeMillis
();
long
end
=
System
.
currentTimeMillis
();
...
...
src/task/TaskBitcoin.java
View file @
5b7d4e2f
...
@@ -16,9 +16,12 @@ public class TaskBitcoin extends TaskImpl {
...
@@ -16,9 +16,12 @@ public class TaskBitcoin extends TaskImpl {
@Override
@Override
public
void
execute
()
{
public
void
execute
()
{
String
[]
stringArray
=
input
.
split
(
","
);
try
{
int
times
=
Integer
.
valueOf
(
stringArray
[
0
]);
int
times
=
Integer
.
valueOf
(
input
);
result
=
getInfo
(
times
);
result
=
getInfo
(
times
);
}
catch
(
Exception
e
)
{
result
=
"Exception: "
+
e
.
getMessage
();
}
}
}
public
String
getInfo
(
int
times
)
{
public
String
getInfo
(
int
times
)
{
...
...
src/task/TaskFiboRecursive.java
View file @
5b7d4e2f
...
@@ -8,10 +8,12 @@ public class TaskFiboRecursive extends TaskImpl {
...
@@ -8,10 +8,12 @@ public class TaskFiboRecursive extends TaskImpl {
@Override
@Override
public
void
execute
()
{
public
void
execute
()
{
String
[]
stringArray
=
input
.
split
(
","
);
try
{
// just one number is expected
int
n
=
Integer
.
valueOf
(
input
);
int
n
=
Integer
.
valueOf
(
stringArray
[
0
]);
result
=
String
.
valueOf
(
fibonacci
(
n
));
result
=
String
.
valueOf
(
fibonacci
(
n
));
}
catch
(
Exception
e
)
{
result
=
"Exception: "
+
e
.
getMessage
();
}
}
}
/**
/**
...
...
src/task/
NoTask
.java
→
src/task/
TaskNotFound
.java
View file @
5b7d4e2f
package
task
;
package
task
;
public
class
NoTask
extends
TaskImpl
{
public
final
class
TaskNotFound
extends
TaskImpl
{
public
NoTask
(
String
input
)
{
public
TaskNotFound
(
String
input
)
{
super
(
input
);
super
(
input
);
}
}
...
@@ -11,6 +11,6 @@ public class NoTask extends TaskImpl {
...
@@ -11,6 +11,6 @@ public class NoTask extends TaskImpl {
@Override
@Override
public
String
getResult
()
{
public
String
getResult
()
{
return
"This task doesn't exist.\n"
;
return
"
ERROR:
This task doesn't exist.\n"
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment