use of org.apache.ignite.internal.client.thin.TcpClientTransactions.TcpClientTransaction in project ignite by apache.
the class TcpClientCache method writeCacheInfo.
/**
* Write cache ID and flags.
*/
private void writeCacheInfo(PayloadOutputChannel payloadCh) {
BinaryOutputStream out = payloadCh.out();
out.writeInt(cacheId);
byte flags = keepBinary ? KEEP_BINARY_FLAG_MASK : 0;
TcpClientTransaction tx = transactions.tx();
if (expiryPlc != null) {
ProtocolContext protocolCtx = payloadCh.clientChannel().protocolCtx();
if (!protocolCtx.isFeatureSupported(EXPIRY_POLICY)) {
throw new ClientProtocolError(String.format("Expire policies are not supported by the server " + "version %s, required version %s", protocolCtx.version(), EXPIRY_POLICY.verIntroduced()));
}
flags |= WITH_EXPIRY_POLICY_FLAG_MASK;
}
if (tx != null) {
if (tx.clientChannel() != payloadCh.clientChannel()) {
throw new ClientException("Transaction context has been lost due to connection errors. " + "Cache operations are prohibited until current transaction closed.");
}
flags |= TRANSACTIONAL_FLAG_MASK;
}
out.writeByte(flags);
if ((flags & WITH_EXPIRY_POLICY_FLAG_MASK) != 0) {
out.writeLong(convertDuration(expiryPlc.getExpiryForCreation()));
out.writeLong(convertDuration(expiryPlc.getExpiryForUpdate()));
out.writeLong(convertDuration(expiryPlc.getExpiryForAccess()));
}
if ((flags & TRANSACTIONAL_FLAG_MASK) != 0)
out.writeInt(tx.txId());
}
Aggregations