use of io.questdb.std.str.CharSequenceZ in project questdb by bluestreak01.
the class Os method generateKerberosToken.
public static byte[] generateKerberosToken(CharSequence spn) throws KerberosException {
try (CharSequenceZ cs = new CharSequenceZ(spn)) {
final long struct = generateKrbToken(cs.address());
int status = Unsafe.getUnsafe().getInt(struct);
int bufLen = Unsafe.getUnsafe().getInt(struct + 4);
long ptoken = Unsafe.getUnsafe().getLong(struct + 8);
if (status != 0) {
freeKrbToken(struct);
throw new KerberosException(status);
}
byte[] token = new byte[bufLen];
for (int i = 0; i < bufLen; i++) {
token[i] = Unsafe.getUnsafe().getByte(ptoken + i);
}
freeKrbToken(struct);
return token;
}
}
use of io.questdb.std.str.CharSequenceZ in project questdb by bluestreak01.
the class NetTest method testSeek.
@Test
public void testSeek() {
int port = 9993;
NativeLPSZ lpsz = new NativeLPSZ();
String msg = "Test ABC";
CharSequenceZ charSink = new CharSequenceZ(msg);
int msgLen = charSink.length() + 1;
long acceptFd = Net.socketTcp(true);
Assert.assertTrue(acceptFd > 0);
Assert.assertTrue(Net.bindTcp(acceptFd, 0, port));
Net.listen(acceptFd, 1024);
long clientFd = Net.socketTcp(true);
long sockAddr = Net.sockaddr("127.0.0.1", port);
TestUtils.assertConnect(clientFd, sockAddr);
Assert.assertEquals(msgLen, Net.send(clientFd, charSink.address(), msgLen));
Net.close(clientFd);
Net.freeSockAddr(sockAddr);
long serverFd = Net.accept(acceptFd);
long serverBuf = Unsafe.malloc(msgLen, MemoryTag.NATIVE_DEFAULT);
Assert.assertEquals(msgLen, Net.peek(serverFd, serverBuf, msgLen));
lpsz.of(serverBuf);
Assert.assertEquals(msg, lpsz.toString());
Assert.assertEquals(msgLen, Net.recv(serverFd, serverBuf, msgLen));
lpsz.of(serverBuf);
Assert.assertEquals(msg, lpsz.toString());
Unsafe.free(serverBuf, msgLen, MemoryTag.NATIVE_DEFAULT);
Net.close(serverFd);
Net.close(acceptFd);
charSink.close();
}
Aggregations