{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-reef/pulls/comments/29880492","id":29880492,"diff_hunk":"@@ -0,0 +1,138 @@\n+﻿/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+using System;\n+using System.Collections.Generic;\n+using System.IO;\n+using System.Net;\n+using System.Net.Sockets;\n+using System.Runtime.Remoting;\n+using Org.Apache.REEF.Common.Io;\n+using Org.Apache.REEF.Tang.Exceptions;\n+using Org.Apache.REEF.Utilities.Logging;\n+using Org.Apache.REEF.Wake;\n+using Org.Apache.REEF.Wake.Remote;\n+\n+namespace Org.Apache.REEF.Network.NetworkService\n+{\n+    /// <summary>\n+    /// Represents a connection between two hosts using the Writable NetworkService.\n+    /// </summary>\n+    [Obsolete(\"Need to remove Iwritable and use IstreamingCodec. Please see Jira REEF-295 \", false)]\n+    public class WritableNsConnection<T> : IConnection<T> where T : IWritable\n+    {\n+        private static readonly Logger Logger = Logger.GetLogger(typeof (WritableNsConnection<T>));\n+\n+        private readonly IIdentifier _sourceId;\n+        private readonly IIdentifier _destId;\n+        private readonly INameClient _nameClient;\n+        private readonly IRemoteManager<WritableNsMessage<T>> _remoteManager;\n+        private readonly Dictionary<IIdentifier, IConnection<T>> _connectionMap;\n+        private IObserver<WritableNsMessage<T>> _remoteSender;\n+\n+        /// <summary>\n+        /// Creates a new NsConnection between two hosts.\n+        /// </summary>\n+        /// <param name=\"sourceId\">The identifier of the sender</param>\n+        /// <param name=\"destId\">The identifier of the receiver</param>\n+        /// <param name=\"nameClient\">The NameClient used for naming lookup</param>\n+        /// <param name=\"remoteManager\">The remote manager used for network communication</param>\n+        /// <param name=\"connectionMap\">A cache of opened connections.  Will remove itself from\n+        /// the cache when the NsConnection is disposed.</param>\n+        public WritableNsConnection(\n+            IIdentifier sourceId,\n+            IIdentifier destId,\n+            INameClient nameClient,\n+            IRemoteManager<WritableNsMessage<T>> remoteManager,\n+            Dictionary<IIdentifier, IConnection<T>> connectionMap)\n+        {\n+            _sourceId = sourceId;\n+            _destId = destId;\n+            _nameClient = nameClient;\n+            _remoteManager = remoteManager;\n+            _connectionMap = connectionMap;\n+        }\n+\n+        /// <summary>\n+        /// Opens the connection to the remote host.\n+        /// </summary>\n+        public void Open()\n+        {\n+            string destStr = _destId.ToString();\n+            Logger.Log(Level.Verbose, \"Network service opening connection to {0}...\", destStr);\n+\n+            IPEndPoint destAddr = _nameClient.Lookup(_destId.ToString());","path":"lang/cs/Org.Apache.REEF.Network/NetworkService/WritableNsConnection.cs","position":80,"original_position":80,"commit_id":"4894d4277215f38d595d8813b646a26480901d9b","original_commit_id":"4894d4277215f38d595d8813b646a26480901d9b","user":{"login":"markusweimer","id":502371,"avatar_url":"https://avatars.githubusercontent.com/u/502371?v=3","gravatar_id":"","url":"https://api.github.com/users/markusweimer","html_url":"https://github.com/markusweimer","followers_url":"https://api.github.com/users/markusweimer/followers","following_url":"https://api.github.com/users/markusweimer/following{/other_user}","gists_url":"https://api.github.com/users/markusweimer/gists{/gist_id}","starred_url":"https://api.github.com/users/markusweimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markusweimer/subscriptions","organizations_url":"https://api.github.com/users/markusweimer/orgs","repos_url":"https://api.github.com/users/markusweimer/repos","events_url":"https://api.github.com/users/markusweimer/events{/privacy}","received_events_url":"https://api.github.com/users/markusweimer/received_events","type":"User","site_admin":false},"body":"use `destStr` already created.","created_at":"2015-05-07T18:21:49Z","updated_at":"2015-05-07T18:21:49Z","html_url":"https://github.com/apache/incubator-reef/pull/178#discussion_r29880492","pull_request_url":"https://api.github.com/repos/apache/incubator-reef/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/comments/29880492"},"html":{"href":"https://github.com/apache/incubator-reef/pull/178#discussion_r29880492"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-reef/pulls/178","id":34869288,"html_url":"https://github.com/apache/incubator-reef/pull/178","diff_url":"https://github.com/apache/incubator-reef/pull/178.diff","patch_url":"https://github.com/apache/incubator-reef/pull/178.patch","issue_url":"https://api.github.com/repos/apache/incubator-reef/issues/178","number":178,"state":"open","locked":false,"title":"[REEF-259]  Writable Network Service Layer","user":{"login":"dkm2110","id":151031,"avatar_url":"https://avatars.githubusercontent.com/u/151031?v=3","gravatar_id":"","url":"https://api.github.com/users/dkm2110","html_url":"https://github.com/dkm2110","followers_url":"https://api.github.com/users/dkm2110/followers","following_url":"https://api.github.com/users/dkm2110/following{/other_user}","gists_url":"https://api.github.com/users/dkm2110/gists{/gist_id}","starred_url":"https://api.github.com/users/dkm2110/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkm2110/subscriptions","organizations_url":"https://api.github.com/users/dkm2110/orgs","repos_url":"https://api.github.com/users/dkm2110/repos","events_url":"https://api.github.com/users/dkm2110/events{/privacy}","received_events_url":"https://api.github.com/users/dkm2110/received_events","type":"User","site_admin":false},"body":" [REEF-259]: Make the NetworkService layer memory efficient by introducing streaming and building on top of StreamingRemoteManager in Wake.\r\n\r\nThis addressed the issue by \r\n\r\n* Introducing WritableNetworkServiceLayer which constraints the NsMessage and message passed to it to be Writable. \r\n\r\nJIRA: [REEF-259](https://issues.apache.org/jira/browse/REEF-259)\r\n\r\n@markusweimer @beysims @jwang98052 ","created_at":"2015-05-06T23:01:07Z","updated_at":"2015-05-07T18:21:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f81b260cfa5ec9201612e3c0b5c780c293f321b4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-reef/pulls/178/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-reef/pulls/178/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-reef/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-reef/issues/178/comments","statuses_url":"https://api.github.com/repos/apache/incubator-reef/statuses/4894d4277215f38d595d8813b646a26480901d9b","head":{"label":"Microsoft-CISL:REEF-259","ref":"REEF-259","sha":"4894d4277215f38d595d8813b646a26480901d9b","user":{"login":"Microsoft-CISL","id":2067733,"avatar_url":"https://avatars.githubusercontent.com/u/2067733?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft-CISL","html_url":"https://github.com/Microsoft-CISL","followers_url":"https://api.github.com/users/Microsoft-CISL/followers","following_url":"https://api.github.com/users/Microsoft-CISL/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft-CISL/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft-CISL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft-CISL/subscriptions","organizations_url":"https://api.github.com/users/Microsoft-CISL/orgs","repos_url":"https://api.github.com/users/Microsoft-CISL/repos","events_url":"https://api.github.com/users/Microsoft-CISL/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft-CISL/received_events","type":"Organization","site_admin":false},"repo":{"id":30330372,"name":"incubator-reef","full_name":"Microsoft-CISL/incubator-reef","owner":{"login":"Microsoft-CISL","id":2067733,"avatar_url":"https://avatars.githubusercontent.com/u/2067733?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft-CISL","html_url":"https://github.com/Microsoft-CISL","followers_url":"https://api.github.com/users/Microsoft-CISL/followers","following_url":"https://api.github.com/users/Microsoft-CISL/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft-CISL/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft-CISL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft-CISL/subscriptions","organizations_url":"https://api.github.com/users/Microsoft-CISL/orgs","repos_url":"https://api.github.com/users/Microsoft-CISL/repos","events_url":"https://api.github.com/users/Microsoft-CISL/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft-CISL/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft-CISL/incubator-reef","description":"Mirror of Apache REEF (Incubating) for Pull Request staging","fork":true,"url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef","forks_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/forks","keys_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/teams","hooks_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/hooks","issue_events_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/events","assignees_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/tags","blobs_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/languages","stargazers_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/stargazers","contributors_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/contributors","subscribers_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/subscribers","subscription_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/subscription","commits_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/merges","archive_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/downloads","issues_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft-CISL/incubator-reef/releases{/id}","created_at":"2015-02-05T01:06:12Z","updated_at":"2015-03-17T00:39:59Z","pushed_at":"2015-05-07T18:03:06Z","git_url":"git://github.com/Microsoft-CISL/incubator-reef.git","ssh_url":"git@github.com:Microsoft-CISL/incubator-reef.git","clone_url":"https://github.com/Microsoft-CISL/incubator-reef.git","svn_url":"https://github.com/Microsoft-CISL/incubator-reef","homepage":"","size":35271,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"7a07abcf6a4564e2c9ab91434227d1ca32d8e770","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":25623941,"name":"incubator-reef","full_name":"apache/incubator-reef","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-reef","description":"Mirror of Apache REEF (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-reef","forks_url":"https://api.github.com/repos/apache/incubator-reef/forks","keys_url":"https://api.github.com/repos/apache/incubator-reef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-reef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-reef/teams","hooks_url":"https://api.github.com/repos/apache/incubator-reef/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-reef/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-reef/events","assignees_url":"https://api.github.com/repos/apache/incubator-reef/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-reef/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-reef/tags","blobs_url":"https://api.github.com/repos/apache/incubator-reef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-reef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-reef/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-reef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-reef/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-reef/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-reef/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-reef/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-reef/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-reef/subscription","commits_url":"https://api.github.com/repos/apache/incubator-reef/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-reef/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-reef/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-reef/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-reef/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-reef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-reef/merges","archive_url":"https://api.github.com/repos/apache/incubator-reef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-reef/downloads","issues_url":"https://api.github.com/repos/apache/incubator-reef/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-reef/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-reef/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-reef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-reef/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-reef/releases{/id}","created_at":"2014-10-23T07:00:10Z","updated_at":"2015-05-06T21:37:54Z","pushed_at":"2015-05-07T18:03:41Z","git_url":"git://github.com/apache/incubator-reef.git","ssh_url":"git@github.com:apache/incubator-reef.git","clone_url":"https://github.com/apache/incubator-reef.git","svn_url":"https://github.com/apache/incubator-reef","homepage":null,"size":39620,"stargazers_count":15,"watchers_count":15,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":"git://git.apache.org/incubator-reef.git","open_issues_count":6,"forks":19,"open_issues":6,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/178"},"html":{"href":"https://github.com/apache/incubator-reef/pull/178"},"issue":{"href":"https://api.github.com/repos/apache/incubator-reef/issues/178"},"comments":{"href":"https://api.github.com/repos/apache/incubator-reef/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-reef/statuses/4894d4277215f38d595d8813b646a26480901d9b"}}}}