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
5e0247c7
Commit
5e0247c7
authored
Mar 02, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate plan from planner out put using a new converter
parent
fd6f2491
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
15 deletions
+43
-15
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+31
-7
ClusterCredentials.java
...ava/nl/uva/sne/drip/commons/types/ClusterCredentials.java
+7
-8
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+5
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
5e0247c7
...
...
@@ -15,17 +15,23 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
import
nl.uva.sne.drip.api.dao.PlanDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.MessageParameter
;
import
nl.uva.sne.drip.commons.types.Plan
;
import
nl.uva.sne.drip.commons.types.SimplePlanContainer
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
org.json.JSONException
;
...
...
@@ -43,6 +49,9 @@ public class PlannerService {
@Autowired
private
ToscaService
toscaService
;
@Autowired
private
PlanDao
planDao
;
@Value
(
"${message.broker.host}"
)
private
String
messageBrokerHost
;
...
...
@@ -52,15 +61,30 @@ public class PlannerService {
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
MessageParameter
>
parameters
=
plannerReturnedMessage
.
getParameters
();
for
(
MessageParameter
param
:
parameters
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
JsonParser
.
Feature
.
ALLOW_SINGLE_QUOTES
,
true
);
String
jsonString
=
mapper
.
writeValueAsString
(
plannerReturnedMessage
);
SimplePlanContainer
simplePlan
=
Converter
.
plannerOutput2SimplePlanContainer
(
jsonString
);
Plan
topLevel
=
new
Plan
();
topLevel
.
setLevel
(
0
);
topLevel
.
setToscaID
(
toscaId
);
topLevel
.
setName
(
"planner_output_all.yml"
);
topLevel
.
setKvMap
(
Converter
.
ymlString2Map
(
simplePlan
.
getTopLevel
()));
Map
<
String
,
String
>
map
=
simplePlan
.
getLowerLevels
();
Set
<
String
>
loweLevelPlansIDs
=
new
HashSet
<>();
for
(
String
lowLevelNames
:
map
.
keySet
())
{
Plan
lowLevelPlan
=
new
Plan
();
lowLevelPlan
.
setLevel
(
1
);
lowLevelPlan
.
setToscaID
(
toscaId
);
lowLevelPlan
.
setName
(
lowLevelNames
);
lowLevelPlan
.
setKvMap
(
Converter
.
ymlString2Map
(
map
.
get
(
lowLevelNames
)));
planDao
.
save
(
lowLevelPlan
);
loweLevelPlansIDs
.
add
(
lowLevelPlan
.
getId
());
}
ToscaRepresentation
tr
=
new
ToscaRepresentation
();
Map
<
String
,
Object
>
kvMap
=
null
;
tr
.
setKvMap
(
kvMap
);
return
null
;
topLevel
.
setLoweLevelPlansIDs
(
loweLevelPlansIDs
);
planDao
.
save
(
topLevel
);
return
topLevel
;
}
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/ClusterCredentials.java
View file @
5e0247c7
...
...
@@ -15,7 +15,6 @@
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
/**
...
...
@@ -27,7 +26,7 @@ public class ClusterCredentials {
@Id
private
String
id
;
private
Map
<
String
,
Object
>
kvMap
;
private
String
contents
;
/**
* @return the id
...
...
@@ -44,17 +43,17 @@ public class ClusterCredentials {
}
/**
* @return the
kvMap
* @return the
contents
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
return
kvMap
;
public
String
getContents
()
{
return
contents
;
}
/**
* @param
kvMap the kvMap
to set
* @param
contents the contents
to set
*/
public
void
set
KvMap
(
Map
<
String
,
Object
>
kvMap
)
{
this
.
kvMap
=
kvMap
;
public
void
set
Contents
(
String
contents
)
{
this
.
contents
=
contents
;
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
5e0247c7
...
...
@@ -71,6 +71,11 @@ public class Converter {
return
jsonObject2Map
(
jsonObject
);
}
public
static
SimplePlanContainer
plannerOutput2SimplePlanContainer
(
String
jsonString
)
throws
JSONException
{
return
null
;
}
public
static
Map
<
String
,
Object
>
jsonObject2Map
(
JSONObject
object
)
throws
JSONException
{
Map
<
String
,
Object
>
map
=
new
HashMap
();
...
...
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