Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
VVAS-Match
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b810a59b
authored
Apr 25, 2024
by
朱海
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg]异常捕获
1 parent
8fdb47f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
src/main/java/com/viontech/match/runner/ILM.java
src/main/java/com/viontech/match/runner/ILM.java
View file @
b810a59
...
...
@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -42,21 +43,25 @@ public class ILM implements CommandLineRunner {
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
Map
<
String
,
Phase
>
phases
=
new
HashMap
<>();
Map
<
String
,
LifecycleAction
>
setPriorityAction
=
new
HashMap
<>();
setPriorityAction
.
put
(
SetPriorityAction
.
NAME
,
new
SetPriorityAction
(
100
));
phases
.
put
(
"hot"
,
new
Phase
(
"hot"
,
TimeValue
.
ZERO
,
setPriorityAction
));
Map
<
String
,
LifecycleAction
>
deleteActions
=
Collections
.
singletonMap
(
DeleteAction
.
NAME
,
new
DeleteAction
());
phases
.
put
(
"delete"
,
new
Phase
(
"delete"
,
new
TimeValue
(
deleteAfterDays
,
TimeUnit
.
DAYS
),
deleteActions
));
LifecyclePolicy
policy
=
new
LifecyclePolicy
(
LIFECYCLE_NAME
,
phases
);
PutLifecyclePolicyRequest
lifecyclePolicyRequest
=
new
PutLifecyclePolicyRequest
(
policy
);
AcknowledgedResponse
acknowledgedResponse
=
restHighLevelClient
.
indexLifecycle
().
putLifecyclePolicy
(
lifecyclePolicyRequest
,
RequestOptions
.
DEFAULT
);
if
(
acknowledgedResponse
.
isAcknowledged
())
{
log
.
info
(
LIFECYCLE_NAME
+
"生命周期创建完成"
);
try
{
Map
<
String
,
Phase
>
phases
=
new
HashMap
<>();
Map
<
String
,
LifecycleAction
>
setPriorityAction
=
new
HashMap
<>();
setPriorityAction
.
put
(
SetPriorityAction
.
NAME
,
new
SetPriorityAction
(
100
));
phases
.
put
(
"hot"
,
new
Phase
(
"hot"
,
TimeValue
.
ZERO
,
setPriorityAction
));
Map
<
String
,
LifecycleAction
>
deleteActions
=
Collections
.
singletonMap
(
DeleteAction
.
NAME
,
new
DeleteAction
());
phases
.
put
(
"delete"
,
new
Phase
(
"delete"
,
new
TimeValue
(
deleteAfterDays
,
TimeUnit
.
DAYS
),
deleteActions
));
LifecyclePolicy
policy
=
new
LifecyclePolicy
(
LIFECYCLE_NAME
,
phases
);
PutLifecyclePolicyRequest
lifecyclePolicyRequest
=
new
PutLifecyclePolicyRequest
(
policy
);
AcknowledgedResponse
acknowledgedResponse
=
restHighLevelClient
.
indexLifecycle
().
putLifecyclePolicy
(
lifecyclePolicyRequest
,
RequestOptions
.
DEFAULT
);
if
(
acknowledgedResponse
.
isAcknowledged
())
{
log
.
info
(
LIFECYCLE_NAME
+
"生命周期创建完成"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"生命周期创建异常"
,
e
);
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment