smengcl commented on code in PR #4315:
URL: https://github.com/apache/ozone/pull/4315#discussion_r1123909177


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/MessageQueue.java:
##########
@@ -0,0 +1,188 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hadoop.hdds.utils;
+
+import org.apache.commons.io.input.buffer.CircularByteBuffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Message Queue to Pipe output from one output stream to another inputstream.
+ */
+public class MessageQueue {
+  private CircularByteBuffer byteBuffer;
+  private AtomicBoolean isRunning;
+
+  private MessageOutputStream messageOutputStream;
+  private MessageInputStream messageInputStream;
+
+  public MessageQueue(int bufferSize, long pollIntervalMillis) {
+    this.pollIntervalMillis = pollIntervalMillis;
+    init(bufferSize);
+  }
+
+  private void init(int bufferSize) {
+    this.byteBuffer = new CircularByteBuffer(bufferSize);
+    this.isRunning = new AtomicBoolean(false);
+    this.messageInputStream = new MessageInputStream(this);
+    this.messageOutputStream = new MessageOutputStream(this);
+  }
+
+  public void start() {
+    this.isRunning.set(true);
+  }
+
+  public void stop() {
+    this.isRunning.set(false);
+  }
+
+  public MessageOutputStream getMessageOutputStream() {
+    return messageOutputStream;
+  }
+
+  public MessageInputStream getMessageInputStream() {
+    return messageInputStream;
+  }
+
+  private long pollIntervalMillis;

Review Comment:
   Move this to the beginning of the class.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to