use of io.moyada.sharingan.infrastructure.exception.InstanceNotFountException in project dubbo-faker by moyada.
the class SofaInvoke method doInitialize.
@Override
protected void doInitialize(ClassInvocation metaDate) throws InstanceNotFountException {
ConsumerConfig consumerConfig = new ConsumerConfig<>().setApplication(this.applicationConfig).setInterfaceId(// 指定接口
metaDate.getClassType().getName()).setGeneric(ClassUtil.isGeneric(metaDate.getClassType())).setProtocol(// 指定协议
sofaConfig.getProtocol()).setConcurrents(200).setRetries(0).setDirectUrl(// 指定直连地址
sofaConfig.getDirectUrl()).setRegistry(this.registryConfigs).setRegister(false).setSubscribe(false).setConnectTimeout(sofaConfig.getTimeout()).setTimeout(sofaConfig.getTimeout());
Object ref;
try {
ref = consumerConfig.refer();
} catch (Exception e) {
throw new InstanceNotFountException(e);
}
setInstance(ref);
setMethodHandle(metaDate.getMethodHandle());
this.consumerConfig = consumerConfig;
}
use of io.moyada.sharingan.infrastructure.exception.InstanceNotFountException in project dubbo-faker by moyada.
the class SpringCloudInvoke method beforeInvoke.
/**
* 预处理请求
*/
@Override
protected void beforeInvoke(HttpInvocation metaDate) {
int size = hasBody ? paramSize + 1 : paramSize;
Object[] args = new Object[size];
for (int index = 0; index < size; index++) {
args[index] = "";
}
Invocation invocation = new Invocation(args);
Result result = execute(invocation);
if (!result.isSuccess()) {
String exception = result.getException();
if (exception.contains("does not have available server")) {
throw new InstanceNotFountException(exception);
}
}
}
use of io.moyada.sharingan.infrastructure.exception.InstanceNotFountException in project dubbo-faker by moyada.
the class DubboInvoke method doInitialize.
@Override
protected void doInitialize(ClassInvocation metaDate) throws InstanceNotFountException {
// 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
ReferenceConfig<?> reference = new ReferenceConfig<>();
reference.setApplication(config);
reference.setConsumer(consumer);
reference.setRegistries(registries);
reference.setRetries(0);
reference.setInterface(metaDate.getClassType());
Object ref;
try {
ref = reference.get();
} catch (Exception e) {
throw new InstanceNotFountException(e);
}
setInstance(ref);
setMethodHandle(metaDate.getMethodHandle());
this.reference = reference;
}
Aggregations