public synchronized void close() throws IOException, InterruptedException { logger.info("shutting down group"); if (closed.get()){ return; } LinkedList<RdmaEndpoint> clientEps = new LinkedList<RdmaEndpoint>(); for (RdmaEndpoint ep : clientEndpointMap.values()) { clientEps.add(ep); } for (RdmaEndpoint ep : clientEps){ ep.close(); } LinkedList<RdmaServerEndpoint<C>> serverEps = new LinkedList<RdmaServerEndpoint<C>>(); for (RdmaServerEndpoint<C> ep : serverEndpointMap.values()) { serverEps.add(ep); } for (RdmaServerEndpoint<C> ep: serverEps){ ep.close(); } cmProcessor.close(); closed.set(true); logger.info("shutting down group done"); }
private void run() throws Exception { System.out.println("ReadServer, size " + size + ", loop " + loop); RdmaServerEndpoint<ReadServerEndpoint> serverEndpoint = group.createServerEndpoint(); InetAddress ipAddress = InetAddress.getByName(host); InetSocketAddress address = new InetSocketAddress(ipAddress, port); serverEndpoint.bind(address, 10); ReadServer.ReadServerEndpoint endpoint = serverEndpoint.accept(); System.out.println("ReadServer, client connected, address " + address.toString()); //let's send a message to the client //in the message we include the RDMA information of a local buffer which we allow the client to read using a one-sided RDMA operation System.out.println("ReadServer, sending message"); endpoint.sendMessage(); //we have to wait for the CQ event, only then we know the message has been sent out endpoint.takeEvent(); //let's wait for the final message to be received. We don't need to check the message itself, just the CQ event is enough. endpoint.takeEvent(); System.out.println("ReadServer, final message"); //close everything endpoint.close(); serverEndpoint.close(); group.close(); }
serverEndpoint.close(); group.close();
serverEndpoint.close(); System.out.println("server endpoint closed"); endpointGroup.close();
serverEndpoint.close(); endpointGroup.close();
public void runRDMA() throws Exception { //we can accept new connections SendRecvServer.CustomServerEndpoint clientEndpoint = serverEndpoint.accept(); //we have previously passed our own endpoint factory to the group, therefore new endpoints will be of type CustomServerEndpoint System.out.println("RDMAvsTcpBenchmarkServer::client connection accepted"); //in our custom endpoints we have prepared (memory registration and work request creation) some memory buffers beforehand. ByteBuffer sendBuf = clientEndpoint.getSendBuf(); sendBuf.asCharBuffer().put("PONG"); ByteBuffer recvBuf = clientEndpoint.getRecvBuf(); SVCPostSend postSend = clientEndpoint.postSend(clientEndpoint.getWrList_send()); SVCPostRecv postRecv = clientEndpoint.postRecv(clientEndpoint.getWrList_recv()); for (int i = 0; i < loopCount + 1; i++){ // Recv PING postRecv.execute(); clientEndpoint.getWcEvents().take(); recvBuf.clear(); //Send PONG postSend.execute(); clientEndpoint.getWcEvents().take(); sendBuf.clear(); } clientEndpoint.close(); serverEndpoint.close(); endpointGroup.close(); }