コード例 #1
0
  /**
   * Queue up an indexOperationMessage for multi region execution
   *
   * @param indexOperationMessage
   */
  public void queueIndexOperationMessage(final IndexOperationMessage indexOperationMessage) {

    // don't try to produce something with nothing
    if (indexOperationMessage == null || indexOperationMessage.isEmpty()) {
      return;
    }

    final String jsonValue = ObjectJsonSerializer.INSTANCE.toString(indexOperationMessage);

    final UUID newMessageId = UUIDGenerator.newTimeUUID();

    final int expirationTimeInSeconds =
        (int) TimeUnit.MILLISECONDS.toSeconds(indexProcessorFig.getIndexMessageTtl());

    // write to the map in ES
    esMapPersistence.putString(newMessageId.toString(), jsonValue, expirationTimeInSeconds);

    // now queue up the index message

    final ElasticsearchIndexEvent elasticsearchIndexEvent =
        new ElasticsearchIndexEvent(queueFig.getPrimaryRegion(), newMessageId);

    // send to the topic so all regions index the batch

    offerTopic(elasticsearchIndexEvent);
  }
コード例 #2
0
  /** Write the cursor state to the map in cassandra */
  private void writeCursorState(final String jobId, final EdgeScope edge) {

    final JsonNode node =
        EdgeScopeSerializer.INSTANCE.toNode(CursorSerializerUtil.getMapper(), edge);

    final String serializedState = CursorSerializerUtil.asString(node);

    mapManager.putString(jobId + MAP_CURSOR_KEY, serializedState, INDEX_TTL);
  }
コード例 #3
0
  /**
   * Write our state meta data into cassandra so everyone can see it
   *
   * @param jobId
   * @param status
   * @param processedCount
   * @param lastUpdated
   */
  private void writeStateMeta(
      final String jobId, final Status status, final long processedCount, final long lastUpdated) {

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Flushing state for jobId {}, status {}, processedCount {}, lastUpdated {}",
          jobId,
          status,
          processedCount,
          lastUpdated);
    }

    mapManager.putString(jobId + MAP_STATUS_KEY, status.name());
    mapManager.putLong(jobId + MAP_COUNT_KEY, processedCount);
    mapManager.putLong(jobId + MAP_UPDATED_KEY, lastUpdated);
  }