ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] alex-plekhanov commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi support channels initial commit
Date Wed, 07 Aug 2019 16:01:44 GMT
alex-plekhanov commented on a change in pull request #5619: IGNITE-10619: CommunicationSpi
support channels initial commit
URL: https://github.com/apache/ignite/pull/5619#discussion_r311609206
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ChunkReceiver.java
 ##########
 @@ -0,0 +1,114 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.ReadableByteChannel;
+import java.util.function.BooleanSupplier;
+import java.util.function.Consumer;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Buffered chunked receiver can handle input socket channel by chunks of data and
+ * deliver it to an allocated {@link ByteBuffer}.
+ */
+class ChunkReceiver extends TransmissionReceiver {
+    /** Chunked channel handler to process data with chunks. */
+    private final Consumer<ByteBuffer> hnd;
+
+    /** The destination object to transfer data to\from. */
+    private ByteBuffer buf;
+
+    /**
+     * @param meta Initial file meta info.
+     * @param chunkSize Size of chunks.
+     * @param stopChecker Node stop or prcoess interrupt checker.
+     * @param hnd Transmission handler to process download result.
+     * @param log Ignite looger.
+     */
+    public ChunkReceiver(
+        TransmissionMeta meta,
+        int chunkSize,
+        BooleanSupplier stopChecker,
+        Consumer<ByteBuffer> hnd,
+        IgniteLogger log
+    ) {
+        super(meta, stopChecker, log, chunkSize);
+
+        A.notNull(hnd, "ChunkHandler must be provided by transmission handler");
+
+        this.hnd = hnd;
+
+        buf = ByteBuffer.allocate(chunkSize);
+        buf.order(ByteOrder.nativeOrder());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void readChunk(ReadableByteChannel ch) throws IOException {
+        assert buf != null : "Buffer is used to deilver readed data to the used and cannot
be null: " + this;
+
+        buf.rewind();
+
+        int readed = 0;
+        int res;
+
+        // Read data from input channel utill the buffer will be completely filled
 
 Review comment:
   until

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