lokeshj1703 commented on a change in pull request #29: HDDS-2034. Async RATIS pipeline creation and destroy through heartbeat commands URL: https://github.com/apache/hadoop-ozone/pull/29#discussion_r336429832
########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java ########## @@ -379,6 +418,44 @@ public void deactivatePipeline(PipelineID pipelineID) stateManager.deactivatePipeline(pipelineID); } + /** + * Wait a pipeline to be OPEN. + * + * @param pipelineID ID of the pipeline to wait for. + * @param timeout wait timeout, millisecond + * @throws IOException in case of any Exception, such as timeout + */ + @Override + public void waitPipelineReady(PipelineID pipelineID, long timeout) + throws IOException { + Pipeline pipeline; + try { + pipeline = stateManager.getPipeline(pipelineID); + } catch (PipelineNotFoundException e) { + throw new IOException(String.format("Pipeline %s cannot be found", + pipelineID)); + } + + boolean ready; + long st = Time.monotonicNow(); + if (timeout == 0) { + timeout = pipelineWaitDefaultTimeout; + } + for(ready = pipeline.isOpen(); + !ready && Time.monotonicNow() - st < timeout; + ready = pipeline.isOpen()) { + try { + Thread.sleep((long)1000); Review comment: Since this function will be called by a client call like allocateBlock, maybe we should sleep for a smaller interval like 100ms? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org