Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count the source data & enhance log #110

Merged
merged 3 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ object Configs {
private[this] val DEFAULT_ENABLE_SSL = false
private[this] val DEFAULT_SSL_SIGN_TYPE = "CA"
private[this] val DEFAULT_EDGE_RANKING = 0L
private[this] val DEFAULT_BATCH = 2
private[this] val DEFAULT_BATCH = 500
private[this] val DEFAULT_PARTITION = -1
private[this] val DEFAULT_CHECK_POINT_PATH = None
private[this] val DEFAULT_LOCAL_PATH = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ class NebulaGraphClientWriter(dataBaseConfigEntry: DataBaseConfigEntry,
if (rateLimiter.tryAcquire(rateConfig.timeout, TimeUnit.MILLISECONDS)) {
val result = graphProvider.submit(session, sentence)
if (result.isSucceeded) {
LOG.info(
s" write ${config.name}, batch size(${vertices.values.size}), latency(${result.getLatency})")
return null
}
LOG.error(s"write vertex failed for ${result.getErrorMessage}")
} else {
LOG.error(s"write vertex failed because write speed is too fast")
}
LOG.info(sentence)
sentence
}

Expand All @@ -148,13 +149,14 @@ class NebulaGraphClientWriter(dataBaseConfigEntry: DataBaseConfigEntry,
if (rateLimiter.tryAcquire(rateConfig.timeout, TimeUnit.MILLISECONDS)) {
val result = graphProvider.submit(session, sentence)
if (result.isSucceeded) {
LOG.info(
s" write ${config.name}, batch size(${edges.values.size}), latency(${result.getLatency}us)")
return null
}
LOG.error(s"write edge failed for ${result.getErrorMessage}")
} else {
LOG.error(s"write vertex failed because write speed is too fast")
}
LOG.info(sentence)
sentence
}

Expand All @@ -168,7 +170,6 @@ class NebulaGraphClientWriter(dataBaseConfigEntry: DataBaseConfigEntry,
} else {
LOG.error(s"reimport ngql failed because write speed is too fast")
}
LOG.info(ngql)
ngql
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ object Exchange {
val fields = tagConfig.vertexField :: tagConfig.fields
val data = createDataSource(spark, tagConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess =
spark.sparkContext.longAccumulator(s"batchSuccess.${tagConfig.name}")
Expand All @@ -159,8 +161,10 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for tag ${tagConfig.name} cost time: ${costTime} s")
LOG.info(
s"import for tag ${tagConfig.name}: data total count: $count, total time: ${costTime}s")
if (tagConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${tagConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${tagConfig.name}: ${batchFailure.value}")
Expand Down Expand Up @@ -191,6 +195,8 @@ object Exchange {
}
val data = createDataSource(spark, edgeConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess = spark.sparkContext.longAccumulator(s"batchSuccess.${edgeConfig.name}")
val batchFailure = spark.sparkContext.longAccumulator(s"batchFailure.${edgeConfig.name}")
Expand All @@ -206,8 +212,10 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for edge ${edgeConfig.name} cost time: ${costTime} s")
LOG.info(
s"import for edge ${edgeConfig.name}: data total count: $count, total time: ${costTime}s")
if (edgeConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${edgeConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${edgeConfig.name}: ${batchFailure.value}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ object Exchange {
val fields = tagConfig.vertexField :: tagConfig.fields
val data = createDataSource(spark, tagConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess =
spark.sparkContext.longAccumulator(s"batchSuccess.${tagConfig.name}")
Expand All @@ -159,8 +161,9 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for tag ${tagConfig.name} cost time: ${costTime} s")
LOG.info(s"import for tag ${tagConfig.name}, data count: $count, cost time: ${costTime}s")
if (tagConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${tagConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${tagConfig.name}: ${batchFailure.value}")
Expand Down Expand Up @@ -191,6 +194,8 @@ object Exchange {
}
val data = createDataSource(spark, edgeConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess = spark.sparkContext.longAccumulator(s"batchSuccess.${edgeConfig.name}")
val batchFailure = spark.sparkContext.longAccumulator(s"batchFailure.${edgeConfig.name}")
Expand All @@ -206,8 +211,10 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for edge ${edgeConfig.name} cost time: ${costTime} s")
LOG.info(
s"import for edge ${edgeConfig.name}, data count: $count, cost time: ${costTime}s")
if (edgeConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${edgeConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${edgeConfig.name}: ${batchFailure.value}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ object Exchange {
val fields = tagConfig.vertexField :: tagConfig.fields
val data = createDataSource(spark, tagConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess =
spark.sparkContext.longAccumulator(s"batchSuccess.${tagConfig.name}")
Expand All @@ -159,8 +161,9 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for tag ${tagConfig.name} cost time: ${costTime} s")
LOG.info(s"import for tag ${tagConfig.name}, data count: $count, cost time: ${costTime}s")
if (tagConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${tagConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${tagConfig.name}: ${batchFailure.value}")
Expand Down Expand Up @@ -191,6 +194,8 @@ object Exchange {
}
val data = createDataSource(spark, edgeConfig.dataSourceConfigEntry, fields)
if (data.isDefined && !c.dry) {
data.get.cache()
val count = data.get.count()
val startTime = System.currentTimeMillis()
val batchSuccess = spark.sparkContext.longAccumulator(s"batchSuccess.${edgeConfig.name}")
val batchFailure = spark.sparkContext.longAccumulator(s"batchFailure.${edgeConfig.name}")
Expand All @@ -206,8 +211,10 @@ object Exchange {
batchFailure
)
processor.process()
data.get.unpersist()
val costTime = ((System.currentTimeMillis() - startTime) / 1000.0).formatted("%.2f")
LOG.info(s"import for edge ${edgeConfig.name} cost time: ${costTime} s")
LOG.info(
s"import for edge ${edgeConfig.name}, data count: $count, cost time: ${costTime}s")
if (edgeConfig.dataSinkConfigEntry.category == SinkCategory.CLIENT) {
LOG.info(s"Client-Import: batchSuccess.${edgeConfig.name}: ${batchSuccess.value}")
LOG.info(s"Client-Import: batchFailure.${edgeConfig.name}: ${batchFailure.value}")
Expand Down