-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor changes in instance logging thanks to PR feedback.
Also removed the empty MetadataMigration file that was a result of the last merge (the file was moved) Signed-off-by: Greg Schohn <[email protected]>
- Loading branch information
1 parent
8847c03
commit fd9b306
Showing
6 changed files
with
17 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 7 additions & 20 deletions
27
coreUtilities/src/main/java/org/opensearch/migrations/utils/ProcessHelpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,19 @@ | ||
package org.opensearch.migrations.utils; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class ProcessHelpers { | ||
private static final String DEFAULT_NODE_ID = UUID.randomUUID().toString(); | ||
private static final String DEFAULT_NODE_ID = "generated_" + UUID.randomUUID().toString(); | ||
|
||
public static String getNodeInstanceName() { | ||
String id = null; | ||
try { | ||
id = System.getenv("ECS_TASK_ID"); // for ECS deployments | ||
if (id != null) { | ||
return id; | ||
} | ||
id = System.getenv("HOSTNAME"); // for any kubernetes deployed pod | ||
if (id != null) { | ||
return id; | ||
} | ||
// add additional fallbacks here | ||
id = DEFAULT_NODE_ID; | ||
return id; | ||
} finally { | ||
if (id != null) { | ||
String finalId = id; | ||
log.atInfo().setMessage(() -> "getNodeInstanceName()=" + finalId).log(); | ||
} | ||
} | ||
var nodeId = Optional.of("ECS_TASK_ID").map(System::getenv) | ||
.or(() -> Optional.of("HOSTNAME").map(System::getenv)) | ||
.orElse(DEFAULT_NODE_ID); | ||
log.atInfo().setMessage(() -> "getNodeInstanceName()=" + nodeId).log(); | ||
return nodeId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters