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

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

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

origin: pravega/pravega

/**
 * Tests the ability to truncate Sealed Segments.
 */
@Test
public void testTruncateSealed() throws Exception {
  // Write small and large writes, alternatively.
  @Cleanup
  val baseStorage = new TestStorage();
  @Cleanup
  val s = new RollingStorage(baseStorage, DEFAULT_ROLLING_POLICY);
  s.initialize(1);
  // Create a Segment, write some data, then seal it.
  s.create(SEGMENT_NAME);
  val appendHandle = (RollingSegmentHandle) s.openWrite(SEGMENT_NAME);
  val writeStream = new ByteArrayOutputStream();
  populate(s, appendHandle, writeStream);
  s.seal(appendHandle);
  byte[] writtenData = writeStream.toByteArray();
  val truncateHandle = (RollingSegmentHandle) s.openWrite(SEGMENT_NAME);
  Assert.assertTrue("Handle not read-only after sealing.", truncateHandle.isReadOnly());
  Assert.assertTrue("Handle not sealed after sealing.", truncateHandle.isSealed());
  // Test that truncate works in this scenario.
  testProgressiveTruncate(truncateHandle, truncateHandle, writtenData, s, baseStorage);
}
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

s.create(targetSegmentName);
val targetSegmentHandle = s.openWrite(targetSegmentName);
s.seal(writeHandle);
AssertExtensions.assertThrows(
    "concat() allowed using a truncated segment as a source.",
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

val sourceHandle = (RollingSegmentHandle) s.openWrite(sourceSegmentName);
populate(s, sourceHandle, APPENDS_PER_SEGMENT, initialTargetLength, initialTargetLength, writeStream);
s.seal(sourceHandle);
origin: pravega/pravega

val sourceHandle = (RollingSegmentHandle) s.openWrite(sourceSegmentName);
populate(s, sourceHandle, 1, initialSourceLength, initialSourceLength, writeStream);
s.seal(sourceHandle);
origin: pravega/pravega

seal(writeHandle);
origin: pravega/pravega

val os = new ByteArrayOutputStream();
populate(s, writeHandle, os);
s.seal(writeHandle);
byte[] writtenData = os.toByteArray();
Assert.assertFalse("A header was left behind (after write).",
s.seal(nonHeaderHandle);
val withHeaderHandle = s.openWrite(withHeaderName);
s.concat(withHeaderHandle, 0, nonHeaderName);
s.seal(withHeaderHandle);
s.concat(s.openWrite(nonHeaderName), 0, withHeaderName);
Assert.assertFalse("NonHeader source still exists after concat to Header Segment.", s.exists(withHeaderName));
io.pravega.segmentstore.storage.rollingRollingStorageseal

Popular methods of RollingStorage

  • <init>
    Creates a new instance of the RollingStorage class.
  • create
  • delete
  • openRead
  • openWrite
  • asReadableHandle
  • asWritableHandle
  • canTruncate
  • checkIfEmptyAndNotSealed
  • checkTruncatedSegment
  • concat
  • createChunk
  • concat,
  • 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
  • Top PhpStorm 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