Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SparkStudy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
박준형
SparkStudy
Commits
a2d075eb
Commit
a2d075eb
authored
Jul 21, 2022
by
박준형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
44fb85d7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
RTU_Sample/src/main/scala/rtu/RTUStatistics.scala
RTU_Sample/src/main/scala/rtu/RTUStatistics.scala
+68
-0
No files found.
RTU_Sample/src/main/scala/rtu/RTUStatistics.scala
0 → 100644
View file @
a2d075eb
package
rtu
import
org.apache.spark.sql.
{
DataFrame
,
Encoder
}
import
org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import
java.util.Properties
import
java.io.
{
FileInputStream
,
InputStreamReader
}
import
scala.collection.JavaConverters.propertiesAsScalaMapConverter
import
scala.collection.mutable
object
RTUStatistics
{
def
readProperties
(
file
:
String
)
:
mutable.Map
[
String
,
String
]
={
val
properties
=
new
Properties
properties
.
load
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
"utf8"
))
val
scalaProp
=
properties
.
asScala
println
(
scalaProp
)
scalaProp
}
def
process
(
propertyFile
:
String
,
inputDate
:
String
)
:
Unit
=
{
val
properties
=
readProperties
(
propertyFile
)
val
name
=
properties
.
get
(
"process.name"
)
val
processType
=
properties
.
get
(
"process.type"
)
if
(
name
.
isEmpty
)
{
throw
new
Exception
(
"process name is null"
)
}
else
{
if
(
name
.
get
.
equals
(
""
))
{
throw
new
Exception
(
"process name is null"
)
}
}
val
className
=
properties
.
get
(
"process.class"
).
get
val
statisticsProcess
=
Class
.
forName
(
className
).
newInstance
().
asInstanceOf
[
StatisticsProcess
]
var
date
=
inputDate
;
if
(!
inputDate
.
isEmpty
&&
inputDate
.
length
>=
8
)
{
if
(!
inputDate
.
contains
(
"-"
))
{
date
=
inputDate
.
substring
(
0
,
4
)
+
"-"
+
inputDate
.
substring
(
4
,
6
)
+
"-"
+
inputDate
.
substring
(
6
,
8
)
}
}
var
isLocal
:
Boolean
=
false
if
(!
processType
.
isEmpty
){
isLocal
=
(
processType
.
get
.
equals
(
"local"
))
}
statisticsProcess
.
init
(
name
.
get
,
isLocal
,
properties
)
statisticsProcess
.
process
(
date
)
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
proppertiesFile
=
args
.
apply
(
0
)
val
inputDate
=
args
.
apply
(
1
)
printf
(
"properties : %s, date : %s \n"
,
proppertiesFile
,
inputDate
)
val
rtuStatistics
=
RTUStatistics
rtuStatistics
.
process
(
proppertiesFile
,
inputDate
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment