Runs the IO call
@param string Type of call
772136
function() {
	var mythis = this;
	this.req.onload = function() {
		if (mythis.config.success) {
			var response = new NWTIOResponse(mythis.req);
			mythis.config.success(response);
		}
	};

	this.req.onerror = function() {
		if (mythis.config.failure) {
			var response = new NWTIOResponse(mythis.req);
			mythis.config.failure(response);
		}
	};

	this.req.send(this.ioData ? this.ioData : null);
	return this;
}
96280
function callHook($type,$subtype = false)
    {
        if ($subtype and isset($this->hooks[$type][$subtype]))
        {
            foreach ($this->hooks[$type][$subtype] as $f)
            {
                if (!is_callable($f))
                {
                    trigger_error("SwooleFramework: hook function[$f] is not callable.");
                    continue;
                }
                $f();
            }
        }
        elseif (isset($this->hooks[$type]))
        {
            foreach ($this->hooks[$type] as $f)
            {
                //has subtype
                if (is_array($f) and !is_callable($f))
                {
                    foreach ($f as $subtype => $ff)
                    {
                        if (!is_callable($ff))
                        {
                            trigger_error("SwooleFramework: hook function[$ff] is not callable.");
                            continue;
                        }
                        $ff();
                    }
                } else {
                    if (!is_callable($f))
                    {
                        trigger_error("SwooleFramework: hook function[$f] is not callable.");
                        continue;
                    }
                    $f();
                }
            }
        }
    }
1240084
public function run(InputInterface $input = null, OutputInterface $output = null)
	{
		try
		{
			parent::run($input, $output);
		}
		catch (\Exception $e)
		{
			if (null === $output) {
				$output = new ConsoleOutput();
			}
			$message = array(
				$this->getLongVersion(),
				'',
				$e->getMessage(),
				''
			);
			$output->writeln($message);
		}
	}
809083
public function write($text, $type = 'stdout')
    {
        if (in_array($type, ['stdout', 'stderr']) && ! empty($text)) {
            $f = fopen('php://' . $type, 'w');

            if (is_array($text)) {
                $text = json_encode($text);
            }

            fwrite($f, $text);
            fclose($f);
        }
    }
687762
public function run($request = null)
    {
        $response = $this->dispatch($request);

        if ($response instanceof SymfonyResponse) {
            $response->send();
        } else {
            echo (string) $response;
        }

        if (count($this->middleware) > 0) {
            $this->callTerminableMiddleware($response);
        }
    }
870086
private void run(Class<?> type, Object val, int limit) {
        int initial;

        initial = dest.getSize();

        if (val == null) {
            if (type.isPrimitive()) {
                throw new IllegalArgumentException("primitive null");
            }
            // null is not a string, but otherwise it is  ambiguous
            dest.emit(LDC, (String) null);
        } else if (val instanceof String) {
            dest.emit(LDC, (String) val);
        } else if (type.isPrimitive()) {
            primitive(ClassRef.findComponent(type).id, val);
        } else if (type.isArray()) {
            array(type, val, limit);
        } else {
            object(type, val, limit);
        }

        if (dest.getSize() - initial > limit) {
            throw new IllegalStateException(
                    "limit:" + limit + " used:" + (dest.getSize() - initial) + " val:" + val);
        }
    }
201148
private function load($type)
    {
        $index = $this->$type;
        if ($index) {
            return;
        }

        $cache = $this->di->get("cache");
        $key = $cache->createKey(__CLASS__, $type);
        $index = $cache->get($key);

        if (is_null($index) || $this->ignoreCache) {
            $createMethod = "create$type";
            $index = $this->$createMethod();
            $cache->put($key, $index);
        }

        $this->$type = $index;
    }
481920
def _run_callbacks(kind, *args) #:nodoc:
      options = args.last # Last callback arg MUST be a Hash

      send("_#{kind}").each do |callback, conditions|
        invalid = conditions.find do |key, value|
          value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
        end

        callback.call(*args) unless invalid
      end
    end
792768
public function run(IInput $input, IOutput $output, IConsole $console) {
        if ($input->getOption('--passthrough')) {
            $console->setCatchErrors(false);
        }
    }
