{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments/120541070","pull_request_review_id":42510094,"id":120541070,"diff_hunk":"@@ -34,39 +34,69 @@\n import org.wso2.carbon.event.simulator.core.exception.SimulationConfigDeploymentException;\n import org.wso2.carbon.event.simulator.core.internal.util.EventSimulatorConstants;\n import org.wso2.carbon.event.simulator.core.internal.util.SimulationConfigUploader;\n+import org.wso2.carbon.stream.processor.common.DeployerListener;\n+import org.wso2.carbon.stream.processor.common.DeployerNotifier;\n import org.wso2.carbon.stream.processor.common.EventStreamService;\n+import org.wso2.carbon.stream.processor.common.exception.ResourceNotFoundException;\n+import org.wso2.carbon.stream.processor.core.internal.StreamProcessorDeployer;\n import org.wso2.carbon.utils.Utils;\n \n import java.io.File;\n import java.net.MalformedURLException;\n import java.net.URL;\n import java.nio.file.Paths;\n+import java.util.Collections;\n \n /**\n  * SimulationConfigDeployer is responsible for all simulation config deployment tasks\n- *\n  */\n @Component(\n         name = \"simulation-config-deployer\",\n         immediate = true,\n         service = org.wso2.carbon.deployment.engine.Deployer.class\n )\n-public class SimulationConfigDeployer implements Deployer {\n+public class SimulationConfigDeployer implements Deployer, DeployerListener {\n     private static final Logger log = LoggerFactory.getLogger(SimulationConfigDeployer.class);\n     private ArtifactType artifactType = new ArtifactType<>(EventSimulatorConstants.SIMULATION_FILE_EXTENSION);\n     private URL directoryLocation;\n \n+    /**\n+     * deployConfigFile() is used to deploy a simulation configuration added to directory 'simulation-configs'\n+     *\n+     * @param file simulation config file added\n+     */\n     private void deployConfigFile(File file) throws Exception {\n         if (!file.getName().startsWith(\".\")) {\n             if (FilenameUtils.isExtension(file.getName(), EventSimulatorConstants.SIMULATION_FILE_EXTENSION)) {\n                 String simulationName = FilenameUtils.getBaseName(file.getName());\n-                String simulationConfig = SimulationConfigUploader.getConfigUploader().getSimulationConfig\n-                        (simulationName, (Paths.get(Utils.getCarbonHome().toString(),\n-                                EventSimulatorConstants.DIRECTORY_DEPLOYMENT,\n-                                EventSimulatorConstants.DIRECTORY_SIMULATION_CONFIGS)).toString());\n-                if (!simulationConfig.isEmpty()) {\n-                    EventSimulator simulator = new EventSimulator(simulationName, simulationConfig);\n-                    EventSimulationMap.getSimulatorMap().put(simulationName, simulator);\n+                try {\n+                    String simulationConfig = SimulationConfigUploader.getConfigUploader().getSimulationConfig\n+                            (simulationName, (Paths.get(Utils.getCarbonHome().toString(),\n+                                    EventSimulatorConstants.DIRECTORY_DEPLOYMENT,\n+                                    EventSimulatorConstants.DIRECTORY_SIMULATION_CONFIGS)).toString());\n+                    if (!simulationConfig.isEmpty()) {\n+                        EventSimulator eventSimulator = new EventSimulator(simulationName, simulationConfig);\n+                        EventSimulatorMap.getInstance().getActiveSimulatorMap().put(simulationName,\n+                                Collections.singletonMap(eventSimulator, simulationConfig));\n+                        log.info(\"Successfully deployed active simulation '\" + simulationName + \"'.\");\n+                    }\n+                } catch (ResourceNotFoundException e) {\n+                    EventSimulatorMap eventSimulatorMap = EventSimulatorMap.getInstance();\n+                    if (eventSimulatorMap.containsInActiveSimulator(simulationName)) {\n+                        if (!eventSimulatorMap.getResourceTypeForInActiveSimulator(simulationName)\n+                                .equals(e.getResourceType())\n+                                || !eventSimulatorMap.getResourceNameForInActiveSimulator(simulationName)\n+                                .equals(e.getResourceName())) {\n+                            eventSimulatorMap.deleteInActiveSimulation(simulationName);\n+                            eventSimulatorMap.getInActiveSimulatorMap().put(simulationName, Collections\n+                                    .singletonMap(e.getResourceType(), e.getResourceName()));\n+                        }\n+                    } else {\n+                        eventSimulatorMap.getInActiveSimulatorMap().put(simulationName, Collections\n+                                .singletonMap(e.getResourceType(), e.getResourceName()));\n+                        log.error(e.getMessage(), e);","path":"components/org.wso2.carbon.event.simulator.core/src/main/java/org/wso2/carbon/event/simulator/core/service/SimulationConfigDeployer.java","position":73,"original_position":73,"commit_id":"585f0570f2576db7d32a06f68eabf945cf92d026","original_commit_id":"32dd5c8dc0ad3afbbb8a12bb0901a2e90f27829d","user":{"login":"suhothayan","id":3785208,"avatar_url":"https://avatars0.githubusercontent.com/u/3785208?v=3","gravatar_id":"","url":"https://api.github.com/users/suhothayan","html_url":"https://github.com/suhothayan","followers_url":"https://api.github.com/users/suhothayan/followers","following_url":"https://api.github.com/users/suhothayan/following{/other_user}","gists_url":"https://api.github.com/users/suhothayan/gists{/gist_id}","starred_url":"https://api.github.com/users/suhothayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suhothayan/subscriptions","organizations_url":"https://api.github.com/users/suhothayan/orgs","repos_url":"https://api.github.com/users/suhothayan/repos","events_url":"https://api.github.com/users/suhothayan/events{/privacy}","received_events_url":"https://api.github.com/users/suhothayan/received_events","type":"User","site_admin":false},"body":"You should not say \"Successfully deployed inactive simulation, \" say \"moved simulation to inactive state\".","created_at":"2017-06-07T06:05:03Z","updated_at":"2017-06-07T06:05:03Z","html_url":"https://github.com/wso2/carbon-analytics/pull/287#discussion_r120541070","pull_request_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments/120541070"},"html":{"href":"https://github.com/wso2/carbon-analytics/pull/287#discussion_r120541070"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287","id":124152797,"html_url":"https://github.com/wso2/carbon-analytics/pull/287","diff_url":"https://github.com/wso2/carbon-analytics/pull/287.diff","patch_url":"https://github.com/wso2/carbon-analytics/pull/287.patch","issue_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/287","number":287,"state":"closed","locked":false,"title":"Single event simulation UI","user":{"login":"ruwiniwj","id":20040505,"avatar_url":"https://avatars3.githubusercontent.com/u/20040505?v=3","gravatar_id":"","url":"https://api.github.com/users/ruwiniwj","html_url":"https://github.com/ruwiniwj","followers_url":"https://api.github.com/users/ruwiniwj/followers","following_url":"https://api.github.com/users/ruwiniwj/following{/other_user}","gists_url":"https://api.github.com/users/ruwiniwj/gists{/gist_id}","starred_url":"https://api.github.com/users/ruwiniwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruwiniwj/subscriptions","organizations_url":"https://api.github.com/users/ruwiniwj/orgs","repos_url":"https://api.github.com/users/ruwiniwj/repos","events_url":"https://api.github.com/users/ruwiniwj/events{/privacy}","received_events_url":"https://api.github.com/users/ruwiniwj/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-06T10:03:07Z","updated_at":"2017-06-07T06:05:03Z","closed_at":"2017-06-07T06:00:31Z","merged_at":"2017-06-07T06:00:30Z","merge_commit_sha":"1ec14c6722fc5f0932297625f6f1ae76f52f0c2f","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/287/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics/statuses/585f0570f2576db7d32a06f68eabf945cf92d026","head":{"label":"ruwiniwj:simulator2","ref":"simulator2","sha":"585f0570f2576db7d32a06f68eabf945cf92d026","user":{"login":"ruwiniwj","id":20040505,"avatar_url":"https://avatars3.githubusercontent.com/u/20040505?v=3","gravatar_id":"","url":"https://api.github.com/users/ruwiniwj","html_url":"https://github.com/ruwiniwj","followers_url":"https://api.github.com/users/ruwiniwj/followers","following_url":"https://api.github.com/users/ruwiniwj/following{/other_user}","gists_url":"https://api.github.com/users/ruwiniwj/gists{/gist_id}","starred_url":"https://api.github.com/users/ruwiniwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruwiniwj/subscriptions","organizations_url":"https://api.github.com/users/ruwiniwj/orgs","repos_url":"https://api.github.com/users/ruwiniwj/repos","events_url":"https://api.github.com/users/ruwiniwj/events{/privacy}","received_events_url":"https://api.github.com/users/ruwiniwj/received_events","type":"User","site_admin":false},"repo":{"id":88695591,"name":"carbon-analytics","full_name":"ruwiniwj/carbon-analytics","owner":{"login":"ruwiniwj","id":20040505,"avatar_url":"https://avatars3.githubusercontent.com/u/20040505?v=3","gravatar_id":"","url":"https://api.github.com/users/ruwiniwj","html_url":"https://github.com/ruwiniwj","followers_url":"https://api.github.com/users/ruwiniwj/followers","following_url":"https://api.github.com/users/ruwiniwj/following{/other_user}","gists_url":"https://api.github.com/users/ruwiniwj/gists{/gist_id}","starred_url":"https://api.github.com/users/ruwiniwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruwiniwj/subscriptions","organizations_url":"https://api.github.com/users/ruwiniwj/orgs","repos_url":"https://api.github.com/users/ruwiniwj/repos","events_url":"https://api.github.com/users/ruwiniwj/events{/privacy}","received_events_url":"https://api.github.com/users/ruwiniwj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ruwiniwj/carbon-analytics","description":null,"fork":true,"url":"https://api.github.com/repos/ruwiniwj/carbon-analytics","forks_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/forks","keys_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/teams","hooks_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/hooks","issue_events_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/events","assignees_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/tags","blobs_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/languages","stargazers_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/stargazers","contributors_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/contributors","subscribers_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/subscribers","subscription_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/subscription","commits_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/merges","archive_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/downloads","issues_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/labels{/name}","releases_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/ruwiniwj/carbon-analytics/deployments","created_at":"2017-04-19T03:18:34Z","updated_at":"2017-04-19T03:18:42Z","pushed_at":"2017-06-07T02:49:19Z","git_url":"git://github.com/ruwiniwj/carbon-analytics.git","ssh_url":"git@github.com:ruwiniwj/carbon-analytics.git","clone_url":"https://github.com/ruwiniwj/carbon-analytics.git","svn_url":"https://github.com/ruwiniwj/carbon-analytics","homepage":null,"size":41677,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"33701430db8e544d6ad3fc1ed1af2680f2fc934d","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars0.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":16543113,"name":"carbon-analytics","full_name":"wso2/carbon-analytics","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars0.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-analytics","description":null,"fork":false,"url":"https://api.github.com/repos/wso2/carbon-analytics","forks_url":"https://api.github.com/repos/wso2/carbon-analytics/forks","keys_url":"https://api.github.com/repos/wso2/carbon-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-analytics/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-analytics/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-analytics/events","assignees_url":"https://api.github.com/repos/wso2/carbon-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-analytics/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-analytics/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-analytics/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-analytics/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-analytics/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-analytics/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-analytics/merges","archive_url":"https://api.github.com/repos/wso2/carbon-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-analytics/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-analytics/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-analytics/deployments","created_at":"2014-02-05T11:40:58Z","updated_at":"2017-04-05T13:53:28Z","pushed_at":"2017-06-07T06:00:31Z","git_url":"git://github.com/wso2/carbon-analytics.git","ssh_url":"git@github.com:wso2/carbon-analytics.git","clone_url":"https://github.com/wso2/carbon-analytics.git","svn_url":"https://github.com/wso2/carbon-analytics","homepage":null,"size":41530,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":4,"forks":88,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287"},"html":{"href":"https://github.com/wso2/carbon-analytics/pull/287"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-analytics/issues/287"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics/issues/287/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/287/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-analytics/statuses/585f0570f2576db7d32a06f68eabf945cf92d026"}}}}
{"actor":{"display_login":"suhothayan"}}