Search in sources :

Example 1 with NodeStatus

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

the class GroupRegistrationBridge method execute.

@Override
public UnitResponse execute(UnitRequest request) {
    GroupProxy groupProxy = request.get("group", GroupProxy.class);
    NodeStatus nodeStatus = request.get("nodeStatus", NodeStatus.class);
    try {
        GroupDiscovery.singleton.register(groupInstance(groupProxy, nodeStatus));
        return UnitResponse.success();
    } catch (Exception e) {
        LOG.error(e);
        return UnitResponse.failure(e, "failed to register group");
    }
}
Also used : GroupProxy(info.xiancloud.core.distribution.GroupProxy) NodeStatus(info.xiancloud.core.distribution.NodeStatus)

Example 2 with NodeStatus

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

the class UnitRegistrationBridge method execute.

@Override
public UnitResponse execute(UnitRequest msg) {
    UnitProxy unitProxy = msg.get("unit", UnitProxy.class);
    NodeStatus nodeStatus = msg.get("nodeStatus", NodeStatus.class);
    UnitInstance unitInstance = unitInstance(unitProxy, nodeStatus);
    try {
        UnitDiscovery.singleton.register(unitInstance);
        return UnitResponse.success();
    } catch (Exception e) {
        LOG.error(e);
        return UnitResponse.failure(null, "registration failed.");
    }
}
Also used : UnitInstance(info.xiancloud.core.distribution.service_discovery.UnitInstance) UnitProxy(info.xiancloud.core.distribution.UnitProxy) NodeStatus(info.xiancloud.core.distribution.NodeStatus)

Example 3 with NodeStatus

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

the class GroupUnregistrationBridge method execute.

@Override
public UnitResponse execute(UnitRequest request) {
    GroupProxy groupProxy = request.get("group", GroupProxy.class);
    NodeStatus nodeStatus = request.get("nodeStatus", NodeStatus.class);
    GroupInstance groupInstance = GroupRegistrationBridge.groupInstance(groupProxy, nodeStatus);
    try {
        GroupDiscovery.singleton.unregister(groupInstance);
        return UnitResponse.success();
    } catch (Exception e) {
        return UnitResponse.failure(e, "group注销失败.");
    }
}
Also used : GroupProxy(info.xiancloud.core.distribution.GroupProxy) GroupInstance(info.xiancloud.core.distribution.service_discovery.GroupInstance) NodeStatus(info.xiancloud.core.distribution.NodeStatus)

Example 4 with NodeStatus

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

the class UnitUnregistrationBridge method execute.

@Override
public UnitResponse execute(UnitRequest msg) {
    UnitProxy unitProxy = msg.get("unit", UnitProxy.class);
    NodeStatus nodeStatus = msg.get("nodeStatus", NodeStatus.class);
    UnitInstance unitInstance = UnitRegistrationBridge.unitInstance(unitProxy, nodeStatus);
    try {
        UnitDiscovery.singleton.unregister(unitInstance);
        return UnitResponse.success();
    } catch (Exception e) {
        LOG.error(e);
        return UnitResponse.failure(e, "unit un registration failure.");
    }
}
Also used : UnitInstance(info.xiancloud.core.distribution.service_discovery.UnitInstance) UnitProxy(info.xiancloud.core.distribution.UnitProxy) NodeStatus(info.xiancloud.core.distribution.NodeStatus)

Example 5 with NodeStatus

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

the class TestFastjsonTypeReference method test.

@Test
public void test() {
    final NodeStatus status = new NodeStatus();
    status.setActiveCount(1);
    ServiceInstance<NodeStatus> instance = JSON.parseObject(new JSONObject() {

        {
            put("payload", status);
        }
    }.toJSONString(), new TypeReference<ServiceInstance<NodeStatus>>() {
    });
    Assert.assertEquals(instance.getPayload().getActiveCount(), 1);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ServiceInstance(org.apache.curator.x.discovery.ServiceInstance) NodeStatus(info.xiancloud.core.distribution.NodeStatus) Test(org.junit.Test)

Aggregations

NodeStatus (info.xiancloud.core.distribution.NodeStatus)5 GroupProxy (info.xiancloud.core.distribution.GroupProxy)2 UnitProxy (info.xiancloud.core.distribution.UnitProxy)2 UnitInstance (info.xiancloud.core.distribution.service_discovery.UnitInstance)2 JSONObject (com.alibaba.fastjson.JSONObject)1 GroupInstance (info.xiancloud.core.distribution.service_discovery.GroupInstance)1 ServiceInstance (org.apache.curator.x.discovery.ServiceInstance)1 Test (org.junit.Test)1