Tabnine Logo
ByteArrayDataInputStream.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.jgroups.util.ByteArrayDataInputStream
constructor

Best Java code snippets using org.jgroups.util.ByteArrayDataInputStream.<init> (Showing top 20 results out of 315)

origin: wildfly/wildfly

public static <T extends Streamable> T streamableFromByteBuffer(Class<? extends Streamable> cl,byte[] buffer,int offset,int length) throws Exception {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  T retval=(T)cl.newInstance();
  retval.readFrom(in);
  return retval;
}
origin: wildfly/wildfly

@Deprecated
public static <T extends Streamable> T streamableFromBuffer(Class<T> clazz,byte[] buffer,int offset,int length) throws Exception {
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  return Util.readStreamable(clazz, in);
}
origin: wildfly/wildfly

public static <T extends Streamable> T streamableFromByteBuffer(Supplier<T> factory, byte[] buffer, int offset, int length) throws Exception {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  T retval=factory.get();
  retval.readFrom(in);
  return retval;
}
origin: wildfly/wildfly

public static Throwable exceptionFromBuffer(byte[] buf, int offset, int length) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset,length);
  return exceptionFromStream(in);
}
origin: wildfly/wildfly

public static <T extends Streamable> T streamableFromBuffer(Supplier<T> factory, byte[] buffer, int offset, int length) throws Exception {
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  return Util.readStreamable(factory, in);
}
origin: wildfly/wildfly

public static Message byteBufferToMessage(byte[] buffer,int offset,int length) throws Exception {
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  if(!in.readBoolean())
    return null;
  Message msg=new Message(false); // don't create headers, readFrom() will do this
  msg.readFrom(in);
  return msg;
}
origin: wildfly/wildfly

protected Collection<? extends Address> readMembers(byte[] buffer, int offset, int length) {
  if(buffer == null) return null;
  try {
    DataInput in=new ByteArrayDataInputStream(buffer, offset, length);
    return Util.readAddresses(in, ArrayList::new);
  }
  catch(Exception ex) {
    log.error("%s: failed reading members from message: %s", local_addr, ex);
    return null;
  }
}
origin: wildfly/wildfly

protected ViewId readViewId(byte[] buffer, int offset, int length) {
  if(buffer == null) return null;
  try {
    DataInput in=new ByteArrayDataInputStream(buffer, offset, length);
    return Util.readViewId(in);
  }
  catch(Exception ex) {
    log.error("%s: failed reading ViewId from message: %s", local_addr, ex);
    return null;
  }
}
origin: wildfly/wildfly

protected static MethodCall methodCallFromBuffer(final byte[] buf, int offset, int length, Marshaller marshaller) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  MethodCall call=new MethodCall();
  call.readFrom(in, marshaller);
  return call;
}
origin: wildfly/wildfly

protected static Object replyFromBuffer(final byte[] buf, int offset, int length, Marshaller marshaller) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  return marshaller != null? marshaller.objectFromStream(in) : Util.objectFromStream(in);
}
origin: wildfly/wildfly

protected Map<Address,IpAddress> unmarshal(byte[] buffer, int offset, int length) {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer, offset, length);
  HashMap<Address,IpAddress> addrs=null;
  try {
    int size=in.readInt();
    if(size > 0) {
      addrs=new HashMap<>(size);
      for(int i=0; i < size; i++) {
        Address key=Util.readAddress(in);
        IpAddress val=Util.readStreamable(IpAddress::new, in);
        addrs.put(key, val);
      }
    }
    return addrs;
  }
  catch(Exception ex) {
    log.error("%s: failed reading addresses from message: %s", local_addr, ex);
    return null;
  }
}
origin: wildfly/wildfly

public void run() {
  // System.out.printf("[%s] reading from sock, conn: %s\n", Thread.currentThread().getName(), this);
  try {
    int len=in.readInt();
    if(buffer == null || buffer.length < len)
      buffer=new byte[len];
    in.readFully(buffer, 0, len);
    ByteArrayDataInputStream input=new ByteArrayDataInputStream(buffer, 0, len);
    Message msg=new Message(false);
    msg.readFrom(input);
    thread_pool.execute(() -> up_prot.up(msg));
  }
  catch(IOException io_ex) {
    runner.stop();
    throw new RuntimeException(io_ex);
  }
  catch(Exception ex) {
    if(sock.isClosed())
      runner.stop();
    throw new RuntimeException(ex);
  }
}
origin: wildfly/wildfly

protected static Message readMessage(byte[] buf, int offset, int length) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  short ver=in.readShort();
  byte flags=in.readByte();
  // final boolean multicast=(flags & (byte)2) == (byte)2;
  Message msg=new Message(false); // don't create headers, readFrom() will do this
  msg.readFrom(in);
  return msg;
}
origin: wildfly/wildfly

/**
 * Subclasses must call this method when a unicast or multicast message has been received.
 */
public void receive(Address sender, byte[] data, int offset, int length) {
  if(data == null) return;
  // drop message from self; it has already been looped back up (https://issues.jboss.org/browse/JGRP-1765)
  if(Objects.equals(local_physical_addr, sender))
    return;
  // the length of a message needs to be at least 3 bytes: version (2) and flags (1) // JGRP-2210
  if(length < Global.SHORT_SIZE + Global.BYTE_SIZE)
    return;
  short version=Bits.readShort(data, offset);
  if(!versionMatch(version, sender))
    return;
  offset+=Global.SHORT_SIZE;
  byte flags=data[offset];
  offset+=Global.BYTE_SIZE;
  boolean is_message_list=(flags & LIST) == LIST, multicast=(flags & MULTICAST) == MULTICAST;
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(data, offset, length);
  if(is_message_list) // used if message bundling is enabled
    handleMessageBatch(in, multicast);
  else
    handleSingleMessage(in, multicast);
}
origin: wildfly/wildfly

