use of info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean in project xian by happyyangyuan.
the class UnitRegistrationBridge method unitInstance.
static UnitInstance unitInstance(UnitProxy unitProxy, NodeStatus nodeStatus) {
UnitInstance unitInstance = new UnitInstance();
unitInstance.setPayload(UnitProxy.create(unitProxy));
unitInstance.setRegistrationTimestamp(nodeStatus.getInitTime());
unitInstance.setPort(nodeStatus.getPort());
unitInstance.setName(Unit.fullName(unitProxy));
unitInstance.setEnabled(true);
unitInstance.setAddress(nodeStatus.getHost());
unitInstance.setUnitInstanceIdBean(new UnitInstanceIdBean(Unit.fullName(unitProxy), nodeStatus.getNodeId()));
return unitInstance;
}
use of info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean in project xian by happyyangyuan.
the class UnitRouter method localInstance.
public UnitInstance localInstance(String fullUnitName) {
Unit localUnit = LocalUnitsManager.getLocalUnit(fullUnitName);
if (localUnit != null) {
// 本地有,就直接用即可
UnitInstance unitInstance = new UnitInstance();
unitInstance.setPayload(UnitProxy.create(localUnit));
unitInstance.setRegistrationTimestamp(LocalNodeManager.singleton.getSimpleStatus().getInitTime());
unitInstance.setPort(Node.RPC_PORT);
unitInstance.setName(fullUnitName);
unitInstance.setEnabled(true);
unitInstance.setAddress(EnvUtil.getLocalIp());
unitInstance.setId(new UnitInstanceIdBean(fullUnitName, LocalNodeManager.LOCAL_NODE_ID).getUnitInstanceId());
return unitInstance;
}
return null;
}
use of info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean in project xian by happyyangyuan.
the class ZkUnitDiscovery method instance.
@Override
public UnitInstance instance(String unitInstanceId) {
String name = new UnitInstanceIdBean(unitInstanceId).getFullName();
ServiceInstance<UnitProxy> serviceInstance = serviceProviders.getUnchecked(name).getInstance(unitInstanceId);
if (serviceInstance == null)
serviceInstance = nonCachedInstanceProviders.getUnchecked(name).getInstance(unitInstanceId);
return ZkServiceInstanceAdaptor.unitInstance(serviceInstance);
}
Aggregations