Commit 1f2c970c authored by Spiros Koulouzis's avatar Spiros Koulouzis

close and reopen channel

parent 8344e8e3
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotNull;
/** /**
* *
...@@ -28,8 +30,9 @@ import java.util.List; ...@@ -28,8 +30,9 @@ import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class Message implements Serializable { public class Message implements Serializable {
@NotNull
private String owner; private String owner;
@NotNull
private Long creationDate; private Long creationDate;
private List<MessageParameter> parameters; private List<MessageParameter> parameters;
......
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath nl.uva.sne.drip.Swagger2SpringBoot</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath nl.uva.sne.drip.Swagger2SpringBoot</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>
...@@ -42,26 +42,33 @@ import org.springframework.stereotype.Service; ...@@ -42,26 +42,33 @@ import org.springframework.stereotype.Service;
@Service @Service
public class DRIPCaller implements AutoCloseable { public class DRIPCaller implements AutoCloseable {
private final Connection connection; private Connection connection;
private final Channel channel; private Channel channel;
private final String replyQueueName; private String replyQueueName;
private String requestQeueName; private String requestQeueName;
private final ObjectMapper mapper; private final ObjectMapper mapper;
private final ConnectionFactory factory;
public DRIPCaller(ConnectionFactory factory) throws IOException, TimeoutException { public DRIPCaller(ConnectionFactory factory) throws IOException, TimeoutException {
this.factory = factory;
// factory.setHost(messageBrokerHost); // factory.setHost(messageBrokerHost);
// factory.setPort(AMQP.PROTOCOL.PORT); // factory.setPort(AMQP.PROTOCOL.PORT);
// factory.setUsername(username); // factory.setUsername(username);
// factory.setPassword(password); // factory.setPassword(password);
connection = factory.newConnection(); init();
channel = connection.createChannel();
// create a single callback queue per client not per requests.
replyQueueName = channel.queueDeclare().getQueue();
this.mapper = new ObjectMapper(); this.mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
} }
public void init() throws IOException, TimeoutException {
if (connection == null || !connection.isOpen()) {
connection = factory.newConnection();
channel = connection.createChannel();
// create a single callback queue per client not per requests.
replyQueueName = channel.queueDeclare().getQueue();
}
}
/** /**
* @return the connection * @return the connection
*/ */
......
...@@ -33,10 +33,11 @@ public class DRIPService { ...@@ -33,10 +33,11 @@ public class DRIPService {
public String execute(String id) { public String execute(String id) {
try { try {
caller.init();
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
Message message = new Message(); Message message = new Message();
message.setOwner("user");
message.setCreationDate(System.currentTimeMillis()); message.setCreationDate(System.currentTimeMillis());
message.setToscaTemplate(toscaTemplate); message.setToscaTemplate(toscaTemplate);
......
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment=""> <list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/__main__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__main__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/planner/planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/planner/planner.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/planner/planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/planner/planner.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -25,7 +22,13 @@ ...@@ -25,7 +22,13 @@
</component> </component>
<component name="ProjectId" id="1TI7vNZs1Z3y1uB6wXCH5F47r0F" /> <component name="ProjectId" id="1TI7vNZs1Z3y1uB6wXCH5F47r0F" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" /> <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component> </component>
...@@ -38,18 +41,6 @@ ...@@ -38,18 +41,6 @@
<recent name="$PROJECT_DIR$/test" /> <recent name="$PROJECT_DIR$/test" />
</key> </key>
</component> </component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python.__main__"> <component name="RunManager" selected="Python.__main__">
<configuration name="__main__" type="PythonConfigurationType" factoryName="Python" temporary="true"> <configuration name="__main__" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="drip-planner" /> <module name="drip-planner" />
...@@ -102,8 +93,8 @@ ...@@ -102,8 +93,8 @@
</configuration> </configuration>
<list> <list>
<item itemvalue="Python.__main__" /> <item itemvalue="Python.__main__" />
<item itemvalue="Python tests.Unittests in test_planner.py" />
<item itemvalue="Python tests.Unittests for test_planner.MyTestCase.test_something" /> <item itemvalue="Python tests.Unittests for test_planner.MyTestCase.test_something" />
<item itemvalue="Python tests.Unittests in test_planner.py" />
</list> </list>
<recent_temporary> <recent_temporary>
<list> <list>
...@@ -113,6 +104,18 @@ ...@@ -113,6 +104,18 @@
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration"> <component name="SvnConfiguration">
<configuration /> <configuration />
</component> </component>
...@@ -230,17 +233,71 @@ ...@@ -230,17 +233,71 @@
<MESSAGE value="fixed test" /> <MESSAGE value="fixed test" />
<option name="LAST_COMMIT_MESSAGE" value="fixed test" /> <option name="LAST_COMMIT_MESSAGE" value="fixed test" />
</component> </component>
<component name="WindowStateProjectService">
<state x="808" y="316" width="1000" height="839" key="#Inspections" timestamp="1575885366203">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="808" y="316" width="1000" height="839" key="#Inspections/67.34.2493.1406@67.34.2493.1406" timestamp="1575885366203" />
<state x="925" y="283" width="767" height="906" key="#__main__" timestamp="1575885420596">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="925" y="283" width="767" height="906" key="#__main__/67.34.2493.1406@67.34.2493.1406" timestamp="1575885420596" />
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl" timestamp="1575885341909">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575885341909" />
<state width="2465" height="471" key="GridCell.Tab.0.bottom" timestamp="1575891470097">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470097" />
<state width="2465" height="471" key="GridCell.Tab.0.center" timestamp="1575891470096">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470096" />
<state width="2465" height="471" key="GridCell.Tab.0.left" timestamp="1575891470096">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470096" />
<state width="2465" height="471" key="GridCell.Tab.0.right" timestamp="1575891470096">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470096" />
<state width="2465" height="471" key="GridCell.Tab.1.bottom" timestamp="1575891470098">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.1.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470098" />
<state width="2465" height="471" key="GridCell.Tab.1.center" timestamp="1575891470097">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.1.center/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470097" />
<state width="2465" height="471" key="GridCell.Tab.1.left" timestamp="1575891470097">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.1.left/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470097" />
<state width="2465" height="471" key="GridCell.Tab.1.right" timestamp="1575891470097">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="471" key="GridCell.Tab.1.right/67.34.2493.1406@67.34.2493.1406" timestamp="1575891470097" />
<state x="679" y="283" key="SettingsEditor" timestamp="1575885393075">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="679" y="283" key="SettingsEditor/67.34.2493.1406@67.34.2493.1406" timestamp="1575885393075" />
<state x="893" y="526" key="com.intellij.ide.util.TipDialog" timestamp="1575885327988">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="893" y="526" key="com.intellij.ide.util.TipDialog/67.34.2493.1406@67.34.2493.1406" timestamp="1575885327988" />
</component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/planner/planner.py</url> <url>file://$PROJECT_DIR$/planner/planner.py</url>
<line>71</line> <line>72</line>
<option name="timeStamp" value="8" /> <option name="timeStamp" value="8" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/planner/planner.py</url> <url>file://$PROJECT_DIR$/planner/planner.py</url>
<line>66</line> <line>67</line>
<option name="timeStamp" value="9" /> <option name="timeStamp" value="9" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
...@@ -248,11 +305,6 @@ ...@@ -248,11 +305,6 @@
<line>22</line> <line>22</line>
<option name="timeStamp" value="21" /> <option name="timeStamp" value="21" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/__main__.py</url>
<line>102</line>
<option name="timeStamp" value="22" />
</line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
</component> </component>
......
...@@ -3,6 +3,7 @@ from toscaparser.nodetemplate import NodeTemplate ...@@ -3,6 +3,7 @@ from toscaparser.nodetemplate import NodeTemplate
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
from toscaparser.topology_template import TopologyTemplate from toscaparser.topology_template import TopologyTemplate
import operator import operator
# import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
...@@ -12,7 +13,7 @@ from util import tosca_helper ...@@ -12,7 +13,7 @@ from util import tosca_helper
class Planner: class Planner:
def __init__(self, tosca_path=None, yaml_dict_tpl=None, spec_service=spec_service): def __init__(self, tosca_path=None, yaml_dict_tpl=None, spec_service=None):
if tosca_path: if tosca_path:
self.path = tosca_path self.path = tosca_path
self.tosca_template = ToscaTemplate(tosca_path) self.tosca_template = ToscaTemplate(tosca_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment