public Message preEndpointInvocation(final Service service, final String methodName, Message request) throws IOException { ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env : coprocessors) { if (env.getInstance() instanceof EndpointObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); request = ((EndpointObserver) env.getInstance()).preEndpointInvocation(ctx, service, methodName, request); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } return request; }
public void postEndpointInvocation(final Service service, final String methodName, final Message request, final Message.Builder responseBuilder) throws IOException { ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env : coprocessors) { if (env.getInstance() instanceof EndpointObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((EndpointObserver) env.getInstance()).postEndpointInvocation(ctx, service, methodName, request, responseBuilder); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public Message preEndpointInvocation(final Service service, final String methodName, Message request) throws IOException { return execOperationWithResult(request, coprocessors.isEmpty() ? null : new EndpointOperationWithResult<Message>() { @Override public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException { setResult(oserver.preEndpointInvocation(ctx, service, methodName, getResult())); } }); }
public void postEndpointInvocation(final Service service, final String methodName, final Message request, final Message.Builder responseBuilder) throws IOException { execOperation(coprocessors.isEmpty() ? null : new EndpointOperation() { @Override public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException { oserver.postEndpointInvocation(ctx, service, methodName, request, responseBuilder); } }); }
public Message preEndpointInvocation(final Service service, final String methodName, Message request) throws IOException { if (coprocEnvironments.isEmpty()) { return request; } return execOperationWithResult(new ObserverOperationWithResult<EndpointObserver, Message>(endpointObserverGetter, request) { @Override public Message call(EndpointObserver observer) throws IOException { return observer.preEndpointInvocation(this, service, methodName, getResult()); } }); }
public void postEndpointInvocation(final Service service, final String methodName, final Message request, final Message.Builder responseBuilder) throws IOException { execOperation(coprocEnvironments.isEmpty() ? null : new ObserverOperationWithoutResult<EndpointObserver>(endpointObserverGetter) { @Override public void call(EndpointObserver observer) throws IOException { observer.postEndpointInvocation(this, service, methodName, request, responseBuilder); } }); }
public abstract void call(EndpointObserver observer, ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException;
public boolean hasCall(Coprocessor observer) { return observer instanceof EndpointObserver; }
public void call(Coprocessor observer, ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException { call((EndpointObserver)observer, ctx); }
@Override public Optional<EndpointObserver> getEndpointObserver() { return Optional.of(this); }