Search in sources :

Example 1 with GroupInstanceIdBean

use of info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean in project xian by happyyangyuan.

the class GroupRouter method localInstance.

@Override
public GroupInstance localInstance(String groupName) {
    return LocalUnitsManager.unitMap(unitMap -> {
        if (unitMap.containsKey(groupName)) {
            GroupInstance serviceInstance = new GroupInstance();
            serviceInstance.setRegistrationTimestamp(LocalNodeManager.singleton.getFullStatus().getInitTime());
            serviceInstance.setPort(Node.RPC_PORT);
            serviceInstance.setName(groupName);
            serviceInstance.setEnabled(true);
            serviceInstance.setAddress(EnvUtil.getLocalIp());
            serviceInstance.setId(new GroupInstanceIdBean(groupName, LocalNodeManager.LOCAL_NODE_ID).getGroupInstanceId());
            serviceInstance.setPayload(GroupProxy.create(LocalUnitsManager.getGroupByName(groupName)));
            return serviceInstance;
        } else {
            return null;
        }
    });
}
Also used : GroupInstanceIdBean(info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean) GroupInstance(info.xiancloud.core.distribution.service_discovery.GroupInstance)

Example 2 with GroupInstanceIdBean

use of info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean in project xian by happyyangyuan.

the class ZkGroupDiscovery method instance.

@Override
public GroupInstance instance(String groupInstanceId) {
    String groupName = new GroupInstanceIdBean(groupInstanceId).getGroup();
    ServiceInstance<GroupProxy> instance = serviceProviders.getUnchecked(groupName).getInstance(groupInstanceId);
    if (instance == null)
        instance = nonCachedInstanceProviders.getUnchecked(groupName).getInstance(groupInstanceId);
    return ZkServiceInstanceAdaptor.groupInstance(instance);
}
Also used : GroupProxy(info.xiancloud.core.distribution.GroupProxy) GroupInstanceIdBean(info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean)

Example 3 with GroupInstanceIdBean

use of info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean in project xian by happyyangyuan.

the class GroupRegistrationBridge method groupInstance.

static GroupInstance groupInstance(GroupProxy groupProxy, NodeStatus nodeStatus) {
    GroupInstance groupInstance = new GroupInstance();
    groupInstance.setRegistrationTimestamp(nodeStatus.getInitTime());
    groupInstance.setPort(nodeStatus.getPort());
    groupInstance.setName(groupProxy.getName());
    groupInstance.setEnabled(true);
    groupInstance.setAddress(nodeStatus.getHost());
    groupInstance.setGroupInstanceIdBean(new GroupInstanceIdBean(groupProxy.getName(), LocalNodeManager.LOCAL_NODE_ID));
    groupInstance.setPayload(groupProxy);
    return groupInstance;
}
Also used : GroupInstanceIdBean(info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean) GroupInstance(info.xiancloud.core.distribution.service_discovery.GroupInstance)

Aggregations

GroupInstanceIdBean (info.xiancloud.core.distribution.service_discovery.GroupInstanceIdBean)3 GroupInstance (info.xiancloud.core.distribution.service_discovery.GroupInstance)2 GroupProxy (info.xiancloud.core.distribution.GroupProxy)1