Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4074] optimize cors model init failed unclear prompt problem. #4095

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -85,16 +86,16 @@ public static <CLIENT_POOL> DeploymentOptions createClientDeployOptions(
}

// deploy Verticle and wait for its success. do not call this method in event-loop thread
public static <VERTICLE extends Verticle> boolean blockDeploy(Vertx vertx,
public static <VERTICLE extends Verticle> Map<String, String> blockDeploy(Vertx vertx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Map<String, Object> to avoid data type convert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Class<VERTICLE> cls,
DeploymentOptions options) throws InterruptedException {
Holder<Boolean> result = new Holder<>();
Map<String, String> result = new HashMap<>();

CountDownLatch latch = new CountDownLatch(1);
vertx.deployVerticle(cls.getName(), options, ar -> {
result.value = ar.succeeded();

result.put("code", String.valueOf(ar.succeeded()));
if (ar.failed()) {
result.put("message", ar.cause().getMessage());
LOGGER.error("deploy vertx failed, cause ", ar.cause());
}

Expand All @@ -103,7 +104,7 @@ public static <VERTICLE extends Verticle> boolean blockDeploy(Vertx vertx,

latch.await();

return result.value;
return result;
}

public static Vertx getOrCreateVertxByName(String name, VertxOptions vertxOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.servicecomb.transport.highway;

import java.util.Map;
import java.util.concurrent.TimeoutException;

import javax.ws.rs.core.Response.Status;
Expand Down Expand Up @@ -63,7 +64,10 @@ public void init(Vertx vertx) throws Exception {

DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr,
HighwayConfig.getClientThreadCount());
VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
Map<String, String> result = VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
if (!Boolean.parseBoolean(result.get("code"))) {
throw new Exception(result.get("message"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw new IllegalStageException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.servicecomb.transport.highway;

import java.util.Collections;
import java.util.Map;

import org.apache.servicecomb.core.Const;
import org.apache.servicecomb.core.Invocation;
Expand Down Expand Up @@ -47,7 +48,12 @@ public boolean init() throws Exception {
json.put(ENDPOINT_KEY, getEndpoint());
deployOptions.setConfig(json);
deployOptions.setWorkerPoolName("pool-worker-transport-highway");
return VertxUtils.blockDeploy(transportVertx, HighwayServerVerticle.class, deployOptions);
Map<String, String> result = VertxUtils.blockDeploy(transportVertx, HighwayServerVerticle.class, deployOptions);
if (Boolean.parseBoolean(result.get("code"))) {
return true;
} else {
throw new Exception(result.get("message"));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.apache.servicecomb.core.Const;
import org.apache.servicecomb.core.Invocation;
Expand Down Expand Up @@ -105,7 +106,13 @@ public boolean init() throws Exception {
options.setWorkerPoolSize(VertxOptions.DEFAULT_WORKER_POOL_SIZE);

prepareBlockResource();
return VertxUtils.blockDeploy(transportVertx, TransportConfig.getRestServerVerticle(), options);
Map<String, String> result = VertxUtils.blockDeploy(transportVertx, TransportConfig.getRestServerVerticle(),
options);
if (Boolean.parseBoolean(result.get("code"))) {
return true;
} else {
throw new Exception(result.get("message"));
}
}

private void prepareBlockResource() {
Expand Down