001/* 002 * Copyright (C) 2014 Jörg Prante 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.xbib.elasticsearch.plugin.jdbc.pipeline; 017 018import java.io.IOException; 019import java.util.Collection; 020import java.util.concurrent.ExecutionException; 021 022/** 023 * The Pipeline Executor can execute provided pipelines. 024 * If the concurrency level is set to higher than one, more than one pipeline is executed in parallel. 025 * 026 * @param <T> the result type 027 * @param <R> the request type 028 * @param <P> the pipeline type 029 */ 030public interface PipelineExecutor<T, R extends PipelineRequest, P extends Pipeline<T, R>> { 031 032 /** 033 * Set the concurrency of this pipeline setExecutor 034 * 035 * @param concurrency the concurrency, must be a positive integer 036 * @return this setExecutor 037 */ 038 PipelineExecutor<T, R, P> setConcurrency(int concurrency); 039 040 /** 041 * Set the provider of this pipeline setExecutor 042 * 043 * @param provider the pipeline provider 044 * @return this setExecutor 045 */ 046 PipelineExecutor<T, R, P> setPipelineProvider(PipelineProvider<P> provider); 047 048 /** 049 * Prepare the pipeline execution. 050 * 051 * @return this setExecutor 052 */ 053 PipelineExecutor<T, R, P> prepare(); 054 055 /** 056 * Execute the pipelines. 057 * 058 * @return this setExecutor 059 */ 060 PipelineExecutor<T, R, P> execute(); 061 062 /** 063 * Execute the pipelines. 064 * 065 * @return this setExecutor 066 * @throws InterruptedException 067 * @throws java.util.concurrent.ExecutionException 068 * @throws java.io.IOException 069 */ 070 PipelineExecutor<T, R, P> waitFor() throws InterruptedException, ExecutionException, IOException; 071 072 /** 073 * Shut down this pipeline executor. 074 * 075 * @throws InterruptedException 076 * @throws java.util.concurrent.ExecutionException 077 * @throws java.io.IOException 078 */ 079 void shutdown() throws InterruptedException, ExecutionException, IOException; 080 081 /** 082 * Return pipelines 083 * 084 * @return the pipelines 085 */ 086 Collection<P> getPipelines(); 087}