Search in sources :

Example 1 with UnitInstanceIdBean

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;
}
Also used : UnitInstance(info.xiancloud.core.distribution.service_discovery.UnitInstance) UnitInstanceIdBean(info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean)

Example 2 with UnitInstanceIdBean

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;
}
Also used : UnitInstance(info.xiancloud.core.distribution.service_discovery.UnitInstance) UnitInstanceIdBean(info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean) Unit(info.xiancloud.core.Unit)

Example 3 with UnitInstanceIdBean

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);
}
Also used : UnitInstanceIdBean(info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean) UnitProxy(info.xiancloud.core.distribution.UnitProxy)

Aggregations

UnitInstanceIdBean (info.xiancloud.core.distribution.service_discovery.UnitInstanceIdBean)3 UnitInstance (info.xiancloud.core.distribution.service_discovery.UnitInstance)2 Unit (info.xiancloud.core.Unit)1 UnitProxy (info.xiancloud.core.distribution.UnitProxy)1