1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.shardingsphere.data.pipeline.core.channel; 19 20 import org.apache.shardingsphere.data.pipeline.core.ingest.record.Record; 21 22 import java.util.List; 23 24 /** 25 * Pipeline channel. 26 * <p>It supports multiple push threads and one fetch thread.</p> 27 */ 28 public interface PipelineChannel { 29 30 /** 31 * Push {@code DataRecord} into channel. 32 * 33 * @param records data records 34 */ 35 void push(List<Record> records); 36 37 /** 38 * Fetch {@code Record} list from channel. 39 * It might be blocked at most timeout seconds if available records count doesn't reach batch size. 40 * 41 * @param batchSize record batch size 42 * @param timeoutMillis timeout millis 43 * @return records of transactions 44 */ 45 List<Record> fetch(int batchSize, long timeoutMillis); 46 47 /** 48 * Peek {@code Record} list from channel. 49 * 50 * @return records of a transaction 51 */ 52 List<Record> peek(); 53 54 /** 55 * Poll {@code Record} list from channel. 56 * 57 * @return records of a transaction 58 */ 59 List<Record> poll(); 60 61 /** 62 * Ack the last batch. 63 * 64 * @param records record list 65 */ 66 // TODO Refactor ack param 67 void ack(List<Record> records); 68 }