/** Clean up the environment */ protected void shutdown() { if (state == Coprocessor.State.ACTIVE) { state = Coprocessor.State.STOPPING; Thread currentThread = Thread.currentThread(); ClassLoader hostClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(this.getClassLoader()); impl.stop(this); state = Coprocessor.State.STOPPED; } catch (IOException ioe) { LOG.error("Error stopping coprocessor "+impl.getClass().getName(), ioe); } finally { currentThread.setContextClassLoader(hostClassLoader); } } else { LOG.warn("Not stopping coprocessor "+impl.getClass().getName()+ " because not active (state="+state.toString()+")"); } synchronized (openTables) { // clean up any table references for (HTableInterface table: openTables) { try { ((HTableWrapper)table).internalClose(); } catch (IOException e) { // nothing can be done here LOG.warn("Failed to close " + Bytes.toStringBinary(table.getTableName()), e); } } } }
/** Clean up the environment */ protected void shutdown() { if (state == Coprocessor.State.ACTIVE) { state = Coprocessor.State.STOPPING; Thread currentThread = Thread.currentThread(); ClassLoader hostClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(this.getClassLoader()); impl.stop(this); state = Coprocessor.State.STOPPED; } catch (IOException ioe) { LOG.error("Error stopping coprocessor "+impl.getClass().getName(), ioe); } finally { currentThread.setContextClassLoader(hostClassLoader); } } else { LOG.warn("Not stopping coprocessor "+impl.getClass().getName()+ " because not active (state="+state.toString()+")"); } // clean up any table references for (HTableInterface table: openTables) { try { ((HTableWrapper)table).internalClose(); } catch (IOException e) { // nothing can be done here LOG.warn("Failed to close " + Bytes.toStringBinary(table.getTableName()), e); } } }
/** * Open a table from within the Coprocessor environment * @param tableName the table name * @return an interface for manipulating the table * @exception java.io.IOException Exception */ @Override public HTableInterface getTable(TableName tableName, ExecutorService pool) throws IOException { return HTableWrapper.createWrapper(openTables, tableName, this, pool); }