All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datatorrent.lib.appdata.query.QueueManager Maven / Gradle / Ivy

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.datatorrent.lib.appdata.query;

import com.datatorrent.api.Component;
import com.datatorrent.api.Context.OperatorContext;

/**
 * This is an interface for a manager which manages the queueing of AppData queries.
 * @param  The type of the queries being queued.
 * @param  The type of any meta data to be queued with the query.
 * @param  The type of any additional contextual information that could impact the way in
 * which a query is queued that is known when the query is queued. This queue context information could
 * be updated by the queue manager throughout the lifetime of the query to control things like how long
 * the query has been queued for.
 * @since 3.0.0
 */
public interface QueueManager extends Component
{

  /**
   * This method enqueues an AppData query.
   * @param query The query to queue.
   * @param metaQuery Any additional metadata required by the query.
   * @param queueContext Any additional contextual information that will impact the way in which the query
   * is queued and is known when the query is queued.
   * @return True if the query was successfully queued. False otherwise.
   */
  public boolean enqueue(QUERY_TYPE query, META_QUERY metaQuery, QUEUE_CONTEXT queueContext);

  /**
   * 

* This method dequeues a query, and returns a {@link QueryBundle} which includes the query, * any additional query meta data, and the queue context for the query. *

*

* Note: Calls to {@link #dequeue} can be mixed with calls to {@link #dequeueBlock}. *

* @return The query bundle for a query. */ public QueryBundle dequeue(); /** * This should be called in beginWindow of an operator so that the {@link QueueManager} can correctly update * its internal state for managing queries. * @param windowId The windowId of the current window. */ public void beginWindow(long windowId); /** * This should be called in endWindow of an operator so that the {@link QueueManager} can correctly update its * internal state for managing queries. */ public void endWindow(); /** *

* Returns the next {@link QueryBundle} in the queue. If there is no new {@link QueryBundle} in the queue, then this method * blocks until there is one. *

*

* Note: Calls to {@link #dequeueBlock} can be mixed with calls to {@link #dequeue}. *

* @return The next {@link QueryBundle} in the queue. */ public QueryBundle dequeueBlock(); public int getNumLeft(); public void haltEnqueue(); public void resumeEnqueue(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy