├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java ├── com │ └── jthink │ │ └── teemo │ │ └── properties │ │ └── TaskProperties.java └── org │ └── springframework │ └── context │ └── annotation │ └── PropertySource.java ├── resources ├── application.properties ├── banner.txt ├── log4j.xml └── properties │ └── teemo.properties └── scala └── com └── jthink └── teemo ├── configuration └── SparkConfiguration.scala ├── dto └── ApiStatisticDto.scala ├── launcher └── Launcher.scala ├── model ├── key │ ├── Key.scala │ └── statistic │ │ ├── TimeApiKey.scala │ │ └── TimeApiStatusKey.scala └── value │ ├── Value.scala │ └── statistic │ ├── StatusCntValue.scala │ └── SuccessFailedCntValue.scala └── task ├── Task.scala └── TestTask.scala /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | target/ 3 | file/ 4 | logs/ 5 | gen-java/ 6 | .externalToolBuilders/ 7 | .settings/ 8 | .gradle/ 9 | .classpath 10 | .gradletasknamecache 11 | .buildpath 12 | .project 13 | .springBeans 14 | dependency-reduced-pom.xml 15 | *.iml 16 | nohup.out 17 | /tmp 18 | /.apt_generated/ 19 | .idea/ 20 | disconf/ 21 | /target/ 22 | /build/ 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scala+spring boot写spark代码骨架 2 | 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | jthink 7 | teemo 8 | 0.0.1 9 | jar 10 | http://maven.apache.org 11 | 12 | 13 | UTF-8 14 | 1.7 15 | 0.0.1 16 | 2.10.5 17 | 2.10 18 | 1.6.0-cdh5.9.0 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-parent 24 | 1.3.6.RELEASE 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-logging 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.scala-lang 44 | scala-library 45 | ${scala.version} 46 | provided 47 | 48 | 49 | org.scala-lang 50 | scala-compiler 51 | ${scala.version} 52 | provided 53 | 54 | 55 | 56 | 57 | org.apache.spark 58 | spark-core_${scala.binary.version} 59 | ${spark.version} 60 | provided 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-test 67 | 68 | 69 | 70 | 71 | 72 | net.alchim31.maven 73 | scala-maven-plugin 74 | 3.2.2 75 | 76 | 77 | compile-scala 78 | compile 79 | 80 | add-source 81 | compile 82 | 83 | 84 | 85 | test-compile-scala 86 | test-compile 87 | 88 | add-source 89 | testCompile 90 | 91 | 92 | 93 | 94 | incremental 95 | ${scala.version} 96 | 97 | -deprecation 98 | 99 | 100 | -Xmx8192m 101 | -Xms1024m 102 | 103 | 104 | 105 | 106 | 107 | org.apache.maven.plugins 108 | maven-shade-plugin 109 | 3.0-SNAPSHOT 110 | 111 | 112 | 113 | *:* 114 | 115 | META-INF/*.SF 116 | META-INF/*.DSA 117 | META-INF/*.RSA 118 | 119 | 120 | 121 | 122 | 123 | META-INF/spring.handlers 124 | 125 | 126 | META-INF/spring.schemas 127 | 128 | 129 | 130 | 131 | 132 | package 133 | 134 | shade 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | cloudera 145 | https://repository.cloudera.com/artifactory/cloudera-repos 146 | 147 | 148 | -------------------------------------------------------------------------------- /src/main/java/com/jthink/teemo/properties/TaskProperties.java: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * jthink company 7 | * 8 | * @author jthink 9 | * @version 0.0.1 10 | * @desc 任务相关的task 11 | * @date 2017-01-11 16:17:27 12 | */ 13 | @ConfigurationProperties(prefix = "spring.spark.task") 14 | public class TaskProperties { 15 | 16 | // spark job名字 17 | private String name; 18 | 19 | // hdfs路径 20 | private String srcPath; 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getSrcPath() { 31 | return srcPath; 32 | } 33 | 34 | public void setSrcPath(String srcPath) { 35 | this.srcPath = srcPath; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/context/annotation/PropertySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.context.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * Annotation providing a convenient and declarative mechanism for adding a 23 | * {@link org.springframework.core.env.PropertySource PropertySource} to Spring's 24 | * {@link org.springframework.core.env.Environment Environment}. To be used in 25 | * conjunction with @{@link Configuration} classes. 26 | * 27 | *

