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
11872888
Commit
11872888
authored
11 years ago
by
Karen Feng
Browse files
Options
Downloads
Patches
Plain Diff
Created getByteRange function for logs and log pages, removed lastNBytes function
parent
e3a3fcf6
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/spark/Utils.scala
+23
-7
23 additions, 7 deletions
core/src/main/scala/spark/Utils.scala
core/src/main/scala/spark/deploy/worker/ui/WorkerWebUI.scala
+21
-24
21 additions, 24 deletions
core/src/main/scala/spark/deploy/worker/ui/WorkerWebUI.scala
with
44 additions
and
31 deletions
core/src/main/scala/spark/Utils.scala
+
23
−
7
View file @
11872888
...
...
@@ -621,6 +621,29 @@ private object Utils extends Logging {
callSiteInfo
.
firstUserLine
)
}
/** Determine the byte range for a log or log page. */
def
getByteRange
(
path
:
String
,
offset
:
Option
[
String
],
byteLength
:
Option
[
String
])
:
(
Long
,
Long
,
Long
,
Int
)
=
{
val
defaultBytes
=
10000
val
maxBytes
=
1024
*
1024
val
file
=
new
File
(
path
)
val
logLength
=
file
.
length
()
val
getOffset
=
offset
.
map
(
_
.
toLong
).
getOrElse
(
logLength
-
defaultBytes
)
val
fixedOffset
=
if
(
getOffset
<
0
)
0L
else
if
(
getOffset
>
logLength
)
logLength
else
getOffset
val
getByteLength
=
byteLength
.
map
(
_
.
toInt
).
getOrElse
(
defaultBytes
)
val
logPageLength
=
math
.
min
(
getByteLength
,
maxBytes
)
val
endOffset
=
math
.
min
(
fixedOffset
+
logPageLength
,
logLength
)
(
fixedOffset
,
endOffset
,
logLength
,
logPageLength
)
}
/** Return a string containing part of a file from byte 'start' to 'end'. */
def
offsetBytes
(
path
:
String
,
start
:
Long
,
end
:
Long
)
:
String
=
{
val
file
=
new
File
(
path
)
...
...
@@ -636,13 +659,6 @@ private object Utils extends Logging {
Source
.
fromBytes
(
buff
).
mkString
}
/** Return a string containing the last `n` bytes of a file. */
def
lastNBytes
(
path
:
String
,
n
:
Int
)
:
String
=
{
val
file
=
new
File
(
path
)
val
length
=
file
.
length
()
offsetBytes
(
path
,
length
-
n
,
length
)
}
/**
* Clone an object using a Spark serializer.
*/
...
...
This diff is collapsed.
Click to expand it.
core/src/main/scala/spark/deploy/worker/ui/WorkerWebUI.scala
+
21
−
24
View file @
11872888
...
...
@@ -57,41 +57,39 @@ class WorkerWebUI(val worker: Worker, val workDir: File, requestedPort: Option[I
val
appId
=
request
.
getParameter
(
"appId"
)
val
executorId
=
request
.
getParameter
(
"executorId"
)
val
logType
=
request
.
getParameter
(
"logType"
)
val
offset
=
Option
(
request
.
getParameter
(
"offset"
))
val
byteLength
=
Option
(
request
.
getParameter
(
"byteLength"
))
val
path
=
"%s/%s/%s/%s"
.
format
(
workDir
.
getPath
,
appId
,
executorId
,
logType
)
val
max
Bytes
=
1024
*
1024
// Guard against OOM
val
defaultBytes
=
100
*
1024
val
numBytes
=
Option
(
request
.
getParameter
(
"num
Bytes
"
))
.
flatMap
(
s
=>
Some
(
s
.
toInt
)).
getOrElse
(
defaul
tBytes
)
val
offset
Bytes
=
Utils
.
getByteRange
(
path
,
offset
,
byteLength
)
val
fixedOffset
=
offsetBytes
.
_1
val
endOffset
=
offset
Bytes
.
_2
val
logLength
=
offse
tBytes
.
_3
val
p
ath
=
"
%s/%s/%s/%s"
.
format
(
workDir
.
getPath
,
appId
,
executorId
,
logType
)
val
pre
=
"==== Last %s bytes of %s/%s/%s ====\n"
.
format
(
numBytes
,
appId
,
executorId
,
logType
)
pre
+
Utils
.
lastN
Bytes
(
path
,
math
.
min
(
numBytes
,
maxBytes
)
)
val
p
re
=
"
==== Bytes %s-%s of %s of %s/%s/%s ====\n"
.
format
(
fixedOffset
,
endOffset
,
logLength
,
appId
,
executorId
,
logType
)
pre
+
Utils
.
offset
Bytes
(
path
,
fixedOffset
,
endOffset
)
}
def
logPage
(
request
:
HttpServletRequest
)
:
Seq
[
scala.xml.Node
]
=
{
val
appId
=
request
.
getParameter
(
"appId"
)
val
executorId
=
request
.
getParameter
(
"executorId"
)
val
logType
=
request
.
getParameter
(
"logType"
)
val
maxBytes
=
1024
*
1024
val
defaultBytes
=
10000
val
byteLength
=
Option
(
request
.
getParameter
(
"byteLength"
)).
map
(
_
.
toInt
).
getOrElse
(
defaultBytes
)
val
offset
=
Option
(
request
.
getParameter
(
"offset"
))
val
byteLength
=
Option
(
request
.
getParameter
(
"byteLength"
))
val
path
=
"%s/%s/%s/%s"
.
format
(
workDir
.
getPath
,
appId
,
executorId
,
logType
)
val
logLength
=
new
File
(
path
).
length
()
val
offset
=
Option
(
request
.
getParameter
(
"offset"
)).
map
(
_
.
toLong
).
getOrElse
(
logLength
-
10000
)
val
logPageLength
=
math
.
min
(
byteLength
,
maxBytes
)
val
fixedOffset
=
if
(
offset
<
0
)
0
else
if
(
offset
>
logLength
)
logLength
else
offset
val
offsetBytes
=
Utils
.
getByteRange
(
path
,
offset
,
byteLength
)
val
fixedOffset
=
offsetBytes
.
_1
val
endOffset
=
offsetBytes
.
_2
val
logLength
=
offsetBytes
.
_3
val
logPageLength
=
offsetBytes
.
_4
val
endOffset
=
math
.
min
(
fixedOffset
+
logPageLength
,
logLength
)
val
logText
=
<
node
>{
Utils
.
offsetBytes
(
path
,
fixedOffset
,
endOffset
)}</
node
>
val
linkToMaster
=
<
p
><
a
href
={
worker
.
masterWebUiUrl
}>
Back
to
Master
</
a
></
p
>
val
range
=
<
span
>
Bytes
{
fixedOffset
.
toString
}
-
{
(
endOffset
)
.
toString
}
of
{
logLength
}</
span
>
val
range
=
<
span
>
Bytes
{
fixedOffset
.
toString
}
-
{
endOffset
.
toString
}
of
{
logLength
}</
span
>
val
backButton
=
if
(
fixedOffset
>
0
)
{
...
...
@@ -116,8 +114,6 @@ class WorkerWebUI(val worker: Worker, val workDir: File, requestedPort: Option[I
<
button
disabled
=
"disabled"
>
Next
0
Bytes
</
button
>
}
val
logText
=
<
node
>{
Utils
.
offsetBytes
(
path
,
fixedOffset
,
endOffset
)}</
node
>
val
content
=
<
html
>
<
body
>
...
...
@@ -134,7 +130,8 @@ class WorkerWebUI(val worker: Worker, val workDir: File, requestedPort: Option[I
</
div
>
</
body
>
</
html
>
UIUtils
.
basicSparkPage
(
content
,
logType
+
" log page for "
+
appId
)
UIUtils
.
basicSparkPage
(
content
,
request
.
getParameter
(
"logType"
)
+
" log page for "
+
request
.
getParameter
(
"appId"
))
}
def
stop
()
{
...
...
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