001package org.xbib.elasticsearch.river.jdbc;
002
003import org.elasticsearch.common.metrics.MeterMetric;
004import org.elasticsearch.common.unit.TimeValue;
005import org.xbib.elasticsearch.plugin.jdbc.state.RiverState;
006import org.xbib.elasticsearch.plugin.jdbc.util.SQLCommand;
007
008import java.util.List;
009import java.util.Map;
010
011/**
012 * The River Context is a collection of objects that are relevant to parameterization of
013 * a river run. Beside holding references to river definition, source and mouth,
014 * the objects control the behavior of the river source.
015 */
016public interface RiverContext {
017
018    /**
019     * Set river instance definition
020     *
021     * @param definition the river instance definition
022     * @return this context
023     */
024    RiverContext setDefinition(Map<String, Object> definition);
025
026    /**
027     * Get river instance definition
028     *
029     * @return river instance definition
030     */
031    Map<String, Object> getDefinition();
032
033    /**
034     * Set river state
035     *
036     * @param riverState the river state
037     * @return this context
038     */
039    RiverContext setRiverState(RiverState riverState);
040
041    /**
042     * Get river state
043     *
044     * @return the river state
045     */
046    RiverState getRiverState();
047
048    /**
049     * Set river source
050     *
051     * @param riverSource the river source
052     * @return this context
053     */
054    RiverContext setRiverSource(RiverSource riverSource);
055
056    /**
057     * Get river source
058     *
059     * @return the river source
060     */
061    RiverSource getRiverSource();
062
063    /**
064     * Set river mouth
065     *
066     * @param riverMouth the river mouth
067     * @return this context
068     */
069    RiverContext setRiverMouth(RiverMouth riverMouth);
070
071    /**
072     * Get river mouth
073     *
074     * @return the river mouth
075     */
076    RiverMouth getRiverMouth();
077
078    /**
079     * Set metric
080     *
081     * @param metric the meter metric
082     * @return this context
083     */
084    RiverContext setMetric(MeterMetric metric);
085
086    /**
087     * Get metric
088     *
089     * @return metric
090     */
091    MeterMetric getMetric();
092
093    /**
094     * Set scale of big decimal values.  See java.math.BigDecimal#setScale
095     *
096     * @param scale the scale of big decimal values
097     * @return this context
098     */
099    RiverContext setScale(int scale);
100
101    /**
102     * Set rounding of big decimal values. See java.math.BigDecimal#setScale
103     *
104     * @param rounding the rounding of big decimal values
105     * @return this river context
106     */
107    RiverContext setRounding(String rounding);
108
109    /**
110     * Set the list of SQL statements
111     *
112     * @param sql the list of SQL statements
113     * @return this river context
114     */
115    RiverContext setStatements(List<SQLCommand> sql);
116
117    /**
118     * Set auto commit
119     *
120     * @param autocommit true if automatic commit should be performed
121     * @return this river context
122     */
123    RiverContext setAutoCommit(boolean autocommit);
124
125    /**
126     * Set max rows
127     *
128     * @param maxRows max rows
129     * @return this river context
130     */
131    RiverContext setMaxRows(int maxRows);
132
133    /**
134     * Set fetch size
135     *
136     * @param fetchSize fetch size
137     * @return this river context
138     */
139    RiverContext setFetchSize(int fetchSize);
140
141    /**
142     * Set retries
143     *
144     * @param retries number of retries
145     * @return this river context
146     */
147    RiverContext setRetries(int retries);
148
149    /**
150     * Set maximum count of retries
151     *
152     * @param maxretrywait maximum count of retries
153     * @return this river context
154     */
155    RiverContext setMaxRetryWait(TimeValue maxretrywait);
156
157    /**
158     * Set result set type
159     *
160     * @param resultSetType result set type
161     * @return this river context
162     */
163    RiverContext setResultSetType(String resultSetType);
164
165    /**
166     * Set result set concurrency
167     *
168     * @param resultSetConcurrency result set concurrency
169     * @return this river context
170     */
171    RiverContext setResultSetConcurrency(String resultSetConcurrency);
172
173    /**
174     * Should null values in columns be ignored for indexing
175     *
176     * @param shouldIgnoreNull true if null values in columns should be ignored for indexing
177     * @return this river context
178     */
179    RiverContext shouldIgnoreNull(boolean shouldIgnoreNull);
180
181    /**
182     * Should result set metadata be used in parameter variables
183     *
184     * @param shouldPrepareResultSetMetadata true if result set metadata should be used in parameter variables
185     * @return this river context
186     */
187    RiverContext shouldPrepareResultSetMetadata(boolean shouldPrepareResultSetMetadata);
188
189    /**
190     * Should database metadata be used in parameter variables
191     *
192     * @param shouldPrepareDatabaseMetadata true if database metadata should be used in parameter variables
193     * @return this river context
194     */
195    RiverContext shouldPrepareDatabaseMetadata(boolean shouldPrepareDatabaseMetadata);
196
197    /**
198     * Set result set query timeout
199     *
200     * @param queryTimeout the query timeout in seconds
201     * @return this river context
202     */
203    RiverContext setQueryTimeout(int queryTimeout);
204
205    /**
206     * Optional JDBC connection properties
207     *
208     * @param connectionProperties connection properties
209     * @return this river context
210     */
211    RiverContext setConnectionProperties(Map<String, Object> connectionProperties);
212
213    /**
214     * Set column name map. Useful for expanding shortcolumn names to longer variants.
215     *
216     * @param columnNameMap the column name map
217     * @return this river context
218     */
219    RiverContext setColumnNameMap(Map<String, Object> columnNameMap);
220
221    /**
222     * Should binary types (byte arrays) be treated as JSON strings
223     *
224     * @param shouldTreatBinaryAsString true if binary types (byte arrays) should be treated as JSON strings
225     * @return this river context
226     */
227    RiverContext shouldTreatBinaryAsString(boolean shouldTreatBinaryAsString);
228
229    /**
230     * Release all resources
231     *
232     * @return this river context
233     */
234    RiverContext release();
235
236}