Example #1
0
  @Override
  public void run() {
    // HsmControlGetBfDetailsMsg
    _log.info("Starting working thread");
    try {
      while (true) {
        CellMessage msg = (CellMessage) _fifo.pop();
        if (msg == null) {
          _log.warn("fifo empty");
          break;
        }
        Message request = (Message) msg.getMessageObject();
        try {

          if (request instanceof HsmControlGetBfDetailsMsg) {
            getBfDetails(((HsmControlGetBfDetailsMsg) request).getStorageInfo());
          } else {
            throw new IllegalArgumentException("Not supported " + request.getClass().getName());
          }
          request.setSucceeded();
          msg.revertDirection();
          try {
            sendMessage(msg);
          } catch (Exception ee) {
            _log.warn("Problem replying : " + ee);
          }
        } catch (Exception eee) {
          _failed++;
          _log.warn(eee.toString(), eee);
          request.setFailed(34, eee.toString());
          msg.revertDirection();
          try {
            sendMessage(msg);
          } catch (Exception ee) {
            _log.warn("Problem replying : " + ee);
          }
        }
      }
    } catch (Exception ee) {
      _log.warn("Got exception from run while : " + ee);
    } finally {
      _log.info("Working thread finished");
    }
  }
Example #2
0
 @Override
 public void messageArrived(CellMessage msg) {
   Object obj = msg.getMessageObject();
   _requests++;
   String error;
   if (!(obj instanceof Message)) {
     error = "Illegal dCache message class : " + obj.getClass().getName();
   } else if (_fifo.size() > _maxQueueSize) {
     error = "Queue size exceeded " + _maxQueueSize + ", Request rejected";
   } else {
     _fifo.push(msg);
     return;
   }
   _failed++;
   _log.warn(error);
   ((Message) obj).setFailed(33, error);
   msg.revertDirection();
   try {
     sendMessage(msg);
   } catch (Exception ee) {
     _log.warn("Problem replying : " + ee);
   }
 }