Не удалось предоставить кодировщик для org.apache.hadoop.hbase.client.Mutation с использованием HBaseIO с FlinkRunner.

Я столкнулся с проблемой «Невозможно предоставить кодер для org.apache.hadoop.hbase.client.Mutation». используя HbaseIO с FlinkRunner. Исключение ниже:

Exception in thread "main" java.lang.IllegalStateException: Unable to return a default Coder for ParDo(HBaseProfile)/ParMultiDo(HBaseProfile).output [PCollection]. Correct one of the following root causes:
No Coder has been manually specified;  you may do so using .setCoder().

Inferring a Coder from the CoderRegistry failed: Unable to provide a Coder for org.apache.hadoop.hbase.client.Mutation.
  Building a Coder using a registered CoderProvider failed.
  See suppressed exceptions for detailed failures.
  Using the default output Coder from the producing PTransform failed: PTransform.getOutputCoder called.
    at org.apache.beam.repackaged.beam_sdks_java_core.com.google.common.base.Preconditions.checkState(Preconditions.java:444)
    at org.apache.beam.sdk.values.PCollection.getCoder(PCollection.java:278)
    at org.apache.beam.sdk.values.PCollection.finishSpecifying(PCollection.java:115)
    at org.apache.beam.sdk.runners.TransformHierarchy.finishSpecifyingInput(TransformHierarchy.java:190)
    at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:536)
    at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:488)
    at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:370)
    at ac.cn.iie.process.ProfileProcess.process(ProfileProcess.java:91)
    at ac.cn.iie.Bootstrap.main(Bootstrap.java:25)

У меня есть плагин maven-shade-plugin для упаковки моей банки:

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>ac.cn.iie.Bootstrap</mainClass>
                            </transformer>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>reference.conf</resource>
                            </transformer>
                        </transformers>
                        <relocations>
                            <relocation>
                                <pattern>org.codehaus.plexus.util</pattern>
                                <shadedPattern>org.shaded.plexus.util</shadedPattern>
                                <excludes>
                                    <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                                    <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
                                </excludes>
                            </relocation>
                        </relocations>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Кто-нибудь знает причину?


person K Fred    schedule 08.11.2018    source источник


Ответы (2)


Я решил свою проблему, зарегистрировав Beam CoderProvider вручную. Код ниже:

CoderRegistry coderRegistry = pipeline.getCoderRegistry();
coderRegistry.registerCoderProvider(
    new HBaseCoderProviderRegistrar().getCoderProviders().get(0));

HBaseCoderProviderRegistrar() предоставляет список CoderProvider с помощью метода getCoderProviders(), а индекс 0 списка — это HBaseMutationCoder. Поскольку мой код использует HBaseIO.write(), просто нужно зарегистрировать Mutation Coder.

person K Fred    schedule 08.11.2018

Обратите внимание, что HBaseCoderProviderRegistrar уже автоматически регистрирует HBaseMutationCoder для типа Mutation.

Использование подключаемого модуля maven-shade без обработки файлов service, содержащихся в META-INF/, внутри выходного jar-файла является распространенной ошибкой для пользователей. Вы хотите добавить ServicesResourceTransformer в свой список преобразователей следующим образом:

<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

См. документацию по Apache и ServiceLoader javadoc для получения дополнительной информации. На StackOverflow есть много других подобных вопросов.

person Lukasz Cwik    schedule 08.11.2018