Tabnine Logo
ByteArrayDataOutputStream.getBuffer
Code IndexAdd Tabnine to your IDE (free)

How to use
getBuffer
method
in
org.jgroups.util.ByteArrayDataOutputStream

Best Java code snippets using org.jgroups.util.ByteArrayDataOutputStream.getBuffer (Showing top 20 results out of 315)

origin: wildfly/wildfly

public static Buffer exceptionToBuffer(Throwable t) throws Exception {
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(512, true);
  exceptionToStream(t, out);
  return out.getBuffer();
}
origin: wildfly/wildfly

public static Buffer streamableToBuffer(Streamable obj) {
  int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() +1 : 512;
  final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size);
  try {
    Util.writeStreamable(obj,out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

protected static Buffer marshal(final Collection<? extends Address> participants, final Digest digest) {
  final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(512);
  try {
    Util.writeAddresses(participants, out);
    Util.writeStreamable(digest,out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

protected static Buffer marshal(final ViewId view_id) {
  try {
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(Util.size(view_id));
    Util.writeViewId(view_id, out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

protected static Buffer marshal(Collection<? extends Address> mbrs) {
  try {
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream((int)Util.size(mbrs));
    Util.writeAddresses(mbrs, out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

protected static Buffer methodCallToBuffer(final MethodCall call, Marshaller marshaller) throws Exception {
  Object[] args=call.args();
  int estimated_size=64;
  if(args != null)
    for(Object arg: args)
      estimated_size+=marshaller != null? marshaller.estimatedSize(arg) : (arg == null? 2 : 50);
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(estimated_size, true);
  call.writeTo(out, marshaller);
  return out.getBuffer();
}
origin: wildfly/wildfly

protected static Buffer replyToBuffer(Object obj, Marshaller marshaller) throws Exception {
  int estimated_size=marshaller != null? marshaller.estimatedSize(obj) : 50;
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(estimated_size, true);
  if(marshaller != null)
    marshaller.objectToStream(obj, out);
  else
    Util.objectToStream(obj, out);
  return out.getBuffer();
}
origin: wildfly/wildfly

public static Buffer messageToByteBuffer(Message msg) throws Exception {
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream((int)msg.size()+1);
  out.writeBoolean(msg != null);
  if(msg != null)
    msg.writeTo(out);
  return out.getBuffer();
}
origin: wildfly/wildfly

public static Buffer objectToBuffer(Object obj) throws Exception {
  if(obj == null)
    return new Buffer(TYPE_NULL_ARRAY);
  if(obj instanceof Streamable) {
    int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() : 512;
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size, true);
    out.write(TYPE_STREAMABLE);
    writeGenericStreamable((Streamable)obj,out);
    return out.getBuffer();
  }
  Byte type=PRIMITIVE_TYPES.get(obj.getClass());
  if(type == null) { // will throw an exception if object is not serializable
    final ByteArrayDataOutputStream out_stream=new ByteArrayDataOutputStream(512, true);
    out_stream.write(TYPE_SERIALIZABLE);
    try(ObjectOutputStream out=new ObjectOutputStream(new OutputStreamAdapter(out_stream))) {
      out.writeObject(obj);
      out.flush();
      return out_stream.getBuffer();
    }
  }
  return new Buffer(marshalPrimitiveType(type, obj));
}
origin: wildfly/wildfly

public static Buffer marshal(LazyRemovalCache<Address,IpAddress> addrs) {
  final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(512);
  try {
    int size=addrs != null? addrs.size() : 0;
    out.writeInt(size);
    if(size > 0) {
      for(Map.Entry<Address,LazyRemovalCache.Entry<IpAddress>> entry: addrs.entrySet()) {
        Address key=entry.getKey();
        IpAddress val=entry.getValue().getVal();
        Util.writeAddress(key, out);
        Util.writeStreamable(val, out);
      }
    }
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

dos.writeByte(flags);
msg.writeTo(dos);
Buffer buffer=dos.getBuffer();
origin: wildfly/wildfly

protected static Buffer marshal(final View view, final Digest digest) {
  try {
    int expected_size=Global.SHORT_SIZE;
    if(view != null)
      expected_size+=view.serializedSize();
    boolean write_addrs=writeAddresses(view, digest);
    if(digest != null)
      expected_size=(int)digest.serializedSize(write_addrs);
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size +10);
    out.writeShort(determineFlags(view, digest));
    if(view != null)
      view.writeTo(out);
    if(digest != null)
      digest.writeTo(out, write_addrs);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: wildfly/wildfly

@Override
protected void sendMcastDiscoveryRequest(Message msg) {
  try {
    if(msg.getSrc() == null)
      msg.setSrc(local_addr);
    ByteArrayDataOutputStream out=new ByteArrayDataOutputStream((int)(msg.size()+1));
    msg.writeTo(out);
    Buffer buf=out.getBuffer();
    DatagramPacket packet=new DatagramPacket(buf.getBuf(), buf.getOffset(), buf.getLength(), mcast_addr, mcast_port);
    if(mcast_send_sockets != null) {
      MulticastSocket s;
      for(int i=0; i < mcast_send_sockets.length; i++) {
        s=mcast_send_sockets[i];
        try {
          s.send(packet);
        }
        catch(Exception e) {
          log.error(Util.getMessage("FailedSendingPacketOnSocket"), s);
        }
      }
    }
    else { // DEFAULT path
      if(mcast_sock != null)
        mcast_sock.send(packet);
    }
  }
  catch(Exception ex) {
    log.error(Util.getMessage("FailedSendingDiscoveryRequest"), ex);
  }
}
origin: org.jboss.eap/wildfly-client-all

protected static Buffer marshal(Collection<? extends Address> mbrs) {
  try {
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream((int)Util.size(mbrs));
    Util.writeAddresses(mbrs, out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

protected static Buffer marshal(final Collection<? extends Address> participants, final Digest digest) {
  final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(512);
  try {
    Util.writeAddresses(participants, out);
    Util.writeStreamable(digest,out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

public static Buffer streamableToBuffer(Streamable obj) {
  int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() +1 : 512;
  final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size);
  try {
    Util.writeStreamable(obj,out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

protected static Buffer marshal(final ViewId view_id) {
  try {
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(Util.size(view_id));
    Util.writeViewId(view_id, out);
    return out.getBuffer();
  }
  catch(Exception ex) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

protected static Buffer methodCallToBuffer(final MethodCall call, Marshaller marshaller) throws Exception {
  Object[] args=call.args();
  int estimated_size=64;
  if(args != null)
    for(Object arg: args)
      estimated_size+=marshaller != null? marshaller.estimatedSize(arg) : (arg == null? 2 : 50);
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(estimated_size, true);
  call.writeTo(out, marshaller);
  return out.getBuffer();
}
origin: org.jboss.eap/wildfly-client-all

protected static Buffer replyToBuffer(Object obj, Marshaller marshaller) throws Exception {
  int estimated_size=marshaller != null? marshaller.estimatedSize(obj) : 50;
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(estimated_size, true);
  if(marshaller != null)
    marshaller.objectToStream(obj, out);
  else
    Util.objectToStream(obj, out);
  return out.getBuffer();
}
origin: org.jboss.eap/wildfly-client-all

public static Buffer messageToByteBuffer(Message msg) throws Exception {
  ByteArrayDataOutputStream out=new ByteArrayDataOutputStream((int)msg.size()+1);
  out.writeBoolean(msg != null);
  if(msg != null)
    msg.writeTo(out);
  return out.getBuffer();
}
org.jgroups.utilByteArrayDataOutputStreamgetBuffer

Popular methods of ByteArrayDataOutputStream

  • <init>
  • buffer
  • checkBounds
  • ensureCapacity
    Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentially
  • getByteBuffer
  • position
  • write
  • writeBoolean
  • writeByte
  • writeChar
  • writeInt
  • writeLong
  • writeInt,
  • writeLong,
  • writeShort,
  • writeUTF

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getExternalFilesDir (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now