From notifications-return-3740-apmail-ignite-notifications-archive=ignite.apache.org@ignite.apache.org Mon Jun 10 08:27:45 2019 Return-Path: X-Original-To: apmail-ignite-notifications-archive@minotaur.apache.org Delivered-To: apmail-ignite-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id AFF5419128 for ; Mon, 10 Jun 2019 08:27:44 +0000 (UTC) Received: (qmail 58520 invoked by uid 500); 10 Jun 2019 08:27:44 -0000 Delivered-To: apmail-ignite-notifications-archive@ignite.apache.org Received: (qmail 58506 invoked by uid 500); 10 Jun 2019 08:27:44 -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 58497 invoked by uid 99); 10 Jun 2019 08:27:44 -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 08:27:44 +0000 From: GitBox To: notifications@ignite.apache.org Subject: [GitHub] [ignite] nizhikov commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit Message-ID: <156015525900.3197.16315623320609762405.gitbox@gitbox.apache.org> Date: Mon, 10 Jun 2019 08:27:39 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit nizhikov commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit URL: https://github.com/apache/ignite/pull/5619#discussion_r291921738 ########## File path: modules/core/src/main/java/org/apache/ignite/internal/managers/communication/transmit/channel/TransmitOutputChannel.java ########## @@ -0,0 +1,141 @@ +/* + * 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.IOException; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; +import java.nio.channels.WritableByteChannel; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.transmit.ReadPolicy; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Class represents an output transmission connection channel. + *

+ * Please, see {@link TransmitAbstractChannel} fot details. + */ +public class TransmitOutputChannel extends TransmitAbstractChannel { + /** */ + private final ObjectOutput dos; + + /** + * @param ktx Kernal context. + * @param channel Ignite channel to upload files to. + * @throws IOException If fails. + */ + public TransmitOutputChannel( + GridKernalContext ktx, + SocketChannel channel + ) throws IOException { + super(ktx, channel); + + dos = new ObjectOutputStream(channel.socket().getOutputStream()); + } + + /** + * @param plc The {@link ReadPolicy} to write to channel. + * @throws IOException If fails. + */ + public void writePolicy(ReadPolicy plc) throws IOException { + try { + dos.writeInt(plc.ordinal()); + + dos.flush(); + } catch (IOException e) { + throw transformExceptionIfNeed(e); + } + } + + /** + * @param hash The hash of transmitted data. + * @throws IOException If fails. + */ + public void acknowledge(long hash) throws IOException { + try { + dos.writeLong(hash); + + dos.flush(); + } catch (IOException e) { + throw transformExceptionIfNeed(e); + } + } + + /** + * @param meta The file meta to write from. + * @throws IOException If fails. + */ + public void writeMeta(TransmitMeta meta) throws IOException { + try { + meta.writeExternal(dos); + + dos.flush(); + + if (log.isDebugEnabled()) + log.debug("The file meta info have been written:" + meta + ']'); + } catch (IOException e) { + throw transformExceptionIfNeed(e); + } + } + + /** + * @param position The position to start from. + * @param count The number of bytes to write. + * @param fileIO The I\O file + * @return The number of writed bytes. + * @throws IOException If fails. + */ + public long writeFrom(long position, long count, FileIO fileIO) throws IOException { Review comment: This method never used. Do we need it? ---------------------------------------------------------------- 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