Package com.cloudhopper.mq.message

Examples of com.cloudhopper.mq.message.PriorityMQMessage


      //message of type T, transcode it as that, and then construct the PriorityMQMessage
      //from scratch. This way, we can have backwards compatibility when loading items
      //into new priority queues over remote brokers by upgrading the receiving side first,
      //then the sending side.
      logger.trace("No PRIORITY_MAGIC_NUMBER detected, attempting backwards compatible.");
      return new PriorityMQMessage(Priority.MIN_PRIORITY, (T)transcoder.decode(encoded));
  } else {
      long dataLen = buf.getLong();
      long metaLen = buf.getLong();
     
      byte[] bencoded = new byte[((int)dataLen)];
View Full Code Here


    @Override protected void afterStore(PriorityMQMessage<E> item, byte[] encoded) {
  // nothing
    }

    @Override protected PriorityMQMessage<E> doTake() throws QueueInvalidStateException, QueueFatalException, QueueTimeoutException, DataStoreFatalException {
  PriorityMQMessage w = queue.peek();
  long itemId = w.key();
  byte[] key = priorityKeyUtil.encode(getId(), itemId);
  try {
      ds.deleteRecord(key);
  } catch (RecordNotFoundException e) {
      logger.error("Key not found in DataStore for queueId=" + getId() + ", itemId=" + itemId, e);
      this.errorCount.incrementAndGet();
  } catch (DataStoreFatalException e) {
      logger.error("Unable to permanently delete key for queueId=" + getId() + ", itemId=" + itemId, e);
      this.errorCount.incrementAndGet();
  }
  PriorityMQMessage item = queue.remove();
  return item;
    }
View Full Code Here

    public void preload(DataStoreIterator iterator) throws DataStoreFatalException, QueueFatalException {
  int itemsLoaded = 0;
  while (iterator.next()) {
      DataStoreIterator.Record record = iterator.getRecord();
      CompositeKey key = priorityKeyUtil.decode(record.getKey());
      PriorityMQMessage element = null;
      try {
    element = priorityTranscoder.decode(record.getValue());
      } catch (Throwable t) {
    throw new QueueFatalException("Unable to decode element with transcoder for queueId " + getId() + ". Perhaps incorrect transcoder?", t);
      }
View Full Code Here

  boolean replaceLast = false;
  int qsize = queue.size(); //maybe use memoryCount.get() instead of queue.size()? which is more performant?
  if (qsize != 0 && qsize == maxItemsInMemory) {
      if (!overflow) logger.trace("Overflow at {}", qsize);
      overflow = true;
      PriorityMQMessage tail = queue.peekLast();
      int compare = item.compareTo(tail);
      if (compare >= 0) {
    dsOnly = true;
      } else if (compare < 0) {
    replaceLast = true;
View Full Code Here

  return true;
    }

    @Override
    protected PriorityMQMessage<E> doTake() {
  PriorityMQMessage w = queue.peek();
  long itemId = w.key();
  logger.trace("[{}] itemId={} in queue.take()", getName(), itemId);
  byte[] key = priorityKeyUtil.encode(getId(), itemId);
  try {
      ds.deleteRecord(key);
  } catch (RecordNotFoundException e) {
      logger.error("Key not found in DataStore for queueId=" + getId() + ", itemId=" + itemId, e);
      this.errorCount.incrementAndGet();
  } catch (DataStoreFatalException e) {
      logger.error("Unable to permanently delete key for queueId=" + getId() + ", itemId=" + itemId, e);
      this.errorCount.incrementAndGet();
  }
  PriorityMQMessage item = queue.remove();
  return item;
    }
View Full Code Here

    public void preload(DataStoreIterator iterator) throws DataStoreFatalException, QueueFatalException {
  int itemsLoaded = 0;
  while (iterator.next()) {
      DataStoreIterator.Record record = iterator.getRecord();
      CompositeKey key = priorityKeyUtil.decode(record.getKey());
      PriorityMQMessage element = null;
      try {
    element = priorityTranscoder.decode(record.getValue());
      } catch (Throwable t) {
    throw new QueueFatalException("Unable to decode element with transcoder for queueId " + getId() + ". Perhaps incorrect transcoder?", t);
      }
View Full Code Here

TOP

Related Classes of com.cloudhopper.mq.message.PriorityMQMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.