Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
d19bb690
Commit
d19bb690
authored
Mar 10, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove commons from simple planner
parent
f63cf846
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
77 deletions
+62
-77
vcs.xml
.idea/vcs.xml
+0
-6
NOTES
doc/NOTES
+1
-1
drip.properties
drip-api/src/main/resources/drip.properties
+1
-1
rpc_server.py
drip-deployer/rpc_server.py
+2
-2
rpc_server.py
drip-planner/rpc_server.py
+1
-1
RPCServer.java
...main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java
+1
-1
pom.xml
drip-simple_planner/pom.xml
+1
-7
Consumer.java
.../src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
+55
-57
Planner.java
...r/src/main/java/nl/uva/sne/drip/drip/planner/Planner.java
+0
-1
No files found.
.idea/vcs.xml
deleted
100644 → 0
View file @
f63cf846
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
doc/NOTES
View file @
d19bb690
#-------------------------Dockers--------------------------------------------
docker run -
d --hostname my-rabbit --name some-rabbit
rabbitmq:3-management
docker run -
-hostname my-rabbit --name some-rabbit -p 127.0.0.1:15672:15672 -d
rabbitmq:3-management
docker run --name mongo-inst -p 127.0.0.1:27017:27017 -d mongo:3
drip-api/src/main/resources/drip.properties
View file @
d19bb690
message.broker.host
=
1
72.17.0.3
message.broker.host
=
1
27.0.0.1
db.name
=
drip
db.username
=
drip-user
db.password
=
drip-pass
drip-deployer/rpc_server.py
View file @
d19bb690
...
...
@@ -11,7 +11,7 @@ import docker_swarm
import
control_agent
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'1
72.17.0.3
'
))
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'1
27.0.0.1
'
))
channel
=
connection
.
channel
()
channel
.
queue_declare
(
queue
=
'deployer_queue'
)
...
...
drip-planner/rpc_server.py
View file @
d19bb690
...
...
@@ -17,7 +17,7 @@ import json
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'1
72.17.0.3
'
))
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'1
27.0.0.1
'
))
channel
=
connection
.
channel
()
channel
.
queue_declare
(
queue
=
'planner_queue'
)
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java
View file @
d19bb690
...
...
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
public
class
RPCServer
{
private
static
final
String
RPC_QUEUE_NAME
=
"provisioner_queue"
;
private
static
final
String
HOST
=
"1
72.17.0.3
"
;
private
static
final
String
HOST
=
"1
27.0.0.1
"
;
public
static
void
main
(
String
[]
argv
)
{
start
();
...
...
drip-simple_planner/pom.xml
View file @
d19bb690
...
...
@@ -14,12 +14,6 @@
</properties>
<dependencies>
<dependency>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip-commons
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.rabbitmq
</groupId>
<artifactId>
amqp-client
</artifactId>
...
...
drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
View file @
d19bb690
...
...
@@ -33,8 +33,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.commons.types.MessageParameter
;
import
nl.uva.sne.drip.commons.types.Message
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -77,9 +75,9 @@ public class Consumer extends DefaultConsumer {
throw
new
FileNotFoundException
(
"Could not create output directory: "
+
tempDir
.
getAbsolutePath
());
}
//We need to extact the call parameters form the json message.
inputFiles
=
jacksonUnmarshalExample
(
message
);
//
inputFiles = jacksonUnmarshalExample(message);
//Call the method with the extracted parameters
List
<
File
>
files
=
panner
.
plan
(
inputFiles
[
0
].
getAbsolutePath
(),
inputFiles
[
1
].
getAbsolutePath
(),
tempDir
.
getAbsolutePath
());
//
List<File> files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath());
//Here we do the same as above with a different API
// inputFiles = simpleJsonUnmarshalExample(message);
...
...
@@ -87,7 +85,7 @@ public class Consumer extends DefaultConsumer {
// files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath());
//Now we need to put the result of the call to a message and respond
//Example 1
response
=
jacksonMarshalExample
(
files
);
//
response = jacksonMarshalExample(files);
//Example 2
// response = simpleJsonMarshalExample(files);
...
...
@@ -102,35 +100,35 @@ public class Consumer extends DefaultConsumer {
}
private
File
[]
jacksonUnmarshalExample
(
String
message
)
throws
IOException
{
//Use the Jackson API to convert json to Object
File
[]
files
=
new
File
[
2
];
ObjectMapper
mapper
=
new
ObjectMapper
();
Message
request
=
mapper
.
readValue
(
message
,
Message
.
class
);
List
<
MessageParameter
>
params
=
request
.
getParameters
();
//Create tmp input files
File
inputFile
=
File
.
createTempFile
(
"input-"
,
Long
.
toString
(
System
.
nanoTime
()));
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
//loop through the parameters in a message to find the input files
for
(
MessageParameter
param
:
params
)
{
if
(
param
.
getName
().
equals
(
"input"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
out
.
print
(
param
.
getValue
());
}
files
[
0
]
=
inputFile
;
}
if
(
param
.
getName
().
equals
(
"example"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
exampleFile
))
{
out
.
print
(
param
.
getValue
());
}
files
[
1
]
=
exampleFile
;
}
}
//Return the array with input files
return
files
;
}
//
private File[] jacksonUnmarshalExample(String message) throws IOException {
//
//Use the Jackson API to convert json to Object
//
File[] files = new File[2];
//
ObjectMapper mapper = new ObjectMapper();
//
Message request = mapper.readValue(message, Message.class);
//
//
List<MessageParameter> params = request.getParameters();
//
//
//Create tmp input files
//
File inputFile = File.createTempFile("input-", Long.toString(System.nanoTime()));
//
File exampleFile = File.createTempFile("example-", Long.toString(System.nanoTime()));
//
//loop through the parameters in a message to find the input files
//
for (MessageParameter param : params) {
//
if (param.getName().equals("input")) {
//
try (PrintWriter out = new PrintWriter(inputFile)) {
//
out.print(param.getValue());
//
}
//
files[0] = inputFile;
//
}
//
if (param.getName().equals("example")) {
//
try (PrintWriter out = new PrintWriter(exampleFile)) {
//
out.print(param.getValue());
//
}
//
files[1] = exampleFile;
//
}
//
}
//
//Return the array with input files
//
return files;
//
}
private
File
[]
simpleJsonUnmarshalExample
(
String
message
)
throws
JSONException
,
FileNotFoundException
,
IOException
{
//Use the JSONObject API to convert json to Object (Message)
...
...
@@ -141,16 +139,16 @@ public class Consumer extends DefaultConsumer {
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
MessageParameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
"name"
);
if
(
name
.
equals
(
"input"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
out
.
print
(
param
.
get
(
MessageParameter
.
VALUE
));
out
.
print
(
param
.
get
(
"value"
));
}
files
[
0
]
=
inputFile
;
}
if
(
name
.
equals
(
"example"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
exampleFile
))
{
out
.
print
(
param
.
get
(
MessageParameter
.
VALUE
));
out
.
print
(
param
.
get
(
"value"
));
}
files
[
1
]
=
exampleFile
;
}
...
...
@@ -158,26 +156,26 @@ public class Consumer extends DefaultConsumer {
return
files
;
}
private
String
jacksonMarshalExample
(
List
<
File
>
files
)
throws
UnsupportedEncodingException
,
IOException
{
//Use the jackson API to convert Object (Message) to json
Message
responseMessage
=
new
Message
();
List
parameters
=
new
ArrayList
();
String
charset
=
"UTF-8"
;
for
(
File
f
:
files
)
{
MessageParameter
fileParam
=
new
MessageParameter
();
byte
[]
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
f
.
getAbsolutePath
()));
fileParam
.
setValue
(
new
String
(
bytes
,
charset
));
fileParam
.
setEncoding
(
charset
);
fileParam
.
setName
(
f
.
getName
());
parameters
.
add
(
fileParam
);
}
responseMessage
.
setParameters
(
parameters
);
//The creationDate is the only filed that has to be there
responseMessage
.
setCreationDate
((
System
.
currentTimeMillis
()));
ObjectMapper
mapper
=
new
ObjectMapper
();
return
mapper
.
writeValueAsString
(
responseMessage
);
}
//
private String jacksonMarshalExample(List<File> files) throws UnsupportedEncodingException, IOException {
//
//Use the jackson API to convert Object (Message) to json
//
Message responseMessage = new Message();
//
List parameters = new ArrayList();
//
String charset = "UTF-8";
//
for (File f : files) {
//
MessageParameter fileParam = new MessageParameter();
//
byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath()));
//
fileParam.setValue(new String(bytes, charset));
//
fileParam.setEncoding(charset);
//
fileParam.setName(f.getName());
//
parameters.add(fileParam);
//
}
//
responseMessage.setParameters(parameters);
//
//The creationDate is the only filed that has to be there
//
responseMessage.setCreationDate((System.currentTimeMillis()));
//
//
ObjectMapper mapper = new ObjectMapper();
//
return mapper.writeValueAsString(responseMessage);
//
}
private
String
simpleJsonMarshalExample
(
List
<
File
>
files
)
throws
JSONException
,
IOException
{
//Use the JSONObject API to convert Object (Message) to json
...
...
drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/Planner.java
View file @
d19bb690
...
...
@@ -24,7 +24,6 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
nl.uva.sne.drip.commons.utils.Converter
;
/**
*
...
...
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