write phase one - Invalidation reply

This commit is contained in:
lyr90329 2014-08-05 15:35:23 +08:00
parent 013f08e7e3
commit 8c929769b8
1 changed files with 32 additions and 0 deletions

View File

@ -383,6 +383,38 @@ public class memSession implements Runnable
} }
} }
break; break;
case nm_write_1:
{
nm_write_1 msgLite = msg.getMessageLite();
Integer state = getLockState(msgLite.getKey());
if (state == LockKey.waitLock)
{
System.err.println("write_1 error wait lock state");
return ;
}
else if(state == LockKey.badLock)
{
removeLock(msgLite.getKey());
}
nm_write_1_res.Builder builder = nm_write_1_res.newBuilder();
builder.setKey(msgLite.getKey());
builder.setValue(msgLite.getValue());
builder.setTime(msgLite.getTime());
NetMsg send = NetMsg.newMessage();
send.setMessageLite(builder);
send.setMsgID(EMSGID.nm_write_1_res);
getClientChannel(msgLite.getMemID()).write(send);
LockKey lockKey = new LockKey(ClientMgr.getInstance().mClientNumber, 0,System.currentTimeMillis(),LockKey.waitLock);
if(lockKey(msgLite.getKey(), lockKey)==false)
{
System.out.println("nm_write_1 Lock fail");
}
}
break;
default: default:
System.err.println(msg.getMsgID().toString()); System.err.println(msg.getMsgID().toString());
break; break;