Example #1
1
 /** 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);
     }
   }
 }
Example #2
0
 /**
  * Constructor
  *
  * @param impl the coprocessor instance
  * @param priority chaining priority
  */
 public Environment(
     final Coprocessor impl, final int priority, final int seq, final Configuration conf) {
   this.impl = impl;
   this.classLoader = impl.getClass().getClassLoader();
   this.priority = priority;
   this.state = Coprocessor.State.INSTALLED;
   this.seq = seq;
   this.conf = conf;
 }
Example #3
0
 /** 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()
             + ")");
   }
 }