2. Outline
Why using Handler Socket
How to build Handler Socket Plug-in
Handler Socket configuration parameter
Handler Socket java client program
Best Practice for java client
Helpful sites
5. item with handlesocket without handlesocket
Process=16 and QPS:130429 QPS:95291
request=1000000*16 Mysql server Mysql server
Cpu(s): 29.0%us, 20.6%sy Cpu(s): 71.2%us, 20.8%sy
Process=32 and QPS:268294 QPS:103165
request=1000000*32 Mysql server Mysql server Cpu(s):
Cpu(s): 58.1%us, 27.8%sy 71.1%us, 21.1%sy
Process=64 and QPS:291960 QPS:104180
request=1000000*64 Mysql server Cpu(s): Mysql server Cpu(s):
58.8%us, 28.7%sy 71.3%us, 22.3%sy
13. Java Key methods(1)
• public HSClientImpl(InetSocketAddress
inetSocketAddress, int poolSize)
• public IndexSession openIndexSession(String
dbname, String tableName,String indexName,
String[] columns)
• public IndexSession openIndexSession(int
indexId, String dbname, String
tableName, String indexName, String[]
columns)
14. Java Key methods(2)
• public boolean insert(String[] values)
• public int delete(String[] keys)
• public int delete(String[] keys, FindOperator
operator)
• public int delete(String[] keys, FindOperator
operator, int limit,int offset)
• public int update(String[] keys, String[] values,
FindOperator operator)
15. Java Key methods(3)
• public int update(String[] keys, String[] values,
FindOperator operator,int limit, int offset)
• public ResultSet find(String[] keys)
• public ResultSet find(String[] keys,
FindOperator operator, int limit,int offset)
• public ModifyStatement createStatement()
16. Create the MYSQL tables
create table mt_data
(
guid varchar(18) not null,
orgid int(9) not null,
tabid int(9) not null,
name varchar(128) not null,
IsDeleted char(1) not null,
createtime datetime not null,
modifytime datetime not null,
....
primary key(guid,orgid)
) ENGINE=InnoDB CHARSET=utf8;
19. • HSClient is thread-safe, so you must use it as
SINGLETON object in your application.
• Open index is an expensive operation, so
reuse an opened index id as much as possible.
• IndexSession is thread-safe,so please reuse an
opened IndexSession as much as possible.
• Use IndexSession rather than HSClient
• Use ModifyStatement to insert/update data