940065
public function run(InputInterface $input, OutputInterface $output)
    {
        $this->setInput($input);
        $this->setOutput($output);

        return parent::run($input, $output);
    }
1292549
public function setType( $type )
	{
		if ( $type == $this->getType() ) { return; }

		$this->_checkType( $type );

		$this->_values['type'] = (string) $type;
		$this->setModified();
	}
1045338
protected function call( $type, $params ) {
		if ( !isset( $this->callbacks[$type] ) ) {
			return;
		}
		foreach ( $this->callbacks[$type] as $callback ) {
			if ( is_callable( $callback ) ) {
				call_user_func_array( $callback, $params );
			}
		}
	}
78279
public function run() {
		$isPost = $_SERVER["REQUEST_METHOD"] == 'POST';
		$src    = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
		if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
			// for support IE XDomainRequest()
			$parts = explode('&', $rawPostData);
			foreach($parts as $part) {
				list($key, $value) = array_pad(explode('=', $part), 2, '');
				$src[$key] = rawurldecode($value);
			}
			$_POST = $this->input_filter($src);
			$_REQUEST = $this->input_filter(array_merge_recursive($src, $_REQUEST));
		}
		$cmd    = isset($src['cmd']) ? $src['cmd'] : '';
		$args   = array();
		
		if (!function_exists('json_encode')) {
			$error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
			$this->output(array('error' => '{"error":["'.implode('","', $error).'"]}', 'raw' => true));
		}
		
		if (!$this->elFinder->loaded()) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors));
		}
		
		// telepat_mode: on
		if (!$cmd && $isPost) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html'));
		}
		// telepat_mode: off
		
		if (!$this->elFinder->commandExists($cmd)) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)));
		}
		
		// collect required arguments to exec command
		foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
			$arg = $name == 'FILES' 
				? $_FILES 
				: (isset($src[$name]) ? $src[$name] : '');
				
			if (!is_array($arg)) {
				$arg = trim($arg);
			}
			if ($req && (!isset($arg) || $arg === '')) {
				$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)));
			}
			$args[$name] = $arg;
		}
		
		$args['debug'] = isset($src['debug']) ? !!$src['debug'] : false;
		
		$this->output($this->elFinder->exec($cmd, $this->input_filter($args)));
	}
1137685
@Override
  public void run()
  {
    try {
      while (! isClosed() && _is.read() > 0 && _in.readMessage(_is)) {
        ServiceRef.flushOutbox();
      }
    } catch (EOFException e) {
      log.finer(this + " end of file");
      
      if (log.isLoggable(Level.ALL)) {
        log.log(Level.ALL, e.toString(), e);
      }
    } catch (SocketException e) {
      e.printStackTrace();
      log.finer(this + " socket closed:" + e);
      
      if (log.isLoggable(Level.ALL)) {
        log.log(Level.ALL, e.toString(), e);
      }
    } catch (IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    } catch (Throwable e) {
      e.printStackTrace();
      throw e;
    } finally {
      close();
    }
  }
