Skip to content

Commit

Permalink
Introduce property shortenNodeNameIfNecessary with default false
Browse files Browse the repository at this point in the history
  • Loading branch information
graben committed Apr 21, 2024
1 parent d29b79d commit 6ca17d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class NarayanaProperties {
*/
private String logDir;

private boolean shortenNodeNameIfNecessary = false;

/**
* Unique transaction manager id.
*/
Expand Down Expand Up @@ -138,6 +140,14 @@ public void setLogDir(String logDir) {
this.logDir = logDir;
}

public boolean isShortenNodeNameIfNecessary() {
return this.shortenNodeNameIfNecessary;
}

public void setShortenNodeNameIfNecessary(boolean shortenNodeNameIfNecessary) {
this.shortenNodeNameIfNecessary = shortenNodeNameIfNecessary;
}

public String getTransactionManagerId() {
return this.transactionManagerId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public NarayanaPropertiesInitializer(NarayanaProperties narayanaProperties) {

@Override
public void afterPropertiesSet() {
setNodeIdentifier(this.properties.getTransactionManagerId());
setNodeIdentifier(this.properties.getTransactionManagerId(), this.properties.isShortenNodeNameIfNecessary());
setXARecoveryNodes(this.properties.getXaRecoveryNodes());
setObjectStoreDir(this.properties.getLogDir());
setCommitOnePhase(this.properties.isOnePhaseCommit());
Expand All @@ -63,10 +63,12 @@ public void afterPropertiesSet() {
setExpiryScanners(this.properties.getExpiryScanners());
}

private void setNodeIdentifier(String nodeIdentifier) {
private void setNodeIdentifier(String nodeIdentifier, boolean shortenNodeNameIfNecessary) {
String verifiedNodeIdentifier = nodeIdentifier;
try {
if (nodeIdentifier != null && nodeIdentifier.getBytes(StandardCharsets.UTF_8).length > 28) {
if (nodeIdentifier != null
&& nodeIdentifier.getBytes(StandardCharsets.UTF_8).length > 28
&& shortenNodeNameIfNecessary) {
verifiedNodeIdentifier = shortenNodeIdentifier(nodeIdentifier);
}

Expand Down

0 comments on commit 6ca17d3

Please sign in to comment.