Skip to content

Commit

Permalink
[apache#4682] Support framework information can be updated when servi…
Browse files Browse the repository at this point in the history
…ce information is updated
  • Loading branch information
chengyouling committed Jan 22, 2025
1 parent 2ec1cc0 commit 7adabdc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.servicecomb.service.center.client.model.CreateSchemaRequest;
import org.apache.servicecomb.service.center.client.model.ErrorMessage;
import org.apache.servicecomb.service.center.client.model.FindMicroserviceInstancesResponse;
import org.apache.servicecomb.service.center.client.model.Framework;
import org.apache.servicecomb.service.center.client.model.GetSchemaListResponse;
import org.apache.servicecomb.service.center.client.model.GetSchemaResponse;
import org.apache.servicecomb.service.center.client.model.HeartbeatsRequest;
Expand Down Expand Up @@ -535,10 +536,12 @@ public RbacTokenResponse queryToken(RbacTokenRequest request) {
}

@Override
public boolean updateMicroserviceProperties(String serviceId, Map<String, String> serviceProperties) {
public boolean updateMicroserviceProperties(String serviceId, Map<String, String> serviceProperties,
Framework framework) {
try {
UpdatePropertiesRequest request = new UpdatePropertiesRequest();
request.setProperties(serviceProperties);
request.setFramework(framework);
HttpResponse response = httpClient.putHttpRequest(
"/registry/microservices/" + serviceId + "/properties", null, HttpUtils.serialize(request));
if (response.getStatusCode() == HttpStatus.SC_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.servicecomb.service.center.client.exception.OperationException;
import org.apache.servicecomb.service.center.client.model.CreateSchemaRequest;
import org.apache.servicecomb.service.center.client.model.FindMicroserviceInstancesResponse;
import org.apache.servicecomb.service.center.client.model.Framework;
import org.apache.servicecomb.service.center.client.model.HeartbeatsRequest;
import org.apache.servicecomb.service.center.client.model.Microservice;
import org.apache.servicecomb.service.center.client.model.MicroserviceInstance;
Expand Down Expand Up @@ -192,7 +193,8 @@ boolean updateMicroserviceInstanceStatus(String serviceId, String instanceId,
* @return if update is successful
* @throws OperationException If some problems happened to contact service center or non http 200 returned.
*/
boolean updateMicroserviceProperties(String microserviceId, Map<String, String> serviceProperties);
boolean updateMicroserviceProperties(String microserviceId, Map<String, String> serviceProperties,
Framework framework);

/**
* Check serviceCenter isolation address available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void execute() {
microservice.setProperties(newMicroservice.getProperties());
microservice.getProperties().putAll(propertiesTemp);
if (serviceCenterClient.updateMicroserviceProperties(serviceResponse.getServiceId(),
microservice.getProperties())) {
microservice.getProperties(), microservice.getFramework())) {
LOGGER.info(
"microservice is already registered. Update microservice properties successfully. properties=[{}]",
microservice.getProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@
public class UpdatePropertiesRequest {
private Map<String, String> properties;

private Framework framework;

public Map<String, String> getProperties() {
return properties;
}

public void setProperties(Map<String, String> properties) {
this.properties = properties;
}

public Framework getFramework() {
return framework;
}

public void setFramework(Framework framework) {
this.framework = framework;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;

import org.apache.servicecomb.http.client.common.HttpResponse;
import org.apache.servicecomb.service.center.client.model.Framework;
import org.apache.servicecomb.service.center.client.model.HeartbeatsRequest;
import org.apache.servicecomb.service.center.client.model.InstancesRequest;
import org.apache.servicecomb.service.center.client.model.Microservice;
Expand Down Expand Up @@ -516,7 +517,7 @@ public void testUpdateMicroserviceProperties() throws IOException {

ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient, addressManager);
boolean result = serviceCenterClient
.updateMicroserviceProperties("111", new HashMap<String, String>());
.updateMicroserviceProperties("111", new HashMap<String, String>(), new Framework());

Assertions.assertTrue(result);
}
Expand Down

0 comments on commit 7adabdc

Please sign in to comment.