Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/jni/JNIQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ internal class JNIQuery(private val ptr: Long) {
timestampEnabled,
if (timestampEnabled) sample.timestamp!!.ntpValue() else 0,
sample.attachment?.bytes,
sample.qos.express,
sample.qos.priority.value,
sample.qos.congestionControl.value
sample.qos.express
)
}

Expand All @@ -62,9 +60,7 @@ internal class JNIQuery(private val ptr: Long) {
timestampEnabled,
if (timestampEnabled) timestamp!!.ntpValue() else 0,
attachment?.into()?.bytes,
qos.express,
qos.priority.value,
qos.congestionControl.value
qos.express
)
}

Expand All @@ -84,8 +80,6 @@ internal class JNIQuery(private val ptr: Long) {
timestampNtp64: Long,
attachment: ByteArray?,
qosExpress: Boolean,
qosPriority: Int,
qosCongestionControl: Int,
)

@Throws(ZError::class)
Expand All @@ -105,8 +99,6 @@ internal class JNIQuery(private val ptr: Long) {
timestampNtp64: Long,
attachment: ByteArray?,
qosExpress: Boolean,
qosPriority: Int,
qosCongestionControl: Int,
)

/** Frees the underlying native Query. */
Expand Down
4 changes: 4 additions & 0 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/query/Reply.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ data class ReplyOptions(
var timeStamp: TimeStamp? = null,
var attachment: IntoZBytes? = null,
var express: Boolean = QoS.defaultResponse.express,
@Deprecated("Congestion control on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
var congestionControl: CongestionControl = QoS.defaultResponse.congestionControl,
@Deprecated("Priority on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
var priority: Priority = QoS.defaultResponse.priority
) {
fun setAttachment(attachment: String) = apply { this.attachment = ZBytes.from(attachment) }
Expand All @@ -112,7 +114,9 @@ data class ReplyDelOptions(
var timeStamp: TimeStamp? = null,
var attachment: IntoZBytes? = null,
var express: Boolean = QoS.defaultResponse.express,
@Deprecated("Congestion control on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
var congestionControl: CongestionControl = QoS.defaultResponse.congestionControl,
@Deprecated("Priority on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
var priority: Priority = QoS.defaultResponse.priority
) {
fun setAttachment(attachment: String) = apply { this.attachment = ZBytes.from(attachment) }
Expand Down
21 changes: 4 additions & 17 deletions zenoh-java/src/jvmTest/java/io/zenoh/QueryableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import io.zenoh.handlers.Handler;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.query.*;
import io.zenoh.qos.CongestionControl;
import io.zenoh.qos.Priority;
import io.zenoh.qos.QoS;
import io.zenoh.sample.Sample;
import io.zenoh.sample.SampleKind;
Expand Down Expand Up @@ -47,16 +45,6 @@ public void tearDown() throws ZError {
public void queryableRunsWithCallback() throws ZError, InterruptedException {
var timestamp = new TimeStamp(Date.from(Instant.now()));

var sample = new Sample(
testKeyExpr,
testPayload,
Encoding.defaultEncoding(),
SampleKind.PUT,
timestamp,
new QoS(CongestionControl.BLOCK, Priority.DATA, false),
null
);

var queryable = session.declareQueryable(testKeyExpr, query ->
{
try {
Expand All @@ -73,7 +61,10 @@ public void queryableRunsWithCallback() throws ZError, InterruptedException {
Thread.sleep(1000);
assertNotNull(reply[0]);
Sample receivedSample = ((Reply.Success) reply[0]).getSample();
assertEquals(sample, receivedSample);
assertEquals(testPayload, receivedSample.getPayload());
assertEquals(Encoding.defaultEncoding(), receivedSample.getEncoding());
assertEquals(SampleKind.PUT, receivedSample.getKind());
assertEquals(timestamp, receivedSample.getTimestamp());
queryable.close();
}

Expand Down Expand Up @@ -137,8 +128,6 @@ public void queryReplySuccessTest() throws ZError, InterruptedException {
Queryable queryable = session.declareQueryable(testKeyExpr, query -> {
var options = new ReplyOptions();
options.setTimeStamp(timestamp);
options.setPriority(Priority.DATA_HIGH);
options.setCongestionControl(CongestionControl.DROP);
options.setExpress(true);
try {
query.reply(testKeyExpr, message, options);
Expand All @@ -158,9 +147,7 @@ public void queryReplySuccessTest() throws ZError, InterruptedException {
var sample = ((Reply.Success) receivedReply[0]).getSample();
assertEquals(message, sample.getPayload());
assertEquals(timestamp, sample.getTimestamp());
assertEquals(Priority.DATA_HIGH, sample.getPriority());
assertTrue(sample.getQos().getExpress());
assertEquals(CongestionControl.DROP, sample.getCongestionControl());
}

@Test
Expand Down
17 changes: 0 additions & 17 deletions zenoh-jni/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use jni::{
use uhlc::ID;
use zenoh::{
key_expr::KeyExpr,
qos::{CongestionControl, Priority},
query::Query,
time::{Timestamp, NTP64},
Wait,
Expand Down Expand Up @@ -71,8 +70,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replySuccessViaJNI(
timestamp_ntp_64: jlong,
attachment: /*nullable*/ JByteArray,
qos_express: jboolean,
qos_priority: jint,
qos_congestion_control: jint,
) {
let _ = || -> ZResult<()> {
let query = Arc::from_raw(query_ptr);
Expand All @@ -89,12 +86,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replySuccessViaJNI(
reply_builder = reply_builder.attachment(decode_byte_array(&env, attachment)?);
}
reply_builder = reply_builder.express(qos_express != 0);
reply_builder = reply_builder.priority(Priority::try_from(qos_priority as u8).unwrap()); // The numeric value is always within range.
reply_builder = if qos_congestion_control != 0 {
reply_builder.congestion_control(CongestionControl::Block)
} else {
reply_builder.congestion_control(CongestionControl::Drop)
};
reply_builder.wait().map_err(|err| zerror!(err))
}()
.map_err(|err| throw_exception!(env, err));
Expand Down Expand Up @@ -173,8 +164,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replyDeleteViaJNI(
timestamp_ntp_64: jlong,
attachment: /*nullable*/ JByteArray,
qos_express: jboolean,
qos_priority: jint,
qos_congestion_control: jint,
) {
let _ = || -> ZResult<()> {
let query = Arc::from_raw(query_ptr);
Expand All @@ -188,12 +177,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replyDeleteViaJNI(
reply_builder = reply_builder.attachment(decode_byte_array(&env, attachment)?);
}
reply_builder = reply_builder.express(qos_express != 0);
reply_builder = reply_builder.priority(Priority::try_from(qos_priority as u8).unwrap()); // The numeric value is always within range.
reply_builder = if qos_congestion_control != 0 {
reply_builder.congestion_control(CongestionControl::Block)
} else {
reply_builder.congestion_control(CongestionControl::Drop)
};
reply_builder.wait().map_err(|err| zerror!(err))
}()
.map_err(|err| throw_exception!(env, err));
Expand Down