From notifications-return-3771-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Mon Jun 10 16:44:49 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8D3CA180649 for ; Mon, 10 Jun 2019 18:44:49 +0200 (CEST) Received: (qmail 8976 invoked by uid 500); 10 Jun 2019 16:44:49 -0000 Mailing-List: contact notifications-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 notifications@ignite.apache.org Received: (qmail 8967 invoked by uid 99); 10 Jun 2019 16:44:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jun 2019 16:44:49 +0000 From: GitBox To: notifications@ignite.apache.org Subject: [GitHub] [ignite] Mmuzaf commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit Message-ID: <156018508716.28051.13314504469660120335.gitbox@gitbox.apache.org> Date: Mon, 10 Jun 2019 16:44:47 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Mmuzaf commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit URL: https://github.com/apache/ignite/pull/5619#discussion_r292091969 ########## File path: modules/core/src/main/java/org/apache/ignite/internal/managers/communication/transmit/channel/TransmitAbstractChannel.java ########## @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.managers.communication.transmit.channel; + +import java.io.Closeable; +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.nio.channels.AsynchronousCloseException; +import java.nio.channels.ClosedByInterruptException; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.FileChannel; +import java.nio.channels.SocketChannel; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + *

+ *

Channel exception handling

+ * + * If the peer has closed the connection in an orderly way, the read operation: + *
    + *
  • read() returns -1
  • + *
  • readLine() returns null
  • + *
  • readXXX() throws EOFException for any other XXX
  • + *
+ * A write will throw an IOException 'Connection reset by peer', eventually, subject to buffering delays. + *

+ *

+ *

Channel timeout handling

+ * + *
    + *
  • For read operations over the {@link InputStream} or write operation through the {@link OutputStream} + * the {@link Socket#setSoTimeout(int)} will be used and an {@link SocketTimeoutException} will be + * thrown when the timeout occured.
  • + *
  • To achive the file zero-copy {@link FileChannel#transferTo(long, long, java.nio.channels.WritableByteChannel)} + * the {@link SocketChannel} must be used directly in the blocking mode. For reading or writing over + * the SocketChannels, using the Socket#setSoTimeout(int) is not possible, because it isn't + * supported for sockets originating as channels. In this case, the decicated wather thread must be + * used which will close conneciton on timeout occured.
  • + *
+ *

+ */ +public abstract class TransmitAbstractChannel implements Closeable { + /** */ + private static final int DFLT_IO_TIMEOUT_MILLIS = 5_000; + + /** */ + private static final String RESET_BY_PEER_MSG = "Connection reset by peer"; + + /** */ + private static final String CLOSED_BY_REMOTE_MSG = "An existing connection was forcibly closed by the remote host"; + + /** */ + private final SocketChannel channel; + + /** */ + protected final IgniteLogger log; + + /** */ + private final int timeoutMillis; + + /** + * @param ktx Kernal context. + * @param channel Socket channel to upload files to. + */ + protected TransmitAbstractChannel( + GridKernalContext ktx, Review comment: Done. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services