handling read and write request

This commit is contained in:
lyr90329 2014-08-13 16:49:42 +08:00
parent b7cc9cee53
commit 5c35bdd822
1 changed files with 90 additions and 2 deletions

View File

@ -49,7 +49,7 @@ public class webSession implements Runnable
public void start()
{
//DBSession.getInstance().start();
//DBSession.getInstance().start(); 数据库连接
new Thread(session).start();
System.out.println("session start");
}
@ -147,7 +147,95 @@ public class webSession implements Runnable
nr_Connected_mem_back msgLite= msg.getMessageLite();
addClientChannel(msgLite.getMemID(), e.getChannel());
}
break;
break;
case nr_read_res:
{
nr_Read_res msgBody = msg.getMessageLite();
// System.out.println("key:"+msgBody.getKey()+" value:"+msgBody.getValue());
// System.out.println(String.valueOf((System.nanoTime()-msgBody.getTime())/1000000.0));
// log.log(Priority.INFO, String.valueOf((System.nanoTime()-msgBody.getTime())/1000000.0));
// log.log(Level.INFO, String.valueOf((System.nanoTime()-msgBody.getTime())/1000000.0));
// System.err.println((System.nanoTime()-msgBody.getTime())/1000000.0);
// if (ticks==0)
// {
// totalTime = System.currentTimeMillis();
// }
// totalTime += System.nanoTime()-msgBody.getTime();
// ticks++;
// if (ticks == 1000)
// {
// System.out.println(totalTime/1000000000.0f);
//
// totalTime = 0;
// ticks = 0;
// }
// if (msgBody.getValue().isEmpty()) //读数据库
// {
// DBMessage dbMsg=new DBMessage();
// dbMsg.mode = DBMessage.mode_query;
// dbMsg.key = msgBody.getKey();
//
// DBSession.getInstance().addDBMessage(dbMsg);
// }
// else
// {
// nc_ReadRes.Builder builder = nc_ReadRes.newBuilder();
// builder.setKey(msgBody.getKey());
// builder.setValue(msgBody.getValue());
//
// NetMsg send = NetMsg.newMessage();
// send.setMessageLite(builder);
// send.setMsgID(EMSGID.nc_read_res);
//
// //sendMsg(getRequestChannel(msgBody.getClientid()), send);
// }
}
break;
case nr_write_res:
{
nr_write_res msgBody = msg.getMessageLite();
// System.out.println("key:"+msgBody.getKey()+" value:"+msgBody.getValue());
//DBMessage dbMsg = new DBMessage(); //异步写数据库
//dbMsg.mode = DBMessage.mode_set;
//dbMsg.key = msgBody.getKey();
//dbMsg.value = msgBody.getValue();
//DBSession.getInstance().addDBMessage(dbMsg);
// log.log(Level.INFO, String.valueOf((System.nanoTime()-msgBody.getTime())/1000000.0));
//System.err.println();
// System.out.println(String.valueOf((System.nanoTime()-msgBody.getTime())/1000000.0));
//
// if (ticks==0)
// {
// totalTime = System.currentTimeMillis();
// }
// totalTime += System.nanoTime()-msgBody.getTime();
// ticks++;
// if (ticks == 1000)
// {
// System.out.println(totalTime/1000000000.0f);
//
// totalTime = 0;
// ticks = 0;
// }
// nc_WriteRes.Builder builder = nc_WriteRes.newBuilder();
// builder.setKey(msgBody.getKey());
// builder.setValue(msgBody.getValue());
//
// NetMsg send = NetMsg.newMessage();
// send.setMessageLite(builder);
// send.setMsgID(EMSGID.nc_write_res);
//sendMsg(getRequestChannel(msgBody.getClientid()), send);
}
break;
default:
System.err.println(msg.getMsgID().toString());
break;