use of com.alibaba.otter.shared.communication.core.exception.CommunicationException in project otter by alibaba.
the class ArbitrateCommmunicationClient method callManager.
/**
* 指定manager,进行event调用
*/
public Object callManager(final Event event) {
CommunicationException ex = null;
for (int i = index; i < index + managerAddress.size(); i++) {
String address = managerAddress.get(i % managerAddress.size());
try {
Object result = delegate.call(address, event);
index = i;
return result;
} catch (CommunicationException e) {
ex = e;
logger.warn("call manager [{}] event [{}] failed, maybe can try another manager.", address, event);
}
}
throw ex;
}
use of com.alibaba.otter.shared.communication.core.exception.CommunicationException in project otter by alibaba.
the class RmiCommunicationEndpoint method initial.
public void initial() {
export = new RmiServiceExporter();
export.setServiceName("endpoint");
// 暴露自己
export.setService(this);
export.setServiceInterface(CommunicationEndpoint.class);
export.setRegistryHost(host);
export.setRegistryPort(port);
// 强制创建一个
export.setAlwaysCreateRegistry(alwaysCreateRegistry);
try {
export.afterPropertiesSet();
} catch (RemoteException e) {
throw new CommunicationException("Rmi_Create_Error", e);
}
}
use of com.alibaba.otter.shared.communication.core.exception.CommunicationException in project otter by alibaba.
the class DefaultCommunicationClientImpl method buildParams.
// ===================== helper method ==================
private CommunicationParam buildParams(String addr) {
CommunicationParam params = new CommunicationParam();
String[] strs = StringUtils.split(addr, ":");
if (strs == null || strs.length != 2) {
throw new IllegalArgumentException("addr example: 127.0.0.1:1099");
}
InetAddress address = null;
try {
address = InetAddress.getByName(strs[0]);
} catch (UnknownHostException e) {
throw new CommunicationException("addr_error", "addr[" + addr + "] is unknow!");
}
params.setIp(address.getHostAddress());
params.setPort(Integer.valueOf(strs[1]));
return params;
}
use of com.alibaba.otter.shared.communication.core.exception.CommunicationException in project otter by alibaba.
the class NodeCommmunicationClient method callManager.
/**
* 指定manager,进行event调用
*/
public Object callManager(final Event event) {
CommunicationException ex = null;
Object object = null;
for (int i = index; i < index + managerAddress.size(); i++) {
// 循环一次manager的所有地址
String address = managerAddress.get(i % managerAddress.size());
try {
object = delegate.call(address, event);
// 更新一下上一次成功的地址
index = i;
return object;
} catch (CommunicationException e) {
// retry next address;
ex = e;
}
}
// 走到这一步,说明肯定有出错了
throw ex;
}
use of com.alibaba.otter.shared.communication.core.exception.CommunicationException in project otter by alibaba.
the class CanalCommmunicationClient method callManager.
/**
* 指定manager,进行event调用
*/
public Object callManager(final Event event) {
CommunicationException ex = null;
Object object = null;
for (int i = index; i < index + managerAddress.size(); i++) {
// 循环一次manager的所有地址
String address = managerAddress.get(i % managerAddress.size());
try {
object = delegate.call(address, event);
// 更新一下上一次成功的地址
index = i;
return object;
} catch (CommunicationException e) {
// retry next address;
ex = e;
}
}
// 走到这一步,说明肯定有出错了
throw ex;
}
Aggregations