Example usage

28 | * 29 | *

Given a file {@code app.properties} containing the key/value pair 30 | * {@code testbean.name=myTestBean}, the following {@code @Configuration} class 31 | * uses {@code @PropertySource} to contribute {@code app.properties} to the 32 | * {@code Environment}'s set of {@code PropertySources}. 33 | * 34 | *

 35 |  * @Configuration
 36 |  * @PropertySource("classpath:/com/myco/app.properties")
 37 |  * public class AppConfig {
 38 |  *     @Autowired
 39 |  *     Environment env;
 40 |  *
 41 |  *     @Bean
 42 |  *     public TestBean testBean() {
 43 |  *         TestBean testBean = new TestBean();
 44 |  *         testBean.setName(env.getProperty("testbean.name"));
 45 |  *         return testBean;
 46 |  *     }
 47 |  * }
48 | * 49 | * Notice that the {@code Environment} object is @{@link 50 | * org.springframework.beans.factory.annotation.Autowired Autowired} into the 51 | * configuration class and then used when populating the {@code TestBean} object. Given 52 | * the configuration above, a call to {@code testBean.getName()} will return "myTestBean". 53 | * 54 | *

Resolving ${...} placeholders in {@code } and {@code @Value} annotations

55 | * 56 | * In order to resolve ${...} placeholders in {@code } definitions or {@code @Value} 57 | * annotations using properties from a {@code PropertySource}, one must register 58 | * a {@code PropertySourcesPlaceholderConfigurer}. This happens automatically when using 59 | * {@code } in XML, but must be explicitly registered using 60 | * a {@code static} {@code @Bean} method when using {@code @Configuration} classes. See 61 | * the "Working with externalized values" section of @{@link Configuration}'s javadoc and 62 | * "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean}'s javadoc 63 | * for details and examples. 64 | * 65 | *

Resolving ${...} placeholders within {@code @PropertySource} resource locations

66 | * 67 | * Any ${...} placeholders present in a {@code @PropertySource} {@linkplain #value() 68 | * resource location} will be resolved against the set of property sources already 69 | * registered against the environment. For example: 70 | * 71 | *
 72 |  * @Configuration
 73 |  * @PropertySource("classpath:/com/${my.placeholder:default/path}/app.properties")
 74 |  * public class AppConfig {
 75 |  *     @Autowired
 76 |  *     Environment env;
 77 |  *
 78 |  *     @Bean
 79 |  *     public TestBean testBean() {
 80 |  *         TestBean testBean = new TestBean();
 81 |  *         testBean.setName(env.getProperty("testbean.name"));
 82 |  *         return testBean;
 83 |  *     }
 84 |  * }
85 | * 86 | * Assuming that "my.placeholder" is present in one of the property sources already 87 | * registered, e.g. system properties or environment variables, the placeholder will 88 | * be resolved to the corresponding value. If not, then "default/path" will be used as a 89 | * default. Expressing a default value (delimited by colon ":") is optional. If no 90 | * default is specified and a property cannot be resolved, an {@code 91 | * IllegalArgumentException} will be thrown. 92 | * 93 | *

A note on property overriding with @PropertySource

94 | * 95 | * In cases where a given property key exists in more than one {@code .properties} 96 | * file, the last {@code @PropertySource} annotation processed will 'win' and override. 97 | * 98 | * For example, given two properties files {@code a.properties} and 99 | * {@code b.properties}, consider the following two configuration classes 100 | * that reference them with {@code @PropertySource} annotations: 101 | * 102 | *
103 |  * @Configuration
104 |  * @PropertySource("classpath:/com/myco/a.properties")
105 |  * public class ConfigA { }
106 |  *
107 |  * @Configuration
108 |  * @PropertySource("classpath:/com/myco/b.properties")
109 |  * public class ConfigB { }
110 |  * 
111 | * 112 | * The override ordering depends on the order in which these classes are registered 113 | * with the application context. 114 | *
115 |  * AnnotationConfigApplicationContext ctx =
116 |  *     new AnnotationConfigApplicationContext();
117 |  * ctx.register(ConfigA.class);
118 |  * ctx.register(ConfigB.class);
119 |  * ctx.refresh();
120 |  * 
121 | * 122 | * In the scenario above, the properties in {@code b.properties} will override any 123 | * duplicates that exist in {@code a.properties}, because {@code ConfigB} was registered 124 | * last. 125 | * 126 | *

In certain situations, it may not be possible or practical to tightly control 127 | * property source ordering when using {@code @ProperySource} annotations. For example, 128 | * if the {@code @Configuration} classes above were registered via component-scanning, 129 | * the ordering is difficult to predict. In such cases - and if overriding is important - 130 | * it is recommended that the user fall back to using the programmatic PropertySource API. 131 | * See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} 132 | * and {@link org.springframework.core.env.MutablePropertySources MutablePropertySources} 133 | * javadocs for details. 134 | * 135 | * @author Chris Beams 136 | * @author Phillip Webb 137 | * @since 3.1 138 | * @see PropertySources 139 | * @see Configuration 140 | * @see org.springframework.core.env.PropertySource 141 | * @see org.springframework.core.env.ConfigurableEnvironment#getPropertySources() 142 | * @see org.springframework.core.env.MutablePropertySources 143 | */ 144 | @Target(ElementType.TYPE) 145 | @Retention(RetentionPolicy.RUNTIME) 146 | @Documented 147 | public @interface PropertySource { 148 | 149 | /** 150 | * Indicate the name of this property source. If omitted, a name 151 | * will be generated based on the description of the underlying 152 | * resource. 153 | * @see org.springframework.core.env.PropertySource#getName() 154 | * @see org.springframework.core.io.Resource#getDescription() 155 | */ 156 | String name() default ""; 157 | 158 | /** 159 | * Indicate the resource location(s) of the properties file to be loaded. 160 | * For example, {@code "classpath:/com/myco/app.properties"} or 161 | * {@code "file:/path/to/file"}. 162 | *

