Skip to content

Instantly share code, notes, and snippets.

@robdaemon
Created August 22, 2012 03:17
Show Gist options
  • Save robdaemon/3421996 to your computer and use it in GitHub Desktop.
Save robdaemon/3421996 to your computer and use it in GitHub Desktop.
rejected execution exception
@Override
public void persist(Map<String, Object> data) throws Exception {
Map<String, List<Row>> databaseOperations = generateDatabaseOperations(data);
for(String table: databaseOperations.keySet()) {
List<Row> batch = databaseOperations.get(table);
PutHelper.writeToTable(connectionPool, table, batch);
}
}
package com.simplymeasured.models;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool;
/**
* @author rob
* @since 3/12/12
*/
public class HBaseConnectionPool implements ConnectionPool {
public static final int TABLE_POOL_MAX_SIZE = 100;
private HTablePool tablePool;
public HBaseConnectionPool() {
Configuration configuration = HBaseConfiguration.create();
tablePool = new HTablePool(configuration, TABLE_POOL_MAX_SIZE);
}
@Override
public HTableInterface getTable(String table) {
HTableInterface tableInstance = tablePool.getTable(table);
return tableInstance;
}
@Override
public void putTable(HTableInterface table) {
tablePool.putTable(table);
}
}
package com.simplymeasured.models;
import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.util.Bytes;
import javax.sound.midi.SysexMessage;
import java.util.LinkedList;
import java.util.List;
/**
* @author rob
* @since 3/12/12
*/
public class HBaseConnectionPool implements ConnectionPool {
public static final int TABLE_POOL_MAX_SIZE = 100;
private HTablePool tablePool;
private static final List<HTableInterface> activeTableHandles = new LinkedList<HTableInterface>();
public HBaseConnectionPool() {
Configuration configuration = HBaseConfiguration.create();
tablePool = new HTablePool(configuration, TABLE_POOL_MAX_SIZE);
}
@Override
public HTableInterface getTable(String table) {
HTableInterface tableInstance = tablePool.getTable(table);
synchronized (activeTableHandles) {
activeTableHandles.add(tableInstance);
}
return tableInstance;
}
@Override
public void putTable(HTableInterface table) {
synchronized (activeTableHandles) {
if(!activeTableHandles.contains(table)) {
try {
throw new Exception("Attempt to release a table handle that's not in use!");
} catch(Exception ex) {
ex.printStackTrace();
}
}
activeTableHandles.remove(table);
}
tablePool.putTable(table);
}
}
public static void writeToTable(ConnectionPool connectionPool, String tableName, List<Row> puts) throws Exception {
HTableInterface table = connectionPool.getTable(tableName);
try {
table.batch(puts);
} finally {
connectionPool.putTable(table);
}
}
java.util.concurrent.RejectedExecutionException: null
java/util/concurrent/ThreadPoolExecutor.java:1956:in `rejectedExecution'
java/util/concurrent/ThreadPoolExecutor.java:816:in `reject'
java/util/concurrent/ThreadPoolExecutor.java:1337:in `execute'
java/util/concurrent/AbstractExecutorService.java:120:in `submit'
org/apache/hadoop/hbase/client/HConnectionManager.java:1340:in `processBatch'
org/apache/hadoop/hbase/client/HTable.java:624:in `batch'
com/simplymeasured/models/PutHelper.java:157:in `writeToTable'
com/simplymeasured/models/adapters/AbstractModelAdapter.java:44:in `persist'
/home/deploy/hbase_worker/app/releases/20120822004505/lib/hbase_workers/rpc/tweets.rb:15:in `persist'
org/jruby/RubyArray.java:1615:in `each'
/home/deploy/hbase_worker/app/releases/20120822004505/lib/hbase_workers/rpc/tweets.rb:14:in `persist'
/home/deploy/hbase_worker/app/releases/20120822004505/lib/hbase_workers/rpc/rpc_base.rb:13:in 'safe_handler'
/home/deploy/hbase_worker/app/releases/20120822004505/lib/hbase_workers/rpc/tweets.rb:13:in `persist' org/jruby/RubyKernel.java:2080:in `send'
[GEM_ROOT]/bundler/gems/redisrpc-61352680ae0a/ruby/lib/redisrpc.rb:135:in `run_one'
[GEM_ROOT]/bundler/gems/redisrpc-61352680ae0a/ruby/lib/redisrpc.rb:104:in `run'
org/jruby/RubyKernel.java:1410:in `loop'
[GEM_ROOT]/bundler/gems/redisrpc-61352680ae0a/ruby/lib/redisrpc.rb:104:in `run'
bin/rpc_server:40:in `(root)'
org/jruby/RubyKernel.java:1410:in `loop'
bin/rpc_server:27:in `__file__'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:224:in `call'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment