congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Table
Code IndexAdd Tabnine to your IDE (free)

How to use
Table
in
org.jgroups.util

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

origin: wildfly/wildfly

/**
 * Adds elements from list to the table
 * @param list
 * @return True if at least 1 element was added successfully
 */
public boolean add(final List<LongTuple<T>> list) {
  return add(list, false);
}
origin: wildfly/wildfly

public SenderEntry(short send_conn_id) {
  super(send_conn_id, new Table<>(xmit_table_num_rows, xmit_table_msgs_per_row, 0,
                  xmit_table_resize_factor, xmit_table_max_compaction_time));
}
origin: wildfly/wildfly

boolean added=false;
long highest_seqno=findHighestSeqno(list);
lock.lock();
try {
  if(highest_seqno != -1 && computeRow(highest_seqno) >= matrix.length)
    resize(highest_seqno);
    long seqno=tuple.getVal1();
    T element=const_value != null? const_value : tuple.getVal2();
    if(_add(seqno, element, false, null))
      added=true;
    else if(remove_added_elements)
origin: wildfly/wildfly

/**
 * To be used only for testing; doesn't do any index or sanity checks
 * @param seqno
 * @return
 */
public T _get(long seqno) {
  lock.lock();
  try {
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

  return false;
int row_index=computeRow(seqno);
if(check_if_resize_needed && row_index >= matrix.length) {
  resize(seqno);
  row_index=computeRow(seqno);
T[] row=getRow(row_index);
int index=computeIndex(seqno);
T existing_element=row[index];
if(existing_element == null) {
    hr=seqno;
  if(remove_filter != null && hd +1 == seqno) {
    forEach(hd + 1, hr,
        (seq, msg, r, c) -> {
          if(msg == null || !remove_filter.test(msg))
origin: wildfly/wildfly

/** Moves rows down the matrix, by removing purged rows. If resizing to accommodate seqno is still needed, computes
 * a new size. Then either moves existing rows down, or copies them into a new array (if resizing took place).
 * The lock must be held by the caller of resize(). */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void resize(long seqno) {
  int num_rows_to_purge=computeRow(low);
  int row_index=computeRow(seqno) - num_rows_to_purge;
  if(row_index < 0)
    return;
  int new_size=Math.max(row_index +1, matrix.length);
  if(new_size > matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, num_rows_to_purge, new_matrix, 0, matrix.length - num_rows_to_purge);
    matrix=new_matrix;
    num_resizes++;
  }
  else if(num_rows_to_purge > 0) {
    move(num_rows_to_purge);
  }
  offset+=(num_rows_to_purge * elements_per_row);
}
origin: wildfly/wildfly

int start_row=computeRow(low), end_row=computeRow(seqno);
if(start_row < 0) start_row=0;
if(end_row < 0)
  int index=computeIndex(seqno);
  for(int i=0; i <= index; i++) // null all elements up to and including seqno in the given row
    matrix[end_row][i]=null;
  if(seqno - hd > 0)
    low=hd=seqno;
  size=computeSize();
if(last_compaction_timestamp > 0) {
  if(current_time - last_compaction_timestamp >= max_compaction_time) {
    _compact();
    last_compaction_timestamp=current_time;
origin: wildfly/wildfly

protected void handleBatchReceived(final ReceiverEntry entry, Address sender, List<LongTuple<Message>> msgs, boolean oob) {
  if(is_trace)
    log.trace("%s <-- DATA(%s: %s)", local_addr, sender, printMessageList(msgs));
  int batch_size=msgs.size();
  Table<Message> win=entry.msgs;
  // adds all messages to the table, removing messages from 'msgs' which could not be added (already present)
  boolean added=win.add(msgs, oob, oob? DUMMY_OOB_MSG : null);
  update(entry, batch_size);
  if(batch_size >= ack_threshold)
    sendAck(sender, win.getHighestDeliverable(), entry.connId());
  else
    entry.sendAck(true);
  // OOB msg is passed up. When removed, we discard it. Affects ordering: http://jira.jboss.com/jira/browse/JGRP-379
  if(added && oob) {
    MessageBatch oob_batch=new MessageBatch(local_addr, sender, null, false, MessageBatch.Mode.OOB, msgs.size());
    for(LongTuple<Message> tuple: msgs)
      oob_batch.add(tuple.getVal2());
    deliverBatch(oob_batch);
  }
  removeAndDeliver(win, sender);
}
origin: wildfly/wildfly

boolean added=loopback || buf.add(msgs, oob, oob? DUMMY_OOB_MSG : null);
    for(LongTuple<Message> tuple: msgs) {
      long    seq=tuple.getVal1();
      Message msg=buf.get(seq); // we *have* to get the message, because loopback means we didn't add it to win !
      if(msg != null && msg.isFlagSet(Message.Flag.OOB) && msg.setTransientFlagIfAbsent(Message.TransientFlag.OOB_DELIVERED))
        oob_batch.add(msg);
origin: wildfly/wildfly

msg.putHeader(this.id,UnicastHeader3.createDataHeader(seqno,send_conn_id,seqno == DEFAULT_FIRST_SEQNO));
entry.msgs.add(seqno, msg, dont_loopback_set? dont_loopback_filter : null);
if(conn_expiry_timeout > 0)
  entry.update();
if(dont_loopback_set)
  entry.msgs.purge(entry.msgs.getHighestDeliverable());
break;
origin: stackoverflow.com

menuTable.setPosition(0, 0);
menuTable.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
menuTable.align(Align.top);
menuTable.add(image);
menuTable.add(imageButton);
menuTable.add(button);
origin: stackoverflow.com

 //Pixmap with one pixel
Pixmap pm1 = new Pixmap(1, 1, Format.RGB565);
pm1.setColor(Color.GREEN);
pm1.fill();

Pixmap pm2 = new Pixmap(1, 1, Format.RGB565);
pm2.setColor(Color.RED);
pm2.fill();

dialogueWindow = getWindow();

dialogueWindow.setTitle("New Game");
// The table that will have the green color 
Table row1 = new Table(mySkin);
row1.add(nameStation);
row1.add(nameStationField);
row1.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(pm1))));
dialogueWindow.add(row1);
dialogueWindow.row();

// The table that will have  the green color
Table row2 = new Table(mySkin);
row2.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(pm2))));
row2.add(cancel).size(120, 60);
row2.add(ok).size(100, 60);

dialogueWindow.add(row2).fillX();
dialogueWindow.row();
origin: stackoverflow.com

filler.setFillParent(true);
filler.add(hGroup).fill().center();
origin: wildfly/wildfly

/**
 * Adds an element if the element at the given index is null. Returns true if no element existed at the given index,
 * else returns false and doesn't set the element.
 * @param seqno
 * @param element
 * @return True if the element at the computed index was null, else false
 */
public boolean add(long seqno, T element) {
  lock.lock();
  try {
    return _add(seqno, element, true, null);
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

@ManagedAttribute(description="Capacity of the retransmit buffer. Computed as xmit_table_num_rows * xmit_table_msgs_per_row")
public long getXmitTableCapacity() {
  Table<Message> table=local_addr != null? xmit_table.get(local_addr) : null;
  return table != null? table.capacity() : 0;
}
origin: wildfly/wildfly

public void compact() {
  lock.lock();
  try {
    _compact();
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

@ManagedOperation(description="Compacts the retransmit buffer")
public void compact() {
  Table<Message> table=local_addr != null? xmit_table.get(local_addr) : null;
  if(table != null)
    table.compact();
}
origin: wildfly/wildfly

/**
 * Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly. The
 * capacity of the matrix should be size * resize_factor. Caller must hold the lock.
 */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void _compact() {
  // This is the range we need to copy into the new matrix (including from and to)
  int from=computeRow(low), to=computeRow(hr);
  int range=to - from +1;  // e.g. from=3, to=5, new_size has to be [3 .. 5] (=3)
  int new_size=(int)Math.max( (double)range * resize_factor, (double) range +1 );
  new_size=Math.max(new_size, num_rows); // don't fall below the initial size defined
  if(new_size < matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, from, new_matrix, 0, range);
    matrix=new_matrix;
    offset+=from * elements_per_row;
    num_compactions++;
  }
}
origin: org.jboss.eap/wildfly-client-all

  return false;
int row_index=computeRow(seqno);
if(check_if_resize_needed && row_index >= matrix.length) {
  resize(seqno);
  row_index=computeRow(seqno);
T[] row=getRow(row_index);
int index=computeIndex(seqno);
T existing_element=row[index];
if(existing_element == null) {
    hr=seqno;
  if(remove_filter != null && hd +1 == seqno) {
    forEach(hd + 1, hr,
        (seq, msg, r, c) -> {
          if(msg == null || !remove_filter.test(msg))
origin: wildfly/wildfly

/**
 * Returns an element at seqno
 * @param seqno
 * @return
 */
public T get(long seqno) {
  lock.lock();
  try {
    if(seqno - low <= 0 || seqno - hr > 0)
      return null;
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
org.jgroups.utilTable

Javadoc

A store for elements (typically messages) to be retransmitted or delivered. Used on sender and receiver side, as a replacement for HashMap. Table should use less memory than HashMap, as HashMap.Entry has 4 fields, plus arrays for storage.

Table maintains a matrix (an array of arrays) of elements, which are stored in the matrix by mapping their seqno to an index. E.g. when we have 10 rows of 1000 elements each, and first_seqno is 3000, then an element with seqno=5600, will be stored in the 3rd row, at index 600.

Rows are removed when all elements in that row have been received.

Table started out as a copy of RetransmitTable, but is synchronized and maintains its own low, hd and hr pointers, so it can be used as a replacement for NakReceiverWindow. The idea is to put messages into Table, deliver them in order of seqnos, and periodically scan over all tables in NAKACK2 to do retransmission.

Most used methods

  • add
    Adds elements from the list to the table
  • <init>
  • _add
  • _compact
    Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly. T
  • capacity
    Returns the total capacity in the matrix
  • compact
  • computeIndex
    Computes and returns the index within a row for seqno
  • computeRow
    Computes and returns the row index for seqno. The caller must hold the lock.
  • computeSize
    Iterate from low to hr and add up non-null values. Caller must hold the lock.
  • findHighestSeqno
  • forEach
    Iterates over the matrix with range [from .. to] (including from and to), and calls Visitor#visit(lo
  • get
    Returns an element at seqno
  • forEach,
  • get,
  • getAdders,
  • getDigest,
  • getHighestDeliverable,
  • getHighestDelivered,
  • getHighestReceived,
  • getLow,
  • getMissing,
  • getNumCompactions

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • requestLocationUpdates (LocationManager)
  • runOnUiThread (Activity)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top Vim 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