camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1377257 - in /camel/branches/camel-2.10.x: ./ components/camel-hbase/src/main/java/org/apache/camel/component/hbase/ components/camel-hbase/src/test/java/org/apache/camel/component/hbase/
Date Sat, 25 Aug 2012 10:35:51 GMT
Author: davsclaus
Date: Sat Aug 25 10:35:50 2012
New Revision: 1377257

URL: http://svn.apache.org/viewvc?rev=1377257&view=rev
Log:
CAMEL-5530: Polished camel-hbase. Thanks to Claudio Corsi for the patch.

Added:
    camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConstants.java
      - copied unchanged from r1377256, camel/trunk/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConstants.java
Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseContats.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
    camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1377256

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
Sat Aug 25 10:35:50 2012
@@ -170,14 +170,11 @@ public class HBaseConsumer extends Sched
      * Delegates to the {@link HBaseRemoveHandler}.
      */
     private void remove(byte[] row) throws IOException {
-        HTableInterface table = null;
+        HTableInterface table = tablePool.getTable(tableName);
         try {
-            table = tablePool.getTable(tableName);
             endpoint.getRemoveHandler().remove(table, row);
         } finally {
-            if (table != null) {
-                table.close();
-            }
+            table.close();
         }
     }
 

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseContats.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseContats.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseContats.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseContats.java
Sat Aug 25 10:35:50 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.hbase;
 
+@Deprecated
 public final class HBaseContats {
 
     public static final String OPERATION = "CamelHBaseOperation";

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
Sat Aug 25 10:35:50 2012
@@ -61,12 +61,11 @@ public class HBaseProducer extends Defau
 
 
     public void process(Exchange exchange) throws Exception {
-        HTableInterface table = null;
+        HTableInterface table = tablePool.getTable(tableName.getBytes());
         try {
-            table = tablePool.getTable(tableName.getBytes());
 
             updateHeaders(exchange);
-            String operation = (String) exchange.getIn().getHeader(HBaseContats.OPERATION);
+            String operation = (String) exchange.getIn().getHeader(HBaseConstants.OPERATION);
             CellMappingStrategy mappingStrategy = endpoint.getCellMappingStrategyFactory().getStrategy(exchange.getIn());
 
             HBaseData data = mappingStrategy.resolveModel(exchange.getIn());
@@ -78,14 +77,14 @@ public class HBaseProducer extends Defau
 
             for (HBaseRow hRow : data.getRows()) {
                 hRow.apply(rowModel);
-                if (HBaseContats.PUT.equals(operation)) {
+                if (HBaseConstants.PUT.equals(operation)) {
                     putOperations.add(createPut(hRow));
-                } else if (HBaseContats.GET.equals(operation)) {
+                } else if (HBaseConstants.GET.equals(operation)) {
                     HBaseRow getResultRow = getCells(table, hRow);
                     getOperationResult.add(getResultRow);
-                } else if (HBaseContats.DELETE.equals(operation)) {
+                } else if (HBaseConstants.DELETE.equals(operation)) {
                     deleteOperations.add(createDeleteRow(hRow));
-                } else if (HBaseContats.SCAN.equals(operation)) {
+                } else if (HBaseConstants.SCAN.equals(operation)) {
                     scanOperationResult = scanCells(table, hRow, endpoint.getFilters());
                 }
             }
@@ -254,8 +253,8 @@ public class HBaseProducer extends Defau
      */
     private void updateHeaders(Exchange exchange) {
         if (exchange != null && exchange.getIn() != null) {
-            if (endpoint.getMaxResults() != 0 && exchange.getIn().getHeader(HBaseContats.HBASE_MAX_SCAN_RESULTS)
== null) {
-                exchange.getIn().setHeader(HBaseContats.HBASE_MAX_SCAN_RESULTS, endpoint.getMaxResults());
+            if (endpoint.getMaxResults() != 0 && exchange.getIn().getHeader(HBaseConstants.HBASE_MAX_SCAN_RESULTS)
== null) {
+                exchange.getIn().setHeader(HBaseConstants.HBASE_MAX_SCAN_RESULTS, endpoint.getMaxResults());
             }
             if (endpoint.getMappingStrategyName() != null && exchange.getIn().getHeader(CellMappingStrategyFactory.STRATEGY)
== null) {
                 exchange.getIn().setHeader(CellMappingStrategyFactory.STRATEGY, endpoint.getMappingStrategyName());
@@ -265,10 +264,10 @@ public class HBaseProducer extends Defau
                 exchange.getIn().setHeader(CellMappingStrategyFactory.STRATEGY_CLASS_NAME,
endpoint.getMappingStrategyClassName());
             }
 
-            if (endpoint.getOperation() != null && exchange.getIn().getHeader(HBaseContats.OPERATION)
== null) {
-                exchange.getIn().setHeader(HBaseContats.OPERATION, endpoint.getOperation());
-            } else if (endpoint.getOperation() == null && exchange.getIn().getHeader(HBaseContats.OPERATION)
== null) {
-                exchange.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.PUT);
+            if (endpoint.getOperation() != null && exchange.getIn().getHeader(HBaseConstants.OPERATION)
== null) {
+                exchange.getIn().setHeader(HBaseConstants.OPERATION, endpoint.getOperation());
+            } else if (endpoint.getOperation() == null && exchange.getIn().getHeader(HBaseConstants.OPERATION)
== null) {
+                exchange.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.PUT);
             }
         }
     }

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
Sat Aug 25 10:35:50 2012
@@ -95,7 +95,7 @@ public class CamelHBaseFilterTest extend
                 from("direct:start")
                         .to("hbase://" + DEFAULTTABLE);
                 from("direct:scan")
-                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseContats.SCAN
+ "&maxResults=2&filters=#myFilters");
+                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseConstants.SCAN
+ "&maxResults=2&filters=#myFilters");
             }
         };
     }

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
Sat Aug 25 10:35:50 2012
@@ -69,7 +69,7 @@ public class HBaseConsumerTest extends C
             headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(3), column[0]);
             headers.put(HbaseAttribute.HBASE_VALUE.asHeader(3), body[2]);
 
