コード例 #1
0
  @Override
  public Queue updateQueue(String queuePath, Queue queue) {
    queue.setPath(queuePath);

    UUID timestampUuid = newTimeUUID();
    long timestamp = getTimestampInMicros(timestampUuid);

    Mutator<ByteBuffer> batch = createMutator(cass.getApplicationKeyspace(applicationId), be);

    addQueueToMutator(batch, queue, timestamp);

    try {
      batchUpdateQueuePropertiesIndexes(
          batch, queuePath, queue.getUuid(), queue.getProperties(), timestampUuid);
    } catch (Exception e) {
      logger.error("Unable to update queue", e);
    }

    batch.addInsertion(
        bytebuffer(queue.getUuid()),
        QUEUE_PROPERTIES.getColumnFamily(),
        createColumn(QUEUE_CREATED, timestamp / 1000, Long.MAX_VALUE - timestamp, se, le));

    batch.addInsertion(
        bytebuffer(queue.getUuid()),
        QUEUE_PROPERTIES.getColumnFamily(),
        createColumn(QUEUE_MODIFIED, timestamp / 1000, timestamp, se, le));

    batchExecute(batch, RETRY_COUNT);

    return queue;
  }
コード例 #2
0
  @Override
  public QueueSet unsubscribeFromQueues(
      String subscriberQueuePath, List<String> publisherQueuePaths) {

    subscriberQueuePath = normalizeQueuePath(subscriberQueuePath);
    UUID subscriberQueueId = getQueueId(subscriberQueuePath);

    UUID timestampUuid = newTimeUUID();
    long timestamp = getTimestampInMicros(timestampUuid);

    Mutator<ByteBuffer> batch = createMutator(cass.getApplicationKeyspace(applicationId), be);

    QueueSet queues = new QueueSet();

    for (String publisherQueuePath : publisherQueuePaths) {

      publisherQueuePath = normalizeQueuePath(publisherQueuePath);
      UUID publisherQueueId = getQueueId(publisherQueuePath);

      batchUnsubscribeFromQueue(
          batch,
          publisherQueuePath,
          publisherQueueId,
          subscriberQueuePath,
          subscriberQueueId,
          timestamp);

      try {
        Queue queue = getQueue(subscriberQueuePath, subscriberQueueId);

        batchUpdateQueuePropertiesIndexes(
            batch,
            publisherQueueId,
            subscriberQueuePath,
            subscriberQueueId,
            emptyMapWithKeys(queue.getProperties()),
            timestampUuid);
      } catch (Exception e) {
        logger.error("Unable to update index", e);
      }

      queues.addQueue(publisherQueuePath, publisherQueueId);
    }

    batchExecute(batch, RETRY_COUNT);

    return queues;
  }
コード例 #3
0
  @Override
  public QueueSet subscribeToQueue(String publisherQueuePath, String subscriberQueuePath) {

    publisherQueuePath = normalizeQueuePath(publisherQueuePath);
    UUID publisherQueueId = getQueueId(publisherQueuePath);

    subscriberQueuePath = normalizeQueuePath(subscriberQueuePath);
    UUID subscriberQueueId = getQueueId(subscriberQueuePath);

    UUID timestampUuid = newTimeUUID();
    long timestamp = getTimestampInMicros(timestampUuid);

    Mutator<ByteBuffer> batch = createMutator(cass.getApplicationKeyspace(applicationId), be);

    batchSubscribeToQueue(
        batch,
        publisherQueuePath,
        publisherQueueId,
        subscriberQueuePath,
        subscriberQueueId,
        timestamp);

    try {
      Queue queue = getQueue(subscriberQueuePath, subscriberQueueId);
      if (queue != null) {
        batchUpdateQueuePropertiesIndexes(
            batch,
            publisherQueueId,
            subscriberQueuePath,
            subscriberQueueId,
            queue.getProperties(),
            timestampUuid);
      }
    } catch (Exception e) {
      logger.error("Unable to update index", e);
    }

    batchExecute(batch, RETRY_COUNT);

    return new QueueSet().addQueue(subscriberQueuePath, subscriberQueueId);
  }