Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Administrator
arthas-master
Commits
7c094a26
Commit
7c094a26
authored
Dec 18, 2023
by
liang.tang
Browse files
arthas-master
parents
Pipeline
#220
failed with stages
in 0 seconds
Changes
361
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
820 additions
and
0 deletions
+820
-0
core/src/main/java/com/taobao/arthas/core/command/view/OptionsView.java
...java/com/taobao/arthas/core/command/view/OptionsView.java
+50
-0
core/src/main/java/com/taobao/arthas/core/command/view/PerfCounterView.java
.../com/taobao/arthas/core/command/view/PerfCounterView.java
+46
-0
core/src/main/java/com/taobao/arthas/core/command/view/ProfilerView.java
...ava/com/taobao/arthas/core/command/view/ProfilerView.java
+42
-0
core/src/main/java/com/taobao/arthas/core/command/view/PwdView.java
...ain/java/com/taobao/arthas/core/command/view/PwdView.java
+14
-0
core/src/main/java/com/taobao/arthas/core/command/view/RedefineView.java
...ava/com/taobao/arthas/core/command/view/RedefineView.java
+28
-0
core/src/main/java/com/taobao/arthas/core/command/view/ResetView.java
...n/java/com/taobao/arthas/core/command/view/ResetView.java
+16
-0
core/src/main/java/com/taobao/arthas/core/command/view/ResultView.java
.../java/com/taobao/arthas/core/command/view/ResultView.java
+30
-0
core/src/main/java/com/taobao/arthas/core/command/view/ResultViewResolver.java
...m/taobao/arthas/core/command/view/ResultViewResolver.java
+139
-0
core/src/main/java/com/taobao/arthas/core/command/view/RetransformView.java
.../com/taobao/arthas/core/command/view/RetransformView.java
+63
-0
core/src/main/java/com/taobao/arthas/core/command/view/RowAffectView.java
...va/com/taobao/arthas/core/command/view/RowAffectView.java
+14
-0
core/src/main/java/com/taobao/arthas/core/command/view/SearchClassView.java
.../com/taobao/arthas/core/command/view/SearchClassView.java
+33
-0
core/src/main/java/com/taobao/arthas/core/command/view/SearchMethodView.java
...com/taobao/arthas/core/command/view/SearchMethodView.java
+46
-0
core/src/main/java/com/taobao/arthas/core/command/view/SessionView.java
...java/com/taobao/arthas/core/command/view/SessionView.java
+37
-0
core/src/main/java/com/taobao/arthas/core/command/view/ShutdownView.java
...ava/com/taobao/arthas/core/command/view/ShutdownView.java
+14
-0
core/src/main/java/com/taobao/arthas/core/command/view/StackView.java
...n/java/com/taobao/arthas/core/command/view/StackView.java
+41
-0
core/src/main/java/com/taobao/arthas/core/command/view/StatusView.java
.../java/com/taobao/arthas/core/command/view/StatusView.java
+18
-0
core/src/main/java/com/taobao/arthas/core/command/view/SystemEnvView.java
...va/com/taobao/arthas/core/command/view/SystemEnvView.java
+16
-0
core/src/main/java/com/taobao/arthas/core/command/view/SystemPropertyView.java
...m/taobao/arthas/core/command/view/SystemPropertyView.java
+16
-0
core/src/main/java/com/taobao/arthas/core/command/view/ThreadView.java
.../java/com/taobao/arthas/core/command/view/ThreadView.java
+81
-0
core/src/main/java/com/taobao/arthas/core/command/view/TimeTunnelView.java
...a/com/taobao/arthas/core/command/view/TimeTunnelView.java
+76
-0
No files found.
Too many changes to show.
To preserve performance only
361 of 361+
files are displayed.
Plain diff
Email patch
core/src/main/java/com/taobao/arthas/core/command/view/OptionsView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.OptionVO
;
import
com.taobao.arthas.core.command.model.OptionsModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.text.Decoration
;
import
com.taobao.text.ui.Element
;
import
com.taobao.text.ui.TableElement
;
import
com.taobao.text.util.RenderUtil
;
import
java.util.Collection
;
import
static
com
.
taobao
.
text
.
ui
.
Element
.
label
;
/**
* @author gongdewei 2020/4/15
*/
public
class
OptionsView
extends
ResultView
<
OptionsModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
OptionsModel
result
)
{
if
(
result
.
getOptions
()
!=
null
)
{
process
.
write
(
RenderUtil
.
render
(
drawShowTable
(
result
.
getOptions
()),
process
.
width
()));
}
else
if
(
result
.
getChangeResult
()
!=
null
)
{
TableElement
table
=
ViewRenderUtil
.
renderChangeResult
(
result
.
getChangeResult
());
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
}
private
Element
drawShowTable
(
Collection
<
OptionVO
>
options
)
{
TableElement
table
=
new
TableElement
(
1
,
1
,
2
,
1
,
3
,
6
)
.
leftCellPadding
(
1
).
rightCellPadding
(
1
);
table
.
row
(
true
,
label
(
"LEVEL"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"TYPE"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"NAME"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"VALUE"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"SUMMARY"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"DESCRIPTION"
).
style
(
Decoration
.
bold
.
bold
()));
for
(
final
OptionVO
optionVO
:
options
)
{
table
.
row
(
""
+
optionVO
.
getLevel
(),
optionVO
.
getType
(),
optionVO
.
getName
(),
optionVO
.
getValue
(),
optionVO
.
getSummary
(),
optionVO
.
getDescription
());
}
return
table
;
}
}
core/src/main/java/com/taobao/arthas/core/command/view/PerfCounterView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.PerfCounterModel
;
import
com.taobao.arthas.core.command.model.PerfCounterVO
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.text.Decoration
;
import
com.taobao.text.ui.TableElement
;
import
com.taobao.text.util.RenderUtil
;
import
java.util.List
;
import
static
com
.
taobao
.
text
.
ui
.
Element
.
label
;
/**
* View of 'perfcounter' command
*
* @author gongdewei 2020/4/27
*/
public
class
PerfCounterView
extends
ResultView
<
PerfCounterModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
PerfCounterModel
result
)
{
List
<
PerfCounterVO
>
perfCounters
=
result
.
getPerfCounters
();
boolean
details
=
result
.
isDetails
();
TableElement
table
;
if
(
details
)
{
table
=
new
TableElement
(
3
,
1
,
1
,
10
).
leftCellPadding
(
1
).
rightCellPadding
(
1
);
table
.
row
(
true
,
label
(
"Name"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"Variability"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"Units"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"Value"
).
style
(
Decoration
.
bold
.
bold
()));
}
else
{
table
=
new
TableElement
(
4
,
6
).
leftCellPadding
(
1
).
rightCellPadding
(
1
);
table
.
row
(
true
,
label
(
"Name"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"Value"
).
style
(
Decoration
.
bold
.
bold
()));
}
for
(
PerfCounterVO
counter
:
perfCounters
)
{
if
(
details
)
{
table
.
row
(
counter
.
getName
(),
counter
.
getVariability
(),
counter
.
getUnits
(),
String
.
valueOf
(
counter
.
getValue
()));
}
else
{
table
.
row
(
counter
.
getName
(),
String
.
valueOf
(
counter
.
getValue
()));
}
}
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ProfilerView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ProfilerModel
;
import
com.taobao.arthas.core.command.monitor200.ProfilerCommand.ProfilerAction
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* Term view for ProfilerModel
*
* @author gongdewei 2020/4/27
*/
public
class
ProfilerView
extends
ResultView
<
ProfilerModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
ProfilerModel
model
)
{
if
(
model
.
getSupportedActions
()
!=
null
)
{
process
.
write
(
"Supported Actions: "
+
model
.
getSupportedActions
()).
write
(
"\n"
);
return
;
}
drawExecuteResult
(
process
,
model
);
if
(
ProfilerAction
.
start
.
name
().
equals
(
model
.
getAction
()))
{
if
(
model
.
getDuration
()
!=
null
)
{
process
.
write
(
String
.
format
(
"profiler will silent stop after %d seconds.\n"
,
model
.
getDuration
().
longValue
()));
process
.
write
(
"profiler output file will be: "
+
model
.
getOutputFile
()
+
"\n"
);
}
}
else
if
(
ProfilerAction
.
stop
.
name
().
equals
(
model
.
getAction
()))
{
process
.
write
(
"profiler output file: "
+
model
.
getOutputFile
()
+
"\n"
);
}
}
private
void
drawExecuteResult
(
CommandProcess
process
,
ProfilerModel
model
)
{
if
(
model
.
getExecuteResult
()
!=
null
)
{
process
.
write
(
model
.
getExecuteResult
());
if
(!
model
.
getExecuteResult
().
endsWith
(
"\n"
))
{
process
.
write
(
"\n"
);
}
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/PwdView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.PwdModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/5/11
*/
public
class
PwdView
extends
ResultView
<
PwdModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
PwdModel
result
)
{
process
.
write
(
result
.
getWorkingDir
()).
write
(
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/RedefineView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.RedefineModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/4/16
*/
public
class
RedefineView
extends
ResultView
<
RedefineModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
RedefineModel
result
)
{
if
(
result
.
getMatchedClassLoaders
()
!=
null
)
{
process
.
write
(
"Matched classloaders: \n"
);
ClassLoaderView
.
drawClassLoaders
(
process
,
result
.
getMatchedClassLoaders
(),
false
);
process
.
write
(
"\n"
);
return
;
}
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
aClass
:
result
.
getRedefinedClasses
())
{
sb
.
append
(
aClass
).
append
(
"\n"
);
}
process
.
write
(
"redefine success, size: "
+
result
.
getRedefinitionCount
())
.
write
(
", classes:\n"
)
.
write
(
sb
.
toString
());
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ResetView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ResetModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/6/22
*/
public
class
ResetView
extends
ResultView
<
ResetModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
ResetModel
result
)
{
process
.
write
(
ViewRenderUtil
.
renderEnhancerAffect
(
result
.
getAffect
()));
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ResultView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ResultModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* Command result view for telnet term/tty.
* Note: Result view is a reusable and stateless instance
*
* @author gongdewei 2020/3/27
*/
public
abstract
class
ResultView
<
T
extends
ResultModel
>
{
/**
* formatted printing data to term/tty
*
* @param process
*/
public
abstract
void
draw
(
CommandProcess
process
,
T
result
);
/**
* write str and append a new line
*
* @param process
* @param str
*/
protected
void
writeln
(
CommandProcess
process
,
String
str
)
{
process
.
write
(
str
).
write
(
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ResultViewResolver.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.alibaba.arthas.deps.org.slf4j.Logger
;
import
com.alibaba.arthas.deps.org.slf4j.LoggerFactory
;
import
com.taobao.arthas.core.command.model.ResultModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* Result view resolver for term
*
* @author gongdewei 2020/3/27
*/
public
class
ResultViewResolver
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResultViewResolver
.
class
);
// modelClass -> view
private
Map
<
Class
,
ResultView
>
resultViewMap
=
new
ConcurrentHashMap
<
Class
,
ResultView
>();
public
ResultViewResolver
()
{
initResultViews
();
}
/**
* 需要调用此方法初始化注册ResultView
*/
private
void
initResultViews
()
{
try
{
registerView
(
RowAffectView
.
class
);
//basic1000
registerView
(
StatusView
.
class
);
registerView
(
VersionView
.
class
);
registerView
(
MessageView
.
class
);
registerView
(
HelpView
.
class
);
//registerView(HistoryView.class);
registerView
(
EchoView
.
class
);
registerView
(
CatView
.
class
);
registerView
(
Base64View
.
class
);
registerView
(
OptionsView
.
class
);
registerView
(
SystemPropertyView
.
class
);
registerView
(
SystemEnvView
.
class
);
registerView
(
PwdView
.
class
);
registerView
(
VMOptionView
.
class
);
registerView
(
SessionView
.
class
);
registerView
(
ResetView
.
class
);
registerView
(
ShutdownView
.
class
);
//klass100
registerView
(
ClassLoaderView
.
class
);
registerView
(
DumpClassView
.
class
);
registerView
(
GetStaticView
.
class
);
registerView
(
JadView
.
class
);
registerView
(
MemoryCompilerView
.
class
);
registerView
(
OgnlView
.
class
);
registerView
(
RedefineView
.
class
);
registerView
(
RetransformView
.
class
);
registerView
(
SearchClassView
.
class
);
registerView
(
SearchMethodView
.
class
);
//logger
registerView
(
LoggerView
.
class
);
//monitor2000
registerView
(
DashboardView
.
class
);
registerView
(
JvmView
.
class
);
registerView
(
MemoryView
.
class
);
registerView
(
MBeanView
.
class
);
registerView
(
PerfCounterView
.
class
);
registerView
(
ThreadView
.
class
);
registerView
(
ProfilerView
.
class
);
registerView
(
EnhancerView
.
class
);
registerView
(
MonitorView
.
class
);
registerView
(
StackView
.
class
);
registerView
(
TimeTunnelView
.
class
);
registerView
(
TraceView
.
class
);
registerView
(
WatchView
.
class
);
registerView
(
VmToolView
.
class
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
"register result view failed"
,
e
);
}
}
public
ResultView
getResultView
(
ResultModel
model
)
{
return
resultViewMap
.
get
(
model
.
getClass
());
}
public
ResultViewResolver
registerView
(
Class
modelClass
,
ResultView
view
)
{
//TODO 检查model的type是否重复,避免复制代码带来的bug
this
.
resultViewMap
.
put
(
modelClass
,
view
);
return
this
;
}
public
ResultViewResolver
registerView
(
ResultView
view
)
{
Class
modelClass
=
getModelClass
(
view
);
if
(
modelClass
==
null
)
{
throw
new
NullPointerException
(
"model class is null"
);
}
return
this
.
registerView
(
modelClass
,
view
);
}
public
void
registerView
(
Class
<?
extends
ResultView
>
viewClass
)
{
ResultView
view
=
null
;
try
{
view
=
viewClass
.
newInstance
();
}
catch
(
Throwable
e
)
{
throw
new
RuntimeException
(
"create view instance failure, viewClass:"
+
viewClass
,
e
);
}
this
.
registerView
(
view
);
}
/**
* Get model class of result view
*
* @return
*/
public
static
<
V
extends
ResultView
>
Class
getModelClass
(
V
view
)
{
//类反射获取子类的draw方法第二个参数的ResultModel具体类型
Class
<?
extends
ResultView
>
viewClass
=
view
.
getClass
();
Method
[]
declaredMethods
=
viewClass
.
getDeclaredMethods
();
for
(
int
i
=
0
;
i
<
declaredMethods
.
length
;
i
++)
{
Method
method
=
declaredMethods
[
i
];
if
(
method
.
getName
().
equals
(
"draw"
))
{
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
if
(
parameterTypes
.
length
==
2
&&
parameterTypes
[
0
]
==
CommandProcess
.
class
&&
parameterTypes
[
1
]
!=
ResultModel
.
class
&&
ResultModel
.
class
.
isAssignableFrom
(
parameterTypes
[
1
]))
{
return
parameterTypes
[
1
];
}
}
}
return
null
;
}
}
core/src/main/java/com/taobao/arthas/core/command/view/RetransformView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.klass100.RetransformCommand.RetransformEntry
;
import
com.taobao.arthas.core.command.model.RetransformModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.text.Decoration
;
import
com.taobao.text.ui.RowElement
;
import
com.taobao.text.ui.TableElement
;
import
com.taobao.text.util.RenderUtil
;
/**
*
* @author hengyunabc 2021-01-06
*
*/
public
class
RetransformView
extends
ResultView
<
RetransformModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
RetransformModel
result
)
{
// 匹配到多个 classloader
if
(
result
.
getMatchedClassLoaders
()
!=
null
)
{
process
.
write
(
"Matched classloaders: \n"
);
ClassLoaderView
.
drawClassLoaders
(
process
,
result
.
getMatchedClassLoaders
(),
false
);
process
.
write
(
"\n"
);
return
;
}
// retransform -d
if
(
result
.
getDeletedRetransformEntry
()
!=
null
)
{
process
.
write
(
"Delete RetransformEntry by id success. id: "
+
result
.
getDeletedRetransformEntry
().
getId
());
process
.
write
(
"\n"
);
return
;
}
// retransform -l
if
(
result
.
getRetransformEntries
()
!=
null
)
{
// header
TableElement
table
=
new
TableElement
(
1
,
1
,
1
,
1
,
1
).
rightCellPadding
(
1
);
table
.
add
(
new
RowElement
().
style
(
Decoration
.
bold
.
bold
()).
add
(
"Id"
,
"ClassName"
,
"TransformCount"
,
"LoaderHash"
,
"LoaderClassName"
));
for
(
RetransformEntry
entry
:
result
.
getRetransformEntries
())
{
table
.
row
(
""
+
entry
.
getId
(),
""
+
entry
.
getClassName
(),
""
+
entry
.
getTransformCount
(),
""
+
entry
.
getHashCode
(),
""
+
entry
.
getClassLoaderClass
());
}
process
.
write
(
RenderUtil
.
render
(
table
));
return
;
}
// retransform /tmp/Demo.class
if
(
result
.
getRetransformClasses
()
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
aClass
:
result
.
getRetransformClasses
())
{
sb
.
append
(
aClass
).
append
(
"\n"
);
}
process
.
write
(
"retransform success, size: "
+
result
.
getRetransformCount
()).
write
(
", classes:\n"
)
.
write
(
sb
.
toString
());
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/RowAffectView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.RowAffectModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/4/8
*/
public
class
RowAffectView
extends
ResultView
<
RowAffectModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
RowAffectModel
result
)
{
process
.
write
(
result
.
affect
()
+
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/SearchClassView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.FieldVO
;
import
com.taobao.arthas.core.command.model.SearchClassModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.ClassUtils
;
import
com.taobao.text.util.RenderUtil
;
/**
* @author gongdewei 2020/4/8
*/
public
class
SearchClassView
extends
ResultView
<
SearchClassModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
SearchClassModel
result
)
{
if
(
result
.
getMatchedClassLoaders
()
!=
null
)
{
process
.
write
(
"Matched classloaders: \n"
);
ClassLoaderView
.
drawClassLoaders
(
process
,
result
.
getMatchedClassLoaders
(),
false
);
process
.
write
(
"\n"
);
return
;
}
if
(
result
.
isDetailed
())
{
process
.
write
(
RenderUtil
.
render
(
ClassUtils
.
renderClassInfo
(
result
.
getClassInfo
(),
result
.
isWithField
()),
process
.
width
()));
process
.
write
(
"\n"
);
}
else
if
(
result
.
getClassNames
()
!=
null
)
{
for
(
String
className
:
result
.
getClassNames
())
{
process
.
write
(
className
).
write
(
"\n"
);
}
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/SearchMethodView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.SearchMethodModel
;
import
com.taobao.arthas.core.command.model.MethodVO
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.ClassUtils
;
import
com.taobao.text.util.RenderUtil
;
/**
* render for SearchMethodCommand
* @author gongdewei 2020/4/9
*/
public
class
SearchMethodView
extends
ResultView
<
SearchMethodModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
SearchMethodModel
result
)
{
if
(
result
.
getMatchedClassLoaders
()
!=
null
)
{
process
.
write
(
"Matched classloaders: \n"
);
ClassLoaderView
.
drawClassLoaders
(
process
,
result
.
getMatchedClassLoaders
(),
false
);
process
.
write
(
"\n"
);
return
;
}
boolean
detail
=
result
.
isDetail
();
MethodVO
methodInfo
=
result
.
getMethodInfo
();
if
(
detail
)
{
if
(
methodInfo
.
isConstructor
())
{
//render constructor
process
.
write
(
RenderUtil
.
render
(
ClassUtils
.
renderConstructor
(
methodInfo
),
process
.
width
())
+
"\n"
);
}
else
{
//render method
process
.
write
(
RenderUtil
.
render
(
ClassUtils
.
renderMethod
(
methodInfo
),
process
.
width
())
+
"\n"
);
}
}
else
{
//java.util.List indexOf(Ljava/lang/Object;)I
//className methodName+Descriptor
process
.
write
(
methodInfo
.
getDeclaringClass
())
.
write
(
" "
)
.
write
(
methodInfo
.
getMethodName
())
.
write
(
methodInfo
.
getDescriptor
())
.
write
(
"\n"
);
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/SessionView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.SessionModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.text.Decoration
;
import
com.taobao.text.ui.TableElement
;
import
com.taobao.text.util.RenderUtil
;
import
static
com
.
taobao
.
text
.
ui
.
Element
.
label
;
/**
* Term / Tty view for session result
*
* @author gongdewei 2020/3/27
*/
public
class
SessionView
extends
ResultView
<
SessionModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
SessionModel
result
)
{
//会话详情
TableElement
table
=
new
TableElement
().
leftCellPadding
(
1
).
rightCellPadding
(
1
);
table
.
row
(
true
,
label
(
"Name"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"Value"
).
style
(
Decoration
.
bold
.
bold
()));
table
.
row
(
"JAVA_PID"
,
""
+
result
.
getJavaPid
()).
row
(
"SESSION_ID"
,
""
+
result
.
getSessionId
());
if
(
result
.
getAgentId
()
!=
null
)
{
table
.
row
(
"AGENT_ID"
,
""
+
result
.
getAgentId
());
}
if
(
result
.
getTunnelServer
()
!=
null
)
{
table
.
row
(
"TUNNEL_SERVER"
,
""
+
result
.
getTunnelServer
());
table
.
row
(
"TUNNEL_CONNECTED"
,
""
+
result
.
isTunnelConnected
());
}
if
(
result
.
getStatUrl
()
!=
null
)
{
table
.
row
(
"STAT_URL"
,
result
.
getStatUrl
());
}
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ShutdownView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ShutdownModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/6/22
*/
public
class
ShutdownView
extends
ResultView
<
ShutdownModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
ShutdownModel
result
)
{
process
.
write
(
result
.
getMessage
()).
write
(
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/StackView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.StackModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.DateUtils
;
import
com.taobao.arthas.core.util.ThreadUtil
;
/**
* Term view for StackModel
* @author gongdewei 2020/4/13
*/
public
class
StackView
extends
ResultView
<
StackModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
StackModel
result
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
ThreadUtil
.
getThreadTitle
(
result
)).
append
(
"\n"
);
StackTraceElement
[]
stackTraceElements
=
result
.
getStackTrace
();
StackTraceElement
locationStackTraceElement
=
stackTraceElements
[
0
];
String
locationString
=
String
.
format
(
" @%s.%s()"
,
locationStackTraceElement
.
getClassName
(),
locationStackTraceElement
.
getMethodName
());
sb
.
append
(
locationString
).
append
(
"\n"
);
int
skip
=
1
;
for
(
int
index
=
skip
;
index
<
stackTraceElements
.
length
;
index
++)
{
StackTraceElement
ste
=
stackTraceElements
[
index
];
sb
.
append
(
" at "
)
.
append
(
ste
.
getClassName
())
.
append
(
"."
)
.
append
(
ste
.
getMethodName
())
.
append
(
"("
)
.
append
(
ste
.
getFileName
())
.
append
(
":"
)
.
append
(
ste
.
getLineNumber
())
.
append
(
")\n"
);
}
process
.
write
(
"ts="
+
DateUtils
.
formatDate
(
result
.
getTs
())
+
";"
+
sb
.
toString
()
+
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/StatusView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.StatusModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/3/27
*/
public
class
StatusView
extends
ResultView
<
StatusModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
StatusModel
result
)
{
if
(
result
.
getMessage
()
!=
null
)
{
writeln
(
process
,
result
.
getMessage
());
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/SystemEnvView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.SystemEnvModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/4/2
*/
public
class
SystemEnvView
extends
ResultView
<
SystemEnvModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
SystemEnvModel
result
)
{
process
.
write
(
ViewRenderUtil
.
renderKeyValueTable
(
result
.
getEnv
(),
process
.
width
()));
}
}
core/src/main/java/com/taobao/arthas/core/command/view/SystemPropertyView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.SystemPropertyModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
/**
* @author gongdewei 2020/4/2
*/
public
class
SystemPropertyView
extends
ResultView
<
SystemPropertyModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
SystemPropertyModel
result
)
{
process
.
write
(
ViewRenderUtil
.
renderKeyValueTable
(
result
.
getProps
(),
process
.
width
()));
}
}
core/src/main/java/com/taobao/arthas/core/command/view/ThreadView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.BusyThreadInfo
;
import
com.taobao.arthas.core.command.model.ThreadModel
;
import
com.taobao.arthas.core.command.model.ThreadVO
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.ThreadUtil
;
import
com.taobao.text.ui.LabelElement
;
import
com.taobao.text.util.RenderUtil
;
import
java.util.List
;
import
java.util.Map
;
/**
* View of 'thread' command
*
* @author gongdewei 2020/4/26
*/
public
class
ThreadView
extends
ResultView
<
ThreadModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
ThreadModel
result
)
{
if
(
result
.
getThreadInfo
()
!=
null
)
{
// no cpu usage info
String
content
=
ThreadUtil
.
getFullStacktrace
(
result
.
getThreadInfo
());
process
.
write
(
content
);
}
else
if
(
result
.
getBusyThreads
()
!=
null
)
{
List
<
BusyThreadInfo
>
threadInfos
=
result
.
getBusyThreads
();
for
(
BusyThreadInfo
info
:
threadInfos
)
{
String
stacktrace
=
ThreadUtil
.
getFullStacktrace
(
info
,
-
1
,
-
1
);
process
.
write
(
stacktrace
).
write
(
"\n"
);
}
}
else
if
(
result
.
getBlockingLockInfo
()
!=
null
)
{
String
stacktrace
=
ThreadUtil
.
getFullStacktrace
(
result
.
getBlockingLockInfo
());
process
.
write
(
stacktrace
);
}
else
if
(
result
.
getThreadStateCount
()
!=
null
)
{
Map
<
Thread
.
State
,
Integer
>
threadStateCount
=
result
.
getThreadStateCount
();
List
<
ThreadVO
>
threadStats
=
result
.
getThreadStats
();
//sum total thread count
int
total
=
0
;
for
(
Integer
value
:
threadStateCount
.
values
())
{
total
+=
value
;
}
int
internalThreadCount
=
0
;
for
(
ThreadVO
thread
:
threadStats
)
{
if
(
thread
.
getId
()
<=
0
)
{
internalThreadCount
+=
1
;
}
}
total
+=
internalThreadCount
;
StringBuilder
threadStat
=
new
StringBuilder
();
threadStat
.
append
(
"Threads Total: "
).
append
(
total
);
for
(
Thread
.
State
s
:
Thread
.
State
.
values
())
{
Integer
count
=
threadStateCount
.
get
(
s
);
threadStat
.
append
(
", "
).
append
(
s
.
name
()).
append
(
": "
).
append
(
count
);
}
if
(
internalThreadCount
>
0
)
{
threadStat
.
append
(
", Internal threads: "
).
append
(
internalThreadCount
);
}
String
stat
=
RenderUtil
.
render
(
new
LabelElement
(
threadStat
),
process
.
width
());
//thread stats
int
height
;
if
(
result
.
isAll
())
{
height
=
threadStats
.
size
()
+
1
;
}
else
{
height
=
Math
.
max
(
5
,
process
.
height
()
-
2
);
//remove blank lines
height
=
Math
.
min
(
height
,
threadStats
.
size
()
+
2
);
}
String
content
=
ViewRenderUtil
.
drawThreadInfo
(
threadStats
,
process
.
width
(),
height
);
process
.
write
(
stat
+
content
);
}
}
}
core/src/main/java/com/taobao/arthas/core/command/view/TimeTunnelView.java
0 → 100644
View file @
7c094a26
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ObjectVO
;
import
com.taobao.arthas.core.command.model.TimeFragmentVO
;
import
com.taobao.arthas.core.command.model.TimeTunnelModel
;
import
com.taobao.arthas.core.command.monitor200.TimeTunnelTable
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.StringUtils
;
import
com.taobao.arthas.core.view.ObjectView
;
import
com.taobao.text.ui.Element
;
import
com.taobao.text.ui.TableElement
;
import
com.taobao.text.util.RenderUtil
;
import
static
com
.
taobao
.
arthas
.
core
.
command
.
monitor200
.
TimeTunnelTable
.*;
import
static
java
.
lang
.
String
.
format
;
/**
* Term view for TimeTunnelCommand
* @author gongdewei 2020/4/27
*/
public
class
TimeTunnelView
extends
ResultView
<
TimeTunnelModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
TimeTunnelModel
timeTunnelModel
)
{
Integer
sizeLimit
=
timeTunnelModel
.
getSizeLimit
();
if
(
timeTunnelModel
.
getTimeFragmentList
()
!=
null
)
{
//show list table: tt -l / tt -t
Element
table
=
drawTimeTunnelTable
(
timeTunnelModel
.
getTimeFragmentList
(),
timeTunnelModel
.
getFirst
());
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
else
if
(
timeTunnelModel
.
getTimeFragment
()
!=
null
)
{
//show detail of single TimeFragment: tt -i 1000
TimeFragmentVO
tf
=
timeTunnelModel
.
getTimeFragment
();
TableElement
table
=
TimeTunnelTable
.
createDefaultTable
();
TimeTunnelTable
.
drawTimeTunnel
(
table
,
tf
);
TimeTunnelTable
.
drawParameters
(
table
,
tf
.
getParams
());
TimeTunnelTable
.
drawReturnObj
(
table
,
tf
,
sizeLimit
);
TimeTunnelTable
.
drawThrowException
(
table
,
tf
);
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
else
if
(
timeTunnelModel
.
getWatchValue
()
!=
null
)
{
//watch single TimeFragment: tt -i 1000 -w 'params'
ObjectVO
valueVO
=
timeTunnelModel
.
getWatchValue
();
if
(
valueVO
.
needExpand
())
{
process
.
write
(
new
ObjectView
(
sizeLimit
,
valueVO
).
draw
()).
write
(
"\n"
);
}
else
{
process
.
write
(
StringUtils
.
objectToString
(
valueVO
.
getObject
())).
write
(
"\n"
);
}
}
else
if
(
timeTunnelModel
.
getWatchResults
()
!=
null
)
{
//search & watch: tt -s 'returnObj!=null' -w 'returnObj'
TableElement
table
=
TimeTunnelTable
.
createDefaultTable
();
TimeTunnelTable
.
drawWatchTableHeader
(
table
);
TimeTunnelTable
.
drawWatchResults
(
table
,
timeTunnelModel
.
getWatchResults
(),
sizeLimit
);
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()));
}
else
if
(
timeTunnelModel
.
getReplayResult
()
!=
null
)
{
//replay: tt -i 1000 -p
TimeFragmentVO
replayResult
=
timeTunnelModel
.
getReplayResult
();
Integer
replayNo
=
timeTunnelModel
.
getReplayNo
();
TableElement
table
=
TimeTunnelTable
.
createDefaultTable
();
TimeTunnelTable
.
drawPlayHeader
(
replayResult
.
getClassName
(),
replayResult
.
getMethodName
(),
replayResult
.
getObject
(),
replayResult
.
getIndex
(),
table
);
TimeTunnelTable
.
drawParameters
(
table
,
replayResult
.
getParams
());
if
(
replayResult
.
isReturn
())
{
TimeTunnelTable
.
drawPlayResult
(
table
,
replayResult
.
getReturnObj
(),
sizeLimit
,
replayResult
.
getCost
());
}
else
{
TimeTunnelTable
.
drawPlayException
(
table
,
replayResult
.
getThrowExp
());
}
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
()))
.
write
(
format
(
"Time fragment[%d] successfully replayed %d times."
,
replayResult
.
getIndex
(),
replayNo
))
.
write
(
"\n\n"
);
}
}
}
Prev
1
…
13
14
15
16
17
18
19
Next
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