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");
}
}
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.");
}
}
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注销失败.");
}
}
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.");
}
}
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);
}
Aggregations