Instruct the EE to execute an Export poll and/or ack action. Poll response
data is returned in the usual results buffer, length preceded as usual.
508112
@Override
    public void exportAction(boolean syncAction,
            long uso, long seqNo, int partitionId, String streamName)
    {
        if (EXPORT_LOG.isDebugEnabled()) {
            EXPORT_LOG.debug("exportAction on partition " + partitionId + " syncAction: " + syncAction + ", uso: " +
                    uso + ", seqNo: " + seqNo + ", streamName: " + streamName);
        }
        //Clear is destructive, do it before the native call
        m_nextDeserializer.clear();
        long retval = nativeExportAction(pointer,
                                         syncAction, uso, seqNo, getStringBytes(streamName));
        if (retval < 0) {
            LOG.info("exportAction failed.  syncAction: " + syncAction + ", uso: " +
                    uso + ", seqNo: " + seqNo + ", partitionId: " + partitionId +
                    ", streamName: " + streamName);
        }
    }
1042532
def handle_response(self, item_session: ItemSession) -> Actions:
        '''
        '''
        action = self.consult_response_hook(item_session)

        if action == Actions.RETRY:
            item_session.set_status(Status.error)
        elif action == Actions.FINISH:
            item_session.set_status(Status.done)
        elif action == Actions.STOP:
            raise HookStop('Script requested immediate stop.')

        return action
206885
def do_execute(self):
        
        result = None
        cont = self.input.payload
        name = str(self.resolve_option("value"))
        value = cont.get(name)
        switch = bool(self.resolve_option("switch"))
        if switch:
            if self.first_active is not None:
                self.first_active.input = self.input
                result = self._director.execute()
            if result is None:
                self._output.append(Token(value))
        else:
            if self.first_active is not None:
                self.first_active.input = Token(value)
                result = self._director.execute()
            if result is None:
                self._output.append(self.input)
        return result
713063
public void dumpResponse(Map<String, Object> result) {
        if(!dumpConfig.isResponseEnabled()) { return; }

        Map<String, Object> responseResult = new LinkedHashMap<>();
        for(IResponseDumpable dumper: dumperFactory.createResponseDumpers(dumpConfig, exchange)) {
            if (dumper.isApplicableForResponse()) {
                dumper.dumpResponse(responseResult);
            }
        }
        result.put(DumpConstants.RESPONSE, responseResult);
    }
817945
def _handle_api_result(result: Optional[Dict[str, Any]]) -> Any:
    
    if isinstance(result, dict):
        if result.get('status') == 'failed':
            raise ActionFailed(retcode=result.get('retcode'))
        return result.get('data')
646710
def respond_to_action_responses
      if !respond_to_performed? && action_responses.any?
        respond_to do |responder|
          action_responses.each {|response| instance_exec(responder, &response) }
        end
      end
    end
613544
def _handle_response(self, request: Request, response: Response) -> Actions:
        '''
        '''
        self._item_session.update_record_value(status_code=response.status_code)

        if self._web_client_session.redirect_tracker.is_redirect() or \
                self._web_client_session.loop_type() == LoopType.authentication:
            self._file_writer_session.discard_document(response)

            return self._result_rule.handle_intermediate_response(
                self._item_session
            )
        elif (response.status_code in self._document_codes
              or self._processor.fetch_params.content_on_error):
            filename = self._file_writer_session.save_document(response)

            self._processing_rule.scrape_document(self._item_session)

            return self._result_rule.handle_document(
                self._item_session, filename
            )
        elif response.status_code in self._no_document_codes:
            self._file_writer_session.discard_document(response)

            return self._result_rule.handle_no_document(
                self._item_session
            )
        else:
            self._file_writer_session.discard_document(response)

            return self._result_rule.handle_document_error(
                self._item_session
            )
1003175
def _BuildResponse(self,
                     status,
                     rendered_data,
                     method_name=None,
                     headers=None,
                     content_length=None,
                     token=None,
                     no_audit_log=False):
    """"""

    # To avoid IE content sniffing problems, escape the tags. Otherwise somebody
    # may send a link with malicious payload that will be opened in IE (which
    # does content sniffing and doesn't respect Content-Disposition header) and
    # IE will treat the document as html and executre arbitrary JS that was
    # passed with the payload.
    str_data = json.Dump(
        rendered_data, encoder=JSONEncoderWithRDFPrimitivesSupport)
    # XSSI protection and tags escaping
    rendered_data = ")]}'\n" + str_data.replace("<", r"\u003c").replace(
        ">", r"\u003e")

    response = werkzeug_wrappers.Response(
        rendered_data,
        status=status,
        content_type="application/json; charset=utf-8")
    response.headers[
        "Content-Disposition"] = "attachment; filename=response.json"
    response.headers["X-Content-Type-Options"] = "nosniff"

    if token and token.reason:
      response.headers["X-GRR-Reason"] = utils.SmartStr(token.reason)
    if method_name:
      response.headers["X-API-Method"] = method_name
    if no_audit_log:
      response.headers["X-No-Log"] = "True"

    for key, value in iteritems(headers or {}):
      response.headers[key] = value

    if content_length is not None:
      response.content_length = content_length

    return response
