Repository: ignite Updated Branches: refs/heads/ignite-gg-10760 d9c5f6998 -> 4b84f7332
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java new file mode 100644 index 0000000..5092b42 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java @@ -0,0 +1,1520 @@ +/* + * 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 org.apache.ignite.internal.jdbc2; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.ignite.Ignite; +import org.jetbrains.annotations.Nullable; + +/** + * JDBC result set implementation. + */ +public class JdbcResultSet implements ResultSet { + /** Uuid. */ + private final UUID uuid; + + /** Statement. */ + private final JdbcStatement stmt; + + /** Table names. */ + private final List<String> tbls; + + /** Column names. */ + private final List<String> cols; + + /** Class names. */ + private final List<String> types; + + /** Rows cursor iterator. */ + private Iterator<List<?>> it; + + /** Finished flag. */ + private boolean finished; + + /** Current position. */ + private int pos; + + /** Current. */ + private List<Object> curr; + + /** Closed flag. */ + private boolean closed; + + /** Was {@code NULL} flag. */ + private boolean wasNull; + + /** Fetch size. */ + private int fetchSize; + + /** + * Creates new result set with predefined fields. + * Result set created with this constructor will + * never execute remote tasks. + * + * @param uuid Query UUID. + * @param stmt Statement. + * @param tbls Table names. + * @param cols Column names. + * @param types Types. + * @param fields Fields. + */ + JdbcResultSet(@Nullable UUID uuid, JdbcStatement stmt, List<String> tbls, List<String> cols, + List<String> types, Collection<List<?>> fields, boolean finished) { + assert stmt != null; + assert tbls != null; + assert cols != null; + assert types != null; + assert fields != null; + + this.uuid = uuid; + this.stmt = stmt; + this.tbls = tbls; + this.cols = cols; + this.types = types; + this.finished = finished; + + this.it = fields.iterator(); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public boolean next() throws SQLException { + ensureNotClosed(); + + if (it == null || (stmt.getMaxRows() > 0 && pos >= stmt.getMaxRows())) { + curr = null; + + return false; + } + else if (it.hasNext()) { + curr = new ArrayList<>(it.next()); + + pos++; + + if (finished && !it.hasNext()) + it = null; + + return true; + } + else if (!finished) { + JdbcConnection conn = (JdbcConnection)stmt.getConnection(); + + Ignite ignite = conn.ignite(); + + UUID nodeId = conn.nodeId(); + + boolean loc = nodeId == null; + + JdbcQueryTask qryTask = new JdbcQueryTask(loc ? ignite : null, conn.cacheName(), + null, loc, null, fetchSize, uuid, conn.isLocalQuery(), conn.isCollocatedQuery()); + + try { + JdbcQueryTask.QueryResult res = + loc ? qryTask.call() : ignite.compute(ignite.cluster().forNodeId(nodeId)).call(qryTask); + + finished = res.isFinished(); + + it = res.getRows().iterator(); + + return next(); + } + catch (Exception e) { + throw new SQLException("Failed to query Ignite.", e); + } + } + + it = null; + + return false; + } + + /** {@inheritDoc} */ + @Override public void close() throws SQLException { + if (uuid != null) + stmt.resSets.remove(this); + + closeInternal(); + } + + /** + * Marks result set as closed. + * If this result set is associated with locally executed query then query cursor will also closed. + */ + void closeInternal() throws SQLException { + if (((JdbcConnection)stmt.getConnection()).nodeId() == null) + JdbcQueryTask.remove(uuid); + + closed = true; + } + + /** {@inheritDoc} */ + @Override public boolean wasNull() throws SQLException { + return wasNull; + } + + /** {@inheritDoc} */ + @Override public String getString(int colIdx) throws SQLException { + return getTypedValue(colIdx, String.class); + } + + /** {@inheritDoc} */ + @Override public boolean getBoolean(int colIdx) throws SQLException { + Boolean val = getTypedValue(colIdx, Boolean.class); + + return val != null ? val : false; + } + + /** {@inheritDoc} */ + @Override public byte getByte(int colIdx) throws SQLException { + Byte val = getTypedValue(colIdx, Byte.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public short getShort(int colIdx) throws SQLException { + Short val = getTypedValue(colIdx, Short.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public int getInt(int colIdx) throws SQLException { + Integer val = getTypedValue(colIdx, Integer.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public long getLong(int colIdx) throws SQLException { + Long val = getTypedValue(colIdx, Long.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public float getFloat(int colIdx) throws SQLException { + Float val = getTypedValue(colIdx, Float.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public double getDouble(int colIdx) throws SQLException { + Double val = getTypedValue(colIdx, Double.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public BigDecimal getBigDecimal(int colIdx, int scale) throws SQLException { + return getTypedValue(colIdx, BigDecimal.class); + } + + /** {@inheritDoc} */ + @Override public byte[] getBytes(int colIdx) throws SQLException { + return getTypedValue(colIdx, byte[].class); + } + + /** {@inheritDoc} */ + @Override public Date getDate(int colIdx) throws SQLException { + return getTypedValue(colIdx, Date.class); + } + + /** {@inheritDoc} */ + @Override public Time getTime(int colIdx) throws SQLException { + return getTypedValue(colIdx, Time.class); + } + + /** {@inheritDoc} */ + @Override public Timestamp getTimestamp(int colIdx) throws SQLException { + return getTypedValue(colIdx, Timestamp.class); + } + + /** {@inheritDoc} */ + @Override public InputStream getAsciiStream(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public InputStream getUnicodeStream(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public InputStream getBinaryStream(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Stream are not supported."); + } + + /** {@inheritDoc} */ + @Override public String getString(String colLb) throws SQLException { + return getTypedValue(colLb, String.class); + } + + /** {@inheritDoc} */ + @Override public boolean getBoolean(String colLb) throws SQLException { + Boolean val = getTypedValue(colLb, Boolean.class); + + return val != null ? val : false; + } + + /** {@inheritDoc} */ + @Override public byte getByte(String colLb) throws SQLException { + Byte val = getTypedValue(colLb, Byte.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public short getShort(String colLb) throws SQLException { + Short val = getTypedValue(colLb, Short.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public int getInt(String colLb) throws SQLException { + Integer val = getTypedValue(colLb, Integer.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public long getLong(String colLb) throws SQLException { + Long val = getTypedValue(colLb, Long.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public float getFloat(String colLb) throws SQLException { + Float val = getTypedValue(colLb, Float.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public double getDouble(String colLb) throws SQLException { + Double val = getTypedValue(colLb, Double.class); + + return val != null ? val : 0; + } + + /** {@inheritDoc} */ + @Override public BigDecimal getBigDecimal(String colLb, int scale) throws SQLException { + return getTypedValue(colLb, BigDecimal.class); + } + + /** {@inheritDoc} */ + @Override public byte[] getBytes(String colLb) throws SQLException { + return getTypedValue(colLb, byte[].class); + } + + /** {@inheritDoc} */ + @Override public Date getDate(String colLb) throws SQLException { + return getTypedValue(colLb, Date.class); + } + + /** {@inheritDoc} */ + @Override public Time getTime(String colLb) throws SQLException { + return getTypedValue(colLb, Time.class); + } + + /** {@inheritDoc} */ + @Override public Timestamp getTimestamp(String colLb) throws SQLException { + return getTypedValue(colLb, Timestamp.class); + } + + /** {@inheritDoc} */ + @Override public InputStream getAsciiStream(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public InputStream getUnicodeStream(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public InputStream getBinaryStream(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLWarning getWarnings() throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void clearWarnings() throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public String getCursorName() throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public ResultSetMetaData getMetaData() throws SQLException { + ensureNotClosed(); + + return new JdbcResultSetMetadata(tbls, cols, types); + } + + /** {@inheritDoc} */ + @Override public Object getObject(int colIdx) throws SQLException { + return getTypedValue(colIdx, Object.class); + } + + /** {@inheritDoc} */ + @Override public Object getObject(String colLb) throws SQLException { + return getTypedValue(colLb, Object.class); + } + + /** {@inheritDoc} */ + @Override public int findColumn(String colLb) throws SQLException { + ensureNotClosed(); + + int idx = cols.indexOf(colLb.toUpperCase()); + + if (idx == -1) + throw new SQLException("Column not found: " + colLb); + + return idx + 1; + } + + /** {@inheritDoc} */ + @Override public Reader getCharacterStream(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public Reader getCharacterStream(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Streams are not supported."); + } + + /** {@inheritDoc} */ + @Override public BigDecimal getBigDecimal(int colIdx) throws SQLException { + return getTypedValue(colIdx, BigDecimal.class); + } + + /** {@inheritDoc} */ + @Override public BigDecimal getBigDecimal(String colLb) throws SQLException { + return getTypedValue(colLb, BigDecimal.class); + } + + /** {@inheritDoc} */ + @Override public boolean isBeforeFirst() throws SQLException { + ensureNotClosed(); + + return pos < 1; + } + + /** {@inheritDoc} */ + @Override public boolean isAfterLast() throws SQLException { + ensureNotClosed(); + + return finished && it == null && curr == null; + } + + /** {@inheritDoc} */ + @Override public boolean isFirst() throws SQLException { + ensureNotClosed(); + + return pos == 1; + } + + /** {@inheritDoc} */ + @Override public boolean isLast() throws SQLException { + ensureNotClosed(); + + return finished && it == null && curr != null; + } + + /** {@inheritDoc} */ + @Override public void beforeFirst() throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public void afterLast() throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public boolean first() throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public boolean last() throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public int getRow() throws SQLException { + ensureNotClosed(); + + return isAfterLast() ? 0 : pos; + } + + /** {@inheritDoc} */ + @Override public boolean absolute(int row) throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public boolean relative(int rows) throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public boolean previous() throws SQLException { + ensureNotClosed(); + + throw new SQLException("Result set is forward-only."); + } + + /** {@inheritDoc} */ + @Override public void setFetchDirection(int direction) throws SQLException { + ensureNotClosed(); + + if (direction != FETCH_FORWARD) + throw new SQLFeatureNotSupportedException("Only forward direction is supported"); + } + + /** {@inheritDoc} */ + @Override public int getFetchDirection() throws SQLException { + ensureNotClosed(); + + return FETCH_FORWARD; + } + + /** {@inheritDoc} */ + @Override public void setFetchSize(int fetchSize) throws SQLException { + ensureNotClosed(); + + if (fetchSize <= 0) + throw new SQLException("Fetch size must be greater than zero."); + + this.fetchSize = fetchSize; + } + + /** {@inheritDoc} */ + @Override public int getFetchSize() throws SQLException { + ensureNotClosed(); + + return fetchSize; + } + + /** {@inheritDoc} */ + @Override public int getType() throws SQLException { + ensureNotClosed(); + + return stmt.getResultSetType(); + } + + /** {@inheritDoc} */ + @Override public int getConcurrency() throws SQLException { + ensureNotClosed(); + + return CONCUR_READ_ONLY; + } + + /** {@inheritDoc} */ + @Override public boolean rowUpdated() throws SQLException { + ensureNotClosed(); + + return false; + } + + /** {@inheritDoc} */ + @Override public boolean rowInserted() throws SQLException { + ensureNotClosed(); + + return false; + } + + /** {@inheritDoc} */ + @Override public boolean rowDeleted() throws SQLException { + ensureNotClosed(); + + return false; + } + + /** {@inheritDoc} */ + @Override public void updateNull(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBoolean(int colIdx, boolean x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateByte(int colIdx, byte x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateShort(int colIdx, short x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateInt(int colIdx, int x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateLong(int colIdx, long x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateFloat(int colIdx, float x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateDouble(int colIdx, double x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBigDecimal(int colIdx, BigDecimal x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateString(int colIdx, String x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBytes(int colIdx, byte[] x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateDate(int colIdx, Date x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateTime(int colIdx, Time x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateTimestamp(int colIdx, Timestamp x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(int colIdx, InputStream x, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(int colIdx, InputStream x, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(int colIdx, Reader x, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateObject(int colIdx, Object x, int scaleOrLen) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateObject(int colIdx, Object x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNull(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBoolean(String colLb, boolean x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateByte(String colLb, byte x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateShort(String colLb, short x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateInt(String colLb, int x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateLong(String colLb, long x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateFloat(String colLb, float x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateDouble(String colLb, double x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBigDecimal(String colLb, BigDecimal x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateString(String colLb, String x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBytes(String colLb, byte[] x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateDate(String colLb, Date x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateTime(String colLb, Time x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateTimestamp(String colLb, Timestamp x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(String colLb, InputStream x, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(String colLb, InputStream x, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(String colLb, Reader reader, int len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateObject(String colLb, Object x, int scaleOrLen) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateObject(String colLb, Object x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void insertRow() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateRow() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void deleteRow() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void refreshRow() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Row refreshing is not supported."); + } + + /** {@inheritDoc} */ + @Override public void cancelRowUpdates() throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public void moveToInsertRow() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void moveToCurrentRow() throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public Statement getStatement() throws SQLException { + ensureNotClosed(); + + return stmt; + } + + /** {@inheritDoc} */ + @Override public Object getObject(int colIdx, Map<String, Class<?>> map) throws SQLException { + return getTypedValue(colIdx, Object.class); + } + + /** {@inheritDoc} */ + @Override public Ref getRef(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Blob getBlob(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Clob getClob(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Array getArray(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Object getObject(String colLb, Map<String, Class<?>> map) throws SQLException { + return getTypedValue(colLb, Object.class); + } + + /** {@inheritDoc} */ + @Override public Ref getRef(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Blob getBlob(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Clob getClob(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Array getArray(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Date getDate(int colIdx, Calendar cal) throws SQLException { + return getTypedValue(colIdx, Date.class); + } + + /** {@inheritDoc} */ + @Override public Date getDate(String colLb, Calendar cal) throws SQLException { + return getTypedValue(colLb, Date.class); + } + + /** {@inheritDoc} */ + @Override public Time getTime(int colIdx, Calendar cal) throws SQLException { + return getTypedValue(colIdx, Time.class); + } + + /** {@inheritDoc} */ + @Override public Time getTime(String colLb, Calendar cal) throws SQLException { + return getTypedValue(colLb, Time.class); + } + + /** {@inheritDoc} */ + @Override public Timestamp getTimestamp(int colIdx, Calendar cal) throws SQLException { + return getTypedValue(colIdx, Timestamp.class); + } + + /** {@inheritDoc} */ + @Override public Timestamp getTimestamp(String colLb, Calendar cal) throws SQLException { + return getTypedValue(colLb, Timestamp.class); + } + + /** {@inheritDoc} */ + @Override public URL getURL(int colIdx) throws SQLException { + return getTypedValue(colIdx, URL.class); + } + + /** {@inheritDoc} */ + @Override public URL getURL(String colLb) throws SQLException { + return getTypedValue(colLb, URL.class); + } + + /** {@inheritDoc} */ + @Override public void updateRef(int colIdx, Ref x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateRef(String colLb, Ref x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(int colIdx, Blob x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(String colLb, Blob x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(int colIdx, Clob x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(String colLb, Clob x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateArray(int colIdx, Array x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateArray(String colLb, Array x) throws SQLException { + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public RowId getRowId(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public RowId getRowId(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateRowId(int colIdx, RowId x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateRowId(String colLb, RowId x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public int getHoldability() throws SQLException { + ensureNotClosed(); + + return HOLD_CURSORS_OVER_COMMIT; + } + + /** {@inheritDoc} */ + @Override public boolean isClosed() throws SQLException { + return closed; + } + + /** {@inheritDoc} */ + @Override public void updateNString(int colIdx, String nStr) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNString(String colLb, String nStr) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(int colIdx, NClob nClob) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(String colLb, NClob nClob) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public NClob getNClob(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public NClob getNClob(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLXML getSQLXML(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLXML getSQLXML(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateSQLXML(int colIdx, SQLXML xmlObj) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateSQLXML(String colLb, SQLXML xmlObj) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public String getNString(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public String getNString(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Reader getNCharacterStream(int colIdx) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Reader getNCharacterStream(String colLb) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNCharacterStream(int colIdx, Reader x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNCharacterStream(String colLb, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(int colIdx, InputStream x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(int colIdx, InputStream x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(int colIdx, Reader x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(String colLb, InputStream x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(String colLb, InputStream x, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(String colLb, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(int colIdx, InputStream inputStream, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(String colLb, InputStream inputStream, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(int colIdx, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(String colLb, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(int colIdx, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(String colLb, Reader reader, long len) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNCharacterStream(int colIdx, Reader x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNCharacterStream(String colLb, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(int colIdx, InputStream x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(int colIdx, InputStream x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(int colIdx, Reader x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateAsciiStream(String colLb, InputStream x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBinaryStream(String colLb, InputStream x) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateCharacterStream(String colLb, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(int colIdx, InputStream inputStream) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateBlob(String colLb, InputStream inputStream) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(int colIdx, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateClob(String colLb, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(int colIdx, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void updateNClob(String colLb, Reader reader) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public <T> T unwrap(Class<T> iface) throws SQLException { + if (!isWrapperFor(iface)) + throw new SQLException("Result set is not a wrapper for " + iface.getName()); + + return (T)this; + } + + /** {@inheritDoc} */ + @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { + return iface != null && iface == ResultSet.class; + } + + /** {@inheritDoc} */ + @Override public <T> T getObject(int colIdx, Class<T> type) throws SQLException { + return getTypedValue(colIdx, type); + } + + /** {@inheritDoc} */ + @Override public <T> T getObject(String colLb, Class<T> type) throws SQLException { + return getTypedValue(colLb, type); + } + + /** + * Gets casted field value by label. + * + * @param colLb Column label. + * @param cls Value class. + * @return Casted field value. + * @throws SQLException In case of error. + */ + private <T> T getTypedValue(String colLb, Class<T> cls) throws SQLException { + ensureNotClosed(); + ensureHasCurrentRow(); + + String name = colLb.toUpperCase(); + + Integer idx = stmt.fieldsIdxs.get(name); + + int colIdx; + + if (idx != null) + colIdx = idx; + else { + colIdx = cols.indexOf(name) + 1; + + if (colIdx <= 0) + throw new SQLException("Invalid column label: " + colLb); + + stmt.fieldsIdxs.put(name, colIdx); + } + + return getTypedValue(colIdx, cls); + } + + /** + * Gets casted field value by index. + * + * @param colIdx Column index. + * @param cls Value class. + * @return Casted field value. + * @throws SQLException In case of error. + */ + @SuppressWarnings("unchecked") + private <T> T getTypedValue(int colIdx, Class<T> cls) throws SQLException { + ensureNotClosed(); + ensureHasCurrentRow(); + + try { + T val = cls == String.class ? (T)String.valueOf(curr.get(colIdx - 1)) : (T)curr.get(colIdx - 1); + + wasNull = val == null; + + return val; + } + catch (IndexOutOfBoundsException ignored) { + throw new SQLException("Invalid column index: " + colIdx); + } + catch (ClassCastException ignored) { + throw new SQLException("Value is an not instance of " + cls.getName()); + } + } + + /** + * Ensures that result set is not closed. + * + * @throws SQLException If result set is closed. + */ + private void ensureNotClosed() throws SQLException { + if (closed) + throw new SQLException("Result set is closed."); + } + + /** + * Ensures that result set is positioned on a row. + * + * @throws SQLException If result set is not positioned on a row. + */ + private void ensureHasCurrentRow() throws SQLException { + if (curr == null) + throw new SQLException("Result set is not positioned on a row."); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java new file mode 100644 index 0000000..ce8c269 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java @@ -0,0 +1,171 @@ +/* + * 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 org.apache.ignite.internal.jdbc2; + +import java.sql.*; +import java.util.*; + +/** + * JDBC result set metadata implementation. + */ +public class JdbcResultSetMetadata implements ResultSetMetaData { + /** Column width. */ + private static final int COL_WIDTH = 30; + + /** Table names. */ + private final List<String> tbls; + + /** Column names. */ + private final List<String> cols; + + /** Class names. */ + private final List<String> types; + + /** + * @param tbls Table names. + * @param cols Column names. + * @param types Types. + */ + JdbcResultSetMetadata(List<String> tbls, List<String> cols, List<String> types) { + assert cols != null; + assert types != null; + + this.tbls = tbls; + this.cols = cols; + this.types = types; + } + + /** {@inheritDoc} */ + @Override public int getColumnCount() throws SQLException { + return cols.size(); + } + + /** {@inheritDoc} */ + @Override public boolean isAutoIncrement(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean isCaseSensitive(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean isSearchable(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean isCurrency(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public int isNullable(int col) throws SQLException { + return columnNullable; + } + + /** {@inheritDoc} */ + @Override public boolean isSigned(int col) throws SQLException { + return true; + } + + /** {@inheritDoc} */ + @Override public int getColumnDisplaySize(int col) throws SQLException { + return COL_WIDTH; + } + + /** {@inheritDoc} */ + @Override public String getColumnLabel(int col) throws SQLException { + return cols.get(col - 1); + } + + /** {@inheritDoc} */ + @Override public String getColumnName(int col) throws SQLException { + return cols.get(col - 1); + } + + /** {@inheritDoc} */ + @Override public String getSchemaName(int col) throws SQLException { + return ""; + } + + /** {@inheritDoc} */ + @Override public int getPrecision(int col) throws SQLException { + return 0; + } + + /** {@inheritDoc} */ + @Override public int getScale(int col) throws SQLException { + return 0; + } + + /** {@inheritDoc} */ + @Override public String getTableName(int col) throws SQLException { + return tbls != null ? tbls.get(col - 1) : ""; + } + + /** {@inheritDoc} */ + @Override public String getCatalogName(int col) throws SQLException { + return ""; + } + + /** {@inheritDoc} */ + @Override public int getColumnType(int col) throws SQLException { + return JdbcUtils.type(types.get(col - 1)); + } + + /** {@inheritDoc} */ + @Override public String getColumnTypeName(int col) throws SQLException { + return JdbcUtils.typeName(types.get(col - 1)); + } + + /** {@inheritDoc} */ + @Override public boolean isReadOnly(int col) throws SQLException { + return true; + } + + /** {@inheritDoc} */ + @Override public boolean isWritable(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean isDefinitelyWritable(int col) throws SQLException { + return false; + } + + /** {@inheritDoc} */ + @Override public String getColumnClassName(int col) throws SQLException { + return types.get(col - 1); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public <T> T unwrap(Class<T> iface) throws SQLException { + if (!isWrapperFor(iface)) + throw new SQLException("Result set meta data is not a wrapper for " + iface.getName()); + + return (T)this; + } + + /** {@inheritDoc} */ + @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { + return iface == ResultSetMetaData.class; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java new file mode 100644 index 0000000..f4a3e1d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java @@ -0,0 +1,456 @@ +/* + * 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 org.apache.ignite.internal.jdbc2; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLWarning; +import java.sql.Statement; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import org.apache.ignite.Ignite; + +import static java.sql.ResultSet.CONCUR_READ_ONLY; +import static java.sql.ResultSet.FETCH_FORWARD; +import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT; +import static java.sql.ResultSet.TYPE_FORWARD_ONLY; + +/** + * JDBC statement implementation. + */ +public class JdbcStatement implements Statement { + /** Default fetch size. */ + private static final int DFLT_FETCH_SIZE = 1024; + + /** Connection. */ + private final JdbcConnection conn; + + /** Closed flag. */ + private boolean closed; + + /** Rows limit. */ + private int maxRows; + + /** Current result set. */ + private ResultSet rs; + + /** Query arguments. */ + protected Object[] args; + + /** Fetch size. */ + private int fetchSize = DFLT_FETCH_SIZE; + + /** Result sets. */ + final Set<JdbcResultSet> resSets = new HashSet<>(); + + /** Fields indexes. */ + Map<String, Integer> fieldsIdxs = new HashMap<>(); + + /** + * Creates new statement. + * + * @param conn Connection. + */ + JdbcStatement(JdbcConnection conn) { + assert conn != null; + + this.conn = conn; + } + + /** {@inheritDoc} */ + @Override public ResultSet executeQuery(String sql) throws SQLException { + ensureNotClosed(); + + rs = null; + + if (sql == null || sql.isEmpty()) + throw new SQLException("SQL query is empty"); + + Ignite ignite = conn.ignite(); + + UUID nodeId = conn.nodeId(); + + UUID uuid = UUID.randomUUID(); + + boolean loc = nodeId == null; + + JdbcQueryTask qryTask = new JdbcQueryTask(loc ? ignite : null, conn.cacheName(), + sql, loc, args, fetchSize, uuid, conn.isLocalQuery(), conn.isCollocatedQuery()); + + try { + JdbcQueryTask.QueryResult res = + loc ? qryTask.call() : ignite.compute(ignite.cluster().forNodeId(nodeId)).call(qryTask); + + JdbcResultSet rs = new JdbcResultSet(uuid, this, res.getTbls(), res.getCols(), res.getTypes(), + res.getRows(), res.isFinished()); + + rs.setFetchSize(fetchSize); + + resSets.add(rs); + + return rs; + } + catch (Exception e) { + throw new SQLException("Failed to query Ignite.", e); + } + } + + /** {@inheritDoc} */ + @Override public int executeUpdate(String sql) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void close() throws SQLException { + conn.statements.remove(this); + + closeInternal(); + } + + /** + * Marks statement as closed and closes all result sets. + */ + void closeInternal() throws SQLException { + for (Iterator<JdbcResultSet> it = resSets.iterator(); it.hasNext(); ) { + JdbcResultSet rs = it.next(); + + rs.closeInternal(); + + it.remove(); + } + + closed = true; + } + + /** {@inheritDoc} */ + @Override public int getMaxFieldSize() throws SQLException { + ensureNotClosed(); + + return 0; + } + + /** {@inheritDoc} */ + @Override public void setMaxFieldSize(int max) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Field size limitation is not supported."); + } + + /** {@inheritDoc} */ + @Override public int getMaxRows() throws SQLException { + ensureNotClosed(); + + return maxRows; + } + + /** {@inheritDoc} */ + @Override public void setMaxRows(int maxRows) throws SQLException { + ensureNotClosed(); + + this.maxRows = maxRows; + } + + /** {@inheritDoc} */ + @Override public void setEscapeProcessing(boolean enable) throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public int getQueryTimeout() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Query timeout is not supported."); + } + + /** {@inheritDoc} */ + @Override public void setQueryTimeout(int timeout) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Query timeout is not supported."); + } + + /** {@inheritDoc} */ + @Override public void cancel() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Cancellation is not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLWarning getWarnings() throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void clearWarnings() throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public void setCursorName(String name) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean execute(String sql) throws SQLException { + ensureNotClosed(); + + rs = executeQuery(sql); + + return true; + } + + /** {@inheritDoc} */ + @Override public ResultSet getResultSet() throws SQLException { + ensureNotClosed(); + + ResultSet rs0 = rs; + + rs = null; + + return rs0; + } + + /** {@inheritDoc} */ + @Override public int getUpdateCount() throws SQLException { + ensureNotClosed(); + + return -1; + } + + /** {@inheritDoc} */ + @Override public boolean getMoreResults() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Multiple open results are not supported."); + } + + /** {@inheritDoc} */ + @Override public void setFetchDirection(int direction) throws SQLException { + ensureNotClosed(); + + if (direction != FETCH_FORWARD) + throw new SQLFeatureNotSupportedException("Only forward direction is supported"); + } + + /** {@inheritDoc} */ + @Override public int getFetchDirection() throws SQLException { + ensureNotClosed(); + + return FETCH_FORWARD; + } + + /** {@inheritDoc} */ + @Override public void setFetchSize(int fetchSize) throws SQLException { + ensureNotClosed(); + + if (fetchSize < 0) + throw new SQLException("Fetch size must be greater or equal zero."); + + this.fetchSize = fetchSize; + } + + /** {@inheritDoc} */ + @Override public int getFetchSize() throws SQLException { + ensureNotClosed(); + + return fetchSize; + } + + /** {@inheritDoc} */ + @Override public int getResultSetConcurrency() throws SQLException { + ensureNotClosed(); + + return CONCUR_READ_ONLY; + } + + /** {@inheritDoc} */ + @Override public int getResultSetType() throws SQLException { + ensureNotClosed(); + + return TYPE_FORWARD_ONLY; + } + + /** {@inheritDoc} */ + @Override public void addBatch(String sql) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public void clearBatch() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public int[] executeBatch() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public Connection getConnection() throws SQLException { + ensureNotClosed(); + + return conn; + } + + /** {@inheritDoc} */ + @Override public boolean getMoreResults(int curr) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Multiple open results are not supported."); + } + + /** {@inheritDoc} */ + @Override public ResultSet getGeneratedKeys() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public int executeUpdate(String sql, int[] colIndexes) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public int executeUpdate(String sql, String[] colNames) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + ensureNotClosed(); + + if (autoGeneratedKeys == RETURN_GENERATED_KEYS) + throw new SQLFeatureNotSupportedException("Updates are not supported."); + + return execute(sql); + } + + /** {@inheritDoc} */ + @Override public boolean execute(String sql, int[] colIndexes) throws SQLException { + ensureNotClosed(); + + if (colIndexes != null && colIndexes.length > 0) + throw new SQLFeatureNotSupportedException("Updates are not supported."); + + return execute(sql); + } + + /** {@inheritDoc} */ + @Override public boolean execute(String sql, String[] colNames) throws SQLException { + ensureNotClosed(); + + if (colNames != null && colNames.length > 0) + throw new SQLFeatureNotSupportedException("Updates are not supported."); + + return execute(sql); + } + + /** {@inheritDoc} */ + @Override public int getResultSetHoldability() throws SQLException { + ensureNotClosed(); + + return HOLD_CURSORS_OVER_COMMIT; + } + + /** {@inheritDoc} */ + @Override public boolean isClosed() throws SQLException { + return closed; + } + + /** {@inheritDoc} */ + @Override public void setPoolable(boolean poolable) throws SQLException { + ensureNotClosed(); + + if (poolable) + throw new SQLFeatureNotSupportedException("Pooling is not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean isPoolable() throws SQLException { + ensureNotClosed(); + + return false; + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public <T> T unwrap(Class<T> iface) throws SQLException { + if (!isWrapperFor(iface)) + throw new SQLException("Statement is not a wrapper for " + iface.getName()); + + return (T)this; + } + + /** {@inheritDoc} */ + @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { + return iface != null && iface == Statement.class; + } + + /** {@inheritDoc} */ + @Override public void closeOnCompletion() throws SQLException { + throw new SQLFeatureNotSupportedException("closeOnCompletion is not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean isCloseOnCompletion() throws SQLException { + ensureNotClosed(); + + return false; + } + + /** + * Ensures that statement is not closed. + * + * @throws SQLException If statement is closed. + */ + protected void ensureNotClosed() throws SQLException { + if (closed) + throw new SQLException("Statement is closed."); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java new file mode 100644 index 0000000..b519340 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java @@ -0,0 +1,155 @@ +/* + * 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 org.apache.ignite.internal.jdbc2; + +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.Date; + +import static java.sql.Types.BIGINT; +import static java.sql.Types.BINARY; +import static java.sql.Types.BOOLEAN; +import static java.sql.Types.DATE; +import static java.sql.Types.DOUBLE; +import static java.sql.Types.FLOAT; +import static java.sql.Types.INTEGER; +import static java.sql.Types.OTHER; +import static java.sql.Types.SMALLINT; +import static java.sql.Types.TIME; +import static java.sql.Types.TIMESTAMP; +import static java.sql.Types.TINYINT; +import static java.sql.Types.VARCHAR; + +/** + * Utility methods for JDBC driver. + */ +public class JdbcUtils { + /** + * Converts Java class name to type from {@link Types}. + * + * @param cls Java class name. + * @return Type from {@link Types}. + */ + public static int type(String cls) { + if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls)) + return BOOLEAN; + else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls)) + return TINYINT; + else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls)) + return SMALLINT; + else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls)) + return INTEGER; + else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls)) + return BIGINT; + else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls)) + return FLOAT; + else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls)) + return DOUBLE; + else if (String.class.getName().equals(cls)) + return VARCHAR; + else if (byte[].class.getName().equals(cls)) + return BINARY; + else if (Time.class.getName().equals(cls)) + return TIME; + else if (Timestamp.class.getName().equals(cls)) + return TIMESTAMP; + else if (Date.class.getName().equals(cls) || java.sql.Date.class.getName().equals(cls)) + return DATE; + else + return OTHER; + } + + /** + * Converts Java class name to SQL type name. + * + * @param cls Java class name. + * @return SQL type name. + */ + public static String typeName(String cls) { + if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls)) + return "BOOLEAN"; + else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls)) + return "TINYINT"; + else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls)) + return "SMALLINT"; + else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls)) + return "INTEGER"; + else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls)) + return "BIGINT"; + else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls)) + return "FLOAT"; + else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls)) + return "DOUBLE"; + else if (String.class.getName().equals(cls)) + return "VARCHAR"; + else if (byte[].class.getName().equals(cls)) + return "BINARY"; + else if (Time.class.getName().equals(cls)) + return "TIME"; + else if (Timestamp.class.getName().equals(cls)) + return "TIMESTAMP"; + else if (Date.class.getName().equals(cls) || java.sql.Date.class.getName().equals(cls)) + return "DATE"; + else + return "OTHER"; + } + + /** + * Determines whether type is nullable. + * + * @param name Column name. + * @param cls Java class name. + * @return {@code True} if nullable. + */ + public static boolean nullable(String name, String cls) { + return !"_KEY".equalsIgnoreCase(name) && + !"_VAL".equalsIgnoreCase(name) && + !(boolean.class.getName().equals(cls) || + byte.class.getName().equals(cls) || + short.class.getName().equals(cls) || + int.class.getName().equals(cls) || + long.class.getName().equals(cls) || + float.class.getName().equals(cls) || + double.class.getName().equals(cls)); + } + + /** + * Checks whether type of the object is SQL-complaint. + * + * @param obj Object. + * @return Whether type of the object is SQL-complaint. + */ + public static boolean sqlType(Object obj) { + return obj == null || + obj instanceof BigDecimal || + obj instanceof Boolean || + obj instanceof Byte || + obj instanceof byte[] || + obj instanceof java.util.Date || + obj instanceof Double || + obj instanceof Float || + obj instanceof Integer || + obj instanceof Long || + obj instanceof Short || + obj instanceof String || + obj instanceof URL; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/resources/META-INF/classnames.properties ---------------------------------------------------------------------- diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index dd8c3f3..70c32e5 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -254,6 +254,15 @@ org.apache.ignite.internal.executor.GridExecutorService org.apache.ignite.internal.executor.GridExecutorService$1 org.apache.ignite.internal.executor.GridExecutorService$TaskTerminateListener org.apache.ignite.internal.igfs.common.IgfsIpcCommand +org.apache.ignite.internal.interop.InteropAwareEventFilter +org.apache.ignite.internal.interop.InteropBootstrapFactory +org.apache.ignite.internal.interop.InteropException +org.apache.ignite.internal.interop.InteropNoCallbackException +org.apache.ignite.internal.jdbc2.JdbcConnection$JdbcConnectionValidationTask +org.apache.ignite.internal.jdbc2.JdbcDatabaseMetadata$UpdateMetadataTask +org.apache.ignite.internal.jdbc2.JdbcQueryTask +org.apache.ignite.internal.jdbc2.JdbcQueryTask$1 +org.apache.ignite.internal.jdbc2.JdbcQueryTask$QueryResult org.apache.ignite.internal.managers.GridManagerAdapter$1$1 org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager$CheckpointSet org.apache.ignite.internal.managers.checkpoint.GridCheckpointRequest @@ -426,7 +435,8 @@ org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$Ex org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$MessageHandler org.apache.ignite.internal.processors.cache.GridCacheProcessor$2 org.apache.ignite.internal.processors.cache.GridCacheProcessor$3 -org.apache.ignite.internal.processors.cache.GridCacheProcessor$5 +org.apache.ignite.internal.processors.cache.GridCacheProcessor$4 +org.apache.ignite.internal.processors.cache.GridCacheProcessor$6 org.apache.ignite.internal.processors.cache.GridCacheProcessor$LocalAffinityFunction org.apache.ignite.internal.processors.cache.GridCacheProxyImpl org.apache.ignite.internal.processors.cache.GridCacheReturn http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/benchmark-query.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-query.properties b/modules/yardstick/config/benchmark-query.properties index 1a75926..486d00e 100644 --- a/modules/yardstick/config/benchmark-query.properties +++ b/modules/yardstick/config/benchmark-query.properties @@ -21,7 +21,7 @@ # JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" # Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. -JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" \ +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \ -XX:+UseParNewGC \ -XX:+UseConcMarkSweepGC \ -XX:+UseTLAB \ @@ -64,5 +64,6 @@ CONFIGS="\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds sql-query-join-offheap-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds sql-query-put-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds sql-query-put-offheap-1-backup,\ --cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite://127.0.0.1/query -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite://127.0.0.1/query -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite:cfg://cache=query@config/ignite-jdbc-config.xml -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup\ " http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/ignite-base-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-base-config.xml b/modules/yardstick/config/ignite-base-config.xml index c77cc9a..6e94b3c 100644 --- a/modules/yardstick/config/ignite-base-config.xml +++ b/modules/yardstick/config/ignite-base-config.xml @@ -25,7 +25,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="base-ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" abstract="true"> - <property name="peerClassLoadingEnabled" value="false"/> + <property name="peerClassLoadingEnabled" value="true"/> <property name="metricsLogFrequency" value="5000"/> http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/ignite-jdbc-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-jdbc-config.xml b/modules/yardstick/config/ignite-jdbc-config.xml new file mode 100644 index 0000000..9428858 --- /dev/null +++ b/modules/yardstick/config/ignite-jdbc-config.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<!-- + Ignite Spring configuration file. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="clientMode" value="true"/> + + <property name="peerClassLoadingEnabled" value="true"/> + + <property name="localHost" value="127.0.0.1"/> + + <property name="marshaller"> + <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller"> + <property name="requireSerializable" value="false"/> + </bean> + </property> + + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47549</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans>