use of org.apache.cassandra.thrift.TBinaryProtocol in project eiger by wlloyd.
the class ColumnFamilyRecordReader method initialize.
@Override
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException {
this.split = (ColumnFamilySplit) split;
Configuration conf = context.getConfiguration();
predicate = ConfigHelper.getInputSlicePredicate(conf);
isEmptyPredicate = isEmptyPredicate(predicate);
totalRowCount = ConfigHelper.getInputSplitSize(conf);
batchRowCount = ConfigHelper.getRangeBatchSize(conf);
cfName = ConfigHelper.getInputColumnFamily(conf);
consistencyLevel = ConsistencyLevel.valueOf(ConfigHelper.getReadConsistencyLevel(conf));
keyspace = ConfigHelper.getInputKeyspace(conf);
try {
// only need to connect once
if (socket != null && socket.isOpen())
return;
// create connection using thrift
String location = getLocation();
socket = new TSocket(location, ConfigHelper.getInputRpcPort(conf));
TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket));
client = new Cassandra.Client(binaryProtocol);
socket.open();
// log in
client.set_keyspace(keyspace, LamportClock.COPS_UNSUPPORTED);
if (ConfigHelper.getInputKeyspaceUserName(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, LamportClock.COPS_UNSUPPORTED);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
iter = new RowIterator();
}
use of org.apache.cassandra.thrift.TBinaryProtocol in project eiger by wlloyd.
the class ConfigHelper method createConnection.
public static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws IOException {
TSocket socket = new TSocket(host, port);
TTransport trans = framed ? new TFramedTransport(socket) : socket;
try {
trans.open();
} catch (TTransportException e) {
throw new IOException("unable to connect to server", e);
}
return new Cassandra.Client(new TBinaryProtocol(trans));
}
use of org.apache.cassandra.thrift.TBinaryProtocol in project brisk by riptano.
the class BriskTool method getConnection.
private Brisk.Iface getConnection() throws IOException {
TTransport trans = new TFramedTransport(new TSocket(host, port));
try {
trans.open();
} catch (TTransportException e) {
throw new IOException("unable to connect to brisk server");
}
Brisk.Iface client = new Brisk.Client(new TBinaryProtocol(trans));
return client;
}
Aggregations