Search in sources :

Example 11 with GSBlobIdentifier

use of org.apache.flink.fs.gs.storage.GSBlobIdentifier in project flink by apache.

the class BlobUtilsTest method shouldProperlyConstructTemporaryObjectPartialName.

@Test
public void shouldProperlyConstructTemporaryObjectPartialName() {
    GSBlobIdentifier identifier = new GSBlobIdentifier("foo", "bar");
    String partialName = BlobUtils.getTemporaryObjectPartialName(identifier);
    assertEquals(".inprogress/foo/bar/", partialName);
}
Also used : GSBlobIdentifier(org.apache.flink.fs.gs.storage.GSBlobIdentifier) Test(org.junit.Test)

Example 12 with GSBlobIdentifier

use of org.apache.flink.fs.gs.storage.GSBlobIdentifier in project flink by apache.

the class BlobUtilsTest method shouldProperlyConstructTemporaryBlobIdentifierWithDefaultBucket.

@Test
public void shouldProperlyConstructTemporaryBlobIdentifierWithDefaultBucket() {
    Configuration flinkConfig = new Configuration();
    GSFileSystemOptions options = new GSFileSystemOptions(flinkConfig);
    GSBlobIdentifier identifier = new GSBlobIdentifier("foo", "bar");
    UUID temporaryObjectId = UUID.fromString("f09c43e5-ea49-4537-a406-0586f8f09d47");
    GSBlobIdentifier temporaryBlobIdentifier = BlobUtils.getTemporaryBlobIdentifier(identifier, temporaryObjectId, options);
    assertEquals("foo", temporaryBlobIdentifier.bucketName);
    assertEquals(".inprogress/foo/bar/f09c43e5-ea49-4537-a406-0586f8f09d47", temporaryBlobIdentifier.objectName);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) GSBlobIdentifier(org.apache.flink.fs.gs.storage.GSBlobIdentifier) UUID(java.util.UUID) GSFileSystemOptions(org.apache.flink.fs.gs.GSFileSystemOptions) Test(org.junit.Test)

Example 13 with GSBlobIdentifier

use of org.apache.flink.fs.gs.storage.GSBlobIdentifier in project flink by apache.

the class BlobUtilsTest method shouldUseTemporaryBucketNameIfSpecified.

@Test
public void shouldUseTemporaryBucketNameIfSpecified() {
    Configuration flinkConfig = new Configuration();
    flinkConfig.set(GSFileSystemOptions.WRITER_TEMPORARY_BUCKET_NAME, "temp");
    GSFileSystemOptions options = new GSFileSystemOptions(flinkConfig);
    GSBlobIdentifier identifier = new GSBlobIdentifier("foo", "bar");
    String bucketName = BlobUtils.getTemporaryBucketName(identifier, options);
    assertEquals("temp", bucketName);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) GSBlobIdentifier(org.apache.flink.fs.gs.storage.GSBlobIdentifier) GSFileSystemOptions(org.apache.flink.fs.gs.GSFileSystemOptions) Test(org.junit.Test)

Example 14 with GSBlobIdentifier

use of org.apache.flink.fs.gs.storage.GSBlobIdentifier in project flink by apache.

the class GSCommitRecoverableSerializerTest method shouldSerdeState.

@Test
public void shouldSerdeState() throws IOException {
    // create the state
    GSBlobIdentifier finalBlobIdentifier = new GSBlobIdentifier(bucketName, objectName);
    ArrayList<UUID> componentObjectIds = new ArrayList<>();
    for (int i = 0; i < componentCount; i++) {
        componentObjectIds.add(UUID.randomUUID());
    }
    GSCommitRecoverable state = new GSCommitRecoverable(finalBlobIdentifier, componentObjectIds);
    // serialize and deserialize
    GSCommitRecoverableSerializer serializer = GSCommitRecoverableSerializer.INSTANCE;
    byte[] serialized = serializer.serialize(state);
    GSCommitRecoverable deserializedState = (GSCommitRecoverable) serializer.deserialize(serializer.getVersion(), serialized);
    // check that states match
    assertEquals(bucketName, deserializedState.finalBlobIdentifier.bucketName);
    assertEquals(objectName, deserializedState.finalBlobIdentifier.objectName);
    assertEquals(componentCount, deserializedState.componentObjectIds.size());
    for (int i = 0; i < componentCount; i++) {
        assertEquals(state.componentObjectIds.get(i), deserializedState.componentObjectIds.get(i));
    }
}
Also used : GSBlobIdentifier(org.apache.flink.fs.gs.storage.GSBlobIdentifier) ArrayList(java.util.ArrayList) UUID(java.util.UUID) Test(org.junit.Test)

Example 15 with GSBlobIdentifier

use of org.apache.flink.fs.gs.storage.GSBlobIdentifier in project flink by apache.

the class GSRecoverableFsDataOutputStreamTest method before.

@Before
public void before() {
    random = new Random(TestUtils.RANDOM_SEED);
    blobIdentifier = new GSBlobIdentifier("foo", "bar");
    byteValue = (byte) 167;
    Configuration flinkConfig = new Configuration();
    if (temporaryBucketName != null) {
        flinkConfig.set(GSFileSystemOptions.WRITER_TEMPORARY_BUCKET_NAME, temporaryBucketName);
    }
    componentObjectIds = new ArrayList<>();
    for (int i = 0; i < componentObjectCount; i++) {
        componentObjectIds.add(UUID.randomUUID());
    }
    options = new GSFileSystemOptions(flinkConfig);
    blobStorage = new MockBlobStorage();
    if (empty) {
        fsDataOutputStream = new GSRecoverableFsDataOutputStream(blobStorage, options, blobIdentifier);
    } else {
        GSResumeRecoverable resumeRecoverable = new GSResumeRecoverable(blobIdentifier, componentObjectIds, position, closed);
        fsDataOutputStream = new GSRecoverableFsDataOutputStream(blobStorage, options, resumeRecoverable);
    }
}
Also used : Random(java.util.Random) Configuration(org.apache.flink.configuration.Configuration) GSBlobIdentifier(org.apache.flink.fs.gs.storage.GSBlobIdentifier) MockBlobStorage(org.apache.flink.fs.gs.storage.MockBlobStorage) GSFileSystemOptions(org.apache.flink.fs.gs.GSFileSystemOptions) Before(org.junit.Before)

Aggregations

GSBlobIdentifier (org.apache.flink.fs.gs.storage.GSBlobIdentifier)25 UUID (java.util.UUID)14 Test (org.junit.Test)11 Configuration (org.apache.flink.configuration.Configuration)9 GSFileSystemOptions (org.apache.flink.fs.gs.GSFileSystemOptions)8 MockBlobStorage (org.apache.flink.fs.gs.storage.MockBlobStorage)7 ArrayList (java.util.ArrayList)6 Before (org.junit.Before)5 Random (java.util.Random)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 MemorySize (org.apache.flink.configuration.MemorySize)1 Path (org.apache.flink.core.fs.Path)1 RecoverableFsDataOutputStream (org.apache.flink.core.fs.RecoverableFsDataOutputStream)1 RecoverableWriter (org.apache.flink.core.fs.RecoverableWriter)1 GSBlobStorage (org.apache.flink.fs.gs.storage.GSBlobStorage)1 GSRecoverableWriter (org.apache.flink.fs.gs.writer.GSRecoverableWriter)1