示例#1
0
 public void setData(final String path, byte[] data) {
   M2mRequestHeader m2mRequestHeader = new M2mRequestHeader();
   m2mRequestHeader.setType(ZooDefs.OpCode.setData);
   m2mRequestHeader.setKey(path);
   M2mSetDataRequest m2mSetDataRequest = new M2mSetDataRequest();
   M2mDataNode m2mDataNode = new M2mDataNode();
   m2mDataNode.setId(path);
   m2mDataNode.setData(1331);
   M2mReplyHeader m2mReplyHeader = new M2mReplyHeader();
   m2mSetDataRequest.setData(ResourceReflection.serializeKryo(m2mDataNode));
   m2mSetDataRequest.setKey(path);
   M2mPacket m2mPacket =
       new M2mPacket(m2mRequestHeader, m2mReplyHeader, m2mSetDataRequest, new M2mCreateResponse());
   tcpClient.write(m2mPacket);
 }
示例#2
0
 public String getData(final String path) {
   M2mRequestHeader m2mRequestHeader = new M2mRequestHeader();
   m2mRequestHeader.setType(ZooDefs.OpCode.getData);
   m2mRequestHeader.setKey(path);
   M2mGetDataRequest m2mGetDataRequest = new M2mGetDataRequest();
   M2mReplyHeader m2mReplyHeader = new M2mReplyHeader();
   m2mGetDataRequest.setPath(path);
   M2mGetDataResponse m2mGetDataResponse = new M2mGetDataResponse();
   M2mPacket m2mPacket =
       new M2mPacket(m2mRequestHeader, m2mReplyHeader, m2mGetDataRequest, m2mGetDataResponse);
   tcpClient.write(m2mPacket);
   M2mDataNode m2mDataNode =
       (M2mDataNode)
           ResourceReflection.deserializeKryo(
               ((M2mGetDataResponse) m2mPacket.getResponse()).getData());
   return m2mDataNode.getData() + "";
 }