Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 459AA200C60 for ; Mon, 24 Apr 2017 17:03:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4459F160BBB; Mon, 24 Apr 2017 15:03:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 54251160BCE for ; Mon, 24 Apr 2017 17:03:27 +0200 (CEST) Received: (qmail 15537 invoked by uid 500); 24 Apr 2017 15:03:26 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 14325 invoked by uid 99); 24 Apr 2017 15:03:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Apr 2017 15:03:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92B0DF4A03; Mon, 24 Apr 2017 15:03:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Mon, 24 Apr 2017 15:03:58 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [35/50] [abbrv] ignite git commit: ignite-3054 - Review fix archived-at: Mon, 24 Apr 2017 15:03:29 -0000 ignite-3054 - Review fix Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/65814986 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/65814986 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/65814986 Branch: refs/heads/ignite-3054 Commit: 65814986f7c7cfc18cc8aaf15325d856394c3b98 Parents: 55988f0 Author: dkarachentsev Authored: Tue Dec 13 17:43:48 2016 +0300 Committer: dkarachentsev Committed: Tue Dec 13 17:43:48 2016 +0300 ---------------------------------------------------------------------- .../ignite/spi/discovery/tcp/ServerImpl.java | 58 +++++--------------- 1 file changed, 15 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/65814986/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index b698b6c..9551acc 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -196,12 +196,6 @@ class ServerImpl extends TcpDiscoveryImpl { /** ClientNioMessageWorker in GridNioSession. */ private static final int NIO_WORKER_META = GridNioSessionMetaKey.nextUniqueKey(); - /** - * Number of tries to reopen ServerSocketChannel on 'SocketException: Invalid argument'. - *

This error may happen on simultaneous server nodes startup on the same JVM.

- */ - private static final int REOPEN_SERVER_SOCKET_CHANNEL_TRIES = 3; - /** */ private IgniteThreadPoolExecutor utilityPool; @@ -5596,11 +5590,9 @@ class ServerImpl extends TcpDiscoveryImpl { int lastPort = spi.locPortRange == 0 ? spi.locPort : spi.locPort + spi.locPortRange - 1; - openServerSocketChannel(); - - int reopenTries = 0; - for (port = spi.locPort; port <= lastPort; port++) { + openServerSocketChannel(); + try { srvCh.bind(new InetSocketAddress(spi.locHost, port)); @@ -5614,30 +5606,9 @@ class ServerImpl extends TcpDiscoveryImpl { return; } catch (AlreadyBoundException | IOException e) { - // TODO: always create new channel on IOException. - - // On simultaneous nodes startup on the same JVM ServerSocketChannel.bind() - // may start throwing 'SocketException: Invalid argument' on each invocation, - // even if port is free. - if (e instanceof SocketException && reopenTries < REOPEN_SERVER_SOCKET_CHANNEL_TRIES - && e.getMessage() != null && e.getMessage().contains("Invalid argument")) { - if (log.isDebugEnabled()) - log.debug("Caught SocketException try to reopen channel. " + - "[port=" + port + ", localHost=" + spi.locHost + ']'); - - U.close(srvCh, log); - - openServerSocketChannel(); - - port = spi.locPort; - - reopenTries++; - } - else { - if (log.isDebugEnabled()) - log.debug("Failed to bind to local port (will try next port within range) " + - "[port=" + port + ", localHost=" + spi.locHost + ']'); - } + if (log.isDebugEnabled()) + log.debug("Failed to bind to local port (will try next port within range) " + + "[port=" + port + ", localHost=" + spi.locHost + ']'); onException("Failed to bind to local port. " + "[port=" + port + ", localHost=" + spi.locHost + ']', e); @@ -5645,6 +5616,8 @@ class ServerImpl extends TcpDiscoveryImpl { } // If free port wasn't found. + U.closeQuiet(srvCh); + throw new IgniteSpiException("Failed to bind TCP server socket (possibly all ports in range " + "are in use) [firstPort=" + spi.locPort + ", lastPort=" + lastPort + ", addr=" + spi.locHost + ']'); @@ -7557,34 +7530,33 @@ class ServerImpl extends TcpDiscoveryImpl { return delegate.getOOBInline(); } - // TODO: check if synchronized is really needed. /** {@inheritDoc} */ - @Override public synchronized void setSoTimeout(final int timeout) throws SocketException { + @Override public void setSoTimeout(final int timeout) throws SocketException { delegate.setSoTimeout(timeout); } /** {@inheritDoc} */ - @Override public synchronized int getSoTimeout() throws SocketException { + @Override public int getSoTimeout() throws SocketException { return delegate.getSoTimeout(); } /** {@inheritDoc} */ - @Override public synchronized void setSendBufferSize(final int size) throws SocketException { + @Override public void setSendBufferSize(final int size) throws SocketException { delegate.setSendBufferSize(size); } /** {@inheritDoc} */ - @Override public synchronized int getSendBufferSize() throws SocketException { + @Override public int getSendBufferSize() throws SocketException { return delegate.getSendBufferSize(); } /** {@inheritDoc} */ - @Override public synchronized void setReceiveBufferSize(final int size) throws SocketException { + @Override public void setReceiveBufferSize(final int size) throws SocketException { delegate.setReceiveBufferSize(size); } /** {@inheritDoc} */ - @Override public synchronized int getReceiveBufferSize() throws SocketException { + @Override public int getReceiveBufferSize() throws SocketException { return delegate.getReceiveBufferSize(); } @@ -7620,7 +7592,7 @@ class ServerImpl extends TcpDiscoveryImpl { // TODO: check if synchronized is really needed. /** {@inheritDoc} */ - @Override public synchronized void close() throws IOException { + @Override public void close() throws IOException { U.closeQuiet(sslIn); U.closeQuiet(sslOut); U.closeQuiet(ch); @@ -7924,7 +7896,7 @@ class ServerImpl extends TcpDiscoveryImpl { /** {@inheritDoc} */ @Override public synchronized void write(final byte[] b, final int off, final int len) throws IOException { - buf = expandBuffer(buf, len); // TODO: take 'off' into account when expand. + buf = expandBuffer(buf, len); buf.put(b, off, len);