Package com.caucho.vfs

Examples of com.caucho.vfs.WriteStream


      Thread thread = Thread.currentThread();
      thread.setName("watchdog-process-log-" + _pid + "-" + _id);

      thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
     
      WriteStream out = _out;

      try {
        int len;

        byte []data = new byte[4096];

        while ((len = _is.read(data, 0, data.length)) > 0) {
          out.write(data, 0, len);
          out.flush();
        }
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);
      } finally {
        try {
          if (! _watchdog.isConsole()) {
            synchronized (out) {
              out.close();
            }
          }
        } catch (IOException e) {
        }
View Full Code Here


    try {
      os = new TempOutputStream();

      Sha256OutputStream mOut = new Sha256OutputStream(os);

      WriteStream out = Vfs.openWrite(mOut);

      out.writeStream(is);

      out.close();

      mOut.close();

      byte[] hash = mOut.getDigest();
View Full Code Here

    TempOutputStream os = null;

    try {
      os = new TempOutputStream();

      WriteStream out = Vfs.openWrite(os);

      if (! getDataBacking().loadData(valueKey, out)) {
        if (! loadClusterData(valueKey, flags)) {
          log.warning(this + " cannot load data for " + valueKey + " from triad");
         
          out.close();
       
          return null;
        }

        if (! getDataBacking().loadData(valueKey, out)) {
          out.close();
       
          return null;
        }
      }

      out.close();

      InputStream is = os.openInputStream();

      try {
        InflaterInputStream gzIn = new InflaterInputStream(is);
View Full Code Here

    throws IOException
  {
    if (valueKey == null || valueKey == HashManager.NULL)
      throw new IllegalStateException(L.l("readData may not be called with a null value"));

    WriteStream out = Vfs.openWrite(os);

    try {
      if (getDataBacking().loadData(valueKey, out))
        return true;

      if (! loadClusterData(valueKey, flags)) {
        log.warning(this + " cannot load cluster value " + valueKey);

        // XXX: error?  since we have the value key, it should exist

        return false;
      }

      if (getDataBacking().loadData(valueKey, out)) {
        return true;
      }

      log.warning(this + " unexpected load failure in readValue " + valueKey);

      // XXX: error?  since we have the value key, it should exist

      return false;
    } finally {
      out.close();
    }
  }
View Full Code Here

  private boolean scanHeaders()
    throws IOException
  {
    boolean isLoggable = log.isLoggable(Level.FINE);
    ReadStream is = getRawRead();
    WriteStream os = getRawWrite();
    CharBuffer cb = getCharBuffer();
    int code;
    int len;

    while (true) {
      _rawWrite.flush();

      code = is.read();

      Server server = getServer();
      if (server == null || server.isDestroyed()) {
        log.fine(dbgId() + " request after server close");
        killKeepalive("after server close");
        return false;
      }

      switch (code) {
      case -1:
        if (isLoggable)
          log.fine(dbgId() + "r: end of file");
        _filter.setClientClosed(true);
        killKeepalive("hmux end of file");
        return false;

      case HMUX_CHANNEL:
        int channel = (is.read() << 8) + is.read();

        if (isLoggable)
          log.fine(dbgId() + "channel-r " + channel);
        break;

      case HMUX_YIELD:
        if (log.isLoggable(Level.FINER))
          log.finer(dbgId() + (char) code + "-r: yield");

        os.write(HMUX_ACK);
        os.write(0);
        os.write(0);
        os.flush();
        break;

      case HMUX_QUIT:
        if (isLoggable)
          log.fine(dbgId() + (char) code + "-r: end of request");
View Full Code Here

  }

  void writeFlush()
    throws IOException
  {
    WriteStream out = _rawWrite;

    synchronized (out) {
      out.flush();
    }
  }
View Full Code Here

  }

  protected void flushNextBuffer()
    throws IOException
  {
    WriteStream next = _rawWrite;

    if (log.isLoggable(Level.FINE))
      log.fine(dbgId() + "flush()");

    int startOffset = _bufferStartOffset;

    if (startOffset > 0) {
      _bufferStartOffset = 0;
      if (startOffset == next.getBufferOffset()) {
        next.setBufferOffset(startOffset - 3);
      }
      else {
        // illegal state because the data isn't filled
        throw new IllegalStateException();
      }
View Full Code Here

  }

  protected void writeTail()
    throws IOException
  {
    WriteStream next = _rawWrite;

    int offset = next.getBufferOffset();

    offset = fillDataBuffer(offset);

    // server/26a6
    // Use setBufferOffset because nextBuffer would
    // force an early flush
    next.setBufferOffset(offset);
  }
View Full Code Here

  void writeString(int code, String value)
    throws IOException
  {
    int len = value.length();

    WriteStream os = _rawWrite;

    os.write(code);
    os.write(len >> 8);
    os.write(len);
    os.print(value);

    if (log.isLoggable(Level.FINE))
      log.fine(dbgId() + (char)code + "-w " + value);
  }
View Full Code Here

  void writeString(int code, CharBuffer cb)
    throws IOException
  {
    int len = cb.length();

    WriteStream os = _rawWrite;

    os.write(code);
    os.write(len >> 8);
    os.write(len);
    os.print(cb.getBuffer(), 0, len);

    if (log.isLoggable(Level.FINE))
      log.fine(dbgId() + (char)code + "-w: " + cb);
  }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.WriteStream

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.