protected  Tuple<Collection<? extends Address>,Digest> readParticipantsAndDigest(byte[] buffer, int offset, int length) {
  if(buffer == null) return null;
  try {
    DataInput in=new ByteArrayDataInputStream(buffer, offset, length);
    Collection<Address> participants=Util.readAddresses(in, ArrayList::new);
    Digest digest=Util.readStreamable(Digest::new, in);
    return new Tuple<>(participants, digest);
  }
  catch(Exception ex) {
    log.error("%s: failed reading particpants and digest from message: %s", localAddress, ex);
    return null;
  }
}
origin: wildfly/wildfly

public void run() {
  final byte[]    receive_buf=new byte[65535];
  DatagramPacket  packet=new DatagramPacket(receive_buf, receive_buf.length);
  DataInput       inp;
  while(sock != null && receiver != null && Thread.currentThread().equals(receiver)) {
    packet.setData(receive_buf, 0, receive_buf.length);
    try {
      sock.receive(packet);
      inp=new ByteArrayDataInputStream(packet.getData(), packet.getOffset(), packet.getLength());
      Message msg=new Message();
      msg.readFrom(inp);
      up(msg);
    }
    catch(SocketException socketEx) {
      break;
    }
    catch(Throwable ex) {
      log.error(Util.getMessage("FailedReceivingPacketFrom"), packet.getSocketAddress(), ex);
    }
  }
  if(log.isTraceEnabled())
    log.trace("receiver thread terminated");
}
origin: wildfly/wildfly

public void run() {
  final byte[]   receive_buf=new byte[65535];
  DatagramPacket packet=new DatagramPacket(receive_buf, receive_buf.length);
  while(mcast_sock != null && receiver != null && Thread.currentThread().equals(receiver)) {
    packet.setData(receive_buf, 0, receive_buf.length);
    try {
      mcast_sock.receive(packet);
      DataInput inp=new ByteArrayDataInputStream(packet.getData(), packet.getOffset(), packet.getLength());
      Message msg=new Message();
      msg.readFrom(inp);
      if(!Objects.equals(local_addr,msg.getSrc())) // discard discovery request from self
        up(msg);
    }
    catch(SocketException socketEx) {
      break;
    }
    catch(Throwable ex) {
      log.error(Util.getMessage("FailedReceivingPacketFrom"), packet.getSocketAddress(), ex);
    }
  }
  log.debug("receiver thread terminated");
}
origin: apache/geode

@Test
public void testSeriazilabeToAndFromByteArray() throws IOException {
 Map<String, String> attributesMap = new HashMap<>();
 attributesMap.put(REGION_NAME, "myRegion");
 attributesMap.put(TABLE_NAME, "myTable");
 attributesMap.put(PDX_NAME, "myPdx");
 attributesMap.put(DATA_SOURCE_NAME, "myDatasource");
 attributesMap.put(SYNCHRONOUS_NAME, "false");
 attributesMap.put(ID_NAME, "myId");
 DescribeMappingResult result = new DescribeMappingResult(attributesMap);
 DescribeMappingResult newResult = new DescribeMappingResult();
 ByteArrayDataOutputStream output = new ByteArrayDataOutputStream();
 ByteArrayDataInputStream input;
 result.toData(output);
 input = new ByteArrayDataInputStream(output.buffer());
 newResult.fromData(input);
 Map<String, String> newAttributeMap = newResult.getAttributeMap();
 assertThat(attributesMap).isEqualTo(newAttributeMap);
}
origin: wildfly/wildfly

public static Tuple<View,Digest> _readViewAndDigest(byte[] buffer, int offset, int length) throws Exception {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer, offset, length);
  View tmp_view=null;
  Digest digest=null;
  short flags=in.readShort();
  if((flags & VIEW_PRESENT) == VIEW_PRESENT) {
    tmp_view=(flags & MERGE_VIEW) == MERGE_VIEW? new MergeView() :
     (flags & DELTA_VIEW) == DELTA_VIEW? new DeltaView() :
      new View();
    tmp_view.readFrom(in);
  }
  if((flags & DIGEST_PRESENT) == DIGEST_PRESENT) {
    if((flags & READ_ADDRS) == READ_ADDRS) {
      digest=new Digest();
      digest.readFrom(in);
    }
    else {
      digest=new Digest(tmp_view.getMembersRaw());
      digest.readFrom(in,false);
    }
  }
  return new Tuple<>(tmp_view, digest);
}
origin: wildfly/wildfly

@Override
public void receive(Address sender, byte[] buf, int offset, int length) {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  GossipData data=new GossipData();
  try {
    data.readFrom(in);
    switch(data.getType()) {
      case MESSAGE:
      case SUSPECT:
        if(receiver != null)
          receiver.receive(data);
        break;
      case GET_MBRS_RSP:
        notifyResponse(data.getGroup(), data.getPingData());
        break;
    }
  }
  catch(Exception ex) {
    log.error(Util.getMessage("FailedReadingData"), ex);
  }
}
org.jgroups.utilByteArrayDataInputStream<init>

Popular methods of ByteArrayDataInputStream

  • checkBounds
  • limit
  • position
  • read
  • readByte
  • readFully
  • readInt
  • readLong
  • readShort
  • readUnsignedShort
  • skipBytes
  • skipBytes

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (Timer)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Option (scala)
  • Top plugins for Android Studio
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