public void run()
{
int op;
Fqn fqn;
Object key, val, retval;
NodeSPI n;
boolean flag;
while (t != null && t.equals(Thread.currentThread()) && t.isAlive())
{
try
{
if (trace) log.trace("Reading next byte");
op = input.readByte();
}
catch (IOException e)
{
log.debug("Client closed socket");
close();
break;
}
try
{
if (trace) log.trace("Resetting output");
output.reset();
switch (op)
{
case TcpCacheOperations.GET_CHILDREN_NAMES:
fqn = (Fqn) input.readObject();
Node node = c.getRoot().getChild(fqn);
Set<Object> children = node == null ? Collections.emptySet() : node.getChildrenNames();
output.writeObject(children);
break;
case TcpCacheOperations.GET_KEY:
fqn = (Fqn) input.readObject();
key = input.readObject();
retval = c.get(fqn, key);
output.writeObject(retval);
break;
case TcpCacheOperations.GET:
fqn = (Fqn) input.readObject();
n = c.getNode(fqn);
if (n == null)
{
// node doesn't exist - return null
output.writeObject(null);
break;
}
Map map = n.getData();
if (map == null) map = new HashMap();
output.writeObject(map);
break;
case TcpCacheOperations.EXISTS:
fqn = (Fqn) input.readObject();