Example usage for org.apache.thrift.transport TTransportException ALREADY_OPEN

List of usage examples for org.apache.thrift.transport TTransportException ALREADY_OPEN

Introduction

In this page you can find the example usage for org.apache.thrift.transport TTransportException ALREADY_OPEN.

Prototype

int ALREADY_OPEN

To view the source code for org.apache.thrift.transport TTransportException ALREADY_OPEN.

Click Source Link

Usage

From source file:org.apache.cassandra.thrift.TCustomSocket.java

License:Apache License

/**
 * Connects the socket, creating a new socket object if necessary.
 *///  ww w.j a  v a2s  . c om
public void open() throws TTransportException {
    if (isOpen()) {
        throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected.");
    }

    if (host.length() == 0) {
        throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host.");
    }
    if (port <= 0) {
        throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open without port.");
    }

    if (socket == null) {
        initSocket();
    }

    try {
        socket.connect(new InetSocketAddress(host, port), timeout);
        inputStream_ = new BufferedInputStream(socket.getInputStream(), 1024);
        outputStream_ = new BufferedOutputStream(socket.getOutputStream(), 1024);
    } catch (IOException iox) {
        close();
        throw new TTransportException(TTransportException.NOT_OPEN, iox);
    }
}

From source file:org.apache.hive.beeline.TestBeeLineExceptionHandling.java

License:Apache License

@Test
public void testHandleSQLExceptionLog() throws Exception {
    checkException(TTransportException.ALREADY_OPEN, "hs2-connection-already-open");
    checkException(TTransportException.END_OF_FILE, "hs2-unexpected-end-of-file");
    checkException(TTransportException.NOT_OPEN, "hs2-could-not-open-connection");
    checkException(TTransportException.TIMED_OUT, "hs2-connection-timed-out");
    checkException(TTransportException.UNKNOWN, "hs2-unknown-connection-problem");
    checkException(-1, "hs2-unexpected-error");
}