David Reiss | 04c3159 | 2008-11-21 23:07:05 +0000 | [diff] [blame] | 1 | |
| 2 | package com.facebook.thrift; |
| 3 | |
| 4 | import thrift.test.*; |
| 5 | |
| 6 | import com.facebook.thrift.TApplicationException; |
| 7 | import com.facebook.thrift.TSerializer; |
| 8 | import com.facebook.thrift.transport.TTransport; |
| 9 | import com.facebook.thrift.transport.TSocket; |
| 10 | import com.facebook.thrift.transport.TFramedTransport; |
| 11 | import com.facebook.thrift.transport.TTransportException; |
| 12 | import com.facebook.thrift.protocol.TBinaryProtocol; |
| 13 | import com.facebook.thrift.protocol.TSimpleJSONProtocol; |
| 14 | |
| 15 | import java.util.Map; |
| 16 | import java.util.HashMap; |
| 17 | import java.util.Set; |
| 18 | import java.util.HashSet; |
| 19 | import java.util.List; |
| 20 | import java.util.ArrayList; |
| 21 | |
| 22 | |
| 23 | public class OverloadNonblockingServer { |
| 24 | |
| 25 | public static void main(String[] args) throws Exception { |
| 26 | int msg_size_mb = Integer.parseInt(args[0]); |
| 27 | int msg_size = msg_size_mb * 1024 * 1024; |
| 28 | |
| 29 | TSocket socket = new TSocket("localhost", 9090); |
| 30 | TBinaryProtocol binprot = new TBinaryProtocol(socket); |
| 31 | socket.open(); |
| 32 | binprot.writeI32(msg_size); |
| 33 | binprot.writeI32(1); |
| 34 | socket.flush(); |
| 35 | |
| 36 | System.in.read(); |
| 37 | // Thread.sleep(30000); |
| 38 | for (int i = 0; i < msg_size_mb; i++) { |
| 39 | binprot.writeBinary(new byte[1024 * 1024]); |
| 40 | } |
| 41 | |
| 42 | socket.close(); |
| 43 | } |
| 44 | } |