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
Commits
5d7c4150
Commit
5d7c4150
authored
Dec 21, 2023
by
shengnan hu
Browse files
init
parents
Pipeline
#4715
failed with stage
in 30 seconds
Changes
457
Pipelines
620
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
748 additions
and
0 deletions
+748
-0
core/src/main/java/com/taobao/arthas/core/command/view/MonitorView.java
...java/com/taobao/arthas/core/command/view/MonitorView.java
+58
-0
core/src/main/java/com/taobao/arthas/core/command/view/OgnlView.java
...in/java/com/taobao/arthas/core/command/view/OgnlView.java
+27
-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
No files found.
Too many changes to show.
To preserve performance only
457 of 457+
files are displayed.
Plain diff
Email patch
core/src/main/java/com/taobao/arthas/core/command/view/MonitorView.java
0 → 100644
View file @
5d7c4150
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.MonitorModel
;
import
com.taobao.arthas.core.command.monitor200.MonitorData
;
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.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
static
com
.
taobao
.
text
.
ui
.
Element
.
label
;
/**
* Term view for MonitorModel
* @author gongdewei 2020/4/28
*/
public
class
MonitorView
extends
ResultView
<
MonitorModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
MonitorModel
result
)
{
TableElement
table
=
new
TableElement
(
2
,
3
,
3
,
1
,
1
,
1
,
1
,
1
).
leftCellPadding
(
1
).
rightCellPadding
(
1
);
table
.
row
(
true
,
label
(
"timestamp"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"class"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"method"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"total"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"success"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"fail"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"avg-rt(ms)"
).
style
(
Decoration
.
bold
.
bold
()),
label
(
"fail-rate"
).
style
(
Decoration
.
bold
.
bold
()));
final
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
for
(
MonitorData
data
:
result
.
getMonitorDataList
())
{
table
.
row
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()),
data
.
getClassName
(),
data
.
getMethodName
(),
""
+
data
.
getTotal
(),
""
+
data
.
getSuccess
(),
""
+
data
.
getFailed
(),
df
.
format
(
div
(
data
.
getCost
(),
data
.
getTotal
())),
df
.
format
(
100.0d
*
div
(
data
.
getFailed
(),
data
.
getTotal
()))
+
"%"
);
}
process
.
write
(
RenderUtil
.
render
(
table
,
process
.
width
())
+
"\n"
);
}
private
double
div
(
double
a
,
double
b
)
{
if
(
b
==
0
)
{
return
0
;
}
return
a
/
b
;
}
}
core/src/main/java/com/taobao/arthas/core/command/view/OgnlView.java
0 → 100644
View file @
5d7c4150
package
com.taobao.arthas.core.command.view
;
import
com.taobao.arthas.core.command.model.ObjectVO
;
import
com.taobao.arthas.core.command.model.OgnlModel
;
import
com.taobao.arthas.core.shell.command.CommandProcess
;
import
com.taobao.arthas.core.util.StringUtils
;
import
com.taobao.arthas.core.view.ObjectView
;
/**
* Term view of OgnlCommand
* @author gongdewei 2020/4/29
*/
public
class
OgnlView
extends
ResultView
<
OgnlModel
>
{
@Override
public
void
draw
(
CommandProcess
process
,
OgnlModel
model
)
{
if
(
model
.
getMatchedClassLoaders
()
!=
null
)
{
process
.
write
(
"Matched classloaders: \n"
);
ClassLoaderView
.
drawClassLoaders
(
process
,
model
.
getMatchedClassLoaders
(),
false
);
process
.
write
(
"\n"
);
return
;
}
ObjectVO
objectVO
=
model
.
getValue
();
String
resultStr
=
StringUtils
.
objectToString
(
objectVO
.
needExpand
()
?
new
ObjectView
(
objectVO
).
draw
()
:
objectVO
.
getObject
());
process
.
write
(
resultStr
).
write
(
"\n"
);
}
}
core/src/main/java/com/taobao/arthas/core/command/view/OptionsView.java
0 → 100644
View file @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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 @
5d7c4150
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
()));
}
}
Prev
1
…
17
18
19
20
21
22
23
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