public void OnClose(ThriftPool ipro) { ipro.transport.Close(); ipro.transport.Dispose(); ipro.protocol.Dispose(); ipro = null; }
private ThriftPool OnInit() { ThriftPool thriftpool = new ThriftPool(server_ip, server_port); thriftpool.transport.Open(); return(thriftpool); }
public TestThrift() { /* * transport = new TFramedTransport(new TSocket(SERVER_IP, SERVER_PORT, TIMEOUT)); * // 协议要和服务端一致 * // TBinaryProtocol * // TJSONProtocol * * protocol = new TBinaryProtocol(transport); */ pool = new PoolManager(SERVER_IP, SERVER_PORT); thriftpool = pool.Get(); transport = thriftpool.transport; protocol = thriftpool.protocol; SERVICE_NAME += ":"; }
public void Return(ThriftPool ipro) { pool.Return(ipro); }
static void TestFunc(string svrAddr, int threadCount) { List<Reserve> list = new List<Reserve>(); for (int j = 0; j < packageCount; j++) { Reserve r = CreateTestReserve(j); list.Add(r); } ThriftPool pool = new ThriftPool(new ThriftConfig() { #region 配置连接池 Host = svrAddr, Port = 9090, Timeout = 60, MaxActive = 100, MaxIdle = 20, MinIdle = 5, Encode = Encoding.UTF8 #endregion }); using (FileStream fs = new FileStream(".\\output.log", FileMode.Create, FileAccess.Write)) { PerformanceTestHelper helper = new PerformanceTestHelper((index) => { TTransport transport = pool.BorrowInstance(); //TTransport transport = new TFramedTransport(new TSocket(svrAddr, 9090)); //TProtocol protocol = new TBinaryProtocol(transport); TProtocol protocol = new TCompactProtocol(transport); //transport.Open(); Serv.Client client = new Serv.Client(protocol); client.createBatch(list); pool.ReturnInstance(transport); //transport.Close(); }, threadCount, 1000, true, fs); helper.Run(); } }