@Override public boolean isOpen() { return !socket.isClosed(); }
@Override public boolean isOpen() { return !socket.isClosed(); }
@Override public boolean isOpen() { return !socket.isClosed(); }
@Override boolean isSocketClosed() { return socket.isClosed(); } }
public boolean isRunning() {return thread != null && thread.isAlive() && diag_sock != null && !diag_sock.isClosed();}
@Override public void run() { byte[] buf = new byte[2048]; DatagramPacket recv = new DatagramPacket(buf, buf.length); while (!multicastSocket.isClosed()) { try { multicastSocket.receive(recv); String msg = new String(recv.getData()).trim(); int i = msg.indexOf('\n'); if (i > 0) { msg = msg.substring(0, i).trim(); } MulticastRegistry.this.receive(msg, (InetSocketAddress) recv.getSocketAddress()); Arrays.fill(buf, (byte) 0); } catch (Throwable e) { if (!multicastSocket.isClosed()) { logger.error(e.getMessage(), e); } } } } }, "DubboMulticastRegistryReceiver");
@Override public void run() { byte[] buf = new byte[2048]; DatagramPacket recv = new DatagramPacket(buf, buf.length); while (!multicastSocket.isClosed()) { try { multicastSocket.receive(recv); String msg = new String(recv.getData()).trim(); int i = msg.indexOf('\n'); if (i > 0) { msg = msg.substring(0, i).trim(); } MulticastRegistry.this.receive(msg, (InetSocketAddress) recv.getSocketAddress()); Arrays.fill(buf, (byte) 0); } catch (Throwable e) { if (!multicastSocket.isClosed()) { logger.error(e.getMessage(), e); } } } } }, "DubboMulticastRegistryReceiver");
synchronized public void stop() { if (socket != null && !socket.isClosed()) { socket.close(); } }
public void run() { while(!mcast_sock.isClosed()) { DatagramPacket packet=new DatagramPacket(buf, 0, buf.length); try { mcast_sock.receive(packet); handleData(); } catch(IOException e) { e.printStackTrace(); } } } }
synchronized public void stop() { if (socket != null && !socket.isClosed()) { try { log.fine("Leaving multicast group"); socket.leaveGroup(multicastAddress, multicastInterface); // Well this doesn't work and I have no idea why I get "java.net.SocketException: Can't assign requested address" } catch (Exception ex) { log.fine("Could not leave multicast group: " + ex); } // So... just close it and ignore the log messages socket.close(); } }
public void stop() throws IOException { if (isRunning() == false) { return; } // shutdown executor service try { if (getShutdownListenerSeconds() <= 0) { executorService.shutdownNow(); } else { executorService.shutdown(); } executorService.awaitTermination(getShutdownListenerSeconds(), TimeUnit.SECONDS); } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); } finally { if (executorService.isTerminated()) { logger.info("Multicast Listener has been terminated successfully."); } else { logger.warn("Multicast Listener has not terminated properly. There exists an uninterruptable thread that will take an indeterminate amount of time to stop."); } } // shutdown server socket if (multicastSocket.isClosed() == false) { multicastSocket.leaveGroup(multicastAddress.getAddress()); multicastSocket.close(); } }
if (!socket.isClosed()) { log.fine("Closing unicast socket"); socket.close();
if (!socket.isClosed()) { log.fine("Closing multicast socket"); socket.close();
@Override protected void _send(Message msg, Address dest) { try { send(msg, dest); } catch (InterruptedIOException iex) { } catch (InterruptedException interruptedEx) { Thread.currentThread().interrupt(); // let someone else handle the interrupt } catch (SocketException e) { if (!this.sock.isClosed() && !stack.getChannel().isClosed()) { log.error("Exception caught while sending message", e); } } catch (IOException e) { if (messenger != null /* && e.getMessage().contains("Operation not permitted") */) { // this is the english Oracle // JDK exception condition we // really want to catch messenger.handleJGroupsIOException(e, dest); } } catch (Throwable e) { log.error("Exception caught while sending message", e); } }
protected IpAddress createLocalAddress() { if(sock == null || sock.isClosed()) return null; if(external_addr != null) { if(external_port > 0) return new IpAddress(external_addr, external_port); return new IpAddress(external_addr, sock.getLocalPort()); } return new IpAddress(sock.getLocalAddress(), sock.getLocalPort()); }
@Override protected void doSend(AsciiString cluster_name, byte[] buf, int offset, int length, Address dest) throws Exception { try { super.doSend(cluster_name, buf, offset, length, dest); } catch (SocketException sock_ex) { if (!this.sock.isClosed() && !stack.getChannel().isClosed()) { log.error("Exception caught while sending message", sock_ex); } } catch (IOException e) { if (messenger != null /* && e.getMessage().contains("Operation not permitted") */) { // this is the english Oracle // JDK exception condition we // really want to catch messenger.handleJGroupsIOException(e, dest); } } catch (Throwable e) { log.error("Exception caught while sending message", e); } }
synchronized public void stop() { if (socket != null && !socket.isClosed()) { socket.close(); } }
synchronized public void stop() { if (socket != null && !socket.isClosed()) { try { log.fine("Leaving multicast group"); socket.leaveGroup(multicastAddress, multicastInterface); // Well this doesn't work and I have no idea why I get "java.net.SocketException: Can't assign requested address" } catch (Exception ex) { log.fine("Could not leave multicast group: " + ex); } // So... just close it and ignore the log messages socket.close(); } }
private void send(DiscoveryOutgoingMessage pAnswer) { byte[] message = pAnswer.getData(); final DatagramPacket packet = new DatagramPacket(message, message.length, pAnswer.getTargetAddress(),pAnswer.getTargetPort()); if (!socket.isClosed()) { try { socket.send(packet); } catch (IOException exp) { logHandler.info(address + "<-- Can not send discovery response to " + packet.getAddress()); } } }
private void refreshSocket() { if (socket.isClosed()) { logHandler.info(address + "<-- Socket closed, reopening it"); try { socket = MulticastUtil.newMulticastSocket(address, logHandler); } catch (IOException exp) { logHandler.error("Cannot reopen socket. Exiting multicast listener thread ...",exp); throw new SocketVerificationFailedException(exp); } } }