Skip to content

Commit 0c2052e

Browse files
authored
Merge pull request #430 from milyin-zenoh-zbobr/zbobr_fix-34-fix-issue-428
deprecate reply priority values
2 parents 14d90fd + 44ff769 commit 0c2052e

4 files changed

Lines changed: 10 additions & 44 deletions

File tree

zenoh-java/src/commonMain/kotlin/io/zenoh/jni/JNIQuery.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ internal class JNIQuery(private val ptr: Long) {
4343
timestampEnabled,
4444
if (timestampEnabled) sample.timestamp!!.ntpValue() else 0,
4545
sample.attachment?.bytes,
46-
sample.qos.express,
47-
sample.qos.priority.value,
48-
sample.qos.congestionControl.value
46+
sample.qos.express
4947
)
5048
}
5149

@@ -62,9 +60,7 @@ internal class JNIQuery(private val ptr: Long) {
6260
timestampEnabled,
6361
if (timestampEnabled) timestamp!!.ntpValue() else 0,
6462
attachment?.into()?.bytes,
65-
qos.express,
66-
qos.priority.value,
67-
qos.congestionControl.value
63+
qos.express
6864
)
6965
}
7066

@@ -84,8 +80,6 @@ internal class JNIQuery(private val ptr: Long) {
8480
timestampNtp64: Long,
8581
attachment: ByteArray?,
8682
qosExpress: Boolean,
87-
qosPriority: Int,
88-
qosCongestionControl: Int,
8983
)
9084

9185
@Throws(ZError::class)
@@ -105,8 +99,6 @@ internal class JNIQuery(private val ptr: Long) {
10599
timestampNtp64: Long,
106100
attachment: ByteArray?,
107101
qosExpress: Boolean,
108-
qosPriority: Int,
109-
qosCongestionControl: Int,
110102
)
111103

112104
/** Frees the underlying native Query. */

