aurora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Farner <wfar...@apache.org>
Subject Re: Aurora Client over HTTP/JSON
Date Thu, 27 Mar 2014 19:34:32 GMT
Hi Smarth!

This is out of scope of AURORA-20.  That ticket tracks creating a
guide for new developers on the client.  However, i'm not opposed to
the feature you propose.

The client currently speaks HTTP/JSON.  If you invoke ./gradlew run,
you might notice these API calls when you view some of the pages on
the scheduler web interface.  Chrome developer tools makes it easy to
convert these calls into curl commands.  Here's one stripped down:

$ curl 'http://localhost:8081/api' --data-binary '[1,"getRoleSummary",1,0,{}]'
[1,"getRoleSummary",2,0,{"0":{"rec":{"1":{"i32":1},"3":{"rec":{"17":{"rec":{"1":{"set":["rec",1,{"1":{"str":"mesos"},"2":{"i32":40},"3":{"i32":20}}]}}}}},"4":{"rec":{"1":{"i32":3}}},"5":{"rec":{"1":{"str":"local"},"2":{"i32":3}}}}}}]

This is invoking methods on the thrift API [1], and results are
encoded using TJSONProtocol (configured in SchedulerAPIServlet [2]).
You'll notice from the output above that TJSONProtocol encodes fields
with their numeric field IDs, as specified in api.thrift.  This is a
fundamental characteristic of IDLs like thrift and protobuf - field
IDs rather than names are transmitted over the wire.  Obviously, this
is somewhat at odds with the traditional HTTP/JSON approach.

I see three obvious paths forward, some of which might not suit your needs:

- use a part of our client as a python API from your tooling

- use thrift-compiled code in your tooling

- augment the scheduler to have separate endpoints that expose fields
by name rather than numeric ID.  there may be prior art for this, but
otherwise would look something like SchedulerAPIServlet along with a
different TProtocolFactory [3].

Hope that helps!  Cheers!


-=Bill


[1]
https://github.com/apache/incubator-aurora/blob/master/src/main/thrift/org/apache/aurora/gen/api.thrift#L496-531
[2]
https://github.com/apache/incubator-aurora/blob/master/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerAPIServlet.java
[3]
http://people.apache.org/~thejas/thrift-0.9/javadoc/org/apache/thrift/protocol/TProtocolFactory.html

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message