Repository: cassandra Updated Branches: refs/heads/trunk b5a232b04 -> 17d9791d6
move null guard to where it's useful Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/12b96915 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/12b96915 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/12b96915 Branch: refs/heads/trunk Commit: 12b96915c3e37edc1ea6b584ebc406f44426d4ec Parents: b53fefa Author: Dave Brosius <dbros...@mebigfatguy.com> Authored: Sat Dec 27 15:18:59 2014 -0500 Committer: Dave Brosius <dbros...@mebigfatguy.com> Committed: Sat Dec 27 15:18:59 2014 -0500 ---------------------------------------------------------------------- .../cassandra/hadoop/cql3/CqlRecordWriter.java | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/12b96915/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java index ff1989d..702cae3 100644 --- a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java +++ b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java @@ -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) {