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:
wfranchi@computer:~$
curl
-d
TaskHello
-d
World http://localhost:8000
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
### 1. Download the project
...
...
@@ -78,12 +82,12 @@ cd task-webserver-docker
$ docker build -t taskwebserver:1.0 .
```
### 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
```
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
```
...
...
src/singleton/TaskExecutor.java
View file @
5b7d4e2f
...
...
@@ -13,28 +13,33 @@ public enum TaskExecutor {
INSTANCE
;
public
String
run
(
String
parameters
)
{
Task
task
;
List
<
String
>
list
=
Arrays
.
stream
(
parameters
.
split
(
"&"
)).
collect
(
Collectors
.
toList
());
String
taskName
=
list
.
get
(
0
);
String
input
=
list
.
get
(
1
);
long
start
=
System
.
currentTimeMillis
();
Task
task
;
switch
(
taskName
)
{
case
"TaskBubbleSort"
:
task
=
new
TaskBubbleSort
(
input
);
break
;
case
"TaskFiboRecursive"
:
task
=
new
TaskFiboRecursive
(
input
);
break
;
case
"TaskBitcoin"
:
task
=
new
TaskBitcoin
(
input
);
break
;
default
:
task
=
new
NoTask
(
""
);
break
;
if
(
list
.
size
()
!=
2
)
{
task
=
new
TaskIncorrectParams
(
""
);
}
else
{
String
taskName
=
list
.
get
(
0
);
String
input
=
list
.
get
(
1
);
switch
(
taskName
)
{
case
"TaskBubbleSort"
:
task
=
new
TaskBubbleSort
(
input
);
break
;
case
"TaskFiboRecursive"
:
task
=
new
TaskFiboRecursive
(
input
);
break
;
case
"TaskBitcoin"
:
task
=
new
TaskBitcoin
(
input
);
break
;
default
:
task
=
new
TaskNotFound
(
""
);
break
;
}
task
.
execute
();
}
task
.
execute
();
TasksList
.
INSTANCE
.
add
(
task
);
long
end
=
System
.
currentTimeMillis
();
...
...
src/task/TaskBitcoin.java
View file @
5b7d4e2f
...
...
@@ -16,9 +16,12 @@ public class TaskBitcoin extends TaskImpl {
@Override
public
void
execute
()
{
String
[]
stringArray
=
input
.
split
(
","
);
int
times
=
Integer
.
valueOf
(
stringArray
[
0
]);
result
=
getInfo
(
times
);
try
{
int
times
=
Integer
.
valueOf
(
input
);
result
=
getInfo
(
times
);
}
catch
(
Exception
e
)
{
result
=
"Exception: "
+
e
.
getMessage
();
}
}
public
String
getInfo
(
int
times
)
{
...
...
src/task/TaskFiboRecursive.java
View file @
5b7d4e2f
...
...
@@ -8,10 +8,12 @@ public class TaskFiboRecursive extends TaskImpl {
@Override
public
void
execute
()
{
String
[]
stringArray
=
input
.
split
(
","
);
// just one number is expected
int
n
=
Integer
.
valueOf
(
stringArray
[
0
]);
result
=
String
.
valueOf
(
fibonacci
(
n
));
try
{
int
n
=
Integer
.
valueOf
(
input
);
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
;
public
class
NoTask
extends
TaskImpl
{
public
final
class
TaskNotFound
extends
TaskImpl
{
public
NoTask
(
String
input
)
{
public
TaskNotFound
(
String
input
)
{
super
(
input
);
}
...
...
@@ -11,6 +11,6 @@ public class NoTask extends TaskImpl {
@Override
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