@Override public CoprocessorEnvironment<E> createEnvironment(final E instance, final int priority, int sequence, Configuration conf) { return new BaseEnvironment<>(instance, priority, 0, cpHostConf); } }
public void shutdown(E e) { assert e instanceof BaseEnvironment; if (LOG.isDebugEnabled()) { LOG.debug("Stop coprocessor " + e.getInstance().getClass().getName()); } ((BaseEnvironment<C>) e).shutdown(); }
/** Clean up the environment */ public 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()+")"); } }
/** * @param implClass Implementation class * @param priority priority * @param conf configuration * @throws java.io.IOException Exception */ public E checkAndLoadInstance(Class<?> implClass, int priority, Configuration conf) throws IOException { // create the instance C impl; try { impl = checkAndGetInstance(implClass); if (impl == null) { LOG.error("Cannot load coprocessor " + implClass.getSimpleName()); return null; } } catch (InstantiationException|IllegalAccessException e) { throw new IOException(e); } // create the environment E env = createEnvironment(impl, priority, loadSequence.incrementAndGet(), conf); assert env instanceof BaseEnvironment; ((BaseEnvironment<C>) env).startup(); // HBASE-4014: maintain list of loaded coprocessors for later crash analysis // if server (master or regionserver) aborts. coprocessorNames.add(implClass.getName()); return env; }
/** Initialize the environment */ public void startup() throws IOException { if (state == Coprocessor.State.INSTALLED || state == Coprocessor.State.STOPPED) { state = Coprocessor.State.STARTING; Thread currentThread = Thread.currentThread(); ClassLoader hostClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(this.getClassLoader()); impl.start(this); state = Coprocessor.State.ACTIVE; } finally { currentThread.setContextClassLoader(hostClassLoader); } } else { LOG.warn("Not starting coprocessor " + impl.getClass().getName() + " because not inactive (state=" + state.toString() + ")"); } }
@Override public void shutdown() { super.shutdown(); MetricsCoprocessor.removeRegistry(this.metricRegistry); } }
@Override public CoprocessorEnvironment<E> createEnvironment(final E instance, final int priority, int sequence, Configuration conf) { return new BaseEnvironment<>(instance, priority, 0, cpHostConf); } }
@Override public void shutdown() { super.shutdown(); MetricsCoprocessor.removeRegistry(this.metricRegistry); } }
@Override public void shutdown() { super.shutdown(); MetricsCoprocessor.removeRegistry(metricRegistry); } }
@Override public void shutdown() { super.shutdown(); MetricsCoprocessor.removeRegistry(this.metricRegistry); }