670288
@SuppressWarnings("unchecked")
    @Override
    public E poll() {
        // local load of field to avoid repeated loads after volatile reads
        final AtomicReferenceArray<E> buffer = consumerBuffer;
        final long index = lpConsumerIndex();
        final long mask = consumerMask;
        final int offset = calcElementOffset(index, mask);
        // LoadLoad
        final Object e = lvElement(buffer, offset);
        boolean isNextBuffer = e == JUMP;
        if (null != e && !isNextBuffer) {
            // this ensures correctness on 32bit platforms
            soConsumerIndex(index + 1);
            soElement(buffer, offset, null);
            return (E) e;
        } else if (isNextBuffer) {
            return newBufferPoll(buffer, index);
        }
        return null;
    }
1289228
void poll_cmd(final WorkItem to_do) throws DevFailed {
	Util.out5.println("poll_cmd  --> Time = " + now.tv_sec + "," + now.tv_usec + " Dev name = "
		+ to_do.dev.get_name() + ", Cmd name = " + to_do.name);

	Any argout;
	final TimeVal before_cmd = new TimeVal();
	final TimeVal after_cmd = new TimeVal();
	TimeVal needed_time;
	try {
	    long ctm = System.currentTimeMillis();
	    before_cmd.tv_sec = (int) (ctm / 1000);
	    before_cmd.tv_usec = (int) (ctm - 1000 * before_cmd.tv_sec) * 1000;
	    before_cmd.tv_sec = before_cmd.tv_sec - Tango_DELTA_T;

	    // Execute the command
	    final Any in_any = fr.esrf.TangoApi.ApiUtil.get_orb().create_any();
	    argout = to_do.dev.command_inout(to_do.name, in_any);

	    ctm = System.currentTimeMillis();
	    after_cmd.tv_sec = (int) (ctm / 1000);
	    after_cmd.tv_usec = (int) (ctm - 1000 * after_cmd.tv_sec) * 1000;
	    after_cmd.tv_sec = after_cmd.tv_sec - Tango_DELTA_T;

	    needed_time = time_diff(before_cmd, after_cmd);

	    to_do.dev.get_dev_monitor().get_monitor();
	    final PollObj poll_obj = to_do.dev.get_polled_obj_by_type_name(to_do.type, to_do.name);
	    poll_obj.insert_data(argout, before_cmd, needed_time);
	    to_do.dev.get_dev_monitor().rel_monitor();
	} catch (final DevFailed e) {
	    final long ctm = System.currentTimeMillis();
	    after_cmd.tv_sec = (int) (ctm / 1000);
	    after_cmd.tv_usec = (int) (ctm - 1000 * after_cmd.tv_sec) * 1000;
	    after_cmd.tv_sec = after_cmd.tv_sec - Tango_DELTA_T;

	    needed_time = time_diff(before_cmd, after_cmd);

	    // to_do.dev.get_dev_monitor().get_monitor();
	    try {
		final PollObj poll_obj = to_do.dev.get_polled_obj_by_type_name(to_do.type,
			to_do.name);
		poll_obj.insert_except(e, before_cmd, needed_time);
	    } catch (final DevFailed ex) {
	    }
	    to_do.dev.get_dev_monitor().rel_monitor();
	}
    }
796059
def post_execute(self):
        
        result = super(Transformer, self).post_execute()
        if result is None:
            self._input = None
        return result
1131719
def _poll(self, future):
        """"""

        if future._poll_backoff is None:
            # on first poll, start with minimal back-off
            future._poll_backoff = self._POLL_BACKOFF_MIN

            # if we have ETA of results, schedule the first poll for then
            if future.eta_min and self._is_clock_diff_acceptable(future):
                at = datetime_to_timestamp(future.eta_min)
                _LOGGER.debug("Response ETA indicated and local clock reliable. "
                              "Scheduling first polling at +%.2f sec", at - epochnow())
            else:
                at = time.time() + future._poll_backoff
                _LOGGER.debug("Response ETA not indicated, or local clock unreliable. "
                              "Scheduling first polling at +%.2f sec", at - epochnow())

        else:
            # update exponential poll back-off, clipped to a range
            future._poll_backoff = \
                max(self._POLL_BACKOFF_MIN,
                    min(future._poll_backoff * 2, self._POLL_BACKOFF_MAX))

            # for poll priority we use timestamp of next scheduled poll
            at = time.time() + future._poll_backoff

        now = utcnow()
        future_age = (now - future.time_created).total_seconds()
        _LOGGER.debug("Polling scheduled at %.2f with %.2f sec new back-off for: %s (future's age: %.2f sec)",
                      at, future._poll_backoff, future.id, future_age)

        # don't enqueue for next poll if polling_timeout is exceeded by then
        future_age_on_next_poll = future_age + (at - datetime_to_timestamp(now))
        if self.polling_timeout is not None and future_age_on_next_poll > self.polling_timeout:
            _LOGGER.debug("Polling timeout exceeded before next poll: %.2f sec > %.2f sec, aborting polling!",
                          future_age_on_next_poll, self.polling_timeout)
            raise PollingTimeout

        self._poll_queue.put((at, future))