-            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);
+            headers.put(HBaseConstants.OPERATION, HBaseConstants.PUT);
 
             template.sendBodyAndHeaders("direct:start", null, headers);
 

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
Sat Aug 25 10:35:50 2012
@@ -78,7 +78,7 @@ public class HBaseConvertionsTest extend
             headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(3), column[0]);
             headers.put(HbaseAttribute.HBASE_VALUE.asHeader(3), body[2]);
 
-            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);
+            headers.put(HBaseConstants.OPERATION, HBaseConstants.PUT);
 
             template.sendBodyAndHeaders("direct:start", null, headers);
 
@@ -122,7 +122,7 @@ public class HBaseConvertionsTest extend
                         .to("hbase://" + DEFAULTTABLE);
 
                 from("direct:scan")
-                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseContats.SCAN
+ "&maxResults=2&family=family1&qualifier=column1");
+                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseConstants.SCAN
+ "&maxResults=2&family=family1&qualifier=column1");
             }
         };
     }

Modified: camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java?rev=1377257&r1=1377256&r2=1377257&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
Sat Aug 25 10:35:50 2012
@@ -66,7 +66,7 @@ public class HBaseProducerTest extends C
             headers.put(HbaseAttribute.HBASE_FAMILY.asHeader(), family[0]);
             headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(), column[0]);
             headers.put(HbaseAttribute.HBASE_VALUE.asHeader(), body[0]);
-            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);
+            headers.put(HBaseConstants.OPERATION, HBaseConstants.PUT);
             template.sendBodyAndHeaders("direct:start", null, headers);
 
             Configuration configuration = hbaseUtil.getHBaseAdmin().getConfiguration();
@@ -91,7 +91,7 @@ public class HBaseProducerTest extends C
             exchange.getIn().setHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(), key[0]);
             exchange.getIn().setHeader(HbaseAttribute.HBASE_FAMILY.asHeader(), family[0]);
             exchange.getIn().setHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(), column[0]);
-            exchange.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.GET);
+            exchange.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.GET);
             Exchange resp = template.send(endpoint, exchange);
             assertEquals(body[0], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader()));
         }
@@ -118,7 +118,7 @@ public class HBaseProducerTest extends C
             headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(3), column[0]);
             headers.put(HbaseAttribute.HBASE_VALUE.asHeader(3), body[2]);
 
-            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);
+            headers.put(HBaseConstants.OPERATION, HBaseConstants.PUT);
 
             template.sendBodyAndHeaders("direct:start", null, headers);
 
@@ -163,7 +163,7 @@ public class HBaseProducerTest extends C
             exchange.getIn().setHeader(HbaseAttribute.HBASE_FAMILY.asHeader(2), family[0]);
             exchange.getIn().setHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(2), column[0]);
 
-            exchange.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.GET);
+            exchange.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.GET);
             Exchange resp = template.send(endpoint, exchange);
             assertEquals(body[0], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader()));
             assertEquals(body[1], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader(2)));
@@ -186,7 +186,7 @@ public class HBaseProducerTest extends C
             headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(2), column[1]);
             headers.put(HbaseAttribute.HBASE_VALUE.asHeader(2), body[1]);
 
-            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);
+            headers.put(HBaseConstants.OPERATION, HBaseConstants.PUT);
 
             template.sendBodyAndHeaders("direct:start", null, headers);
 
@@ -225,7 +225,7 @@ public class HBaseProducerTest extends C
             exchange.getIn().setHeader(HbaseAttribute.HBASE_FAMILY.asHeader(2), family[1]);
             exchange.getIn().setHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(2), column[1]);
 
-            exchange.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.GET);
+            exchange.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.GET);
             Exchange resp = template.send(endpoint, exchange);
             assertEquals(body[0], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader()));
             assertEquals(body[1], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader(2)));
@@ -242,7 +242,7 @@ public class HBaseProducerTest extends C
 
             Exchange exchange1 = endpoint.createExchange(ExchangePattern.InOnly);
             exchange1.getIn().setHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(), key[0]);
-            exchange1.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.DELETE);
+            exchange1.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.DELETE);
             template.send(endpoint, exchange1);
 
             Exchange exchange2 = endpoint.createExchange(ExchangePattern.InOut);
@@ -253,7 +253,7 @@ public class HBaseProducerTest extends C
             exchange2.getIn().setHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(2), key[1]);
             exchange2.getIn().setHeader(HbaseAttribute.HBASE_FAMILY.asHeader(2), family[0]);
             exchange2.getIn().setHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(2), column[0]);
-            exchange2.getIn().setHeader(HBaseContats.OPERATION, HBaseContats.GET);
+            exchange2.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.GET);
             Exchange resp = template.send(endpoint, exchange2);
             assertEquals(null, resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader()));
             assertEquals(body[1], resp.getOut().getHeader(HbaseAttribute.HBASE_VALUE.asHeader(2)));
@@ -294,7 +294,7 @@ public class HBaseProducerTest extends C
                         .to("hbase://" + DEFAULTTABLE);
 
                 from("direct:scan")
-                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseContats.SCAN
+ "&maxResults=2");
+                        .to("hbase://" + DEFAULTTABLE + "?operation=" + HBaseConstants.SCAN
+ "&maxResults=2");
             }
         };
     }



Mime
View raw message