protected boolean doStore(E item, byte[] encoded) throws QueueIsFullException { // temporarily get the next index (but don't increment it yet) long itemId = this.index.getNextLast(); logger.trace("[{}] itemId={} in queue.put()", getName(), itemId); // is the queue full? if (itemId < 0) { throw new QueueIsFullException("Queue is full [method=add(), queue=" + getName() + ", size=" + index.getSize() + "]"); } // generate the composite key we'll use within the queue (queueId and itemId) byte[] key = keyUtil.encode(getId(), itemId); // put the value into the data store by key -- will throw an exception // if there was an error while storing it, this is the most likely // place that an error would occur try { ds.setRecord(key, encoded); } catch (DataStoreFatalException e) { // this should only happen if there was a serious error with // the underlying data store -- we'll ignore so that the system doesn't crash logger.error("Unable to permanently store key and value for queueId=" + getId() + ", itemId=" + itemId, e); this.errorCount.incrementAndGet(); return false; } queue.add(item); return true; }
protected boolean doStore(E item, byte[] encoded) throws QueueIsFullException { // temporarily get the next index (but don't increment it yet) long itemId = this.index.getNextLast(); logger.trace("[{}] itemId={} in queue.put()", getName(), itemId); // is the queue full? if (itemId < 0) { throw new QueueIsFullException("Queue is full [method=add(), queue=" + getName() + ", size=" + index.getSize() + "]"); } // generate the composite key we'll use within the queue (queueId and itemId) byte[] key = keyUtil.encode(getId(), itemId); // put the value into the data store by key -- will throw an exception // if there was an error while storing it, this is the most likely // place that an error would occur try { ds.setRecord(key, encoded); } catch (DataStoreFatalException e) { // this should only happen if there was a serious error with // the underlying data store -- we'll ignore so that the system doesn't crash logger.error("Unable to permanently store key and value for queueId=" + getId() + ", itemId=" + itemId, e); this.errorCount.incrementAndGet(); return false; } return true; }