1288170
private void cmdExecuteActionPerformed(java.awt.event.ActionEvent evt) {
		releaseResultset();
		try {
			if (selectedSource == null) {
				JOptionPane.showMessageDialog(this, "Please select data source first", "Error", JOptionPane.ERROR_MESSAGE);
			} else {
				OBDAProgressMonitor progMonitor = new OBDAProgressMonitor("Executing query...", getRootPane());
				CountDownLatch latch = new CountDownLatch(1);
				ExecuteSQLQueryAction action = new ExecuteSQLQueryAction(latch);
				progMonitor.addProgressListener(action);
				progMonitor.start();
				action.run();
				latch.await();
				progMonitor.stop();
				ResultSet set = action.getResult();
				if (set != null) {
					ResultSetTableModel model = new ResultSetTableModel(set);
					tblQueryResult.setModel(model);
					set.close();
				}
			}
		} catch (Exception e) {
			OptionPaneUtils.showPrettyMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
			log.error("Error while executing query.", e);
		}
	}
341092
def _poll(self):
        
        while True:
            self.poll_count += 1
            self._poll_action()
            if self.poll_complete:
                break
            time.sleep(self.poll_interval_s)
            self._poll_update_interval()
360172
def execute(self, return_results=True):
        '''
        
        '''
        if self.results:
            return self.results if return_results else None

        self.execute_raw()

        if self._raw_results_only:
            self.results = self.raw_results
        else:
            self.map_results()

        if return_results:
            return self.results
313062
protected void doAction(final HttpServletRequest req, final HttpServletResponse resp, String action) {
        // Read the request.
        ApiRequest srequest;
        try {
            srequest = readRequest(req);
            srequest.setType(action);
        } catch (Exception e) {
            writeError(null, resp, e);
            return;
        }

        final CountDownLatch latch = new CountDownLatch(1);
        final ApiRequest finalRequest = srequest;

        // Now execute the request via the apiman engine
        IApiRequestExecutor executor = getEngine().executor(srequest, new IAsyncResultHandler<IEngineResult>() {
            @Override
            public void handle(IAsyncResult<IEngineResult> asyncResult) {
                if (asyncResult.isSuccess()) {
                    IEngineResult engineResult = asyncResult.getResult();
                    if (engineResult.isResponse()) {
                        try {
                            writeResponse(resp, engineResult.getApiResponse());
                            final ServletOutputStream outputStream = resp.getOutputStream();
                            engineResult.bodyHandler(new IAsyncHandler<IApimanBuffer>() {
                                @Override
                                public void handle(IApimanBuffer chunk) {
                                    try {
                                        if (chunk instanceof ByteBuffer) {
                                            byte [] buffer = (byte []) chunk.getNativeBuffer();
                                            outputStream.write(buffer, 0, chunk.length());
                                        } else {
                                            outputStream.write(chunk.getBytes());
                                        }
                                    } catch (IOException e) {
                                        // This will get caught by the API connector, which will abort the
                                        // connection to the back-end API.
                                        throw new RuntimeException(e);
                                    }
                                }
                            });
                            engineResult.endHandler(new IAsyncHandler<Void>() {
                                @Override
                                public void handle(Void result) {
                                    try {
                                        resp.flushBuffer();
                                    } catch (IOException e) {
                                        // This will get caught by the API connector, which will abort the
                                        // connection to the back-end API.
                                        throw new RuntimeException(e);
                                    } finally {
                                        latch.countDown();
                                    }
                                }
                            });
                        } catch (IOException e) {
                            // this would mean we couldn't get the output stream from the response, so we
                            // need to abort the engine result (which will let the back-end connection
                            // close down).
                            engineResult.abort(e);
                            latch.countDown();
                            throw new RuntimeException(e);
                        }
                    } else {
                        writeFailure(finalRequest, resp, engineResult.getPolicyFailure());
                        latch.countDown();
                    }
                } else {
                    writeError(finalRequest, resp, asyncResult.getError());
                    latch.countDown();
                }
            }
        });
        executor.streamHandler(new IAsyncHandler<ISignalWriteStream>() {
            @Override
            public void handle(ISignalWriteStream connectorStream) {
                try {
                    final InputStream is = req.getInputStream();
                    ByteBuffer buffer = new ByteBuffer(2048);
                    int numBytes = buffer.readFrom(is);
                    while (numBytes != -1) {
                        connectorStream.write(buffer);
                        numBytes = buffer.readFrom(is);
                    }
                    connectorStream.end();
                } catch (Throwable e) {
                    connectorStream.abort(e);
                }
            }
        });
        executor.execute();
        try { latch.await(); } catch (InterruptedException e) { }
    }
772995
def send_response(self, transaction):
        
        if transaction.cacheHit is False:
            """
            handling response based on the code
            """
            logger.debug("handling response")
            self._handle_response(transaction)
        return transaction