ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] Mmuzaf commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit
Date Mon, 10 Jun 2019 16:42:57 GMT
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_r292091352
 
 

 ##########
 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.
+ * <p>
+ * 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:
   No, we don't need it. Removed.

----------------------------------------------------------------
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

Mime
View raw message