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
00a13b34
Commit
00a13b34
authored
Mar 02, 2017
by
Oceans
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'package' of
https://github.com/skoulouzis/DRIP
into package
parents
0d4ddf27
5e0247c7
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 @
00a13b34
...
@@ -15,17 +15,23 @@
...
@@ -15,17 +15,23 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
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.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
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.exception.BadRequestException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.MessageParameter
;
import
nl.uva.sne.drip.commons.types.MessageParameter
;
import
nl.uva.sne.drip.commons.types.Plan
;
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.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
org.json.JSONException
;
import
org.json.JSONException
;
...
@@ -43,6 +49,9 @@ public class PlannerService {
...
@@ -43,6 +49,9 @@ public class PlannerService {
@Autowired
@Autowired
private
ToscaService
toscaService
;
private
ToscaService
toscaService
;
@Autowired
private
PlanDao
planDao
;
@Value
(
"${message.broker.host}"
)
@Value
(
"${message.broker.host}"
)
private
String
messageBrokerHost
;
private
String
messageBrokerHost
;
...
@@ -52,15 +61,30 @@ public class PlannerService {
...
@@ -52,15 +61,30 @@ public class PlannerService {
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
MessageParameter
>
parameters
=
plannerReturnedMessage
.
getParameters
();
ObjectMapper
mapper
=
new
ObjectMapper
();
for
(
MessageParameter
param
:
parameters
)
{
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 @
00a13b34
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
/**
/**
...
@@ -27,7 +26,7 @@ public class ClusterCredentials {
...
@@ -27,7 +26,7 @@ public class ClusterCredentials {
@Id
@Id
private
String
id
;
private
String
id
;
private
Map
<
String
,
Object
>
kvMap
;
private
String
contents
;
/**
/**
* @return the id
* @return the id
...
@@ -44,17 +43,17 @@ public class ClusterCredentials {
...
@@ -44,17 +43,17 @@ public class ClusterCredentials {
}
}
/**
/**
* @return the
kvMap
* @return the
contents
*/
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
public
String
getContents
()
{
return
kvMap
;
return
contents
;
}
}
/**
/**
* @param
kvMap the kvMap
to set
* @param
contents the contents
to set
*/
*/
public
void
set
KvMap
(
Map
<
String
,
Object
>
kvMap
)
{
public
void
set
Contents
(
String
contents
)
{
this
.
kvMap
=
kvMap
;
this
.
contents
=
contents
;
}
}
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
00a13b34
...
@@ -71,6 +71,11 @@ public class Converter {
...
@@ -71,6 +71,11 @@ public class Converter {
return
jsonObject2Map
(
jsonObject
);
return
jsonObject2Map
(
jsonObject
);
}
}
public
static
SimplePlanContainer
plannerOutput2SimplePlanContainer
(
String
jsonString
)
throws
JSONException
{
return
null
;
}
public
static
Map
<
String
,
Object
>
jsonObject2Map
(
JSONObject
object
)
throws
JSONException
{
public
static
Map
<
String
,
Object
>
jsonObject2Map
(
JSONObject
object
)
throws
JSONException
{
Map
<
String
,
Object
>
map
=
new
HashMap
();
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