mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: define insideCluster in HandlerLocation
This commit is contained in:
parent
59121684a8
commit
d6f3ae6c44
@ -15,6 +15,7 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ToString
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class HandlerLocation implements Serializable {
|
public class HandlerLocation implements Serializable {
|
||||||
/**
|
/**
|
||||||
@ -25,13 +26,12 @@ public class HandlerLocation implements Serializable {
|
|||||||
* 方法路径
|
* 方法路径
|
||||||
*/
|
*/
|
||||||
private String methodPath;
|
private String methodPath;
|
||||||
|
/**
|
||||||
|
* 是否在本集群内(用于兼容 AKKA 等除了IP还需要指定 system 访问的情况)
|
||||||
|
*/
|
||||||
|
private boolean insideCluster;
|
||||||
|
|
||||||
public String toPath() {
|
public String toPath() {
|
||||||
return String.format("/%s/%s", rootPath, methodPath);
|
return String.format("/%s/%s", rootPath, methodPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return toPath();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import tech.powerjob.common.PowerSerializable;
|
|||||||
import tech.powerjob.common.RemoteConstant;
|
import tech.powerjob.common.RemoteConstant;
|
||||||
import tech.powerjob.common.request.ServerScheduleJobReq;
|
import tech.powerjob.common.request.ServerScheduleJobReq;
|
||||||
import tech.powerjob.common.utils.CommonUtils;
|
import tech.powerjob.common.utils.CommonUtils;
|
||||||
|
import tech.powerjob.remote.framework.base.HandlerLocation;
|
||||||
import tech.powerjob.remote.framework.base.RemotingException;
|
import tech.powerjob.remote.framework.base.RemotingException;
|
||||||
import tech.powerjob.remote.framework.base.ServerType;
|
import tech.powerjob.remote.framework.base.ServerType;
|
||||||
import tech.powerjob.remote.framework.base.URL;
|
import tech.powerjob.remote.framework.base.URL;
|
||||||
@ -27,9 +28,9 @@ import java.util.concurrent.ExecutorService;
|
|||||||
*/
|
*/
|
||||||
public class AkkaTransporter implements Transporter {
|
public class AkkaTransporter implements Transporter {
|
||||||
|
|
||||||
|
private final ServerType serverType;
|
||||||
private final ActorSystem actorSystem;
|
private final ActorSystem actorSystem;
|
||||||
|
|
||||||
private final String targetActorSystemName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* akka://<actor system>@<hostname>:<port>/<actor path>
|
* akka://<actor system>@<hostname>:<port>/<actor path>
|
||||||
@ -38,7 +39,7 @@ public class AkkaTransporter implements Transporter {
|
|||||||
|
|
||||||
public AkkaTransporter(ServerType serverType, ActorSystem actorSystem) {
|
public AkkaTransporter(ServerType serverType, ActorSystem actorSystem) {
|
||||||
this.actorSystem = actorSystem;
|
this.actorSystem = actorSystem;
|
||||||
this.targetActorSystemName = AkkaConstant.fetchActorSystemName(serverType, false);
|
this.serverType = serverType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,9 +62,12 @@ public class AkkaTransporter implements Transporter {
|
|||||||
|
|
||||||
private ActorSelection fetchActorSelection(URL url) {
|
private ActorSelection fetchActorSelection(URL url) {
|
||||||
|
|
||||||
String targetActorName = AkkaMappingService.parseActorName(url.getLocation().getRootPath()).getActorName();
|
HandlerLocation location = url.getLocation();
|
||||||
|
String targetActorSystemName = AkkaConstant.fetchActorSystemName(serverType, location.isInsideCluster());
|
||||||
|
|
||||||
CommonUtils.requireNonNull(targetActorName, "can't find actor by URL: " + url.getLocation());
|
String targetActorName = AkkaMappingService.parseActorName(location.getRootPath()).getActorName();
|
||||||
|
|
||||||
|
CommonUtils.requireNonNull(targetActorName, "can't find actor by URL: " + location);
|
||||||
|
|
||||||
String address = url.getAddress().toFullAddress();
|
String address = url.getAddress().toFullAddress();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user