Package com.alibaba.dubbo.common.io

Examples of com.alibaba.dubbo.common.io.UnsafeByteArrayOutputStream.toByteArray()


    services.put("test.service", "http://127.0.0.1:9010/test.service");
    map.put("services", services);

    os = new UnsafeByteArrayOutputStream();
    builder.writeTo(map, os);
    b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
    map = builder.parseFrom(b);
    assertTrue(map.size() > 0);
    assertEquals("http://127.0.0.1:9010/test.service", ((Map) map.get("services")).get("test.service"));
View Full Code Here


    node1.prev = node0;
    // write.
    Builder<Node> nodebuilder = Builder.register(Node.class);
    os = new UnsafeByteArrayOutputStream();
    nodebuilder.writeTo(node0, os);
    b = os.toByteArray();
    System.out.println("Node:"+b.length+":"+Bytes.bytes2hex(b));
    // parse
    node0 = nodebuilder.parseFrom(b);
    assertEquals(node0, node0.prev);
    assertEquals(node0, node0.next.prev);
View Full Code Here

    sd.b = 2;
    sd.c = 3;
    sd.str1 = "12345";
    sd.str2 = "54321";
    builder.writeTo(sd, os);
    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));

    sd = builder.parseFrom(b);
    assertEquals(sd.a, 1);
    assertEquals(sd.b, 2);
View Full Code Here

            encodeRequestData(channel, out, req.getData());
        }
        out.flushBuffer();
        bos.flush();
        bos.close();
        byte[] data = bos.toByteArray();
        Bytes.int2bytes(data.length, header, 12);

        // write
        os.write(header); // write header.
        os.write(data); // write data.
View Full Code Here

            else out.writeUTF(res.getErrorMessage());
            out.flushBuffer();
            bos.flush();
            bos.close();
   
            byte[] data = bos.toByteArray();
            Bytes.int2bytes(data.length, header, 12);
            // write
            os.write(header); // write header.
            os.write(data); // write data.
        } catch (Throwable t) {
View Full Code Here

            }else{
                upstreamCodec.encode(channel, output, context.getMessage());
            }
           
            GrizzlyChannel.removeChannelIfDisconnectd(connection);
            byte[] bytes = output.toByteArray();
            Buffer buffer = connection.getTransport().getMemoryManager().allocate(bytes.length);
            buffer.put(bytes);
            buffer.flip();
            buffer.allowBufferDispose(true);
            context.setMessage(buffer);
View Full Code Here

            encodeRequestData(channel, out, req.getData());
        }
        out.flushBuffer();
        bos.flush();
        bos.close();
        byte[] data = bos.toByteArray();
        Bytes.int2bytes(data.length, header, 12);

        // write
        os.write(header); // write header.
        os.write(data); // write data.
View Full Code Here

            else out.writeUTF(res.getErrorMessage());
            out.flushBuffer();
            bos.flush();
            bos.close();
   
            byte[] data = bos.toByteArray();
            Bytes.int2bytes(data.length, header, 12);
            // write
            os.write(header); // write header.
            os.write(data); // write data.
        } catch (Throwable t) {
View Full Code Here

                }
               
            } finally {
                MinaChannel.removeChannelIfDisconnectd(session);
            }
            out.write(ByteBuffer.wrap(os.toByteArray()));
            out.flush();
        }
    }

    private class InternalDecoder implements ProtocolDecoder {
View Full Code Here

                    upstreamCodec.encode(channel, os, msg);
                }
            } finally {
                MinaChannel.removeChannelIfDisconnectd(session);
            }
            out.write(ByteBuffer.wrap(os.toByteArray()));
            out.flush();
        }
    }

    private class InternalDecoder implements ProtocolDecoder {
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.