List of usage examples for org.apache.cassandra.hadoop ConfigHelper getOutputKeyspacePassword
public static String getOutputKeyspacePassword(Configuration conf)
From source file:com.buzzinate.dm.cassandra.ColumnFamilyOutputFormat.java
License:Apache License
/** * Return a client based on the given socket that points to the configured * keyspace, and is logged in with the configured credentials. * * @param socket a socket pointing to a particular node, seed or otherwise * @param conf a job configuration/*w ww . j a va2s .com*/ * @return a cassandra client * @throws InvalidRequestException * @throws TException * @throws AuthenticationException * @throws AuthorizationException */ public static Cassandra.Client createAuthenticatedClient(TSocket socket, Configuration conf) throws InvalidRequestException, TException, AuthenticationException, AuthorizationException { TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket)); Cassandra.Client client = new Cassandra.Client(binaryProtocol); socket.open(); client.set_keyspace(ConfigHelper.getOutputKeyspace(conf)); if (ConfigHelper.getOutputKeyspaceUserName(conf) != null) { Map<String, String> creds = new HashMap<String, String>(); creds.put(IAuthenticator.USERNAME_KEY, ConfigHelper.getOutputKeyspaceUserName(conf)); creds.put(IAuthenticator.PASSWORD_KEY, ConfigHelper.getOutputKeyspacePassword(conf)); AuthenticationRequest authRequest = new AuthenticationRequest(creds); client.login(authRequest); } return client; }
From source file:com.spotify.hdfs2cass.cassandra.thrift.CrunchBulkRecordWriter.java
License:Apache License
private void prepareWriter() { String columnFamily = CrunchConfigHelper.getOutputColumnFamily(conf); String keyspace = ConfigHelper.getOutputKeyspace(conf); if (outputdir == null) { // dir must be named by ks/cf for the loader outputdir = Paths.get(getOutputLocation(), keyspace, columnFamily).toFile(); outputdir.mkdirs();/*ww w .jav a2 s .c o m*/ } if (writer == null) { AbstractType<?> subcomparator = null; if (cfType == CFType.SUPER) subcomparator = BytesType.instance; int bufferSizeInMB = Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")); this.writer = new SSTableSimpleUnsortedWriter(outputdir, ConfigHelper.getOutputPartitioner(conf), keyspace, columnFamily, BytesType.instance, subcomparator, bufferSizeInMB, ConfigHelper.getOutputCompressionParamaters(conf)); ExternalSSTableLoaderClient externalClient = new ExternalSSTableLoaderClient( ConfigHelper.getOutputInitialAddress(conf), ConfigHelper.getOutputRpcPort(conf), ConfigHelper.getOutputKeyspaceUserName(conf), ConfigHelper.getOutputKeyspacePassword(conf)); this.loader = new SSTableLoader(outputdir, externalClient, new OutputHandler.SystemOutput(true, true)); } }