Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Indexer
Commits
6d7721fd
Commit
6d7721fd
authored
2 years ago
by
Zhibin Mai
Committed by
David Diederich
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Failure to create the alias should not have impact on the status of index creation
(cherry picked from commit
eab4a842
)
parent
9b38530e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndicesServiceImpl.java
+18
-12
18 additions, 12 deletions
...rg/opengroup/osdu/indexer/service/IndicesServiceImpl.java
with
18 additions
and
12 deletions
indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndicesServiceImpl.java
+
18
−
12
View file @
6d7721fd
...
...
@@ -307,22 +307,28 @@ public class IndicesServiceImpl implements IndicesService {
}
}
private
void
createIndexAlias
(
RestHighLevelClient
client
,
String
index
)
throws
IOException
{
private
void
createIndexAlias
(
RestHighLevelClient
client
,
String
index
)
{
String
kind
=
this
.
elasticIndexNameResolver
.
getKindFromIndexName
(
index
);
String
kindWithMajorVersion
=
getKindWithMajorVersion
(
kind
);
for
(
String
kd
:
Arrays
.
asList
(
kind
,
kindWithMajorVersion
))
{
index
=
elasticIndexNameResolver
.
getIndexNameFromKind
(
kd
);
String
alias
=
elasticIndexNameResolver
.
getIndexAliasFromKind
(
kd
);
IndicesAliasesRequest
addRequest
=
new
IndicesAliasesRequest
();
IndicesAliasesRequest
.
AliasActions
aliasActions
=
new
IndicesAliasesRequest
.
AliasActions
(
IndicesAliasesRequest
.
AliasActions
.
Type
.
ADD
)
.
index
(
index
)
.
alias
(
alias
);
addRequest
.
addAliasAction
(
aliasActions
);
AcknowledgedResponse
response
=
client
.
indices
().
updateAliases
(
addRequest
,
RequestOptions
.
DEFAULT
);
if
(
response
.
isAcknowledged
())
{
this
.
log
.
info
(
String
.
format
(
"Alias %s was created for index %s"
,
alias
,
index
));
try
{
for
(
String
kd
:
Arrays
.
asList
(
kind
,
kindWithMajorVersion
))
{
index
=
elasticIndexNameResolver
.
getIndexNameFromKind
(
kd
);
String
alias
=
elasticIndexNameResolver
.
getIndexAliasFromKind
(
kd
);
IndicesAliasesRequest
addRequest
=
new
IndicesAliasesRequest
();
IndicesAliasesRequest
.
AliasActions
aliasActions
=
new
IndicesAliasesRequest
.
AliasActions
(
IndicesAliasesRequest
.
AliasActions
.
Type
.
ADD
)
.
index
(
index
)
.
alias
(
alias
);
addRequest
.
addAliasAction
(
aliasActions
);
AcknowledgedResponse
response
=
client
.
indices
().
updateAliases
(
addRequest
,
RequestOptions
.
DEFAULT
);
if
(
response
.
isAcknowledged
())
{
this
.
log
.
info
(
String
.
format
(
"Alias %s was created for index %s"
,
alias
,
index
));
}
}
}
catch
(
Exception
ex
)
{
// Failed to create alias is not the end. It should not affect the status of index creation
this
.
log
.
error
(
String
.
format
(
"Fail to create aliases for index %s"
,
index
),
ex
);
}
}
private
String
getKindWithMajorVersion
(
String
kind
)
{
...
...
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