Hi all, I am trying to use fileSink with abfs and ...
# troubleshooting
l
Hi all, I am trying to use fileSink with abfs and I am getting this error. I will appreciate if someone can explain me what am I missing My code -
Copy code
package com.controlup.blobuploader.sink

import com.controlup.blobuploader.EntityBucketAssigner
import com.controlup.common.logging.LoggingConfigs
import com.controlup.common.logging.msgs.LogMessage
import com.controlup.crossflink.logging.LoggerFactory.logger
import com.google.protobuf.Message
import com.typesafe.config.Config
import org.apache.flink.connector.file.sink.FileSink
import org.apache.flink.core.fs.Path
import org.apache.flink.core.io.SimpleVersionedSerializer
import org.apache.flink.formats.parquet.ParquetBuilder
import org.apache.flink.formats.parquet.ParquetWriterFactory
import org.apache.flink.formats.parquet.protobuf.ParquetProtoWriters
import org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner
import org.apache.flink.streaming.api.functions.sink.filesystem.OutputFileConfig
import org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.SimpleVersionedStringSerializer
import org.apache.hadoop.conf.Configuration
import org.apache.parquet.hadoop.ParquetWriter
import org.apache.parquet.io.OutputFile

import java.net.URI
import scala.reflect.{ClassTag, classTag}

object ParquetSink {

  def parquetFileSink[A <: Message: ClassTag: BucketIdCreator](
                                                                basePath: Path,
                                               config: Config
                                             ): FileSink[A] = {

    val accountName = <account_namw>
    val accountKey = <account_key>
    val containerName = <container_name>
    val conf = new Configuration()
    conf.set(s"fs.azure.account.key.$accountName.dfs.core.windows.net", accountKey)

    def builder(outFile: OutputFile): ParquetWriter[A] =
      new ParquetProtoWriters.ParquetProtoWriterBuilder(
        outFile,
        implicitly[ClassTag[A]].runtimeClass.asInstanceOf[Class[A]]
      ).withConf(conf).build()

    val parquetBuilder: ParquetBuilder[A] = path => builder(path)

    FileSink
      .forBulkFormat(
        new Path(s"abfs://$containerName@$accountName.dfs.core.windows.net"),
        new ParquetWriterFactory[A](parquetBuilder)
      )
      .withBucketAssigner(EntityBucketAssigner.apply)
      .withOutputFileConfig(
        OutputFileConfig
          .builder()
          .withPartSuffix(".parquet")
          .build()
      )
      .build()
  }

}
The error I receive -
Copy code
Exception in thread "main" org.apache.flink.util.FlinkRuntimeException: Could not create committable serializer.
	at org.apache.flink.connector.file.sink.FileSink.getCommittableSerializer(FileSink.java:182)
	at org.apache.flink.streaming.api.connector.sink2.CommittableMessageTypeInfo.toString(CommittableMessageTypeInfo.java:120)
	at java.base/java.lang.String.valueOf(String.java:2951)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:172)
	at org.apache.flink.api.dag.Transformation.toString(Transformation.java:591)
	at java.base/java.lang.String.valueOf(String.java:2951)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:172)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transform(StreamGraphGenerator.java:530)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator.access$200(StreamGraphGenerator.java:136)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator$ContextImpl.transform(StreamGraphGenerator.java:957)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.apache.flink.streaming.runtime.translators.SinkTransformationTranslator$SinkExpander.expand(SinkTransformationTranslator.java:165)
	at org.apache.flink.streaming.runtime.translators.SinkTransformationTranslator$SinkExpander.access$000(SinkTransformationTranslator.java:101)
	at org.apache.flink.streaming.runtime.translators.SinkTransformationTranslator.translateInternal(SinkTransformationTranslator.java:91)
	at org.apache.flink.streaming.runtime.translators.SinkTransformationTranslator.translateForStreaming(SinkTransformationTranslator.java:79)
	at org.apache.flink.streaming.runtime.translators.SinkTransformationTranslator.translateForStreaming(SinkTransformationTranslator.java:63)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator.translate(StreamGraphGenerator.java:849)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transform(StreamGraphGenerator.java:579)
	at org.apache.flink.streaming.api.graph.StreamGraphGenerator.generate(StreamGraphGenerator.java:319)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2248)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2239)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2225)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:2052)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:2036)
	at org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.scala:858)
	at com.controlup.blobuploader.Stream$.execute(Stream.scala:89)
	at com.controlup.blobuploader.Stream$.main(Stream.scala:64)
	at com.controlup.blobuploader.Stream.main(Stream.scala)
Caused by: Failure to initialize configuration
	at org.apache.hadoop.fs.azurebfs.services.SimpleKeyProvider.getStorageAccountKey(SimpleKeyProvider.java:51)
	at org.apache.hadoop.fs.azurebfs.AbfsConfiguration.getStorageAccountKey(AbfsConfiguration.java:586)
	at org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.initializeClient(AzureBlobFileSystemStore.java:1560)
	at org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.<init>(AzureBlobFileSystemStore.java:236)
	at org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem.initialize(AzureBlobFileSystem.java:183)
	at org.apache.flink.fs.azurefs.AbstractAzureFSFactory.create(AbstractAzureFSFactory.java:78)
	at org.apache.flink.core.fs.FileSystem.getUnguardedFileSystem(FileSystem.java:508)
	at org.apache.flink.core.fs.FileSystem.get(FileSystem.java:409)
	at org.apache.flink.connector.file.sink.FileSink$BulkFormatBuilder.createBucketWriter(FileSink.java:674)
	at org.apache.flink.connector.file.sink.FileSink$BulkFormatBuilder.getCommittableSerializer(FileSink.java:665)
	at org.apache.flink.connector.file.sink.FileSink.getCommittableSerializer(FileSink.java:177)
y
If you take a look at the method call, there's a try catch there with a comment saying that there's an internal FileSystem.get() call when creating the serializer.
Copy code
// it's not optimal that we have to do this but creating the serializers for the
        // FileSink requires (among other things) a call to FileSystem.get() which declares. 
       // IOException.
    throw new FlinkRuntimeException("Could not create committable serializer.", e);
I would check the permissions on your ADFS and make sure the path is valid. Put a breakpoint in the exception and see the internal error
l
Thank you @Yuval Itzchakov I will check
πŸ‘πŸ» 1
I put a break point in the exception and I see the error that we see above
Copy code
Caused by: Failure to initialize configuration