001/*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.hbase.namequeues;
021
022import org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest;
023import org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse;
024import org.apache.yetus.audience.InterfaceAudience;
025
026/**
027 * In-memory Queue service provider for multiple use-cases. Implementers should be
028 * registered in LogEventHandler
029 */
030@InterfaceAudience.Private
031public interface NamedQueueService {
032
033  /**
034   * Retrieve event type for NamedQueueService implementation.
035   *
036   * @return {@link NamedQueuePayload.NamedQueueEvent}
037   */
038  NamedQueuePayload.NamedQueueEvent getEvent();
039
040  /**
041   * This implementation is generic for consuming records from LMAX
042   * disruptor and inserts records to EvictingQueue which is maintained by each
043   * ringbuffer provider.
044   *
045   * @param namedQueuePayload namedQueue payload from disruptor ring buffer
046   */
047  void consumeEventFromDisruptor(NamedQueuePayload namedQueuePayload);
048
049  /**
050   * Cleans up queues maintained by services.
051   *
052   * @return true if slow log payloads are cleaned up, false otherwise
053   */
054  boolean clearNamedQueue();
055
056  /**
057   * Retrieve in memory queue records from ringbuffer
058   *
059   * @param request namedQueue request with event type
060   * @return queue records from ringbuffer after filter (if applied)
061   */
062  NamedQueueGetResponse getNamedQueueRecords(NamedQueueGetRequest request);
063
064  /**
065   * Add all in memory queue records to system table. The implementors can use system table
066   * or direct HDFS file or ZK as persistence system.
067   */
068  void persistAll();
069}