Skip to content

Wire Format Json, JsonSmile, and Xml

edwardcapriolo edited this page Feb 3, 2013 · 3 revisions

JSON

Intravert operations consist of a VERB (such as set, get, or slice) and a map of parameters.
Many of the verbs are familiar to those of the Cassandra thrift interface. The design is intentionally simple to avoid the complexities of code generation and cross language RPC issues.

Example

Here is a sample of what a request looks like.

{"e":[
  {"type":"SETKEYSPACE","op":{"keyspace":"myks"}},
  {"type":"CREATEKEYSPACE","op":{"name":"myks","replication":1}},
  {"type":"CREATECOLUMNFAMILY","op":{"name":"mycf"}},
  {"type":"SETCOLUMNFAMILY","op":{"columnfamily":"mycf"}},
  {"type":"AUTOTIMESTAMP","op":{}},
  {"type":"SET","op":{"columnName":"6","rowkey":"5","value":"7"}},
  {"type":"SLICE","op":{"end":"9","rowkey":"5","size":4,"start":"1"}}
 ]}

The Java classes that make up IntraVert include static methods to make constructing requests even easier. The above JSON was generated by the following code:

IntraClient i = new IntraClient();
i.payload="json";
IntraReq req = new IntraReq();
req.add( IntraOp.setKeyspaceOp("myks") );
req.add( IntraOp.createKsOp("myks", 1) );
req.add( IntraOp.createCfOp("mycf") );
req.add( IntraOp.setColumnFamilyOp("mycf") );
req.add( IntraOp.setAutotimestampOp() );
req.add( IntraOp.setOp("5", "6", "7") );
req.add( IntraOp.sliceOp("5", "1", "9", 4) );		
System.out.println( i.sendBlocking(req) );

The Intravert server currently supports three transports JSON, JSON compressed using smile, and XML. The message format and the transport are not tightly coupled. The client server communication is done over HTTP keeping network administrators happy.

Behind the scenes

IntraVert currently has three endpoints intravert-json, intravertjsonsmile, intravert-xml. Once connected via an http transport the client if free to switch between the three per request. For larger requests the smile compression might to better then raw json. Session information is available across transports.