System.err.println("Failed to create datagram because its size " +
"would exceed the maximum");
System.exit(1);
}
UnixDomainSocketClient unixSocket = null;
/* Here we use a third party library that uses JNI to write to Bruce's
UNIX domain datagram socket. See the following links:
https://github.com/caprica/juds
http://mvnrepository.com/artifact/uk.co.caprica/juds/0.94.1
Alternatively, you can write your own JNI code that uses Bruce's
client C library. */
try {
// create socket for sending to Bruce
unixSocket = new UnixDomainSocketClient(brucePath,
JUDS.SOCK_DGRAM);
// send AnyPartition message to Bruce
unixSocket.getOutputStream().write(datagram1);
// send PartitionKey message to Bruce
unixSocket.getOutputStream().write(datagram2);
} catch (IOException x) {
System.err.println("IOException on attempt to send to Bruce: " +
x.getMessage());
System.exit(1);
} finally {
if (unixSocket != null) {
unixSocket.close();
}
}
}