protected void handleNewRunRequest(Owner sender) { _consumerLock.lock(); try { if (!_runRequests.contains(sender)) { _runRequests.add(sender); } } finally { _consumerLock.unlock(); } }
protected void handleNewConsumer(Owner sender) { _consumerLock.lock(); try { if (!_consumersAvailable.contains(sender)) { _consumersAvailable.add(sender); } } finally { _consumerLock.unlock(); } }
protected void handleConsumerReadyRequest(long requestId, Address address) { Owner requestor; final Owner source = new Owner(address, requestId); _consumerLock.lock(); try { requestor = _runRequests.poll(); // We don't add duplicate consumers - this allows for resubmission // if it is thought the message may have been dropped if (requestor == null && !_consumersAvailable.contains(source)) { _consumersAvailable.add(source); } } finally { _consumerLock.unlock(); } if (requestor != null) { sendRequest( requestor.getAddress(), Type.CONSUMER_FOUND, source.getRequestId(), source.getAddress()); sendRemoveRunRequest(requestor); } else { sendNewConsumerRequest(source); } }