Resource location wildcards (e.g. **/*.properties) are not permitted; 163 | * each location must evaluate to exactly one {@code .properties} resource. 164 | *

${...} placeholders will be resolved against any/all property sources already 165 | * registered with the {@code Environment}. See {@linkplain org.springframework.context.annotation.PropertySource above} 166 | * for examples. 167 | *

Each location will be added to the enclosing {@code Environment} as its own 168 | * property source, and in the order declared. 169 | */ 170 | String[] value(); 171 | 172 | /** 173 | * Indicate if failure to find the a {@link #value() property resource} should be 174 | * ignored. 175 | *

{@code true} is appropriate if the properties file is completely optional. 176 | * Default is {@code false}. 177 | * @since 4.0 178 | */ 179 | boolean ignoreResourceNotFound() default false; 180 | 181 | } 182 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.spark.task.name=${task.name} 2 | spring.spark.task.srcPath=${task.src.path} 3 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ▄▄▄▄▀ ▄███▄ ▄███▄ █▀▄▀█ ████▄ 4 | ▀▀▀ █ █▀ ▀ █▀ ▀ █ █ █ █ █ 5 | █ ██▄▄ ██▄▄ █ ▄ █ █ █ 6 | █ █▄ ▄▀ █▄ ▄▀ █ █ ▀████ 7 | ▀ ▀███▀ ▀███▀ █ 8 | ▀ 9 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/main/resources/properties/teemo.properties: -------------------------------------------------------------------------------- 1 | task.name=xxx algorithm 2 | task.src.path=/user/xxx/xxx/xxx 3 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/configuration/SparkConfiguration.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.configuration 2 | 3 | import com.jthink.teemo.properties.TaskProperties 4 | import org.apache.spark.{SparkConf, SparkContext} 5 | import org.springframework.beans.factory.annotation.Autowired 6 | import org.springframework.context.annotation.{Bean, Configuration} 7 | 8 | /** 9 | * jthink company 10 | * 11 | * @author jthink 12 | * @version 0.0.1 13 | */ 14 | @Configuration 15 | class SparkConfiguration { 16 | 17 | @Autowired 18 | @transient 19 | var taskProperties: TaskProperties = _ 20 | 21 | @Bean 22 | def sparkContext(): SparkContext = { 23 | val conf = new SparkConf().setAppName(this.taskProperties.getName) 24 | val sc = new SparkContext(conf) 25 | sc 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/dto/ApiStatisticDto.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.dto 2 | 3 | /** 4 | * jthink company 5 | * 6 | * @author jthink 7 | * @version 0.0.1 8 | */ 9 | class ApiStatisticDto { 10 | 11 | // row key 12 | var row: String = _ 13 | // api 14 | var api: String = _ 15 | // api请求的状态 16 | var status: String = _ 17 | // api请求的次数 18 | var cnt: Int = _ 19 | } 20 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/launcher/Launcher.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.launcher 2 | 3 | import com.jthink.teemo.properties.TaskProperties 4 | import com.jthink.teemo.task.TestTask 5 | import org.slf4j.{Logger, LoggerFactory} 6 | import org.springframework.boot.autoconfigure.SpringBootApplication 7 | import org.springframework.boot.builder.SpringApplicationBuilder 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties 9 | import org.springframework.context.ConfigurableApplicationContext 10 | import org.springframework.context.annotation.{ComponentScan, PropertySource} 11 | 12 | /** 13 | * jthink company 14 | * 15 | * 项目启动器 16 | * 17 | * @author jthink 18 | * @version 0.0.1 19 | */ 20 | @SpringBootApplication 21 | @ComponentScan(basePackages = Array("com.jthink.teemo")) 22 | //@PropertySource(Array("file:/the/file/location/teemo/teemo.properties")) 23 | @PropertySource(Array("classpath:properties/teemo.properties")) 24 | @EnableConfigurationProperties(Array(classOf[TaskProperties])) 25 | class Launcher { 26 | } 27 | 28 | object Launcher { 29 | private val TASK_MAPPING = Map("test" -> classOf[TestTask]) 30 | private val LOGGER: Logger = LoggerFactory.getLogger(classOf[Launcher]) 31 | 32 | def main(args: Array[String]): Unit = { 33 | if (args.length != 1) { 34 | LOGGER.info("参数不对, 参数如下:") 35 | LOGGER.info("参数1: 需要执行的task name") 36 | } else { 37 | val t = args(0).toString 38 | if (!TASK_MAPPING.contains(t)) { 39 | LOGGER.info("task 不存在") 40 | } else { 41 | val context: ConfigurableApplicationContext = new SpringApplicationBuilder(classOf[Launcher]).run(args: _*) 42 | LOGGER.info("teemo start successfully") 43 | val task = context.getBean(TASK_MAPPING.get(t).get) 44 | // 开始执行具体的业务 45 | task.doTask() 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/key/Key.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.key 2 | 3 | /** 4 | * jthink company 5 | * 6 | * @author jthink 7 | * @version 0.0.1 8 | */ 9 | trait Key extends Serializable { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/key/statistic/TimeApiKey.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.key.statistic 2 | 3 | import com.jthink.teemo.model.key.Key 4 | 5 | /** 6 | * jthink company 7 | * 8 | * 统计的key 9 | * 10 | * @author jthink 11 | * @version 0.0.1 12 | */ 13 | class TimeApiKey(_time: String, _api: String) extends Key { 14 | 15 | // time, 到秒的String 16 | var time: String = _time 17 | // api 18 | var api: String = _api 19 | 20 | def canEqual(other: Any): Boolean = other.isInstanceOf[TimeApiKey] 21 | 22 | override def equals(other: Any): Boolean = other match { 23 | case that: TimeApiKey => 24 | (that canEqual this) && 25 | time == that.time && 26 | api == that.api 27 | case _ => false 28 | } 29 | 30 | override def hashCode(): Int = { 31 | val state = Seq(time, api) 32 | state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) 33 | } 34 | 35 | override def toString = s"TimeApiKey($time, $api)" 36 | } 37 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/key/statistic/TimeApiStatusKey.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.key.statistic 2 | 3 | import com.jthink.teemo.model.key.Key 4 | 5 | /** 6 | * jthink company 7 | * 8 | * 统计的key 9 | * 10 | * @author jthink 11 | * @version 0.0.1 12 | */ 13 | class TimeApiStatusKey(_time: String, _api: String, _status: String) extends Key { 14 | 15 | // time, 到秒的String 16 | var time: String = _time 17 | // api 18 | var api: String = _api 19 | // status 20 | var status: String = _status 21 | 22 | def canEqual(other: Any): Boolean = other.isInstanceOf[TimeApiStatusKey] 23 | 24 | override def equals(other: Any): Boolean = other match { 25 | case that: TimeApiStatusKey => 26 | (that canEqual this) && 27 | time == that.time && 28 | api == that.api && 29 | status == that.status 30 | case _ => false 31 | } 32 | 33 | override def hashCode(): Int = { 34 | val state = Seq(time, api, status) 35 | state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) 36 | } 37 | 38 | override def toString = s"TimeApiStatusKey($time, $api, $status)" 39 | } 40 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/value/Value.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.value 2 | 3 | /** 4 | * jthink company 5 | * 6 | * @author jthink 7 | * @version 0.0.1 8 | */ 9 | trait Value extends Serializable { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/value/statistic/StatusCntValue.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.value.statistic 2 | 3 | import com.jthink.teemo.model.value.Value 4 | 5 | /** 6 | * jthink company 7 | * 8 | * @author jthink 9 | * @version 0.0.1 10 | */ 11 | class StatusCntValue(_status: String, _cnt: Int) extends Value { 12 | 13 | // status 14 | var status: String = _status 15 | // 该状态统计的次数 16 | var cnt: Int = _cnt 17 | 18 | def canEqual(other: Any): Boolean = other.isInstanceOf[StatusCntValue] 19 | 20 | override def equals(other: Any): Boolean = other match { 21 | case that: StatusCntValue => 22 | (that canEqual this) && 23 | status == that.status && 24 | cnt == that.cnt 25 | case _ => false 26 | } 27 | 28 | override def hashCode(): Int = { 29 | val state = Seq(status, cnt) 30 | state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) 31 | } 32 | 33 | override def toString = s"StatusCntValue($status, $cnt)" 34 | } 35 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/model/value/statistic/SuccessFailedCntValue.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.model.value.statistic 2 | 3 | import com.jthink.teemo.model.value.Value 4 | 5 | /** 6 | * jthink company 7 | * 8 | * @author jthink 9 | * @version 0.0.1 10 | */ 11 | class SuccessFailedCntValue(_successCnt: Int, _failedCnt: Int) extends Value { 12 | 13 | // 成功次数 14 | var successCnt: Int = _successCnt 15 | // 失败次数 16 | var failedCnt: Int = _failedCnt 17 | 18 | def canEqual(other: Any): Boolean = other.isInstanceOf[SuccessFailedCntValue] 19 | 20 | override def equals(other: Any): Boolean = other match { 21 | case that: SuccessFailedCntValue => 22 | (that canEqual this) && 23 | successCnt == that.successCnt && 24 | failedCnt == that.failedCnt 25 | case _ => false 26 | } 27 | 28 | override def hashCode(): Int = { 29 | val state = Seq(successCnt, failedCnt) 30 | state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) 31 | } 32 | 33 | override def toString = s"SuccessFailedCntValue($successCnt, $failedCnt)" 34 | } 35 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/task/Task.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.task 2 | 3 | /** 4 | * jthink company 5 | * 6 | * spark任务的父类 7 | * @author jthink 8 | * @version 0.0.1 9 | */ 10 | trait Task extends Serializable { 11 | 12 | def doTask() 13 | } 14 | -------------------------------------------------------------------------------- /src/main/scala/com/jthink/teemo/task/TestTask.scala: -------------------------------------------------------------------------------- 1 | package com.jthink.teemo.task 2 | 3 | import com.jthink.teemo.properties.TaskProperties 4 | import org.apache.spark.SparkContext 5 | import org.slf4j.{Logger, LoggerFactory} 6 | import org.springframework.beans.factory.annotation.Autowired 7 | import org.springframework.stereotype.Component 8 | 9 | /** 10 | * jthink company 11 | * 12 | * 算法具体逻辑 13 | * 14 | * @author jthink 15 | * @version 0.0.1 16 | */ 17 | @Component 18 | class TestTask extends Task { 19 | 20 | private val LOGGER: Logger = LoggerFactory.getLogger(classOf[TestTask]) 21 | 22 | @Autowired 23 | @transient 24 | var taskProperties: TaskProperties = _ 25 | 26 | @Autowired 27 | @transient 28 | var sparkContext: SparkContext = _ 29 | 30 | /** 31 | * 具体的业务逻辑 32 | */ 33 | override def doTask(): Unit = { 34 | LOGGER.info("task test start") 35 | // TODO: 具体的业务逻辑 36 | LOGGER.info("task test stop") 37 | } 38 | 39 | } 40 | --------------------------------------------------------------------------------