zenoh-java/src/commonMain/kotlin/io/zenoh/query/Reply.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ data class ReplyOptions(
9393
var timeStamp: TimeStamp? = null,
9494
var attachment: IntoZBytes? = null,
9595
var express: Boolean = QoS.defaultResponse.express,
96+
@Deprecated("Congestion control on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
9697
var congestionControl: CongestionControl = QoS.defaultResponse.congestionControl,
98+
@Deprecated("Priority on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
9799
var priority: Priority = QoS.defaultResponse.priority
98100
) {
99101
fun setAttachment(attachment: String) = apply { this.attachment = ZBytes.from(attachment) }
@@ -112,7 +114,9 @@ data class ReplyDelOptions(
112114
var timeStamp: TimeStamp? = null,
113115
var attachment: IntoZBytes? = null,
114116
var express: Boolean = QoS.defaultResponse.express,
117+
@Deprecated("Congestion control on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
115118
var congestionControl: CongestionControl = QoS.defaultResponse.congestionControl,
119+
@Deprecated("Priority on reply QoS is deprecated and will be ignored. See eclipse-zenoh/zenoh#2382.")
116120
var priority: Priority = QoS.defaultResponse.priority
117121
) {
118122
fun setAttachment(attachment: String) = apply { this.attachment = ZBytes.from(attachment) }

zenoh-java/src/jvmTest/java/io/zenoh/QueryableTest.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import io.zenoh.handlers.Handler;
77
import io.zenoh.keyexpr.KeyExpr;
88
import io.zenoh.query.*;
9-
import io.zenoh.qos.CongestionControl;
10-
import io.zenoh.qos.Priority;
119
import io.zenoh.qos.QoS;
1210
import io.zenoh.sample.Sample;
1311
import io.zenoh.sample.SampleKind;
@@ -47,16 +45,6 @@ public void tearDown() throws ZError {
4745
public void queryableRunsWithCallback() throws ZError, InterruptedException {
4846
var timestamp = new TimeStamp(Date.from(Instant.now()));
4947

50-
var sample = new Sample(
51-
testKeyExpr,
52-
testPayload,
53-
Encoding.defaultEncoding(),
54-
SampleKind.PUT,
55-
timestamp,
56-
new QoS(CongestionControl.BLOCK, Priority.DATA, false),
57-
null
58-
);
59-
6048
var queryable = session.declareQueryable(testKeyExpr, query ->
6149
{
6250
try {
@@ -73,7 +61,10 @@ public void queryableRunsWithCallback() throws ZError, InterruptedException {
7361
Thread.sleep(1000);
7462
assertNotNull(reply[0]);
7563
Sample receivedSample = ((Reply.Success) reply[0]).getSample();
76-
assertEquals(sample, receivedSample);
64+
assertEquals(testPayload, receivedSample.getPayload());
65+
assertEquals(Encoding.defaultEncoding(), receivedSample.getEncoding());
66+
assertEquals(SampleKind.PUT, receivedSample.getKind());
67+
assertEquals(timestamp, receivedSample.getTimestamp());
7768
queryable.close();
7869
}
7970

@@ -137,8 +128,6 @@ public void queryReplySuccessTest() throws ZError, InterruptedException {
137128
Queryable queryable = session.declareQueryable(testKeyExpr, query -> {
138129
var options = new ReplyOptions();
139130
options.setTimeStamp(timestamp);
140-
options.setPriority(Priority.DATA_HIGH);
141-
options.setCongestionControl(CongestionControl.DROP);
142131
options.setExpress(true);
143132
try {
144133
query.reply(testKeyExpr, message, options);
@@ -158,9 +147,7 @@ public void queryReplySuccessTest() throws ZError, InterruptedException {
158147
var sample = ((Reply.Success) receivedReply[0]).getSample();
159148
assertEquals(message, sample.getPayload());
160149
assertEquals(timestamp, sample.getTimestamp());
161-
assertEquals(Priority.DATA_HIGH, sample.getPriority());
162150
assertTrue(sample.getQos().getExpress());
163-
assertEquals(CongestionControl.DROP, sample.getCongestionControl());
164151
}
165152

166153
@Test

zenoh-jni/src/query.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use jni::{
2525
use uhlc::ID;
2626
use zenoh::{
2727
key_expr::KeyExpr,
28-
qos::{CongestionControl, Priority},
2928
query::Query,
3029
time::{Timestamp, NTP64},
3130
Wait,
@@ -71,8 +70,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replySuccessViaJNI(
7170
timestamp_ntp_64: jlong,
7271
attachment: /*nullable*/ JByteArray,
7372
qos_express: jboolean,
74-
qos_priority: jint,
75-
qos_congestion_control: jint,
7673
) {
7774
let _ = || -> ZResult<()> {
7875
let query = Arc::from_raw(query_ptr);
@@ -89,12 +86,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replySuccessViaJNI(
8986
reply_builder = reply_builder.attachment(decode_byte_array(&env, attachment)?);
9087
}
9188
reply_builder = reply_builder.express(qos_express != 0);
92-
reply_builder = reply_builder.priority(Priority::try_from(qos_priority as u8).unwrap()); // The numeric value is always within range.
93-
reply_builder = if qos_congestion_control != 0 {
94-
reply_builder.congestion_control(CongestionControl::Block)
95-
} else {
96-
reply_builder.congestion_control(CongestionControl::Drop)
97-
};
9889
reply_builder.wait().map_err(|err| zerror!(err))
9990
}()
10091
.map_err(|err| throw_exception!(env, err));
@@ -173,8 +164,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replyDeleteViaJNI(
173164
timestamp_ntp_64: jlong,
174165
attachment: /*nullable*/ JByteArray,
175166
qos_express: jboolean,
176-
qos_priority: jint,
177-
qos_congestion_control: jint,
178167
) {
179168
let _ = || -> ZResult<()> {
180169
let query = Arc::from_raw(query_ptr);
@@ -188,12 +177,6 @@ pub(crate) unsafe extern "C" fn Java_io_zenoh_jni_JNIQuery_replyDeleteViaJNI(
188177
reply_builder = reply_builder.attachment(decode_byte_array(&env, attachment)?);
189178
}
190179
reply_builder = reply_builder.express(qos_express != 0);
191-
reply_builder = reply_builder.priority(Priority::try_from(qos_priority as u8).unwrap()); // The numeric value is always within range.
192-
reply_builder = if qos_congestion_control != 0 {
193-
reply_builder.congestion_control(CongestionControl::Block)
194-
} else {
195-
reply_builder.congestion_control(CongestionControl::Drop)
196-
};
197180
reply_builder.wait().map_err(|err| zerror!(err))
198181
}()
199182
.map_err(|err| throw_exception!(env, err));

0 commit comments

Comments
 (0)