Example usage for java.lang Thread getContextClassLoader

List of usage examples for java.lang Thread getContextClassLoader

Introduction

In this page you can find the example usage for java.lang Thread getContextClassLoader.

Prototype

@CallerSensitive
public ClassLoader getContextClassLoader() 

Source Link

Document

Returns the context ClassLoader for this thread.

Usage

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param get the Get request//  w w w.ja  v  a  2 s .  co  m
 * @param results the result sett
 * @exception IOException Exception
 */
public void postGet(final Get get, final List<Cell> results) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postGetOp(ctx, get, results);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param put The Put object// w  w w.j  ava  2 s  .  c  o  m
 * @param edit The WALEdit object.
 * @param durability The durability used
 * @exception IOException Exception
 */
public void postPut(final Put put, final WALEdit edit, final Durability durability) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postPut(ctx, put, edit, durability);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param miniBatchOp/*from  ww  w .  j  a  v  a2s.co m*/
 * @throws IOException
 */
public void postBatchMutate(final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postBatchMutate(ctx, miniBatchOp);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

public void postBatchMutateIndispensably(final MiniBatchOperationInProgress<Mutation> miniBatchOp,
        final boolean success) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postBatchMutateIndispensably(ctx, miniBatchOp, success);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }//  www  .j a  v  a  2  s  . c  o  m
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param append Append object/*from   ww  w.  ja v  a  2 s .  c  o  m*/
 * @param result the result returned by the append
 * @throws IOException if an error occurred on the coprocessor
 */
public void postAppend(final Append append, final Result result) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postAppend(ctx, append, result);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param s the scanner//from  w  w  w. ja  v  a  2s  . c o  m
 * @exception IOException Exception
 */
public void postScannerClose(final InternalScanner s) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postScannerClose(ctx, s);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

public DeleteTracker postInstantiateDeleteTracker(DeleteTracker tracker) throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                tracker = ((RegionObserver) env.getInstance()).postInstantiateDeleteTracker(ctx, tracker);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }//from ww  w  . j a  v  a  2  s. c o  m
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
    return tracker;
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * Called after the {@link StoreFile}s to be compacted have been selected from the available
 * candidates./* ww w  . j  a  v  a2s . c om*/
 * @param store The store where compaction is being requested
 * @param selected The store files selected to compact
 * @param request custom compaction
 */
public void postCompactSelection(final Store store, final ImmutableList<StoreFile> selected,
        final CompactionRequest request) {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postCompactSelection(ctx, store, selected, request);
            } catch (Throwable e) {
                handleCoprocessorThrowableNoRethrow(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * Called after the store compaction has completed.
 * @param store the store being compacted
 * @param resultFile the new store file written during compaction
 * @param request the compaction that is being executed
 * @throws IOException/*  w  w  w.  ja  v a 2s.  co m*/
 */
public void postCompact(final Store store, final StoreFile resultFile, final CompactionRequest request)
        throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postCompact(ctx, store, resultFile, request);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.java

/**
 * @param row the row key/*www. java 2  s. c  o m*/
 * @param family the family
 * @param result the result set from the region
 * @exception IOException Exception
 */
public void postGetClosestRowBefore(final byte[] row, final byte[] family, final Result result)
        throws IOException {
    ObserverContext<RegionCoprocessorEnvironment> ctx = null;
    for (RegionEnvironment env : coprocessors) {
        if (env.getInstance() instanceof RegionObserver) {
            ctx = ObserverContext.createAndPrepare(env, ctx);
            Thread currentThread = Thread.currentThread();
            ClassLoader cl = currentThread.getContextClassLoader();
            try {
                currentThread.setContextClassLoader(env.getClassLoader());
                ((RegionObserver) env.getInstance()).postGetClosestRowBefore(ctx, row, family, result);
            } catch (Throwable e) {
                handleCoprocessorThrowable(env, e);
            } finally {
                currentThread.setContextClassLoader(cl);
            }
            if (ctx.shouldComplete()) {
                break;
            }
        }
    }
}