Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
8de8ee5d
Commit
8de8ee5d
authored
11 years ago
by
Patrick Wendell
Browse files
Options
Downloads
Patches
Plain Diff
Ganglia sink
parent
6d219864
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/org/apache/spark/metrics/sink/GangliaSink.scala
+82
-0
82 additions, 0 deletions
...ain/scala/org/apache/spark/metrics/sink/GangliaSink.scala
project/SparkBuild.scala
+1
-0
1 addition, 0 deletions
project/SparkBuild.scala
with
83 additions
and
0 deletions
core/src/main/scala/org/apache/spark/metrics/sink/GangliaSink.scala
0 → 100644
+
82
−
0
View file @
8de8ee5d
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.spark.metrics.sink
import
java.util.Properties
import
java.util.concurrent.TimeUnit
import
com.codahale.metrics.ganglia.GangliaReporter
import
com.codahale.metrics.MetricRegistry
import
info.ganglia.gmetric4j.gmetric.GMetric
import
org.apache.spark.metrics.MetricsSystem
class
GangliaSink
(
val
property
:
Properties
,
val
registry
:
MetricRegistry
)
extends
Sink
{
val
GANGLIA_KEY_PERIOD
=
"period"
val
GANGLIA_DEFAULT_PERIOD
=
10
val
GANGLIA_KEY_UNIT
=
"unit"
val
GANGLIA_DEFAULT_UNIT
=
TimeUnit
.
SECONDS
val
GANGLIA_KEY_MODE
=
"mode"
val
GANGLIA_DEFAULT_MODE
=
GMetric
.
UDPAddressingMode
.
MULTICAST
// TTL for multicast messages. If listeners are X hops away in network, must be at least X.
val
GANGLIA_KEY_TTL
=
"ttl"
val
GANGLIA_DEFAULT_TTL
=
1
val
GANGLIA_KEY_HOST
=
"host"
val
GANGLIA_KEY_PORT
=
"port"
def
propertyToOption
(
prop
:
String
)
=
Option
(
property
.
getProperty
(
prop
))
if
(!
propertyToOption
(
GANGLIA_KEY_HOST
).
isDefined
)
{
throw
new
Exception
(
"Ganglia sink requires 'host' property."
)
}
if
(!
propertyToOption
(
GANGLIA_KEY_PORT
).
isDefined
)
{
throw
new
Exception
(
"Ganglia sink requires 'port' property."
)
}
val
host
=
propertyToOption
(
GANGLIA_KEY_HOST
).
get
val
port
=
propertyToOption
(
GANGLIA_KEY_PORT
).
get
.
toInt
val
ttl
=
propertyToOption
(
GANGLIA_KEY_TTL
).
map
(
_
.
toInt
).
getOrElse
(
GANGLIA_DEFAULT_TTL
)
val
mode
=
propertyToOption
(
GANGLIA_KEY_MODE
)
.
map
(
u
=>
GMetric
.
UDPAddressingMode
.
valueOf
(
u
.
toUpperCase
)).
getOrElse
(
GANGLIA_DEFAULT_MODE
)
val
pollPeriod
=
propertyToOption
(
GANGLIA_KEY_PERIOD
).
map
(
_
.
toInt
)
.
getOrElse
(
GANGLIA_DEFAULT_PERIOD
)
val
pollUnit
=
propertyToOption
(
GANGLIA_KEY_UNIT
).
map
(
u
=>
TimeUnit
.
valueOf
(
u
.
toUpperCase
))
.
getOrElse
(
GANGLIA_DEFAULT_UNIT
)
MetricsSystem
.
checkMinimalPollingPeriod
(
pollUnit
,
pollPeriod
)
val
ganglia
=
new
GMetric
(
host
,
port
,
mode
,
ttl
)
val
reporter
:
GangliaReporter
=
GangliaReporter
.
forRegistry
(
registry
)
.
convertDurationsTo
(
TimeUnit
.
MILLISECONDS
)
.
convertRatesTo
(
TimeUnit
.
SECONDS
)
.
build
(
ganglia
)
override
def
start
()
{
reporter
.
start
(
pollPeriod
,
pollUnit
)
}
override
def
stop
()
{
reporter
.
stop
()
}
}
This diff is collapsed.
Click to expand it.
project/SparkBuild.scala
+
1
−
0
View file @
8de8ee5d
...
...
@@ -207,6 +207,7 @@ object SparkBuild extends Build {
"com.codahale.metrics"
%
"metrics-core"
%
"3.0.0"
,
"com.codahale.metrics"
%
"metrics-jvm"
%
"3.0.0"
,
"com.codahale.metrics"
%
"metrics-json"
%
"3.0.0"
,
"com.codahale.metrics"
%
"metrics-ganglia"
%
"3.0.0"
,
"com.twitter"
%
"chill_2.9.3"
%
"0.3.1"
,
"com.twitter"
%
"chill-java"
%
"0.3.1"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment