Tabnine Logo
RollingStorage.concat
Code IndexAdd Tabnine to your IDE (free)

How to use
concat
method
in
io.pravega.segmentstore.storage.rolling.RollingStorage

Best Java code snippets using io.pravega.segmentstore.storage.rolling.RollingStorage.concat (Showing top 7 results out of 315)

origin: pravega/pravega

  AssertExtensions.assertThrows(
      "Unexpected error reported from concat.",
      () -> s.concat(targetHandle, initialTargetLength, sourceSegmentName),
      ex -> ex instanceof IntentionalException);
s.concat(targetHandle, initialTargetLength, sourceSegmentName);
checkConcatResult(s, targetHandle, sourceSegmentName, 1 + sourceHandle.chunks().size(), initialTargetLength + (int) sourceHandle.length());
checkWrittenData(writeStream.toByteArray(), s.openRead(SEGMENT_NAME), s);
origin: pravega/pravega

/**
 * Tests the ability to concat using the header file for those cases when native concat cannot be used because the
 * source Segment has multiple SegmentChunks.
 */
@Test
public void testConcatHeaderMultiFile() throws Exception {
  final int initialTargetLength = (int) DEFAULT_ROLLING_POLICY.getMaxLength() / 2;
  final String sourceSegmentName = "SourceSegment";
  @Cleanup
  val baseStorage = new InMemoryStorage();
  @Cleanup
  val s = new RollingStorage(baseStorage, DEFAULT_ROLLING_POLICY);
  s.initialize(1);
  // Create a Target Segment and a Source Segment and write some data to them.
  s.create(SEGMENT_NAME);
  val targetHandle = (RollingSegmentHandle) s.openWrite(SEGMENT_NAME);
  val writeStream = new ByteArrayOutputStream();
  populate(s, targetHandle, 1, initialTargetLength, initialTargetLength, writeStream);
  s.create(sourceSegmentName);
  val sourceHandle = (RollingSegmentHandle) s.openWrite(sourceSegmentName);
  populate(s, sourceHandle, APPENDS_PER_SEGMENT, initialTargetLength, initialTargetLength, writeStream);
  s.seal(sourceHandle);
  // Concat and verify the handle has been updated accordingly.
  s.concat(targetHandle, initialTargetLength, sourceSegmentName);
  checkConcatResult(s, targetHandle, sourceSegmentName, 1 + sourceHandle.chunks().size(), initialTargetLength + (int) sourceHandle.length());
  checkWrittenData(writeStream.toByteArray(), s.openRead(SEGMENT_NAME), s);
}
origin: pravega/pravega

AssertExtensions.assertThrows(
    "concat() allowed using a truncated segment as a source.",
    () -> s.concat(targetSegmentHandle, 0, SEGMENT_NAME),
    ex -> ex instanceof IllegalStateException);
origin: pravega/pravega

/**
 * Tests the ability to use native concat for those cases when it's appropriate.
 */
@Test
public void testConcatNatively() throws Exception {
  final int initialTargetLength = (int) DEFAULT_ROLLING_POLICY.getMaxLength() / 2;
  final int initialSourceLength = (int) DEFAULT_ROLLING_POLICY.getMaxLength() - initialTargetLength;
  final String sourceSegmentName = "SourceSegment";
  @Cleanup
  val baseStorage = new InMemoryStorage();
  @Cleanup
  val s = new RollingStorage(baseStorage, DEFAULT_ROLLING_POLICY);
  s.initialize(1);
  // Create a target Segment and write a little data to it.
  s.create(SEGMENT_NAME);
  val targetHandle = (RollingSegmentHandle) s.openWrite(SEGMENT_NAME);
  val writeStream = new ByteArrayOutputStream();
  populate(s, targetHandle, 1, initialTargetLength, initialTargetLength, writeStream);
  // Create a source Segment and write a little data to it, making sure it is small enough to fit into the target
  // when we need to concat.
  s.create(sourceSegmentName);
  val sourceHandle = (RollingSegmentHandle) s.openWrite(sourceSegmentName);
  populate(s, sourceHandle, 1, initialSourceLength, initialSourceLength, writeStream);
  s.seal(sourceHandle);
  // Concat and verify the handle has been updated accordingly.
  s.concat(targetHandle, initialTargetLength, sourceSegmentName);
  checkConcatResult(s, targetHandle, sourceSegmentName, 1, initialTargetLength + initialSourceLength);
  checkWrittenData(writeStream.toByteArray(), s.openRead(SEGMENT_NAME), s);
}
origin: pravega/pravega

/**
 * Tests the ability to concat using the header file for those cases when native concat cannot be used because the
 * source Segment has a single SegmentChunk, but it's too large to fit into the Target's active SegmentChunk.
 */
@Test
public void testConcatHeaderSingleFile() throws Exception {
  final int initialTargetLength = (int) DEFAULT_ROLLING_POLICY.getMaxLength() / 2;
  final int bigSourceLength = (int) DEFAULT_ROLLING_POLICY.getMaxLength() - initialTargetLength + 1;
  final String sourceSegmentName = "SourceSegment";
  @Cleanup
  val baseStorage = new InMemoryStorage();
  @Cleanup
  val s = new RollingStorage(baseStorage, DEFAULT_ROLLING_POLICY);
  s.initialize(1);
  // Create a Target Segment and a Source Segment and write some data to them.
  s.create(SEGMENT_NAME);
  val targetHandle = (RollingSegmentHandle) s.openWrite(SEGMENT_NAME);
  val writeStream = new ByteArrayOutputStream();
  populate(s, targetHandle, 1, initialTargetLength, initialTargetLength, writeStream);
  s.create(sourceSegmentName);
  val sourceHandle = (RollingSegmentHandle) s.openWrite(sourceSegmentName);
  populate(s, sourceHandle, 1, bigSourceLength, bigSourceLength, writeStream);
  s.seal(sourceHandle);
  // Concat and verify the handle has been updated accordingly.
  s.concat(targetHandle, initialTargetLength, sourceSegmentName);
  checkConcatResult(s, targetHandle, sourceSegmentName, 2, initialTargetLength + bigSourceLength);
  checkWrittenData(writeStream.toByteArray(), s.openRead(SEGMENT_NAME), s);
}
origin: pravega/pravega

AssertExtensions.assertThrows(
    "Unexpected exception when doing native concat.",
    () -> s.concat(targetHandle, initialTargetLength, sourceSegmentName),
    ex -> ex instanceof IntentionalException);
origin: pravega/pravega

baseStorage.create(nonHeaderName);
val nonHeaderHandle = s.openWrite(nonHeaderName);
s.concat(nonHeaderHandle, 0, segmentName);
Assert.assertFalse("NonHeader source still exists after concat to NonHeader Segment.", s.exists(segmentName));
checkWrittenData(writtenData, s.openRead(nonHeaderName), s);
s.seal(nonHeaderHandle);
val withHeaderHandle = s.openWrite(withHeaderName);
s.concat(withHeaderHandle, 0, nonHeaderName);
Assert.assertFalse("NonHeader source still exists after concat to Header Segment.", s.exists(nonHeaderName));
val h1 = (RollingSegmentHandle) s.openRead(withHeaderName);
s.concat(s.openWrite(nonHeaderName), 0, withHeaderName);
Assert.assertFalse("NonHeader source still exists after concat to Header Segment.", s.exists(withHeaderName));
val h2 = (RollingSegmentHandle) s.openRead(nonHeaderName);
io.pravega.segmentstore.storage.rollingRollingStorageconcat

Popular methods of RollingStorage

  • <init>
    Creates a new instance of the RollingStorage class.
  • create
  • delete
  • openRead
  • openWrite
  • seal
  • asReadableHandle
  • asWritableHandle
  • canTruncate
  • checkIfEmptyAndNotSealed
  • checkTruncatedSegment
  • createChunk
  • checkTruncatedSegment,
  • createChunk,
  • createHeader,
  • deleteChunks,
  • ensureNotDeleted,
  • ensureNotSealed,
  • ensureOffset,
  • exists,
  • getHeaderInfo

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • findViewById (Activity)
  • getSharedPreferences (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • JButton (javax.swing)
  • JPanel (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Best plugins for Eclipse
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