move null guard to where it's useful

This commit is contained in:
Dave Brosius 2014-12-27 15:18:59 -05:00
parent b53fefa731
commit 12b96915c3
1 changed files with 15 additions and 11 deletions

View File

@ -104,23 +104,27 @@ class CqlRecordWriter extends AbstractColumnFamilyRecordWriter<Map<String, ByteB
try
{
Cassandra.Client client = ConfigHelper.getClientFromOutputAddressList(conf);
client.set_keyspace(ConfigHelper.getOutputKeyspace(conf));
String user = ConfigHelper.getOutputKeyspaceUserName(conf);
String password = ConfigHelper.getOutputKeyspacePassword(conf);
if ((user != null) && (password != null))
AbstractColumnFamilyOutputFormat.login(user, password, client);
retrievePartitionKeyValidator(client);
String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
if (cqlQuery.toLowerCase().startsWith("insert"))
throw new UnsupportedOperationException("INSERT with CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
cql = appendKeyWhereClauses(cqlQuery);
if (client != null)
{
client.set_keyspace(ConfigHelper.getOutputKeyspace(conf));
String user = ConfigHelper.getOutputKeyspaceUserName(conf);
String password = ConfigHelper.getOutputKeyspacePassword(conf);
if ((user != null) && (password != null))
AbstractColumnFamilyOutputFormat.login(user, password, client);
retrievePartitionKeyValidator(client);
String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
if (cqlQuery.toLowerCase().startsWith("insert"))
throw new UnsupportedOperationException("INSERT with CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
cql = appendKeyWhereClauses(cqlQuery);
TTransport transport = client.getOutputProtocol().getTransport();
if (transport.isOpen())
transport.close();
}
else
{
throw new IllegalArgumentException("Invalid configuration specified " + conf);
}
}
catch (Exception e)
{