io.atomix.catalyst.util.Assert.index()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中io.atomix.catalyst.util.Assert.index()方法的一些代码示例,展示了Assert.index()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.index()方法的具体详情如下:
包路径:io.atomix.catalyst.util.Assert
类名称:Assert
方法名:index

Assert.index介绍

暂无

代码示例

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * @throws IndexOutOfBoundsException when {@code expression} is false
 */
public static void indexNot(boolean expression, String errorMessageFormat, Object... args) {
 index(!expression, errorMessageFormat, args);
}

代码示例来源:origin: io.atomix.catalyst/catalyst-common

/**
 * @throws IndexOutOfBoundsException when {@code expression} is false
 */
public static void indexNot(boolean expression, String errorMessageFormat, Object... args) {
 index(!expression, errorMessageFormat, args);
}

代码示例来源:origin: atomix/catalyst

/**
 * @throws IndexOutOfBoundsException when {@code expression} is false
 */
public static void indexNot(boolean expression, String errorMessageFormat, Object... args) {
 index(!expression, errorMessageFormat, args);
}

代码示例来源:origin: io.atomix/catalyst-common

public static void indexNot(boolean expression, String errorMessageFormat, Object... args) {
 index(!expression, errorMessageFormat, args);
}

代码示例来源:origin: atomix/copycat

/**
 * Asserts that the index is a valid index.
 *
 * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
 */
