[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-11-09 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996447#comment-14996447
 ] 

Klaus Ma commented on MESOS-3405:
-

[~karya], will MESOS-3580 address this requirement?

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
> Fix For: 0.26.0
>
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-11-07 Thread Michael Park (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14995533#comment-14995533
 ] 

Michael Park commented on MESOS-3405:
-

{noformat}
commit 9c54387db4ebf7c0ddf538a45d1ff58d3da6df44
Author: Klaus Ma 
Date:   Sat Nov 7 21:18:16 2015 -0800

mesos: Added `JSON::protobuf` for `google::protobuf::RepeatedPtrField`.

Review: https://reviews.apache.org/r/38335
{noformat}
{noformat}
commit 3e2b192e3aac842dd51add65fa34b6ef4a00ff40
Author: Klaus Ma 
Date:   Sat Nov 7 21:17:54 2015 -0800

stout: Added `JSON::protobuf` for `google::protobuf::RepeatedPtrField`.

Review: https://reviews.apache.org/r/38342
{noformat}

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
> Fix For: 0.26.0
>
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-11-07 Thread Michael Park (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14995526#comment-14995526
 ] 

Michael Park commented on MESOS-3405:
-

Do you mean so that we won't need functions like {{JSON::Array model(const 
Labels& labels}}?

By the looks of it, it seems like we can simply do:

{code}
if (task.has_labels()) {
  object.values["labels"] = JSON::protobuf(task.labels().labels());
}
{code}

to get rid of the {{model}} function. In general, I think that some of these 
pluralized protobuf messages were introduced due to the fact that this function 
didn't exist before. For example, the {{Machines}} protobuf were introduced, 
but were removed with the introduction of this functionality.

Am I perhaps misunderstanding the situation you're describing?

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-11-06 Thread Till Toenshoff (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14993583#comment-14993583
 ] 

Till Toenshoff commented on MESOS-3405:
---

[~mcypark] seems the RRs are ready to commit, no? We would love to cut the 
0.26.0 and hence need to get this committed or pushed to 0.27.0.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-11-03 Thread Kapil Arya (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14988044#comment-14988044
 ] 

Kapil Arya commented on MESOS-3405:
---

Is it possible to have specialization such as  {{JSON::Protobuf(const Labels& 
labels)}} and {{JSON::Protobuf(const Parameters& parameters)}} to simply some 
of the stuff in {{src/http.cpp}}? For a bunch of messages, we have to 
explicitly model the fields because we want to render Labels as:
{code}
{ "labels": [ {"key": "k", "value": "v"}, ...] }
{code}

as opposed to

{code}
{ "labels": { "labels" : [ {"key": "k", "value": "v"}, ...] } }
{code}



> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-24 Thread Jan Schlicht (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14906541#comment-14906541
 ] 

Jan Schlicht commented on MESOS-3405:
-

Thanks!

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-24 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14906456#comment-14906456
 ] 

Klaus Ma commented on MESOS-3405:
-

The code was re-upload after resolving conflict. [~mcypark], would you continue 
to review them?

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-24 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14906444#comment-14906444
 ] 

Klaus Ma commented on MESOS-3405:
-

The code was re-upload just now after resolving the conflict.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-24 Thread Jan Schlicht (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14906398#comment-14906398
 ] 

Jan Schlicht commented on MESOS-3405:
-

Sorry to be a bit pushy, but what's the current status of this ticket? It seem 
to be in review state for quite some time now.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-21 Thread Joseph Wu (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14901566#comment-14901566
 ] 

Joseph Wu commented on MESOS-3405:
--

Note: With this change, you can also remove this test helper:
https://github.com/apache/mesos/blob/master/src/tests/master_maintenance_tests.cpp#L93-L104

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-14 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14743634#comment-14743634
 ] 

Klaus Ma commented on MESOS-3405:
-

[~mcypark], because we break the compatibility; both build will be failed :(.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-13 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14742932#comment-14742932
 ] 

Klaus Ma commented on MESOS-3405:
-

[~mypark], the patch was updated accordingly to remove {{JSON::Protobuf}}; I 
also add test cases for {{Array protobuf(const 
google::protobuf::RepeatedPtrField& repeated)}}, the 
{{protobuf_tests.pb.h/cc}} were re-generated by protobuf built by mesos make.

If any comments, please let me know; I'll address them asap :).
  

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-13 Thread Michael Park (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14742540#comment-14742540
 ] 

Michael Park commented on MESOS-3405:
-

[~klaus1982]: Thanks for taking this on! We don't need to keep backward 
compatibility. Let's just remove {{JSON::Protobuf}}.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-13 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14742534#comment-14742534
 ] 

Klaus Ma commented on MESOS-3405:
-

RR: https://reviews.apache.org/r/38335/

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-3405) Add JSON::protobuf for google::protobuf::RepeatedPtrField.

2015-09-12 Thread Klaus Ma (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14742365#comment-14742365
 ] 

Klaus Ma commented on MESOS-3405:
-

[~mcypark], I'm working on the patch for this ticket; after checking the code, 
I'd like to do the following enhancement:
- Move {{JSON::Protobuf}} to {{JSON::internal::Protobuf}} to make it 
internal
- Replace {{JSON::Protobuf}} with {{JSON::protobuf}}
- Add serialize function to {{Array protobuf(const 
google::protobuf::RepeatedPtrField& repeated)}}, so the following code can 
be re-used

{code}
   {
 JSON::Array array;
 array.values.reserve(task.statuses().size()); // MESOS-2353.

 foreach (const TaskStatus& status, task.statuses()) {
   array.values.push_back(model(status));// <=== add model as 
protobuf's second parameter.
 }
 object.values["statuses"] = std::move(array);
   }
{code}

After this refactor, {{make && make check}} is enough for the UT.

If any comments, please let me know.

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> --
>
> Key: MESOS-3405
> URL: https://issues.apache.org/jira/browse/MESOS-3405
> Project: Mesos
>  Issue Type: Task
>  Components: stout
>Reporter: Michael Park
>Assignee: Klaus Ma
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
> Object object;
> /* Move the body of JSON::Protobuf constructor here. */
> return object;
>   }
>   template 
>   Array protobuf(const google::protobuf::RepeatedPtrField& repeated)
>   {
> static_assert(std::is_convertible::value,
>   "T must be a google::protobuf::Message");
> JSON::Array array;
> array.values.reserve(repeated.size());
> foreach (const T& elem, repeated) {
>   array.values.push_back(JSON::Protobuf(elem));
> }
> return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)