Github user PepperJo commented on a diff in the pull request:
https://github.com/apache/incubator-crail/pull/16#discussion_r180339324
--- 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() {
+ return keepAliveThread.isAlive();
+ }
public void init(CrailStatistics statistics, CrailBufferCache
bufferCache, CrailConfiguration crailConfiguration,
String[] args) throws IOException {
if (initialized) {
throw new IOException("NvmfStorageTier already
initialized");
}
initialized = true;
-
+ this.statistics = statistics;
+ this.bufferCache = bufferCache;
+ LOG.info("Initialize Nvmf storage client");
NvmfStorageConstants.parseCmdLine(crailConfiguration, args);
+ keepAliveThread.start();
}
public void printConf(Logger logger) {
NvmfStorageConstants.printConf(logger);
}
- public static NvmeEndpointGroup getEndpointGroup() {
- if (clientGroup == null) {
- clientGroup = new NvmeEndpointGroup(new
NvmeTransportType[]{NvmeTransportType.RDMA},
- NvmfStorageConstants.CLIENT_MEMPOOL);
+ public static Nvme getEndpointGroup() throws UnknownHostException {
--- End diff --
Should not be called from anywhere outside this class, so I will make it
private. It is protected in createEndpoint (synchronized)
---