/** * Test address with host and port range. * * @throws Exception If failed. */ @Test public void testAddressHostAndPortRange() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true); // Shouldn't fit into range. check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), false); }
/** * Creates ODBC server configuration by copying all properties from given configuration. * * @param cfg ODBC server configuration. */ public OdbcConfiguration(OdbcConfiguration cfg) { assert cfg != null; endpointAddr = cfg.getEndpointAddress(); maxOpenCursors = cfg.getMaxOpenCursors(); sockRcvBufSize = cfg.getSocketReceiveBufferSize(); sockSndBufSize = cfg.getSocketSendBufferSize(); threadPoolSize = cfg.getThreadPoolSize(); }
/** * Test connection parameters: sendBufferSize, receiveBufferSize, connectionTimeout. * * @throws Exception If failed. */ @Test public void testConnectionParams() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000") .setSocketSendBufferSize(4 * 1024), true); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000") .setSocketReceiveBufferSize(4 * 1024), true); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000") .setSocketSendBufferSize(-64 * 1024), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000") .setSocketReceiveBufferSize(-64 * 1024), false); }
/** * Test thread pool size. * * @throws Exception If failed. */ @Test public void testThreadPoolSize() throws Exception { check(new OdbcConfiguration().setThreadPoolSize(0), false); check(new OdbcConfiguration().setThreadPoolSize(-1), false); check(new OdbcConfiguration().setThreadPoolSize(4), true); }
/** * Ensure we can start with default configuration. * * @throws Exception If failed. */ @Test public void testAddressDefault() throws Exception { check(new OdbcConfiguration(), true); }
/** * Parse ODBC endpoint. * * @param odbcCfg ODBC configuration. * @return ODBC host and port range. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("deprecation") private HostAndPortRange parseOdbcEndpoint(OdbcConfiguration odbcCfg) throws IgniteCheckedException { HostAndPortRange res; if (F.isEmpty(odbcCfg.getEndpointAddress())) { res = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST, OdbcConfiguration.DFLT_TCP_PORT_FROM, OdbcConfiguration.DFLT_TCP_PORT_TO ); } else { res = HostAndPortRange.parse(odbcCfg.getEndpointAddress(), OdbcConfiguration.DFLT_TCP_PORT_FROM, OdbcConfiguration.DFLT_TCP_PORT_TO, "Failed to parse ODBC endpoint address" ); } return res; }
/** * Parse ODBC endpoint. * * @param odbcCfg ODBC configuration. * @return ODBC host and port range. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("deprecation") private HostAndPortRange parseOdbcEndpoint(OdbcConfiguration odbcCfg) throws IgniteCheckedException { HostAndPortRange res; if (F.isEmpty(odbcCfg.getEndpointAddress())) { res = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST, OdbcConfiguration.DFLT_TCP_PORT_FROM, OdbcConfiguration.DFLT_TCP_PORT_TO ); } else { res = HostAndPortRange.parse(odbcCfg.getEndpointAddress(), OdbcConfiguration.DFLT_TCP_PORT_FROM, OdbcConfiguration.DFLT_TCP_PORT_TO, "Failed to parse ODBC endpoint address" ); } return res; }
/** * Test address with both host and port. * * @throws Exception If failed. */ @Test public void testAddressHostAndPort() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), true); // Shouldn't fit into range. check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), false); }
cliConnCfg.setPort(hostAndPort.portFrom()); cliConnCfg.setPortRange(hostAndPort.portTo() - hostAndPort.portFrom()); cliConnCfg.setThreadPoolSize(odbcCfg.getThreadPoolSize()); cliConnCfg.setSocketSendBufferSize(odbcCfg.getSocketSendBufferSize()); cliConnCfg.setSocketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize()); cliConnCfg.setMaxOpenCursorsPerConnection(odbcCfg.getMaxOpenCursors());
/** * Test start with invalid address format. * * @throws Exception If failed. */ @Test public void testAddressInvalidFormat() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:0"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:-1"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:111111"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999.."), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..9998"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a"), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a.."), false); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a..b"), false); check(new OdbcConfiguration().setEndpointAddress(":9999"), false); check(new OdbcConfiguration().setEndpointAddress(":9999..10000"), false); }
/** * Creates ODBC server configuration by copying all properties from given configuration. * * @param cfg ODBC server configuration. */ public OdbcConfiguration(OdbcConfiguration cfg) { assert cfg != null; endpointAddr = cfg.getEndpointAddress(); maxOpenCursors = cfg.getMaxOpenCursors(); sockRcvBufSize = cfg.getSocketReceiveBufferSize(); sockSndBufSize = cfg.getSocketSendBufferSize(); threadPoolSize = cfg.getThreadPoolSize(); }
/** * Test start with invalid host. * * @throws Exception If failed. */ @Test public void testAddressInvalidHost() throws Exception { check(new OdbcConfiguration().setEndpointAddress("126.0.0.1"), false); }
cliConnCfg.setPort(hostAndPort.portFrom()); cliConnCfg.setPortRange(hostAndPort.portTo() - hostAndPort.portFrom()); cliConnCfg.setThreadPoolSize(odbcCfg.getThreadPoolSize()); cliConnCfg.setSocketSendBufferSize(odbcCfg.getSocketSendBufferSize()); cliConnCfg.setSocketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize()); cliConnCfg.setMaxOpenCursorsPerConnection(odbcCfg.getMaxOpenCursors());
/** * Test address where only host is provided. * * @throws Exception If failed. */ @Test public void testAddressHostOnly() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1"), true); }
/** * Test ODBC connector conversion. * * @throws Exception If failed. */ @Test public void testOdbcConnectorConversion() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; IgniteConfiguration cfg = baseConfiguration(); cfg.setOdbcConfiguration(new OdbcConfiguration().setEndpointAddress("127.0.0.1:" + port)); Ignition.start(cfg); checkJdbc(null, port); }
/** * Test SQL connector conversion. * * @throws Exception If failed. */ @Test public void testIgnoreOdbcWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int odbcPort = ClientConnectorConfiguration.DFLT_PORT - 2; IgniteConfiguration cfg = baseConfiguration(); cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setPort(cliPort)); cfg.setOdbcConfiguration(new OdbcConfiguration().setEndpointAddress("127.0.0.1:" + odbcPort)); Ignition.start(cfg); checkJdbc(null, cliPort); }
/** * Test SQL connector conversion. * * @throws Exception If failed. */ @Test public void testIgnoreOdbcWhenSqlSet() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; IgniteConfiguration cfg = baseConfiguration(); cfg.setSqlConnectorConfiguration(new SqlConnectorConfiguration().setPort(port)); cfg.setOdbcConfiguration(new OdbcConfiguration().setEndpointAddress("127.0.0.1:" + (port - 1))); Ignition.start(cfg); checkJdbc(null, port); }
/** * Test SQL connector conversion. * * @throws Exception If failed. */ @Test public void testIgnoreOdbcAndSqlWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int sqlPort = ClientConnectorConfiguration.DFLT_PORT - 2; int odbcPort = ClientConnectorConfiguration.DFLT_PORT - 3; IgniteConfiguration cfg = baseConfiguration(); cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setPort(cliPort)); cfg.setSqlConnectorConfiguration(new SqlConnectorConfiguration().setPort(sqlPort)); cfg.setOdbcConfiguration(new OdbcConfiguration().setEndpointAddress("127.0.0.1:" + odbcPort)); Ignition.start(cfg); checkJdbc(null, cliPort); }