1047006
public void run() {
    DataInputStream in=null; 
    byte op = -1;
    int opsProcessed = 0;
    try {
      s.setTcpNoDelay(true);
      s.setSoTimeout(datanode.socketTimeout*5);

      in = new DataInputStream(
          new BufferedInputStream(NetUtils.getInputStream(s), 
                                  SMALL_BUFFER_SIZE));
      int stdTimeout = s.getSoTimeout();
      
      // We process requests in a loop, and stay around for a short timeout.
      // This optimistic behavior allows the other end to reuse connections.
      // Setting keepalive timeout to 0 to disable this behavior.
      
      do {
        long startNanoTime = System.nanoTime();
        long startTime = DataNode.now(); 
        
        VersionAndOpcode versionAndOpcode = new VersionAndOpcode();
        
        try {
          if (opsProcessed != 0) {
            assert socketKeepaliveTimeout > 0;
            s.setSoTimeout(socketKeepaliveTimeout);
          }
          versionAndOpcode.readFields(in);
          op = versionAndOpcode.getOpCode();
        } catch (InterruptedIOException ignored) {
          // Time out while we wait for client rpc
          break;
        } catch (IOException err) {
          // Since we optimistically expect the next op, it's quite normal to get EOF here.
          if (opsProcessed > 0 && 
              (err instanceof EOFException || err instanceof ClosedChannelException)) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Cached " + s.toString() + " closing after " + opsProcessed + " ops");
            }
          } else {
            throw err;
          }
          break;
        }
        
        // restore normal timeout.
        if (opsProcessed != 0) {
          s.setSoTimeout(stdTimeout);
        }

        boolean local = s.getInetAddress().equals(s.getLocalAddress());
        updateCurrentThreadName("waiting for operation");

        // Make sure the xciver count is not exceeded
        int curXceiverCount = datanode.getXceiverCount();
        if (curXceiverCount > dataXceiverServer.maxXceiverCount) {
          datanode.myMetrics.xceiverCountExceeded.inc();
          throw new IOException("xceiverCount " + curXceiverCount
              + " exceeds the limit of concurrent xcievers "
              + dataXceiverServer.maxXceiverCount);
        }
        
        switch ( op ) {
        case DataTransferProtocol.OP_READ_BLOCK:
          readBlock( in, versionAndOpcode , startNanoTime);
          datanode.myMetrics.readBlockOp.inc(DataNode.now() - startTime);
          if (local)
            datanode.myMetrics.readsFromLocalClient.inc();
          else
            datanode.myMetrics.readsFromRemoteClient.inc();
          break;
        case DataTransferProtocol.OP_READ_BLOCK_ACCELERATOR:
          readBlockAccelerator(in, versionAndOpcode);
          datanode.myMetrics.readBlockOp.inc(DataNode.now() - startTime);
          if (local)
            datanode.myMetrics.readsFromLocalClient.inc();
          else
            datanode.myMetrics.readsFromRemoteClient.inc();
          break;
        case DataTransferProtocol.OP_WRITE_BLOCK:
          writeBlock( in, versionAndOpcode );
          datanode.myMetrics.writeBlockOp.inc(DataNode.now() - startTime);
          if (local)
            datanode.myMetrics.writesFromLocalClient.inc();
          else
            datanode.myMetrics.writesFromRemoteClient.inc();
          break;
        case DataTransferProtocol.OP_READ_METADATA:
          readMetadata(in, versionAndOpcode);
          datanode.myMetrics.readMetadataOp.inc(DataNode.now() - startTime);
          break;
        case DataTransferProtocol.OP_REPLACE_BLOCK: // for balancing purpose; send to a destination
          replaceBlock(in, versionAndOpcode);
          datanode.myMetrics.replaceBlockOp.inc(DataNode.now() - startTime);
          break;
        case DataTransferProtocol.OP_COPY_BLOCK:
          // for balancing purpose; send to a proxy source
          copyBlock(in, versionAndOpcode);
          datanode.myMetrics.copyBlockOp.inc(DataNode.now() - startTime);
          break;
        case DataTransferProtocol.OP_BLOCK_CHECKSUM: //get the checksum of a block
          getBlockChecksum(in, versionAndOpcode);
          datanode.myMetrics.blockChecksumOp.inc(DataNode.now() - startTime);
          break;
        case DataTransferProtocol.OP_BLOCK_CRC: //get the checksum of a block
          getBlockCrc(in, versionAndOpcode);
          datanode.myMetrics.blockChecksumOp.inc(DataNode.now() - startTime);
          break;
        case DataTransferProtocol.OP_APPEND_BLOCK:
          appendBlock(in, versionAndOpcode);
          datanode.myMetrics.appendBlockOp.inc(DataNode.now() - startTime);
          if (local)
            datanode.myMetrics.writesFromLocalClient.inc();
          else
            datanode.myMetrics.writesFromRemoteClient.inc();
          break;
        default:
          throw new IOException("Unknown opcode " + op + " in data stream");
        }
        
        ++ opsProcessed;
        
        if (versionAndOpcode.getDataTransferVersion() < 
            DataTransferProtocol.READ_REUSE_CONNECTION_VERSION ||
            !reuseConnection) {
          break;
        }
      } while (s.isConnected() && socketKeepaliveTimeout > 0);
    } catch (Throwable t) {
      if (op == DataTransferProtocol.OP_READ_BLOCK && t instanceof SocketTimeoutException) {
        // Ignore SocketTimeoutException for reading.
        // This usually means that the client who's reading data from the DataNode has exited.
        if (ClientTraceLog.isInfoEnabled()) {
          ClientTraceLog.info(datanode.getDatanodeInfo() + ":DataXceiver" + " (IGNORED) "
              + StringUtils.stringifyException(t));
        }
      } else {
        if (op == DataTransferProtocol.OP_READ_BLOCK
            || op == DataTransferProtocol.OP_READ_BLOCK_ACCELERATOR) {
          datanode.myMetrics.blockReadFailures.inc();
        }
        datanode.myMetrics.opFailures.inc();
        LOG.error(datanode.getDatanodeInfo() + ":DataXceiver, at " + 
                  s.toString(),t);
      }
    } finally {
      LOG.debug(datanode.getDatanodeInfo() + ":Number of active connections is: "
                               + datanode.getXceiverCount());
      updateCurrentThreadName("Cleaning up");
      IOUtils.closeStream(in);
      IOUtils.closeSocket(s);
      dataXceiverServer.childSockets.remove(s);
    }
  }
