-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
涉及到初始化Hive的话,那么就有20~30秒的延迟,而这个也就是初始化 HiveClient;
- Loading branch information
Showing
6 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package justspark; | ||
|
||
import demo.engine.SparkYarnJob; | ||
import demo.engine.engine.type.EngineType; | ||
import demo.engine.model.Args; | ||
import prepare.Prepare; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @Author: fansy | ||
* @Time: 2018/12/19 17:22 | ||
* @Email: [email protected] | ||
*/ | ||
public class SparkNothingDemo { | ||
static String mainClass = "justspark.SparkNothing"; | ||
public static void main(String[] args) throws IOException { | ||
Prepare.uploadJar(); | ||
first(); | ||
second(); | ||
} | ||
|
||
public static void first() { | ||
String appName = "spark nothing test-true"; | ||
String[] arguments = {"true", "default.spark_nothing", appName}; | ||
Args innerArgs = Args.getArgs(appName, mainClass, arguments, EngineType.SPARK); | ||
SparkYarnJob.runAndMonitor(innerArgs); | ||
} | ||
public static void second() { | ||
String appName = "spark nothing test-false"; | ||
String[] arguments = {"false", "default.spark_nothing", appName}; | ||
Args innerArgs = Args.getArgs(appName, mainClass, arguments, EngineType.SPARK); | ||
SparkYarnJob.runAndMonitor(innerArgs); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
|
||
1. 使用命令行提交的方式来提交: | ||
30m | ||
spark-submit --class statics.DescribeStatics --deploy-mode cluster test_demo-1.0-SNAPSHOT.jar default.demo_30m default.demo_30_statics statics_30m_01 | ||
|
||
|
||
600w 条记录 | ||
spark-submit --class statics.DescribeStatics --deploy-mode cluster test_demo-1.0-SNAPSHOT.jar default.demo_600w default.demo_600w_statics statics_600w_01 | ||
|
||
|
||
Spark延迟30秒 博客:https://blog.csdn.net/fansy1990/article/details/85266553 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package justspark | ||
|
||
import org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructType} | ||
import org.apache.spark.sql.{SaveMode, SparkSession} | ||
|
||
/** | ||
* author : fanzhe | ||
* email : [email protected] | ||
* date : 2019/1/4 PM9:39. | ||
*/ | ||
object SparkNothing { | ||
def main(args: Array[String]): Unit = { | ||
if(args.length != 3){ | ||
println("Usage: justspark.SparkNothing <use_hive_or_not> <hive_table> <appName>") | ||
System.exit(-1) | ||
} | ||
// | ||
val (use_hive, table, appName) = (args(0).toBoolean,args(1),args(2)) | ||
println(new java.util.Date()+": begin spark init...") | ||
val spark = SparkSession.builder().appName(appName).enableHiveSupport().getOrCreate() | ||
println(new java.util.Date()+": spark init done!") | ||
|
||
if(use_hive) { | ||
spark.createDataFrame(List((1, "0"))).write.mode(SaveMode.Overwrite).saveAsTable(table) | ||
} | ||
spark.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters