public static String getRealClientIpAddr(final ResourceContext context) { // If some upstream device added an X-Forwarded-For header // use it for the client ip // This will support scenarios where load balancers or gateways // front the Azkaban web server and a changing Ip address invalidates // the session final Map<String, String> headers = context.getRequestHeaders(); final WebUtils utils = new WebUtils(); return utils.getRealClientIpAddr(headers, (String) context.getRawRequestContext().getLocalAttr("REMOTE_ADDR")); } }
private void addListenerFromContext(Task<Object> task, ResourceContext resourceContext) { @SuppressWarnings("unchecked") PromiseListener<Object> listener = (PromiseListener<Object>) resourceContext.getRawRequestContext().getLocalAttr(ATTRIBUTE_PROMISE_LISTENER); if (listener != null) { task.addListener(new PromiseListener<Object>() { @Override public void onResolved(Promise<Object> promise) { // ParSeq engine doesn't guarantee that the Promise passed in is the task object this listener attached to. // The original listener's business logic may depend on the task. We need this intermediate listener to relay // the task to the original listener. listener.onResolved(task); } }); } }