1136505
public void run(String line, DispatchCallback callback) {
    String filename;
    if (line.length() == "run".length()
        || (filename =
            sqlLine.dequote(line.substring("run".length() + 1))) == null) {
      sqlLine.error("Usage: run <file name>");
      callback.setToFailure();
      return;
    }
    List<String> cmds = new LinkedList<>();

    try {
      final Parser parser = sqlLine.getLineReader().getParser();
      try (BufferedReader reader = new BufferedReader(
          new InputStreamReader(
              new FileInputStream(expand(filename)), StandardCharsets.UTF_8))) {
        // ### NOTE: fix for sf.net bug 879427
        final StringBuilder cmd = new StringBuilder();
        boolean needsContinuation;
        for (;;) {
          final String scriptLine = reader.readLine();
          if (scriptLine == null) {
            break;
          }
          // we're continuing an existing command
          cmd.append(" \n");
          cmd.append(scriptLine);

          try {
            needsContinuation = false;
            parser.parse(cmd.toString(), cmd.length(),
                Parser.ParseContext.ACCEPT_LINE);
          } catch (EOFError e) {
            needsContinuation = true;
          }
          if (!needsContinuation && !cmd.toString().trim().isEmpty()) {
            cmds.add(maybeTrim(cmd.toString()));
            cmd.setLength(0);
          }
        }

        if (SqlLineParser.isSql(sqlLine, cmd.toString(),
            Parser.ParseContext.ACCEPT_LINE)) {
          // ### REVIEW: oops, somebody left the last command
          // unterminated; should we fix it for them or complain?
          // For now be nice and fix it.
          cmd.append(";");
          cmds.add(cmd.toString());
        }
      }

      // success only if all the commands were successful
      if (sqlLine.runCommands(cmds, callback) == cmds.size()) {
        callback.setToSuccess();
      } else {
        callback.setToFailure();
      }
    } catch (Exception e) {
      callback.setToFailure();
      sqlLine.error(e);
    }
  }
952851
protected function runCallbacks($type)
	{
		// make sure we have callbacks of this type
		if (array_key_exists($type, $this->callbacks))
		{
			// run the defined callbacks
			foreach ($this->callbacks[$type] as $callback)
			{
				// check if the callback is valid
				if (is_callable($callback))
				{
					// call the defined callback
					$result = call_user_func_array($callback, array(&$this));

					// and process the results. we need FileError instances only
					foreach ((array) $result as $entry)
					{
						if (is_object($entry) and $entry instanceOf FileError)
						{
							$this->errors[] = $entry;
						}
					}

					// update the status of this validation
					$this->isValid = empty($this->errors);
				}
			}
		}
	}