use of com.alibaba.dubbo.remoting.RemotingException in project dubbo by alibaba.
the class FileGroup method leave.
@Override
public void leave(URL url) throws RemotingException {
super.leave(url);
try {
String full = url.toFullString();
String[] lines = IOUtils.readLines(file);
List<String> saves = new ArrayList<String>();
for (String line : lines) {
if (full.equals(line)) {
return;
}
saves.add(line);
}
IOUtils.appendLines(file, saves.toArray(new String[0]));
} catch (IOException e) {
throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
}
}
use of com.alibaba.dubbo.remoting.RemotingException in project dubbo by alibaba.
the class ThriftProtocol method getServer.
private ExchangeServer getServer(URL url) {
// enable sending readonly event when server closes by default
url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str))
throw new RpcException("Unsupported server type: " + str + ", url: " + url);
ExchangeServer server;
try {
server = Exchangers.bind(url, handler);
} catch (RemotingException e) {
throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
}
str = url.getParameter(Constants.CLIENT_KEY);
if (str != null && str.length() > 0) {
Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
if (!supportedTypes.contains(str)) {
throw new RpcException("Unsupported client type: " + str);
}
}
return server;
}
use of com.alibaba.dubbo.remoting.RemotingException in project dubbo by alibaba.
the class ThriftProtocol method initClient.
private ExchangeClient initClient(URL url) {
ExchangeClient client;
url = url.addParameter(Constants.CODEC_KEY, ThriftCodec.NAME);
try {
client = Exchangers.connect(url);
} catch (RemotingException e) {
throw new RpcException("Fail to create remoting client for service(" + url + "): " + e.getMessage(), e);
}
return client;
}
use of com.alibaba.dubbo.remoting.RemotingException in project dubbo by alibaba.
the class ConnectChannelHandlerTest method test_Received_Event_invoke_direct.
/**
* Events do not pass through the thread pool and execute directly on the IO
*/
@SuppressWarnings("deprecation")
@Ignore("Heartbeat is processed in HeartbeatHandler not WrappedChannelHandler.")
@Test
public void test_Received_Event_invoke_direct() throws RemotingException {
handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
ThreadPoolExecutor executor = (ThreadPoolExecutor) getField(handler, "SHARED_EXECUTOR", 1);
executor.shutdown();
executor = (ThreadPoolExecutor) getField(handler, "executor", 1);
executor.shutdown();
Request req = new Request();
req.setHeartbeat(true);
final AtomicInteger count = new AtomicInteger(0);
handler.received(new MockedChannel() {
@Override
public void send(Object message) throws RemotingException {
Assert.assertEquals("response.heartbeat", true, ((Response) message).isHeartbeat());
count.incrementAndGet();
}
}, req);
Assert.assertEquals("channel.send must be invoke", 1, count.get());
}
use of com.alibaba.dubbo.remoting.RemotingException in project dubbo by alibaba.
the class HeaderExchangeHandlerTest method test_received_request_event_other_discard.
@Test
public void test_received_request_event_other_discard() throws RemotingException {
final Request request = new Request();
request.setTwoWay(true);
request.setEvent("my event");
final Channel mchannel = new MockedChannel() {
@Override
public void send(Object message) throws RemotingException {
Assert.fail();
}
};
HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler() {
@Override
public Object reply(ExchangeChannel channel, Object request) throws RemotingException {
Assert.fail();
throw new RemotingException(channel, "");
}
@Override
public void received(Channel channel, Object message) throws RemotingException {
Assert.fail();
throw new RemotingException(channel, "");
}
});
hexhandler.received(mchannel, request);
}
Aggregations