Skip to content

Commit

Permalink
Try register Service Instance after export (#15113)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Feb 11, 2025
1 parent 5c5e7f4 commit bc729af
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public interface ApplicationDeployer extends Deployer<ApplicationModel> {

void exportMetadataService();

void registerServiceInstance();

/**
* Register application instance and start internal services
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public interface ModuleDeployer extends Deployer<ModuleModel> {

ReferenceCache getReferenceCache();

void registerServiceInstance();

void prepare();

void setPending();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ public void export(RegisterTypeEnum registerType) {
}
}
}

getScopeModel().getDeployer().registerServiceInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ private DynamicConfiguration getDynamicConfiguration(URL connectionURL) {
return factory.getDynamicConfiguration(connectionURL);
}

private volatile boolean registered;
private volatile boolean registered = false;

private final AtomicInteger instanceRefreshScheduleTimes = new AtomicInteger(0);

Expand All @@ -989,21 +989,21 @@ private DynamicConfiguration getDynamicConfiguration(URL connectionURL) {
*/
private final AtomicInteger serviceRefreshState = new AtomicInteger(0);

private void registerServiceInstance() {
try {
registered = true;
public synchronized void registerServiceInstance() {
if (!registered) {
try {
registered = true;

ServiceInstanceMetadataUtils.registerMetadataAndInstance(applicationModel);
ServiceInstanceMetadataUtils.registerMetadataAndInstance(applicationModel);

} catch (Exception e) {
logger.error(
CONFIG_REGISTER_INSTANCE_ERROR,
"configuration server disconnected",
"",
"Register instance error.",
e);
}
if (registered) {
} catch (Exception e) {
logger.error(
CONFIG_REGISTER_INSTANCE_ERROR,
"configuration server disconnected",
"",
"Register instance error.",
e);
}
// scheduled task for updating Metadata and ServiceInstance
asyncMetadataFuture = frameworkExecutorRepository
.getSharedScheduledExecutor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ public ReferenceCache getReferenceCache() {
return referenceCache;
}

@Override
public void registerServiceInstance() {
applicationDeployer.registerServiceInstance();
}

/**
* Prepare for export/refer service, trigger initializing application and module
*/
Expand Down

0 comments on commit bc729af

Please sign in to comment.