use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.
the class MetaDataServiceImpl method delete.
@Override
@Transactional(rollbackFor = Exception.class)
public int delete(final List<String> ids) {
int count = 0;
Set<String> idSet = Optional.ofNullable(ids).orElseGet(ArrayList::new).stream().filter(StringUtils::isNotEmpty).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(idSet)) {
List<MetaDataDO> metaDataDoList = metaDataMapper.selectByIdSet(idSet);
List<MetaData> metaDataList = Optional.ofNullable(metaDataDoList).orElseGet(ArrayList::new).stream().map(MetaDataTransfer.INSTANCE::mapToData).collect(Collectors.toList());
count = metaDataMapper.deleteByIdSet(idSet);
eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, DataEventTypeEnum.DELETE, metaDataList));
}
return count;
}
use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.
the class AlibabaDubboProxyServiceTest method setup.
@BeforeEach
public void setup() {
metaData = new MetaData();
metaData.setId("1332017966661636096");
metaData.setAppName("sofa");
metaData.setPath(PATH);
metaData.setServiceName("org.apache.shenyu.test.dubbo.api.service.DubboTestService");
metaData.setMethodName(METHOD_NAME);
metaData.setRpcType(RpcTypeEnum.SOFA.getName());
}
use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.
the class AlibabaDubboMetaDataSubscriberTest method testOnSubscribe.
@Test
public void testOnSubscribe() {
alibabaDubboMetaDataSubscriber.onSubscribe(metaData);
MetaData metaData = MetaData.builder().id("1332017966661636096").appName("dubbo").path("/dubbo/findAll").serviceName("org.apache.shenyu.test.dubbo.api.service.DubboTestService").methodName("findById").rpcType(RpcTypeEnum.DUBBO.getName()).rpcExt("{\"group\":\"Group\",\"version\":\"2.6.5\",\"loadbalance\":\"roundrobin\",\"url\":\"http://192.168.55.113/dubbo\"}").parameterTypes("parameterTypes").build();
AlibabaDubboMetaDataSubscriber alibabaDubboMetaDataSubscriberMock = mock(AlibabaDubboMetaDataSubscriber.class);
doNothing().when(alibabaDubboMetaDataSubscriberMock).onSubscribe(metaData);
alibabaDubboMetaDataSubscriberMock.onSubscribe(metaData);
alibabaDubboMetaDataSubscriber.unSubscribe(metaData);
}
use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.
the class ApacheDubboConfigCacheTest method testInitRef.
@Test
public void testInitRef() {
MetaData metaData = new MetaData();
metaData.setPath("/test");
ApacheDubboConfigCache apacheDubboConfigCacheMock = mock(ApacheDubboConfigCache.class);
when(apacheDubboConfigCacheMock.initRef(metaData)).thenReturn(new org.apache.dubbo.config.ReferenceConfig<>());
assertNotNull(apacheDubboConfigCacheMock.initRef(metaData));
}
use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.
the class AlibabaDubboPlugin method doDubboInvoker.
/**
* do dubbo invoker.
*
* @param exchange exchange the current server exchange {@linkplain ServerWebExchange}
* @param chain chain the current chain {@linkplain ServerWebExchange}
* @param selector selector {@linkplain SelectorData}
* @param rule rule {@linkplain RuleData}
* @param metaData the medata
* @param param the param
* @return {@code Mono<Void>} to indicate when request handling is complete
*/
@Override
protected Mono<Void> doDubboInvoker(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule, final MetaData metaData, final String param) {
RpcContext.getContext().setAttachment(Constants.DUBBO_SELECTOR_ID, selector.getId());
RpcContext.getContext().setAttachment(Constants.DUBBO_RULE_ID, rule.getId());
RpcContext.getContext().setAttachment(Constants.DUBBO_REMOTE_ADDRESS, Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getAddress().getHostAddress());
return Mono.create(monoSink -> {
ResponseFuture future = alibabaDubboProxyService.genericInvoker(param, metaData);
future.setCallback(new ResponseCallback() {
@Override
public void done(final Object resultObj) {
assert resultObj instanceof Result;
Result result = (Result) resultObj;
if (result.hasException()) {
this.caught(result.getException());
return;
}
monoSink.success(result.getValue());
}
@Override
public void caught(final Throwable ex) {
LOG.error("dubbo failed using async genericInvoker() metaData={} param={}", metaData, param, ex);
monoSink.error(ex);
}
});
}).flatMap(response -> {
exchange.getAttributes().put(Constants.RPC_RESULT, Objects.nonNull(response) ? response : Constants.DUBBO_RPC_RESULT_EMPTY);
exchange.getAttributes().put(Constants.CLIENT_RESPONSE_RESULT_TYPE, ResultEnum.SUCCESS.getName());
return chain.execute(exchange);
});
}
Aggregations