Skip to content

Commit

Permalink
0003599: Read instance.uuid one time for server instance
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Jun 11, 2018
1 parent 84cc52f commit 6d323c3
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -87,8 +87,10 @@ public class ClusterService extends AbstractService implements IClusterService {

private static final String[] sharedActions = new String[] { FILE_SYNC_SHARED };

private static boolean isUpgradedInstanceId;

private String serverId = null;
private String instanceId = null;
private static String instanceId = null;

private INodeService nodeService;

Expand All @@ -108,7 +110,14 @@ public ClusterService(IParameterService parameterService, ISymmetricDialect dial

@Override
public void init() {
initInstanceId();
if (instanceId == null) {
synchronized (ClusterService.class) {
initInstanceId();
}
}
if (isUpgradedInstanceId) {
nodeService.deleteNodeHost(nodeService.findIdentityNodeId()); // This is cleanup mostly for an upgrade.
}
checkSymDbOwnership();

if (isClusteringEnabled()) {
Expand All @@ -131,6 +140,9 @@ public void init() {
}

protected void initInstanceId() {
if (instanceId != null) {
return;
}
File instanceIdFile = new File(AppUtils.getSymHome() + "/" + parameterService.getString(ParameterConstants.INSTANCE_ID_LOCATION));
String instanceIdLocation = instanceIdFile.getAbsolutePath();

Expand All @@ -157,7 +169,7 @@ protected void initInstanceId() {
instanceIdFile.getParentFile().mkdirs();
IOUtils.write(newInstanceId, new FileOutputStream(instanceIdLocation));
instanceId = newInstanceId;
nodeService.deleteNodeHost(nodeService.findIdentityNodeId()); // This is cleanup mostly for an upgrade.
isUpgradedInstanceId = true;
} catch (Exception ex) {
throw new SymmetricException("Failed to save file '" + instanceIdLocation + "' Please correct and restart this node.", ex);
}
Expand Down

0 comments on commit 6d323c3

Please sign in to comment.