Search in sources :

Example 1 with ClientListenerResponse

use of org.apache.ignite.internal.processors.odbc.ClientListenerResponse in project ignite by apache.

the class JdbcConnectionContext method initializeFromHandshake.

/**
 * {@inheritDoc}
 */
@Override
public void initializeFromHandshake(GridNioSession ses, ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) throws IgniteCheckedException {
    assert SUPPORTED_VERS.contains(ver) : "Unsupported JDBC protocol version.";
    boolean distributedJoins = reader.readBoolean();
    boolean enforceJoinOrder = reader.readBoolean();
    boolean collocated = reader.readBoolean();
    boolean replicatedOnly = reader.readBoolean();
    boolean autoCloseCursors = reader.readBoolean();
    boolean lazyExec = false;
    boolean skipReducerOnUpdate = false;
    NestedTxMode nestedTxMode = NestedTxMode.DEFAULT;
    if (ver.compareTo(VER_2_1_5) >= 0)
        lazyExec = reader.readBoolean();
    if (ver.compareTo(VER_2_3_0) >= 0)
        skipReducerOnUpdate = reader.readBoolean();
    if (ver.compareTo(VER_2_7_0) >= 0) {
        String nestedTxModeName = reader.readString();
        if (!F.isEmpty(nestedTxModeName)) {
            try {
                nestedTxMode = NestedTxMode.valueOf(nestedTxModeName);
            } catch (IllegalArgumentException e) {
                throw new IgniteCheckedException("Invalid nested transactions handling mode: " + nestedTxModeName);
            }
        }
    }
    Boolean dataPageScanEnabled = null;
    Integer updateBatchSize = null;
    EnumSet<JdbcThinFeature> features = EnumSet.noneOf(JdbcThinFeature.class);
    if (ver.compareTo(VER_2_8_0) >= 0) {
        dataPageScanEnabled = nullableBooleanFromByte(reader.readByte());
        updateBatchSize = JdbcUtils.readNullableInteger(reader);
    }
    if (ver.compareTo(VER_2_9_0) >= 0) {
        userAttrs = reader.readMap();
        byte[] cliFeatures = reader.readByteArray();
        features = JdbcThinFeature.enumSet(cliFeatures);
    }
    if (ver.compareTo(VER_2_5_0) >= 0) {
        String user = null;
        String passwd = null;
        try {
            if (reader.available() > 0) {
                user = reader.readString();
                passwd = reader.readString();
            }
        } catch (Exception e) {
            throw new IgniteCheckedException("Handshake error: " + e.getMessage(), e);
        }
        authenticate(ses, user, passwd);
    }
    protoCtx = new JdbcProtocolContext(ver, features, true);
    initClientDescriptor("jdbc-thin");
    parser = new JdbcMessageParser(ctx, protoCtx);
    ClientListenerResponseSender sender = new ClientListenerResponseSender() {

        @Override
        public void send(ClientListenerResponse resp) {
            if (resp != null) {
                if (log.isDebugEnabled())
                    log.debug("Async response: [resp=" + resp.status() + ']');
                ses.send(parser.encode(resp));
            }
        }
    };
    handler = new JdbcRequestHandler(busyLock, sender, maxCursors, distributedJoins, enforceJoinOrder, collocated, replicatedOnly, autoCloseCursors, lazyExec, skipReducerOnUpdate, nestedTxMode, dataPageScanEnabled, updateBatchSize, ver, this);
    handler.start();
}
Also used : NestedTxMode(org.apache.ignite.internal.processors.query.NestedTxMode) ClientListenerResponseSender(org.apache.ignite.internal.processors.odbc.ClientListenerResponseSender) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ClientListenerResponse(org.apache.ignite.internal.processors.odbc.ClientListenerResponse)

Example 2 with ClientListenerResponse

use of org.apache.ignite.internal.processors.odbc.ClientListenerResponse in project ignite by apache.

