Github user PepperJo commented on a diff in the pull request:

    https://github.com/apache/incubator-crail/pull/16#discussion_r180331153
  
    --- Diff: 
storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/NvmfStorageClient.java 
---
    @@ -31,41 +30,92 @@
     import org.apache.crail.utils.CrailUtils;
     import org.slf4j.Logger;
     
    -import com.ibm.disni.nvmef.NvmeEndpointGroup;
    -import com.ibm.disni.nvmef.spdk.NvmeTransportType;
    +import java.io.IOException;
    +import java.net.UnknownHostException;
    +import java.util.List;
    +import java.util.concurrent.CopyOnWriteArrayList;
    +import java.util.concurrent.TimeUnit;
     
     public class NvmfStorageClient implements StorageClient {
        private static final Logger LOG = CrailUtils.getLogger();
    -   private static NvmeEndpointGroup clientGroup;
    -   private boolean initialized = false;
    +   private static Nvme nvme;
    +   private boolean initialized;
    +   private volatile boolean closing;
    +   private final Thread keepAliveThread;
    +   private List<NvmfStorageEndpoint> endpoints;
    +   private CrailStatistics statistics;
    +   private CrailBufferCache bufferCache;
    +
    +   public NvmfStorageClient() {
    +           this.initialized = false;
    +           this.endpoints = new CopyOnWriteArrayList<>();
    +           this.closing = false;
    +           this.keepAliveThread = new Thread(() -> {
    +                   while (!closing) {
    +                           for (NvmfStorageEndpoint endpoint : endpoints) {
    +                                   try {
    +                                           endpoint.keepAlive();
    +                                   } catch (IOException e) {
    +                                           e.printStackTrace();
    +                                           return;
    +                                   }
    +                           }
    +                           /* We use the default keep alive timer of 120s 
in jNVMf */
    +                           try {
    +                                   
Thread.sleep(TimeUnit.MILLISECONDS.convert(110, TimeUnit.SECONDS));
    +                           } catch (InterruptedException e) {
    +                                   return;
    +                           }
    +                   }
    +           });
    +   }
    +
    +   boolean isValid() {
    --- End diff --
    
    Makes sense. Will change.


---

Reply via email to