@SuppressWarnings("resource") public static Cassandra.Client createConnection(Configuration conf, String host, Integer port) throws IOException { try { TTransport transport = getClientTransportFactory(conf).openTransport(host, port); return new Cassandra.Client(new TBinaryProtocol(transport, true, true)); } catch (Exception e) { throw new IOException("Unable to connect to server " + host + ":" + port, e); } }
public static Cassandra.Client createConnection(Configuration conf, String host, Integer port) throws IOException { try { TTransport transport = getClientTransportFactory(conf).openTransport(host, port); return new Cassandra.Client(new TBinaryProtocol(transport, true, true)); } catch (Exception e) { throw new IOException("Unable to connect to server " + host + ":" + port, e); } }
@SuppressWarnings("resource") public static Cassandra.Client createConnection(Configuration conf, String host, Integer port) throws IOException { try { TTransport transport = getClientTransportFactory(conf).openTransport(host, port); return new Cassandra.Client(new TBinaryProtocol(transport, true, true)); } catch (Exception e) { throw new IOException("Unable to connect to server " + host + ":" + port, e); } }
@SuppressWarnings("resource") public static Cassandra.Client createConnection(Configuration conf, String host, Integer port) throws IOException { try { TTransport transport = getClientTransportFactory(conf).openTransport(host, port); return new Cassandra.Client(new TBinaryProtocol(transport, true, true)); } catch (Exception e) { throw new IOException("Unable to connect to server " + host + ":" + port, e); } }
public static ITransportFactory getClientTransportFactory(Configuration conf) { String factoryClassName = conf.get(ITransportFactory.PROPERTY_KEY, TFramedTransportFactory.class.getName()); ITransportFactory factory = getClientTransportFactory(factoryClassName); Map<String, String> options = getOptions(conf, factory.supportedOptions()); factory.setOptions(options); return factory; }
public static ITransportFactory getClientTransportFactory(Configuration conf) { String factoryClassName = conf.get(ITransportFactory.PROPERTY_KEY, TFramedTransportFactory.class.getName()); ITransportFactory factory = getClientTransportFactory(factoryClassName); Map<String, String> options = getOptions(conf, factory.supportedOptions()); factory.setOptions(options); return factory; }
public static ITransportFactory getClientTransportFactory(Configuration conf) { String factoryClassName = conf.get(ITransportFactory.PROPERTY_KEY, TFramedTransportFactory.class.getName()); ITransportFactory factory = getClientTransportFactory(factoryClassName); Map<String, String> options = getOptions(conf, factory.supportedOptions()); factory.setOptions(options); return factory; }
public static ITransportFactory getClientTransportFactory(Configuration conf) { String factoryClassName = conf.get(ITransportFactory.PROPERTY_KEY, TFramedTransportFactory.class.getName()); ITransportFactory factory = getClientTransportFactory(factoryClassName); Map<String, String> options = getOptions(conf, factory.supportedOptions()); factory.setOptions(options); return factory; }
private BulkLoader.ExternalClient getExternalClient(Configuration conf) { Set<InetAddress> hosts = new HashSet<InetAddress>(); String outputAddress = ConfigHelper.getOutputInitialAddress(conf); if (outputAddress == null) outputAddress = "localhost"; String[] nodes = outputAddress.split(","); for (String node : nodes) { try { hosts.add(InetAddress.getByName(node)); } catch (UnknownHostException e) { throw new RuntimeException(e); } } int rpcPort = ConfigHelper.getOutputRpcPort(conf); String username = ConfigHelper.getOutputKeyspaceUserName(conf); String password = ConfigHelper.getOutputKeyspacePassword(conf); ITransportFactory transportFactory = ConfigHelper.getClientTransportFactory(conf); return new BulkLoader.ExternalClient(hosts, rpcPort, username, password, transportFactory, CqlBulkOutputFormat.getStoragePort(conf), CqlBulkOutputFormat.getSSLStoragePort(conf), getServerEncryptOpt(conf)); }
public static Cassandra.Client createAuthenticatedClient(String location, int port, Configuration conf) throws Exception { logger.debug("Creating authenticated client for CF input format"); TTransport transport; try { transport = ConfigHelper.getClientTransportFactory(conf).openTransport(location, port); } catch (Exception e) { throw new TTransportException("Failed to open a transport to " + location + ":" + port + ".", e); } TProtocol binaryProtocol = new TBinaryProtocol(transport, true, true); Cassandra.Client client = new Cassandra.Client(binaryProtocol); // log in client.set_keyspace(ConfigHelper.getInputKeyspace(conf)); if ((ConfigHelper.getInputKeyspaceUserName(conf) != null) && (ConfigHelper.getInputKeyspacePassword(conf) != null)) { Map<String, String> creds = new HashMap<String, String>(); creds.put(IAuthenticator.USERNAME_KEY, ConfigHelper.getInputKeyspaceUserName(conf)); creds.put(IAuthenticator.PASSWORD_KEY, ConfigHelper.getInputKeyspacePassword(conf)); AuthenticationRequest authRequest = new AuthenticationRequest(creds); client.login(authRequest); } logger.debug("Authenticated client for CF input format created successfully"); return client; }
/** * Connects to the given server:port and returns a client based on the given socket that points to the configured * keyspace, and is logged in with the configured credentials. * * @param host fully qualified host name to connect to * @param port RPC port of the server * @param conf a job configuration * @return a cassandra client * @throws Exception set of thrown exceptions may be implementation defined, * depending on the used transport factory */ public static Cassandra.Client createAuthenticatedClient(String host, int port, Configuration conf) throws Exception { logger.debug("Creating authenticated client for CF output format"); TTransport transport = ConfigHelper.getClientTransportFactory(conf).openTransport(host, port); TProtocol binaryProtocol = new TBinaryProtocol(transport, true, true); Cassandra.Client client = new Cassandra.Client(binaryProtocol); client.set_keyspace(ConfigHelper.getOutputKeyspace(conf)); String user = ConfigHelper.getOutputKeyspaceUserName(conf); String password = ConfigHelper.getOutputKeyspacePassword(conf); if ((user != null) && (password != null)) login(user, password, client); logger.debug("Authenticated client for CF output format created successfully"); return client; }