protected Receiver sendCmd(
      Receiver rcv, String cmd, String key, String opt, byte[] value, int casid)
      throws IOException {
    if (key.contains(" ")) {
      throw new IllegalArgumentException("Can't include space in a key.");
    }
    boolean retry;
    do {
      retry = false;
      Connection con = null;
      try {
        con = routing.getConnection(key);
        con.write(cmd, key, opt, value, casid);
        rcv.receive(con);
        routing.returnConnection(con);
      } catch (ParseException e) {
        routing.returnConnection(con);
        log.error("sendCmd(): " + e.getMessage());
        throw new RuntimeException(e);
      } catch (Exception e) {
        log.error("sendCmd(): " + e.getMessage());
        retry = true;
        log.debug("sendCmd(): retry=" + rcv.retry);
        routing.failCount(con);
        if (++rcv.retry >= maxRetry) {
          log.error("sendCmd(): Retry out");
          throw new IOException("Retry out", e);
        }
      }
    } while (retry);

    return rcv;
  }
  public ClientObject(String nodeId) {
    BasicConfigurator.configure();

    try {
      RomaSocketPool.getInstance();
    } catch (RuntimeException e) {
      RomaSocketPool.init();
      log.warn("ClientObject() : SocketPool initialized in RomaClient().");
    }

    routing = new Routing(nodeId);
    routing.start();

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      log.error("ClientObject() : " + e.getMessage());
    }
  }
 public void setThreadSleep(int n) {
   routing.setThreadSleep(n);
 }
 public void setFailCount(int n) {
   routing.setFailCount(n);
 }
 public void destroy() {
   routing.stopThread();
 }