Package org.tarantool.core.exception

Examples of org.tarantool.core.exception.CommunicationException


            ByteBuffer welcome = state.getWelcomeBuffer();
            readFully(welcome);
            String firstLine = new String(welcome.array(), 0, welcome.position());
            if (!firstLine.startsWith("Tarantool")) {
                channel.close();
                throw new CommunicationException("Welcome message should starts with tarantool but starts with '" + firstLine + "'");
            }
            welcome = state.getWelcomeBuffer();
            readFully(welcome);
            this.salt = new String(welcome.array(), 0, welcome.position());
        } catch (IOException e) {
            throw new CommunicationException("Can't connect with tarantool", e);
        }
    }
View Full Code Here


            int code;
            while ((code = channel.read(buffer)) > -1 && buffer.remaining() > 0) {

            }
            if (code < 0) {
                throw new CommunicationException("Can't read bytes");
            }
            return code;
        } catch (IOException e) {
            throw new CommunicationException("Can't read bytes", e);
        }
    }
View Full Code Here

            int code;
            while ((code = channel.write(buffer)) > -1 && buffer.remaining() > 0) {

            }
            if (code < 0) {
                throw new CommunicationException("Can't read bytes");
            }
            return code;
        } catch (IOException e) {
            throw new CommunicationException("Can't write bytes", e);
        }

    }
View Full Code Here

            }
            auth.add(p);
            exec(Code.AUTH, Key.USER_NAME, username, Key.TUPLE, auth);

        } catch (NoSuchAlgorithmException e) {
            throw new CommunicationException("Can't use sha-1", e);
        } catch (IOException e) {
            throw new CommunicationException("Can't decode base-64", e);

        }
    }
View Full Code Here

    buffer.flip();
    while (buffer.hasRemaining()) {
      try {
        channel.write(buffer);
      } catch (IOException e) {
        throw new CommunicationException("Can't connect to tarantool", e);
      }
    }
    try {
      ByteBuffer version = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
      readFullyAndFlip(version);
      int v = version.getInt();
      if (v != Const.VERSION) {
        throw new CommunicationException("Server version " + v + " is not supported");
      }
    } catch (IOException e) {
      throw new CommunicationException("Can't get version", e);
    }
  }
View Full Code Here

public class SocketChannelTarantoolConnection extends TarantoolConnectionImpl {
  static SocketChannel channel(String host, int port) {
    try {
      return SocketChannel.open(new InetSocketAddress(host, port));
    } catch (IOException e) {
      throw new CommunicationException("Can't connecto to " + host + ":" + port, e);
    }
  }
View Full Code Here

    int res = 0;
    try {
      while (buffer.hasRemaining() && (res = channel.read(buffer)) > -1) {
      }
    } catch (IOException e) {
      throw new CommunicationException("Can't read data", e);
    }
    if (res == -1) {
      throw new CommunicationException("Connection lost");
    }
    buffer.flip();
    return buffer;
  }
View Full Code Here

    ByteBuffer recvBuffer = request.pack();
    while (recvBuffer.hasRemaining()) {
      try {
        channel.write(recvBuffer);
      } catch (IOException e) {
        throw new CommunicationException("Can't write packet to channel", e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.tarantool.core.exception.CommunicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.