{"action":"created","comment":{"url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/comments/173368579","pull_request_review_id":102548392,"id":173368579,"diff_hunk":"@@ -64,6 +70,19 @@ public struct SocketProperties {\n     string sslProtocol;\n }\n \n+@Description {value:\"Opens a byte channel from a specified file location.\"}\n+@Param {value:\"path: path to the file location.\"}\n+@Param {value:\"accessMode: whether the file should be opened for read,write or append.\"}","path":"stdlib/ballerina-builtin/src/main/ballerina/ballerina/io/natives.bal","position":19,"original_position":19,"commit_id":"2072389dfcc2c621538e9fe53fb8a69e42ceb4d7","original_commit_id":"2072389dfcc2c621538e9fe53fb8a69e42ceb4d7","user":{"login":"pamod","id":3785198,"avatar_url":"https://avatars2.githubusercontent.com/u/3785198?v=4","gravatar_id":"","url":"https://api.github.com/users/pamod","html_url":"https://github.com/pamod","followers_url":"https://api.github.com/users/pamod/followers","following_url":"https://api.github.com/users/pamod/following{/other_user}","gists_url":"https://api.github.com/users/pamod/gists{/gist_id}","starred_url":"https://api.github.com/users/pamod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pamod/subscriptions","organizations_url":"https://api.github.com/users/pamod/orgs","repos_url":"https://api.github.com/users/pamod/repos","events_url":"https://api.github.com/users/pamod/events{/privacy}","received_events_url":"https://api.github.com/users/pamod/received_events","type":"User","site_admin":false},"body":"Yes we discussed on this, we will be adding an enum with the effort which will be put to unify the file apis with io. ","created_at":"2018-03-09T05:33:52Z","updated_at":"2018-03-09T05:33:52Z","html_url":"https://github.com/ballerina-lang/ballerina/pull/5051#discussion_r173368579","pull_request_url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/comments/173368579"},"html":{"href":"https://github.com/ballerina-lang/ballerina/pull/5051#discussion_r173368579"},"pull_request":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051"}},"in_reply_to_id":173366154},"pull_request":{"url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051","id":173680563,"html_url":"https://github.com/ballerina-lang/ballerina/pull/5051","diff_url":"https://github.com/ballerina-lang/ballerina/pull/5051.diff","patch_url":"https://github.com/ballerina-lang/ballerina/pull/5051.patch","issue_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/5051","number":5051,"state":"open","locked":false,"title":"Add async I/O API native impl","user":{"login":"pamod","id":3785198,"avatar_url":"https://avatars2.githubusercontent.com/u/3785198?v=4","gravatar_id":"","url":"https://api.github.com/users/pamod","html_url":"https://github.com/pamod","followers_url":"https://api.github.com/users/pamod/followers","following_url":"https://api.github.com/users/pamod/following{/other_user}","gists_url":"https://api.github.com/users/pamod/gists{/gist_id}","starred_url":"https://api.github.com/users/pamod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pamod/subscriptions","organizations_url":"https://api.github.com/users/pamod/orgs","repos_url":"https://api.github.com/users/pamod/repos","events_url":"https://api.github.com/users/pamod/events{/privacy}","received_events_url":"https://api.github.com/users/pamod/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nRevamp existing I/O APIs to be asynchronous. \r\n\r\nThe new native I/O framework will allow both async and blocking operations to be performed. Both of them are required for different use cases. For instance for transactional use cases which requires the whole operation to run in the same thread would require the blocking I/O.\r\n\r\nAlso the existing buffer implementation was modified, as a result of profiling efforts done in relation to improve performance. For instance Character I/O APIs would retrieve bytes from byte I/O APIs through predicting the number of bytes. If there're excess bytes read, the state of the channel and the excess bytes read should be buffered. The content of this buffer will be managed by referring the pointers, instead of performing deep array copies.  \r\n\r\nThe relevant test cases and samples were modified with relation to the newly implimented I/O API architecture.  \r\n\r\n## Goals\r\n\r\n- Convert the native implementation of existing I/O APIs to fit with the async model. This should ensure that all I/O operations should be done in a controlled amount of threads similar to an NIO implementation. \r\n- Improve the buffer implementation to improve performance of character I/O operations.\r\n- Return I/O related errors.\r\n- Modify the related test cases and the related byte, character and record i/o samples.  \r\n\r\n## Approach\r\n\r\nExisting channel interface will allow any I/O source (file, tcp socket) to represent it's implimentation cannonically. This colud be done by extending the following,\r\n\r\n```\r\norg.ballerinalang.nativeimpl.io.channels.base.Channel\r\n```\r\n\r\nAn implementation of the Channel could be used to read/write bytes directly to/from the channel, or it could be converted into a different channel i.e character channel\r\n\r\nEach I/O operation performed through a channel should be done as an Event. i.e read, write, close. This should be done through the EventManager who will ensure to execute the events in a controlled manner. \r\n\r\nAn Event could be created using the following interface,\r\n\r\n```\r\norg.ballerinalang.nativeimpl.io.events.Event\r\n```\r\n\r\nEventManager has the following interface, which allows publishing an Event. EventManager will ensure that each I/O operation is done in a controlled manner. At present EventManager will perform all I/O operations through using 1/4 of the cores allocated for the VM. \r\n\r\n```\r\nCompletableFuture<EventResult> publish(Event event)\r\n```\r\n\r\n## User stories\r\n- Developers will be able to perform async I/O function calls\r\n- If an error occurs while performing I/O operations the correspoding error message will be returned to the caller. \r\n\r\n## Release note\r\nIntroduces async I/O support for bytes, characters and delimited text records. When handling character I/O operations the new buffer implementation is based on pointers, where the state of the channel be maintained by reference, this approach will reduce the number of array copies (unless the buffer requires to be resized). The newly introduces read, write APIs will also return errors pertaining to I/O operations giving more robust control to the developers. \r\n\r\n## Security checks\r\n - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes\r\n - Ran FindSecurityBugs plugin and verified report? yes\r\n - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes\r\n\r\n## Related PRs\r\nhttps://github.com/ballerina-lang/ballerina/pull/3755\r\n\r\n## Test environment\r\nJDK 1.8","created_at":"2018-03-08T09:08:19Z","updated_at":"2018-03-09T05:33:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20101506157411b084dcd133b91fc40a09700c61","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051/commits","review_comments_url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051/comments","review_comment_url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/5051/comments","statuses_url":"https://api.github.com/repos/ballerina-lang/ballerina/statuses/2072389dfcc2c621538e9fe53fb8a69e42ceb4d7","head":{"label":"pamod:io-revamp","ref":"io-revamp","sha":"2072389dfcc2c621538e9fe53fb8a69e42ceb4d7","user":{"login":"pamod","id":3785198,"avatar_url":"https://avatars2.githubusercontent.com/u/3785198?v=4","gravatar_id":"","url":"https://api.github.com/users/pamod","html_url":"https://github.com/pamod","followers_url":"https://api.github.com/users/pamod/followers","following_url":"https://api.github.com/users/pamod/following{/other_user}","gists_url":"https://api.github.com/users/pamod/gists{/gist_id}","starred_url":"https://api.github.com/users/pamod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pamod/subscriptions","organizations_url":"https://api.github.com/users/pamod/orgs","repos_url":"https://api.github.com/users/pamod/repos","events_url":"https://api.github.com/users/pamod/events{/privacy}","received_events_url":"https://api.github.com/users/pamod/received_events","type":"User","site_admin":false},"repo":{"id":104025523,"name":"ballerina","full_name":"pamod/ballerina","owner":{"login":"pamod","id":3785198,"avatar_url":"https://avatars2.githubusercontent.com/u/3785198?v=4","gravatar_id":"","url":"https://api.github.com/users/pamod","html_url":"https://github.com/pamod","followers_url":"https://api.github.com/users/pamod/followers","following_url":"https://api.github.com/users/pamod/following{/other_user}","gists_url":"https://api.github.com/users/pamod/gists{/gist_id}","starred_url":"https://api.github.com/users/pamod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pamod/subscriptions","organizations_url":"https://api.github.com/users/pamod/orgs","repos_url":"https://api.github.com/users/pamod/repos","events_url":"https://api.github.com/users/pamod/events{/privacy}","received_events_url":"https://api.github.com/users/pamod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pamod/ballerina","description":"Ballerina is a new programming language for integration built on a sequence diagram metaphor.","fork":true,"url":"https://api.github.com/repos/pamod/ballerina","forks_url":"https://api.github.com/repos/pamod/ballerina/forks","keys_url":"https://api.github.com/repos/pamod/ballerina/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pamod/ballerina/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pamod/ballerina/teams","hooks_url":"https://api.github.com/repos/pamod/ballerina/hooks","issue_events_url":"https://api.github.com/repos/pamod/ballerina/issues/events{/number}","events_url":"https://api.github.com/repos/pamod/ballerina/events","assignees_url":"https://api.github.com/repos/pamod/ballerina/assignees{/user}","branches_url":"https://api.github.com/repos/pamod/ballerina/branches{/branch}","tags_url":"https://api.github.com/repos/pamod/ballerina/tags","blobs_url":"https://api.github.com/repos/pamod/ballerina/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pamod/ballerina/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pamod/ballerina/git/refs{/sha}","trees_url":"https://api.github.com/repos/pamod/ballerina/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pamod/ballerina/statuses/{sha}","languages_url":"https://api.github.com/repos/pamod/ballerina/languages","stargazers_url":"https://api.github.com/repos/pamod/ballerina/stargazers","contributors_url":"https://api.github.com/repos/pamod/ballerina/contributors","subscribers_url":"https://api.github.com/repos/pamod/ballerina/subscribers","subscription_url":"https://api.github.com/repos/pamod/ballerina/subscription","commits_url":"https://api.github.com/repos/pamod/ballerina/commits{/sha}","git_commits_url":"https://api.github.com/repos/pamod/ballerina/git/commits{/sha}","comments_url":"https://api.github.com/repos/pamod/ballerina/comments{/number}","issue_comment_url":"https://api.github.com/repos/pamod/ballerina/issues/comments{/number}","contents_url":"https://api.github.com/repos/pamod/ballerina/contents/{+path}","compare_url":"https://api.github.com/repos/pamod/ballerina/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pamod/ballerina/merges","archive_url":"https://api.github.com/repos/pamod/ballerina/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pamod/ballerina/downloads","issues_url":"https://api.github.com/repos/pamod/ballerina/issues{/number}","pulls_url":"https://api.github.com/repos/pamod/ballerina/pulls{/number}","milestones_url":"https://api.github.com/repos/pamod/ballerina/milestones{/number}","notifications_url":"https://api.github.com/repos/pamod/ballerina/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pamod/ballerina/labels{/name}","releases_url":"https://api.github.com/repos/pamod/ballerina/releases{/id}","deployments_url":"https://api.github.com/repos/pamod/ballerina/deployments","created_at":"2017-09-19T04:14:03Z","updated_at":"2017-09-19T04:14:08Z","pushed_at":"2018-03-09T04:37:58Z","git_url":"git://github.com/pamod/ballerina.git","ssh_url":"git@github.com:pamod/ballerina.git","clone_url":"https://github.com/pamod/ballerina.git","svn_url":"https://github.com/pamod/ballerina","homepage":"","size":157110,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ballerina-lang:master","ref":"master","sha":"908cd4ac99fab7f66696498d62189e73cbb6c77c","user":{"login":"ballerina-lang","id":24777199,"avatar_url":"https://avatars1.githubusercontent.com/u/24777199?v=4","gravatar_id":"","url":"https://api.github.com/users/ballerina-lang","html_url":"https://github.com/ballerina-lang","followers_url":"https://api.github.com/users/ballerina-lang/followers","following_url":"https://api.github.com/users/ballerina-lang/following{/other_user}","gists_url":"https://api.github.com/users/ballerina-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/ballerina-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ballerina-lang/subscriptions","organizations_url":"https://api.github.com/users/ballerina-lang/orgs","repos_url":"https://api.github.com/users/ballerina-lang/repos","events_url":"https://api.github.com/users/ballerina-lang/events{/privacy}","received_events_url":"https://api.github.com/users/ballerina-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":73930305,"name":"ballerina","full_name":"ballerina-lang/ballerina","owner":{"login":"ballerina-lang","id":24777199,"avatar_url":"https://avatars1.githubusercontent.com/u/24777199?v=4","gravatar_id":"","url":"https://api.github.com/users/ballerina-lang","html_url":"https://github.com/ballerina-lang","followers_url":"https://api.github.com/users/ballerina-lang/followers","following_url":"https://api.github.com/users/ballerina-lang/following{/other_user}","gists_url":"https://api.github.com/users/ballerina-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/ballerina-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ballerina-lang/subscriptions","organizations_url":"https://api.github.com/users/ballerina-lang/orgs","repos_url":"https://api.github.com/users/ballerina-lang/repos","events_url":"https://api.github.com/users/ballerina-lang/events{/privacy}","received_events_url":"https://api.github.com/users/ballerina-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ballerina-lang/ballerina","description":"Ballerina is a new programming language for integration built on a sequence diagram metaphor.","fork":false,"url":"https://api.github.com/repos/ballerina-lang/ballerina","forks_url":"https://api.github.com/repos/ballerina-lang/ballerina/forks","keys_url":"https://api.github.com/repos/ballerina-lang/ballerina/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ballerina-lang/ballerina/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ballerina-lang/ballerina/teams","hooks_url":"https://api.github.com/repos/ballerina-lang/ballerina/hooks","issue_events_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/events{/number}","events_url":"https://api.github.com/repos/ballerina-lang/ballerina/events","assignees_url":"https://api.github.com/repos/ballerina-lang/ballerina/assignees{/user}","branches_url":"https://api.github.com/repos/ballerina-lang/ballerina/branches{/branch}","tags_url":"https://api.github.com/repos/ballerina-lang/ballerina/tags","blobs_url":"https://api.github.com/repos/ballerina-lang/ballerina/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ballerina-lang/ballerina/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ballerina-lang/ballerina/git/refs{/sha}","trees_url":"https://api.github.com/repos/ballerina-lang/ballerina/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ballerina-lang/ballerina/statuses/{sha}","languages_url":"https://api.github.com/repos/ballerina-lang/ballerina/languages","stargazers_url":"https://api.github.com/repos/ballerina-lang/ballerina/stargazers","contributors_url":"https://api.github.com/repos/ballerina-lang/ballerina/contributors","subscribers_url":"https://api.github.com/repos/ballerina-lang/ballerina/subscribers","subscription_url":"https://api.github.com/repos/ballerina-lang/ballerina/subscription","commits_url":"https://api.github.com/repos/ballerina-lang/ballerina/commits{/sha}","git_commits_url":"https://api.github.com/repos/ballerina-lang/ballerina/git/commits{/sha}","comments_url":"https://api.github.com/repos/ballerina-lang/ballerina/comments{/number}","issue_comment_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/comments{/number}","contents_url":"https://api.github.com/repos/ballerina-lang/ballerina/contents/{+path}","compare_url":"https://api.github.com/repos/ballerina-lang/ballerina/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ballerina-lang/ballerina/merges","archive_url":"https://api.github.com/repos/ballerina-lang/ballerina/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ballerina-lang/ballerina/downloads","issues_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues{/number}","pulls_url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls{/number}","milestones_url":"https://api.github.com/repos/ballerina-lang/ballerina/milestones{/number}","notifications_url":"https://api.github.com/repos/ballerina-lang/ballerina/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ballerina-lang/ballerina/labels{/name}","releases_url":"https://api.github.com/repos/ballerina-lang/ballerina/releases{/id}","deployments_url":"https://api.github.com/repos/ballerina-lang/ballerina/deployments","created_at":"2016-11-16T14:58:44Z","updated_at":"2018-03-08T08:40:22Z","pushed_at":"2018-03-09T05:31:55Z","git_url":"git://github.com/ballerina-lang/ballerina.git","ssh_url":"git@github.com:ballerina-lang/ballerina.git","clone_url":"https://github.com/ballerina-lang/ballerina.git","svn_url":"https://github.com/ballerina-lang/ballerina","homepage":"","size":158865,"stargazers_count":240,"watchers_count":240,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":229,"mirror_url":null,"archived":false,"open_issues_count":510,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":229,"open_issues":510,"watchers":240,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051"},"html":{"href":"https://github.com/ballerina-lang/ballerina/pull/5051"},"issue":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/issues/5051"},"comments":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/issues/5051/comments"},"review_comments":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051/comments"},"review_comment":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/5051/commits"},"statuses":{"href":"https://api.github.com/repos/ballerina-lang/ballerina/statuses/2072389dfcc2c621538e9fe53fb8a69e42ceb4d7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pamod"}}