Esempio n. 1
0
			public void send_execute(RestRequest request)
			{
				oprot_.WriteMessageBegin(new TMessage("execute", TMessageType.Call, seqid_));
				var args = new execute_args();
				args.Request = request;
				args.Write(oprot_);
				oprot_.WriteMessageEnd();
				oprot_.Transport.Flush();
			}
		public RestResponse Process(string clusterName,string strUrl, string reqdata, string encoding, Method method)
		{
			ESNode node = ESNodeManager.Instance.GetThriftNode(clusterName);
			using (var esSession = new ESSession(node.ConnectionProvider))
			{
				var restRequest = new RestRequest();
				restRequest.Method = method;
				restRequest.Uri = strUrl;

				if (!string.IsNullOrEmpty(reqdata))
				{
					restRequest.Body = Encoding.UTF8.GetBytes(reqdata);
				}

				//				restRequest.Parameters = new Dictionary<string, string>();
				//				restRequest.Parameters.Add("pretty", "true");
				restRequest.Headers = new Dictionary<string, string>();
				restRequest.Headers.Add("Content-Type", "application/json");
				//				restRequest.Headers.Add("charset", encoding);

				RestResponse response = esSession.GetClient().execute(restRequest);
				if (response.Status != Status.OK && response.Status != Status.CREATED)
				{
					var formatedMessage = string.Format("Method:{5},Status:{0},Url:{1}{2},ReqData{3},Response:{4}",
								  response.Status, esSession.CurrentServer, strUrl, reqdata,
								  response.GetBody(), method);


					ExceptionHandler.HandleExceptionResponse(response.GetBody(), formatedMessage);



				}
				return response;
			}
		}
Esempio n. 3
0
			public RestResponse execute(RestRequest request)
			{
				send_execute(request);
				return recv_execute();
			}
Esempio n. 4
0
			public void Read(TProtocol iprot)
			{
				TField field;
				iprot.ReadStructBegin();
				while (true)
				{
					field = iprot.ReadFieldBegin();
					if (field.Type == TType.Stop)
					{
						break;
					}
					switch (field.ID)
					{
						case 1:
							if (field.Type == TType.Struct)
							{
								request = new RestRequest();
								request.Read(iprot);
								__isset.request = true;
							}
							else
							{
								TProtocolUtil.Skip(iprot, field.Type);
							}
							break;
						default:
							TProtocolUtil.Skip(iprot, field.Type);
							break;
					}
					iprot.ReadFieldEnd();
				}
				iprot.ReadStructEnd();
			}