Package ru.vassaev.core.thread

Examples of ru.vassaev.core.thread.Process


  }

  private void process_server() throws IOException {
    while (true) {
      Socket s = ss.accept();
      Process prc = prcs.occupy();
      prc.setCallBackOnEndProcess(finish);
      System.out.println("Created link " + Sockets.getNameLink(s));
      prc.setTarget(new Target());
      prc.start(s);
     
    }
  }
View Full Code Here


  }

  private void process_client() throws UnknownHostException, IOException {
    Socket s = new Socket(host, localport);
    System.out.println("++++3+++PRCPOOL.BusySize = " + prcs.getBusySize());
    Process prc = prcs.occupy();
    prc.setCallBackOnEndProcess(finish);
    System.out.println("Created link " + Sockets.getNameLink(s));
    prc.setTarget(new Target());
    prc.start(s);
  }
View Full Code Here

          }
        } catch (SysException e1) {
          e1.printStackTrace();
        }
        */
        Process tr;
        // Создать поток обработки
        tr = prcs.occupy();
        // старт обработки;
        try {
          SingleProccesor target = new SingleProccesor(msg, this);
          tr.setTarget(target);
          tr.start();
        } catch (RuntimeException e) {
          prcs.free(tr);
          freeMsg(msg);
          e.printStackTrace();
        } catch (SysException e) {
View Full Code Here

      }
      msg = poolmsg.getFactory().create();
      poolmsg.getFactory().initialization(msg);
      ReadMsg rm = new ReadMsg(msg);
      ByteMsg result;
      Process prc = null;
      try {
        synchronized(sync) {
          prc = prcs.occupyWait();
          prc.setTarget(rm);
          prc.setName("READ_MSG_" + cntx.id_task);
          prc.start(s.getInputStream());
          sync.wait(timeout);
          result = rm.getResultMsg();
          if (result == null) {
            prc.kill();
            throw new TaskException(State.DONE_TOUT, "Timeout of receiving message");
          }
        }
      } finally {
        prcs.free(prc);
View Full Code Here

        server = HttpServer.create(new InetSocketAddress(port), 0);
      server.createContext(path, new XMLHttpHandler(cntx));
      server.setExecutor(executor);
      server.start();

      Process prc = Process.currentProcess();
      while (true) {
        try {
          if (prc.isWillBreak())
            return State.BROKEN;
          State st = cntx.ta.getState(cntx.id_task);
          if (st.getType().equals(TypeOfState.LAST))
            return st;
          if (st.equals(State.BREAKING))
View Full Code Here

    public void handle(HttpExchange httpExchange) throws IOException {
      Process.currentProcess().setParent(main_thread);
      try {
        InetSocketAddress ra = httpExchange.getRemoteAddress();
        Process cp = Process.currentProcess();
        Map<String, Object> prms = new HashMap<String, Object>();

        setPrms(cp, prms, "protocol", httpExchange.getProtocol());
        setPrms(cp, prms, "method", httpExchange.getRequestMethod());
        // setPrms(cp, prms, "remote.hostName", ra.getHostName()); !!!
        // TODO
        setPrms(cp, prms, "remote.port", ra.getPort());
        setPrms(cp, prms, "remote.ip", ra.getAddress().getHostAddress());
        setPrms(cp, prms, "query.path", httpExchange.getRequestURI()
            .getPath());
        String query = httpExchange.getRequestURI().getQuery();
        if (query != null) {
          String[] eqs = Strings.parseXVSLine(query, '/', '&');
          for (int i = 0; i < eqs.length; i++) {
            String eq = eqs[i];
            int j = eq.indexOf('=');
            if (j >= 0)
              setPrms(cp, prms, "get." + eq.substring(0, j),
                  eq.substring(j + 1));

          }
          setPrms(cp, prms, "query", query);
        }
        String ct = null;
        int cl = 0;
        for (Map.Entry<String, List<String>> e : httpExchange
            .getRequestHeaders().entrySet()) {
          List<String> v = e.getValue();
          String k = e.getKey();
          if ("Content-type".equals(k))
            ct = v.toString();
          else if ("Content-length".equals(k))
            cl = Strings.parseInteger(v.get(0));
          setPrms(cp, prms, "hdrs." + k, v.toString());
        }
        InputStream is = httpExchange.getRequestBody();
        Process tprc = executor.occupyOrNew();
        OutputByteBuffer obb = null;
        try {
          long read_wait = Strings.parseIntegerNvl(
              cntx.getPrmByFullName("read_wait"), 10000);// !!!
          TimeoutInputStream tis = new TimeoutInputStream(tprc);
          tis.setTimeout(read_wait);
          tis.setLimitRead(cl);
          tis.setCircleBufferSize(50);
          tis.startReadSource(is);
          obb = (cl <= 0) ? Process.getByteBuffer(8000, tis)
              : Process.getByteBuffer(8000, tis, cl);
        } catch (SysException e) {
          e.printStackTrace();
          tprc.interrupt();
          throw new SysRuntimeException(e);
        } finally {
          executor.free(tprc);
        }
        try {
View Full Code Here

TOP

Related Classes of ru.vassaev.core.thread.Process

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.