private void assertValidIndex(long index) {
 Assert.index(validIndex(index), "invalid log index: %d", index);
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Asserts that the index is a valid index.
 * 
 * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
 */
private void assertValidIndex(long index) {
 Assert.index(validIndex(index), "invalid log index: %d", index);
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
 * Asserts that the index is a valid index.
 *
 * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
 */
private void assertValidIndex(long index) {
 Assert.index(validIndex(index), "invalid log index: %d", index);
}

代码示例来源:origin: atomix/copycat

/**
 * Releases the entry at the given index.
 *
 * @param index The index of the entry to release.
 * @return The log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log release(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 segment.release(index);
 return this;
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Cleans the entry at the given index.
 *
 * @param index The index of the entry to clean.
 * @return The log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log clean(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 segment.clean(index);
 return this;
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
 * Releases the entry at the given index.
 *
 * @param index The index of the entry to release.
 * @return The log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log release(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 segment.release(index);
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Returns the term for the entry at the given index.
 * <p>
 * This method provides a more efficient means of reading an entry term without deserializing the entire entry.
 * Servers should use this method when performing consistency checks that don't require reading the full entry
 * object. Terms can typically be read in O(1) time with no disk access on segments that haven't been compacted.
 * <p>
 * If the given index is outside of the bounds of the log then a {@link IndexOutOfBoundsException} will be thrown. If
 * the entry at the given index has been compacted then the returned entry will be {@code null}.
 *
 * @param index The index for which to return the term.
 * @return The term for the entry at the given index.
 */
public long term(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 return segment.term(index);
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Returns the term for the entry at the given index.
 * <p>
 * This method provides a more efficient means of reading an entry term without deserializing the entire entry.
 * Servers should use this method when performing consistency checks that don't require reading the full entry
 * object. Terms can typically be read in O(1) time with no disk access on segments that haven't been compacted.
 * <p>
 * If the given index is outside of the bounds of the log then a {@link IndexOutOfBoundsException} will be thrown. If
 * the entry at the given index has been compacted then the returned entry will be {@code null}.
 *
 * @param index The index for which to return the term.
 * @return The term for the entry at the given index.
 */
public long term(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 return segment.term(index);
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
 * Returns the term for the entry at the given index.
 * <p>
 * This method provides a more efficient means of reading an entry term without deserializing the entire entry.
 * Servers should use this method when performing consistency checks that don't require reading the full entry
 * object. Terms can typically be read in O(1) time with no disk access on segments that haven't been compacted.
 * <p>
 * If the given index is outside of the bounds of the log then a {@link IndexOutOfBoundsException} will be thrown. If
 * the entry at the given index has been compacted then the returned entry will be {@code null}.
 *
 * @param index The index for which to return the term.
 * @return The term for the entry at the given index.
 */
public long term(long index) {
 assertIsOpen();
 assertValidIndex(index);
 Segment segment = segments.segment(index);
 Assert.index(segment != null, "invalid index: " + index);
 return segment.term(index);
}

代码示例来源:origin: atomix/copycat

/**
 * Truncates entries after the given index.
 *
 * @param index The index after which to remove entries.
 * @return The segment.
 * @throws IllegalStateException if the segment is not open
 */
public Segment truncate(long index) {
 assertSegmentOpen();
 Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
 long offset = relativeOffset(index);
 long lastOffset = offsetIndex.lastOffset();
 long diff = Math.abs(lastOffset - offset);
 skip = Math.max(skip - diff, 0);
 if (offset < lastOffset) {
  long position = offsetIndex.truncate(offset);
  buffer.position(position)
   .zero(position)
   .flush();
  termIndex.truncate(offset);
 }
 return this;
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
 * Truncates entries after the given index.
 *
 * @param index The index after which to remove entries.
 * @return The segment.
 * @throws IllegalStateException if the segment is not open
 */
public Segment truncate(long index) {
 assertSegmentOpen();
 Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
 long offset = relativeOffset(index);
 long lastOffset = offsetIndex.lastOffset();
 long diff = Math.abs(lastOffset - offset);
 skip = Math.max(skip - diff, 0);
 if (offset < lastOffset) {
  long position = offsetIndex.truncate(offset);
  buffer.position(position)
   .zero(position)
   .flush();
  termIndex.truncate(offset);
 }
 return this;
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Truncates entries after the given index.
 *
 * @param index The index after which to remove entries.
 * @return The segment.
 * @throws IllegalStateException if the segment is not open
 */
public Segment truncate(long index) {
 assertSegmentOpen();
 Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
 long offset = relativeOffset(index);
 long lastOffset = offsetIndex.lastOffset();
 long diff = Math.abs(lastOffset - offset);
 skip = Math.max(skip - diff, 0);
 if (offset < lastOffset) {
  long position = offsetIndex.truncate(offset);
  buffer.position(position)
   .zero(position)
   .flush();
  termIndex.truncate(offset);
 }
 return this;
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Truncates the log up to the given index.
 *
 * @param index The index at which to truncate the log.
 * @return The updated log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log truncate(long index) {
 assertIsOpen();
 if (index > 0)
  assertValidIndex(index);
 Assert.index(index >= segments.commitIndex(), "cannot truncate committed entries");
 if (lastIndex() == index)
  return this;
 for (Segment segment : segments.reverseSegments()) {
  if (segment.validIndex(index)) {
   segment.truncate(index);
   break;
  } else if (segment.index() > index) {
   segments.removeSegment(segment);
  }
 }
 return this;
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
 * Truncates the log up to the given index.
 *
 * @param index The index at which to truncate the log.
 * @return The updated log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log truncate(long index) {
 assertIsOpen();
 if (index > 0)
  assertValidIndex(index);
 Assert.index(index >= segments.commitIndex(), "cannot truncate committed entries");
 if (lastIndex() == index)
  return this;
 for (Segment segment : segments.reverseSegments()) {
  if (segment.validIndex(index)) {
   segment.truncate(index);
   break;
  } else if (segment.index() > index) {
   segments.removeSegment(segment);
  }
 }
 entryBuffer.clear();
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Truncates the log up to the given index.
 *
 * @param index The index at which to truncate the log.
 * @return The updated log.
 * @throws IllegalStateException If the log is not open.
 * @throws IndexOutOfBoundsException If the given index is not within the bounds of the log.
 */
public Log truncate(long index) {
 assertIsOpen();
 if (index > 0)
  assertValidIndex(index);
 Assert.index(index >= segments.commitIndex(), "cannot truncate committed entries");
 if (lastIndex() == index)
  return this;
 for (Segment segment : segments.reverseSegments()) {
  if (segment.validIndex(index)) {
   segment.truncate(index);
   break;
  } else if (segment.index() > index) {
   segments.removeSegment(segment);
  }
 }
 entryBuffer.clear();
 return this;
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

Assert.index(index == entry.getIndex(), "inconsistent index: %s", entry.getIndex());

相关文章