the class OdbcRequestHandlerWorker method body.

/**
 * {@inheritDoc}
 */
@Override
protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
    try {
        while (!isCancelled()) {
            T2<OdbcRequest, GridFutureAdapter<ClientListenerResponse>> req = queue.take();
            GridFutureAdapter<ClientListenerResponse> fut = req.get2();
            try {
                ClientListenerResponse res = hnd.doHandle(req.get1());
                fut.onDone(res);
            } catch (Exception e) {
                fut.onDone(e);
            }
        }
    } finally {
        // Notify indexing that this worker is being stopped.
        try {
            ctx.query().getIndexing().onClientDisconnect();
        } catch (Exception e) {
        // No-op.
        }
        // Drain the queue on stop.
        T2<OdbcRequest, GridFutureAdapter<ClientListenerResponse>> req = queue.poll();
        while (req != null) {
            req.get2().onDone(ERR_RESPONSE);
            req = queue.poll();
        }
    }
}
Also used : ClientListenerResponse(org.apache.ignite.internal.processors.odbc.ClientListenerResponse) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException)

Example 3 with ClientListenerResponse

use of org.apache.ignite.internal.processors.odbc.ClientListenerResponse in project ignite by apache.

the class OdbcConnectionContext method initializeFromHandshake.

/**
 * {@inheritDoc}
 */
@Override
public void initializeFromHandshake(GridNioSession ses, ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) throws IgniteCheckedException {
    assert SUPPORTED_VERS.contains(ver) : "Unsupported ODBC protocol version.";
    boolean distributedJoins = reader.readBoolean();
    boolean enforceJoinOrder = reader.readBoolean();
    boolean replicatedOnly = reader.readBoolean();
    boolean collocated = reader.readBoolean();
    boolean lazy = false;
    if (ver.compareTo(VER_2_1_5) >= 0)
        lazy = reader.readBoolean();
    boolean skipReducerOnUpdate = false;
    if (ver.compareTo(VER_2_3_0) >= 0)
        skipReducerOnUpdate = reader.readBoolean();
    String user = null;
    String passwd = null;
    NestedTxMode nestedTxMode = NestedTxMode.DEFAULT;
    if (ver.compareTo(VER_2_5_0) >= 0) {
        user = reader.readString();
        passwd = reader.readString();
    }
    if (ver.compareTo(VER_2_7_0) >= 0) {
        byte nestedTxModeVal = reader.readByte();
        nestedTxMode = NestedTxMode.fromByte(nestedTxModeVal);
    }
    authenticate(ses, user, passwd);
    ClientListenerResponseSender sender = new ClientListenerResponseSender() {

        @Override
        public void send(ClientListenerResponse resp) {
            if (resp != null) {
                if (log.isDebugEnabled())
                    log.debug("Async response: [resp=" + resp.status() + ']');
                ses.send(parser.encode(resp));
            }
        }
    };
    initClientDescriptor("odbc");
    handler = new OdbcRequestHandler(ctx, busyLock, sender, maxCursors, distributedJoins, enforceJoinOrder, replicatedOnly, collocated, lazy, skipReducerOnUpdate, nestedTxMode, ver, this);
    parser = new OdbcMessageParser(ctx, ver);
    handler.start();
}
Also used : ClientListenerResponse(org.apache.ignite.internal.processors.odbc.ClientListenerResponse) NestedTxMode(org.apache.ignite.internal.processors.query.NestedTxMode) ClientListenerResponseSender(org.apache.ignite.internal.processors.odbc.ClientListenerResponseSender)

Aggregations

ClientListenerResponse (org.apache.ignite.internal.processors.odbc.ClientListenerResponse)3 ClientListenerResponseSender (org.apache.ignite.internal.processors.odbc.ClientListenerResponseSender)2 NestedTxMode (org.apache.ignite.internal.processors.query.NestedTxMode)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)1