好日子的同事。我开发了一个基于sparkLauncher运行一个可执行的JAR,其中有5个操作的应用程序。取决于具体的变量中的每个操作。我有一个主要的Hadoop集群spark2.3.0-hadoop2.6.5。它的工作原理好就可以了。我工作的代码部分:
private void runSparkJob(String pathToJar, final LocalDate startDate, final LocalDate endDate) {
if (executionInProgress.get()) {
LOGGER.warn("Execution already in progress");
return;
}
Process sparkProcess = null;
try {
LOGGER.info("Create SparkLauncher. SparkHome: [{}]. JarPath: [{}].", sparkHome, vmJarPath);
executionInProgress.set(true);
sparkProcess = new SparkLauncher()
.setAppName(activeOperationProfile)
.setSparkHome(sparkHome) //sparkHome folder on main cluster
.setAppResource(pathToJar) // jar with 5 operation
.setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
String.format("-Drunner.operation-profile=%1$s -Doperation.startDate=%2$s -Doperation.endDate=%3$s", activeOperationProfile, startDate,endDate))
.setConf(SparkLauncher.DRIVER_MEMORY, "12G")
.redirectToLog(LOGGER.getName())
.setMaster("yarn")
.launch();
sparkProcess.waitFor();
int exitCode = sparkProcess.exitValue();
if (exitCode != 0) {
throw new RuntimeException("Illegal exit code. Expected: [0]. Actual: [" + exitCode + "]");
}
} catch (IOException | InterruptedException e) {
LOGGER.error("Error occurred while running SparkApplication.", e);
throw new RuntimeException(e);
} finally {
if (sparkProcess != null && sparkProcess.isAlive()) {
LOGGER.warn("Process still alive. Try to kill");
sparkProcess.destroy();
}
executionInProgress.set(false);
}
}
我已经开始了一个码头工人的容器,其中一个是下载的火花2.3.0-hadoop6。该容器需要测试人员。我换了主人.setMaster(“本地”),提出了新的配置文件与路径sparkHome,jarsWithOpertations和包装罐子没有阴影(带遮阳尝试,并没有工作对我来说)。当我试图运行我sparkLaunch应用程序,我现在有一个例外:
2018年8月6日14:47:53150 INFO [nmmbrSparkBaseOperationsRunner.runSparkJob] 105:创建SparkLauncher。SparkHome:[/opt/bigtv/spark/spark-2.3.0-bin-hadoop2.6]。JarPath:[/opt/bigtv/bin/multirating-bigdata-operations-MASTER-SNAPSHOT.jar]。2018年8月6日14:47:54905 INFO [oaspark.launcher.OutputRedirector.redirect] 63:2018年8月6日14点47分54秒WARN NativeCodeLoader:62 - 无法加载原生的Hadoop库平台...使用内置的Java类在适用情况下2018年8月6日14:47:57042 INFO [oaspark.launcher.OutputRedirector.redirect] 63:2018年8月6日十四点47分57秒ERROR SpringApplication:842 - 应用程序运行失败2018-08 -06 14:47:57043 INFO [oaspark.launcher.OutputRedirector.redirect] 63:。java.lang.NoSuchMethodError:org.yaml.snakeyaml.Yaml(Lorg / YAML / snakeyaml /构造/ BaseConstructor; Lorg / YAML / snakeyaml / Represente / Represente; Lorg / YAML / snakeyaml / DumperOptions; Lorg / YAML / snakeyaml /装载程序选项; Lorg / YAML / snakeyaml /分解器/分解器;)V2018年8月6日14:47:57043 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.env.OriginTrackedYamlLoader.createYaml(OriginTrackedYamlLoader.java:70)2018年8月6日14时四十七: 57043 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:139)2018年8月6日14:47:57044 INFO [oaspark.launcher。 OutputRedirector.redirect] 63:在org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75)2018年8月6日14:47:57044 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在有机springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)2018年8月6日14:47:57044 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config。ConfigFileApplicationListener $ Loader.loadDocuments(ConfigFileApplicationListener.java:547)2018年8月6日14:47:57044 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener $ Loader.load方法(ConfigFileApplicationListener.java:517)2018年8月6日14:47:57045 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener $ Loader.loadForFileExtension(ConfigFileApplicationListener.java: 496)2018年8月6日14:47:57045 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener $ Loader.load方法(ConfigFileApplicationListener.java:464)2018-08 -06 14:47:57045 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config。ConfigFileApplicationListener $ $ Loader.lambda空$ 6(ConfigFileApplicationListener.java:446)2018年8月6日14:47:57046 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在java.lang.Iterable.forEach(Iterable.java: 75)2018年8月6日14:47:57046 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener $ $ Loader.lambda负载$ 7(ConfigFileApplicationListener.java:445) 2018年8月6日14:47:57046 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在java.lang.Iterable.forEach(Iterable.java:75)2018年8月6日14:47:57046 INFO [oaspark .launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener $ Loader.load方法(ConfigFileApplicationListener.java:442)2018年8月6日14:47:57046 INFO [oaspark.launcher.OutputRedirector。重定向] 63:在组织。springframework.boot.context.config.ConfigFileApplicationListener $ Loader.load方法(ConfigFileApplicationListener.java:330)2018年8月6日14:47:57047 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context .config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:212)2018年8月6日14:47:57047 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment( ConfigFileApplicationListener.java:195)2018年8月6日14:47:57047 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)2018 -08-06 14:47:57047 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)2018年8月6日14:47:57048 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.context。 event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)2018年8月6日14:47:57048 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java :165)2018年8月6日14:47:57048 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)2018年8月6日14 :47:57048 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在有机springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)2018年8月6日14:47:57049 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.context.event.EventPublishingRunListener .environmentPrepared(EventPublishingRunListener.java:74)2018年8月6日14:47:57049 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)2018- 08-06 14:47:57049 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)2018年8月6日14:47:57049 INFO [oaspark .launcher.OutputRedirector.redirect] 63:在org.springframework.boot.SpringApplication.run(SpringApplication.java:317)2018年8月6日14:47:57050 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)2018年8月6日14时47: 57050 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)2018年8月6日14:47:57050 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在net.mediascope.multirating.bigdata.operations.OperationRunner.main(OperationRunner.java:21)2018年8月6日14:47:57050 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在sun.reflect。 NativeMethodAccessorImpl.invoke0(本机方法)2018年8月6日14:47:57050 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)2018年8月6日14 :47:57051 INFO [oaspark.launcher。OutputRedirector.redirect] 63:在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)2018年8月6日14:47:57051 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在java.lang.relfect包。 Method.invoke(Method.java:498)2018年8月6日14:47:57051 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48 )2018年8月6日14:47:57051 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.loader.Launcher.launch(Launcher.java:87)2018年8月6日14时47分:57052 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.springframework.boot.loader.Launcher.launch(Launcher.java:50)2018年8月6日14:47:57052 INFO [oaspark.launcher.OutputRedirector .redirect] 63:在org.springframework.boot.loader.JarLauncher。主(JarLauncher.java:51)2018年8月6日14:47:57052 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)2018年8月6日14时47 :57052 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)2018年8月6日14:47:57053 INFO [oaspark.launcher.OutputRedirector.redirect] 63 :在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)2018年8月6日14:47:57053 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在java.lang.reflect.Method.invoke(方法的.java:498)2018年8月6日14:47:57053 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)2018-08- 06 14:47:57053 INFO [oaspark.launcher。OutputRedirector.redirect] 63:在org.apache.spark.deploy.SparkSubmit $ $ .ORG阿帕奇$ $火花部署$ $$ SparkSubmit runMain(SparkSubmit.scala:879)2018年8月6日14:47:57054 INFO [oaspark .launcher.OutputRedirector.redirect] 63:在org.apache.spark.deploy.SparkSubmit $ .doRunMain $ 1(SparkSubmit.scala:197)2018年8月6日14:47:57054 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.apache.spark.deploy.SparkSubmit $ .submit(SparkSubmit.scala:227)2018年8月6日14:47:57054 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.apache.spark .deploy.SparkSubmit $。主要(SparkSubmit.scala:136)2018年8月6日14:47:57054 INFO [oaspark.launcher.OutputRedirector.redirect] 63:在org.apache.spark.deploy.SparkSubmit.main(SparkSubmit .scala)2018年8月6日14:47:57058 INFO [oaspark.launcher.OutputRedirector.redirect] 63:2018年8月6日14时四十七:57 INFO ShutdownHookManager:54 - 关闭钩称为2018年8月6日14:47:57060 INFO [oaspark.launcher.OutputRedirector.redirect] 63:2018年8月6日14时47分57秒INFO ShutdownHookManager:54 - 删除/ tmp目录/火花55b54924-e628-43fe-9e43-ed34d7f35a8b 2018年8月6日14:47:57151 INFO [osbalConditionEvaluationReportLoggingListener.logAutoConfigurationReport] 101:
错误启动的ApplicationContext。要显示的条件报告重新运行应用程序与“调试”启用。
在项目中,我从春天5.0和没有其他dependicies蛇YAML 1.19。我不明白是什么问题,也许当我把它变成搬运工容器手动,有必要安装别的东西,除了火花。
从操作模块双响炮:
<dependencies>
<dependency>
<groupId>net.mediascope</groupId>
<artifactId>multirating-bigdata-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<!-- Data Base -->
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi</artifactId>
<version>2.71</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc42</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.janino</groupId>
<artifactId>commons-compiler</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<profiles>
<profile>${profile.active}</profile>
</profiles>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>hadoop</id>
<build>
<!--Необходимо для адаптации Spring-Boot приложения под запуск через Spark-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.provides</resource>
</transformer>
<transformer
implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${start-class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>I
我已经找到了解决方案。产地火花包有文件夹罐子其中snakeyml 1.15,我改成了1.19和所有的工作了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句