Skip to content

Instantly share code, notes, and snippets.

@tanghaodong25
Created March 8, 2019 12:10
Show Gist options
  • Save tanghaodong25/8f63c607dd42d9a2189afc688b5c1507 to your computer and use it in GitHub Desktop.
Save tanghaodong25/8f63c607dd42d9a2189afc688b5c1507 to your computer and use it in GitHub Desktop.
HPNL
public class Client {
public static void main(String args[]) {
EqService eqService = new EqService(addr, "123456", 1, bufferNbr, false).init();
CqService cqService = new CqService(eqService, eqService.getNativeHandle()).init();
List<Connection> conList = new CopyOnWriteArrayList<Connection>();
ConnectedCallback connectedCallback = new ConnectedCallback(conList, false);
ReadCallback readCallback = new ReadCallback(false, eqService);
ShutdownCallback shutdownCallback = new ShutdownCallback();
eqService.setConnectedCallback(connectedCallback);
eqService.setRecvCallback(readCallback);
eqService.setShutdownCallback(shutdownCallback);
eqService.initBufferPool(bufferNbr, bufferSize, bufferNbr);
eqService.start();
cqService.start();
eqService.waitToConnected();
for (Connection con: conList) {
RdmaBuffer buffer = con.takeSendBuffer(true);
buffer.put(byteBufferTmp, (byte)0, 10);
con.send(buffer.remaining(), buffer.getRdmaBufferId());
}
cqService.join();
eqService.shutdown();
eqService.join();
}
}
public class Server {
public static void main(String args[]) {
EqService eqService = new EqService(addr, "123456", workNbr, bufferNbr, true).init();
CqService cqService = new CqService(eqService, eqService.getNativeHandle()).init();
List<Connection> conList = new ArrayList<Connection>();
ConnectedCallback connectedCallback = new ConnectedCallback(conList, true);
ReadCallback readCallback = new ReadCallback(true, eqService);
eqService.setConnectedCallback(connectedCallback);
eqService.setRecvCallback(readCallback);
eqService.initBufferPool(bufferNbr, bufferSize, bufferNbr);
eqService.start();
cqService.start();
cqService.join();
eqService.shutdown();
eqService.join();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment