Examples of CountingOutputStream


Examples of org.apache.oodt.commons.io.CountingOutputStream

    return new ByteArrayInputStream(baos.toByteArray());
  }

  public long sizeOf(Object obj) {
    try {
      CountingOutputStream c = new CountingOutputStream(new NullOutputStream());
      ObjectOutputStream stream = new ObjectOutputStream(c);
      stream.writeObject(obj);
      stream.close();
      return c.getBytesWritten();
    } catch (IOException ex) {
      throw new IllegalStateException("I/O exception " + ex.getClass().getName() + " can't happen, yet did: "
        + ex.getMessage());
    }
  }
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

                if (null != clusterResponse && null != failure) {

                    clusterHandler.getLogger().debug("Failed to write to ClusterResponse", failure);

                    try {
                        info.setOutputStream(new CountingOutputStream(rawOut));
                        oos = new ObjectOutputStream(info.getOutputStream());
                        clusterResponse.setMetaData(clientProtocol);
                        clusterResponse.writeExternal(oos);
                        oos.flush();
                    } catch (IOException ie) {
                        final String m = "Failed to write to ClusterResponse: " + ie.getMessage();
                        clusterHandler.getLogger().error(m, ie);
                        throw Exceptions.newIOException(m, ie);
                    }

                    throw failure;
                }
            }

            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            final Response response;
            switch (requestType) {
                case EJB_REQUEST:
                    response = processEjbRequest(ois, clientProtocol);
                    break;
                case JNDI_REQUEST:
                    response = processJndiRequest(ois, clientProtocol);
                    break;
                case AUTH_REQUEST:
                    response = processAuthRequest(ois, clientProtocol);
                    break;
                default:
                    logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    return;
            }

            try {
                info.setOutputStream(new CountingOutputStream(rawOut));

                final CountingOutputStream cos = info.getOutputStream();

                //Let client know we are using the requested protocol to respond
                clientProtocol.writeExternal(cos);
                cos.flush();

                oos = new ObjectOutputStream(cos);
                clusterHandler.processResponse(clusterResponse, oos, clientProtocol);
                oos.flush();
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
            + "b, remote-ip =" + info.ip
            + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
            + "b, remote-ip =" + info.ip
            + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingOutputStream

                if (null != clusterResponse && null != failure) {

                    clusterHandler.getLogger().debug("Failed to write to ClusterResponse", failure);

                    try {
                        info.setOutputStream(new CountingOutputStream(rawOut));
                        oos = new ObjectOutputStream(info.getOutputStream());
                        clusterResponse.setMetaData(clientProtocol);
                        clusterResponse.writeExternal(oos);
                        oos.flush();
                    } catch (final IOException ie) {
                        final String m = "Failed to write to ClusterResponse: " + ie.getMessage();
                        clusterHandler.getLogger().error(m, ie);
                        throw Exceptions.newIOException(m, ie);
                    }

                    throw failure;
                }
            }

            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            final Response response;
            switch (requestType) {
                case EJB_REQUEST:
                    response = processEjbRequest(ois, clientProtocol);
                    break;
                case JNDI_REQUEST:
                    response = processJndiRequest(ois, clientProtocol);
                    break;
                case AUTH_REQUEST:
                    response = processAuthRequest(ois, clientProtocol);
                    break;
                default:
                    logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    return;
            }

            try {
                info.setOutputStream(new CountingOutputStream(rawOut));

                final CountingOutputStream cos = info.getOutputStream();

                //Let client know we are using the requested protocol to respond
                clientProtocol.writeExternal(cos);
                cos.flush();

                oos = new ObjectOutputStream(cos);
                clusterHandler.processResponse(clusterResponse, oos, clientProtocol);
                oos.flush();
View Full Code Here

Examples of org.eclipse.jgit.util.io.CountingOutputStream

  private void writePack(DfsObjDatabase objdb, DfsPackDescription pack,
      PackWriter pw, ProgressMonitor pm) throws IOException {
    DfsOutputStream out = objdb.writePackFile(pack);
    try {
      CountingOutputStream cnt = new CountingOutputStream(out);
      pw.writePack(pm, pm, cnt);
      pack.setObjectCount(pw.getObjectCount());
      pack.setPackSize(cnt.getCount());
    } finally {
      out.close();
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.util.io.CountingOutputStream

  private void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack,
      PackWriter pw) throws IOException {
    DfsOutputStream out = objdb.writePackIndex(pack);
    try {
      CountingOutputStream cnt = new CountingOutputStream(out);
      pw.writeIndex(cnt);
      pack.setIndexSize(cnt.getCount());
    } finally {
      out.close();
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.util.io.CountingOutputStream

      packIndex = PackIndex.read(buf.openInputStream());
    }

    DfsOutputStream os = db.writePackIndex(pack);
    try {
      CountingOutputStream cnt = new CountingOutputStream(os);
      if (buf != null)
        buf.writeTo(cnt, null);
      else
        index(cnt, packHash, list);
      pack.setIndexSize(cnt.getCount());
    } finally {
      os.close();
    }
    return packIndex;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.