Announcement Announcement Module
Collapse
No announcement yet.
java.util.concurrent.RejectedExecutionException when using HBaseTemplate twice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.util.concurrent.RejectedExecutionException when using HBaseTemplate twice

    I've encountered a RejectedExecutionException after trying to use HBaseTemplate twice for the same method in a DAO.

    Details:

    Stack trace:

    java.util.concurrent.RejectedExecutionException
    at java.util.concurrent.ThreadPoolExecutor$AbortPolic y.rejectedExecution(ThreadPoolExecutor.java:1768)
    at java.util.concurrent.ThreadPoolExecutor.reject(Thr eadPoolExecutor.java:767)
    at java.util.concurrent.ThreadPoolExecutor.execute(Th readPoolExecutor.java:658)
    at java.util.concurrent.AbstractExecutorService.submi t(AbstractExecutorService.java:92)
    at org.apache.hadoop.hbase.client.HConnectionManager$ HConnectionImplementation.processBatchCallback(HCo nnectionManager.java:1546)
    at org.apache.hadoop.hbase.client.HConnectionManager$ HConnectionImplementation.processBatch(HConnection Manager.java:1409)
    at org.apache.hadoop.hbase.client.HTable.flushCommits (HTable.java:943)
    at org.apache.hadoop.hbase.client.HTable.doPut(HTable .java:820)
    at org.apache.hadoop.hbase.client.HTable.put(HTable.j ava:795)
    at com.osintegrators.example.jackscarco.hbase.reposit ory.HBaseProductRepository$1.doInTable(HBaseProduc tRepository.java:97)
    at org.springframework.data.hadoop.hbase.HbaseTemplat e.execute(HbaseTemplate.java:72)
    at com.osintegrators.example.jackscarco.hbase.reposit ory.HBaseProductRepository.save(HBaseProductReposi tory.java:92)
    at com.osintegrators.example.jackscarco.hbase.reposit ory.TestHBaseProductRepository.testFindByName(Test HBaseProductRepository.java:59)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.e valuate(RunBefores.java:28)
    at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:82)
    at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
    at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.rt.execution.junit.JUnitStarter.main( JUnitStarter.java:63)

    test method:

    @Test
    public void testFindByName() throws Throwable {
    Product p = new Product();
    p.setName(PREMIUM_SPARK_PLUG);
    p.setFailureRate(PREMIUM_SPARK_PLUG_FAILURE_RATE);
    p = repository.save(p);

    p = new Product();
    p.setName(PREMIUM_SPARK_PLUG);
    p.setFailureRate(PREMIUM_SPARK_PLUG_FAILURE_RATE);
    p = repository.save(p);

    // ...
    }

    abbreviated repository:

    @Component
    public class HBaseProductRepository {


    @Autowired
    private Configuration hbaseConfiguration;

    @Inject
    private HbaseTemplate hbaseTemplate;

    public Product save(final Product p) {
    // furnish a random UUID string for the row key if no row key exists
    if (p.getId() == null) {
    p.setId(UUID.randomUUID().toString());
    }

    final byte[] rowKey = Bytes.toBytes(p.getId());
    final byte[] name = Bytes.toBytes(p.getName());
    final byte[] failureRate = Bytes.toBytes(p.getFailureRate().doubleValue());

    hbaseTemplate.execute(TABLE_NAME, new TableCallback<Object>() {
    public Object doInTable(HTable table) throws Throwable {
    Put p = new Put(rowKey);
    p.add(COLUMN_FAMILY_NAME_BYTES, NAME_ATTR_BYTES, name);
    p.add(COLUMN_FAMILY_NAME_BYTES, FAILURE_RATE_ATTR_BYTES, failureRate);
    table.put(p);
    return null;
    }
    });

    return p;
    }
    }

    app-context.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:hdp="http://www.springframework.org/schema/hadoop"
    xmlns="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/hadoop http://www.springframework.org/schem...ing-hadoop.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <description>Spring bean definitions for the JacksCarCo / HBase example project</description>

    <context:component-scan base-package="com.osintegrators.example" />

    <contextroperty-placeholder location="hadoop.properties"/>

    <hdp:configuration>
    fs.default.name=${hd.fs}
    </hdp:configuration>

    <hdp:hbase-configuration configuration-ref="hadoopConfiguration"/>

    <bean id="hTemplate" class="org.springframework.data.hadoop.hbase.Hbase Template" p:configuration-ref="hbaseConfiguration"/>

    <context:component-scan base-package="org.osintegrators.example.jackscarco"/>

    </beans>
    Last edited by cortextual; Jul 15th, 2012, 07:27 PM. Reason: typo

  • #2
    My HBase setup is extremely simple. I downloaded HBase 0.92.1, extracted it, and set the data directory to somewhere on my local filesystem. I set the hd.fs property to file:///opt/fake_hdfs. So there's no HDFS to speak of anywhere.

    Comment


    • #3
      Using the latest build snapshot (version 1.0.0.BUILD-SNAPSHOT) of org.springframework.data:spring-data-hadoop got me past this issue. Thanks once again Costin for your hard work!

      Comment

      Working...
      X