use of info.xiancloud.core.Unit in project xian by happyyangyuan.
the class GroupBean method getUnitNames.
/**
* @return group在本地节点下的unit名称列表视图
*/
public List<String> getUnitNames() {
if (unitNames == null) {
unitNames = new ArrayList<>();
LocalUnitsManager.unitMap(untMap -> {
untMap.forEach((group, unitList) -> {
for (Unit unit : unitList) {
if (Objects.equals(group, getName()))
unitNames.add(unit.getName());
}
});
});
}
return unitNames;
}
use of info.xiancloud.core.Unit in project xian by happyyangyuan.
the class UnitRequestTest method testGetList.
@Test
public void testGetList() {
List<Integer> list = new UnitRequest(new JSONObject() {
{
put("yy", new int[] { 0, 1 });
}
}).getList("yy");
Assert.assertTrue(list.get(0) == 0);
Assert.assertTrue(list.get(1) == 1);
List<Unit> unitList = new UnitRequest(new JSONObject() {
{
put("yy", new Unit[] { new UnitResponseTestUnit() });
}
}).getList("yy");
Assert.assertTrue(unitList.get(0).getName().equals(new UnitResponseTestUnit().getName()));
List<UnitProxy> proxyList = new UnitRequest(new JSONObject() {
{
put("yy", new String[] { new UnitResponseTestUnit().toJSONString() });
}
}).getList("yy", UnitProxy.class);
Assert.assertTrue(proxyList.get(0).getName().equals(new UnitResponseTestUnit().getName()));
}
use of info.xiancloud.core.Unit in project xian by happyyangyuan.
the class IUnitAop method unintercept.
/**
* 注销aop拦截
*
* @deprecated 该功能未测试,请暂时不要使用
*/
default void unintercept() {
Collection<Unit> proxies = getUnitCollection();
for (Unit proxy : proxies) {
if (!Proxy.isProxyClass(proxy.getClass())) {
LOG.warn(proxy.getName() + " 已经不是代理对象了! 不允许重复取消拦截!");
}
ProxyBuilder<Unit> proxyBuilder = ProxyBuilder.removeProxyBuilder(proxy.hashCode());
Unit originUnit = proxyBuilder.getOriginalTarget();
LocalUnitsManager.replaceUnit(originUnit);
}
}
use of info.xiancloud.core.Unit 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.Unit in project xian by happyyangyuan.
the class AbstractMdApidocUnit method specifyBuild.
/**
* 返回生成MD的文件字符串
*/
private static String specifyBuild(String description, String docName, IUnitFilter filter) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ApiBuilder.build(new UnitMdBuilderHandler(description, docName, filter).callback(data -> {
try {
bos.write(data);
if (data.length > 0) {
LOG.info("api-doc接口文档unit文档大小 : " + data.length);
LOG.info("api-doc接口文档unit发布成功");
} else {
LOG.info("api-doc接口文档unit暂无扫描到相关数据");
}
} catch (Exception e) {
LOG.error("api-doc接口文档生成unit接口文档出错", e);
}
}));
return bos.toString();
}
Aggregations