Browse Source
Initial PR for [KIP-714](https://cwiki.apache.org/confluence/display/KAFKA/KIP-714%3A+Client+metrics+and+observability) - [KAFKA-15601](https://issues.apache.org/jira/browse/KAFKA-15601). This PR defines json request and response schemas for the new Telemetry APIs and implements the corresponding java classes. Reviewers: Andrew Schofield <andrew_schofield@uk.ibm.com>, Kirk True <ktrue@confluent.io>, Matthias J. Sax <matthias@confluent.io>, Walker Carlson <wcarlson@apache.org>pull/13909/merge
Apoorv Mittal
1 year ago
committed by
GitHub
22 changed files with 778 additions and 2 deletions
@ -0,0 +1,79 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.GetTelemetrySubscriptionsRequestData; |
||||||
|
import org.apache.kafka.common.message.GetTelemetrySubscriptionsResponseData; |
||||||
|
|
||||||
|
import org.apache.kafka.common.protocol.ApiKeys; |
||||||
|
import org.apache.kafka.common.protocol.ByteBufferAccessor; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
|
||||||
|
import java.nio.ByteBuffer; |
||||||
|
|
||||||
|
public class GetTelemetrySubscriptionsRequest extends AbstractRequest { |
||||||
|
|
||||||
|
public static class Builder extends AbstractRequest.Builder<GetTelemetrySubscriptionsRequest> { |
||||||
|
|
||||||
|
private final GetTelemetrySubscriptionsRequestData data; |
||||||
|
|
||||||
|
public Builder(GetTelemetrySubscriptionsRequestData data) { |
||||||
|
this(data, false); |
||||||
|
} |
||||||
|
|
||||||
|
public Builder(GetTelemetrySubscriptionsRequestData data, boolean enableUnstableLastVersion) { |
||||||
|
super(ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS, enableUnstableLastVersion); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GetTelemetrySubscriptionsRequest build(short version) { |
||||||
|
return new GetTelemetrySubscriptionsRequest(data, version); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return data.toString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private final GetTelemetrySubscriptionsRequestData data; |
||||||
|
|
||||||
|
public GetTelemetrySubscriptionsRequest(GetTelemetrySubscriptionsRequestData data, short version) { |
||||||
|
super(ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS, version); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GetTelemetrySubscriptionsResponse getErrorResponse(int throttleTimeMs, Throwable e) { |
||||||
|
GetTelemetrySubscriptionsResponseData responseData = new GetTelemetrySubscriptionsResponseData() |
||||||
|
.setErrorCode(Errors.forException(e).code()) |
||||||
|
.setThrottleTimeMs(throttleTimeMs); |
||||||
|
return new GetTelemetrySubscriptionsResponse(responseData); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GetTelemetrySubscriptionsRequestData data() { |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
public static GetTelemetrySubscriptionsRequest parse(ByteBuffer buffer, short version) { |
||||||
|
return new GetTelemetrySubscriptionsRequest(new GetTelemetrySubscriptionsRequestData( |
||||||
|
new ByteBufferAccessor(buffer), version), version); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.GetTelemetrySubscriptionsResponseData; |
||||||
|
import org.apache.kafka.common.protocol.ApiKeys; |
||||||
|
import org.apache.kafka.common.protocol.ByteBufferAccessor; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
|
||||||
|
import java.nio.ByteBuffer; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class GetTelemetrySubscriptionsResponse extends AbstractResponse { |
||||||
|
|
||||||
|
private final GetTelemetrySubscriptionsResponseData data; |
||||||
|
|
||||||
|
public GetTelemetrySubscriptionsResponse(GetTelemetrySubscriptionsResponseData data) { |
||||||
|
super(ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GetTelemetrySubscriptionsResponseData data() { |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<Errors, Integer> errorCounts() { |
||||||
|
HashMap<Errors, Integer> counts = new HashMap<>(); |
||||||
|
updateErrorCounts(counts, Errors.forCode(data.errorCode())); |
||||||
|
return counts; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int throttleTimeMs() { |
||||||
|
return data.throttleTimeMs(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void maybeSetThrottleTimeMs(int throttleTimeMs) { |
||||||
|
data.setThrottleTimeMs(throttleTimeMs); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean hasError() { |
||||||
|
return error() != Errors.NONE; |
||||||
|
} |
||||||
|
|
||||||
|
public Errors error() { |
||||||
|
return Errors.forCode(data.errorCode()); |
||||||
|
} |
||||||
|
|
||||||
|
public static GetTelemetrySubscriptionsResponse parse(ByteBuffer buffer, short version) { |
||||||
|
return new GetTelemetrySubscriptionsResponse(new GetTelemetrySubscriptionsResponseData( |
||||||
|
new ByteBufferAccessor(buffer), version)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.PushTelemetryRequestData; |
||||||
|
import org.apache.kafka.common.message.PushTelemetryResponseData; |
||||||
|
import org.apache.kafka.common.protocol.ApiKeys; |
||||||
|
import org.apache.kafka.common.protocol.ByteBufferAccessor; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
|
||||||
|
import java.nio.ByteBuffer; |
||||||
|
|
||||||
|
public class PushTelemetryRequest extends AbstractRequest { |
||||||
|
|
||||||
|
public static class Builder extends AbstractRequest.Builder<PushTelemetryRequest> { |
||||||
|
|
||||||
|
private final PushTelemetryRequestData data; |
||||||
|
|
||||||
|
public Builder(PushTelemetryRequestData data) { |
||||||
|
this(data, false); |
||||||
|
} |
||||||
|
|
||||||
|
public Builder(PushTelemetryRequestData data, boolean enableUnstableLastVersion) { |
||||||
|
super(ApiKeys.PUSH_TELEMETRY, enableUnstableLastVersion); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PushTelemetryRequest build(short version) { |
||||||
|
return new PushTelemetryRequest(data, version); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return data.toString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private final PushTelemetryRequestData data; |
||||||
|
|
||||||
|
public PushTelemetryRequest(PushTelemetryRequestData data, short version) { |
||||||
|
super(ApiKeys.PUSH_TELEMETRY, version); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PushTelemetryResponse getErrorResponse(int throttleTimeMs, Throwable e) { |
||||||
|
PushTelemetryResponseData responseData = new PushTelemetryResponseData() |
||||||
|
.setErrorCode(Errors.forException(e).code()) |
||||||
|
.setThrottleTimeMs(throttleTimeMs); |
||||||
|
return new PushTelemetryResponse(responseData); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PushTelemetryRequestData data() { |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
public static PushTelemetryRequest parse(ByteBuffer buffer, short version) { |
||||||
|
return new PushTelemetryRequest(new PushTelemetryRequestData( |
||||||
|
new ByteBufferAccessor(buffer), version), version); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.PushTelemetryResponseData; |
||||||
|
import org.apache.kafka.common.protocol.ApiKeys; |
||||||
|
import org.apache.kafka.common.protocol.ByteBufferAccessor; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
|
||||||
|
import java.nio.ByteBuffer; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class PushTelemetryResponse extends AbstractResponse { |
||||||
|
|
||||||
|
private final PushTelemetryResponseData data; |
||||||
|
|
||||||
|
public PushTelemetryResponse(PushTelemetryResponseData data) { |
||||||
|
super(ApiKeys.PUSH_TELEMETRY); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PushTelemetryResponseData data() { |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<Errors, Integer> errorCounts() { |
||||||
|
HashMap<Errors, Integer> counts = new HashMap<>(); |
||||||
|
updateErrorCounts(counts, Errors.forCode(data.errorCode())); |
||||||
|
return counts; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int throttleTimeMs() { |
||||||
|
return data.throttleTimeMs(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void maybeSetThrottleTimeMs(int throttleTimeMs) { |
||||||
|
data.setThrottleTimeMs(throttleTimeMs); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean hasError() { |
||||||
|
return error() != Errors.NONE; |
||||||
|
} |
||||||
|
|
||||||
|
public Errors error() { |
||||||
|
return Errors.forCode(data.errorCode()); |
||||||
|
} |
||||||
|
|
||||||
|
public static PushTelemetryResponse parse(ByteBuffer buffer, short version) { |
||||||
|
return new PushTelemetryResponse(new PushTelemetryResponseData( |
||||||
|
new ByteBufferAccessor(buffer), version)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,33 @@ |
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
// contributor license agreements. See the NOTICE file distributed with |
||||||
|
// this work for additional information regarding copyright ownership. |
||||||
|
// The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
// (the "License"); you may not use this file except in compliance with |
||||||
|
// the License. You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
{ |
||||||
|
"apiKey": 71, |
||||||
|
"type": "request", |
||||||
|
"listeners": ["broker"], |
||||||
|
"name": "GetTelemetrySubscriptionsRequest", |
||||||
|
"validVersions": "0", |
||||||
|
"flexibleVersions": "0+", |
||||||
|
// The Telemetry APIs are added as part of KIP-714 and are still under |
||||||
|
// development. Hence, the APIs are not exposed by default unless explicitly |
||||||
|
// enabled. |
||||||
|
"latestVersionUnstable": true, |
||||||
|
"fields": [ |
||||||
|
{ |
||||||
|
"name": "ClientInstanceId", "type": "uuid", "versions": "0+", |
||||||
|
"about": "Unique id for this client instance, must be set to 0 on the first request." |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
// contributor license agreements. See the NOTICE file distributed with |
||||||
|
// this work for additional information regarding copyright ownership. |
||||||
|
// The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
// (the "License"); you may not use this file except in compliance with |
||||||
|
// the License. You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
{ |
||||||
|
"apiKey": 71, |
||||||
|
"type": "response", |
||||||
|
"name": "GetTelemetrySubscriptionsResponse", |
||||||
|
"validVersions": "0", |
||||||
|
"flexibleVersions": "0+", |
||||||
|
"fields": [ |
||||||
|
{ |
||||||
|
"name": "ThrottleTimeMs", "type": "int32", "versions": "0+", |
||||||
|
"about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "ErrorCode", "type": "int16", "versions": "0+", |
||||||
|
"about": "The error code, or 0 if there was no error." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "ClientInstanceId", "type": "uuid", "versions": "0+", |
||||||
|
"about": "Assigned client instance id if ClientInstanceId was 0 in the request, else 0." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "SubscriptionId", "type": "int32", "versions": "0+", |
||||||
|
"about": "Unique identifier for the current subscription set for this client instance." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "AcceptedCompressionTypes", "type": "[]int8", "versions": "0+", |
||||||
|
"about": "Compression types that broker accepts for the PushTelemetryRequest." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "PushIntervalMs", "type": "int32", "versions": "0+", |
||||||
|
"about": "Configured push interval, which is the lowest configured interval in the current subscription set." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "TelemetryMaxBytes", "type": "int32", "versions": "0+", |
||||||
|
"about": "The maximum bytes of binary data the broker accepts in PushTelemetryRequest." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "DeltaTemporality", "type": "bool", "versions": "0+", |
||||||
|
"about": "Flag to indicate monotonic/counter metrics are to be emitted as deltas or cumulative values" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "RequestedMetrics", "type": "[]string", "versions": "0+", |
||||||
|
"about": "Requested metrics prefix string match. Empty array: No metrics subscribed, Array[0] empty string: All metrics subscribed." |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
// contributor license agreements. See the NOTICE file distributed with |
||||||
|
// this work for additional information regarding copyright ownership. |
||||||
|
// The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
// (the "License"); you may not use this file except in compliance with |
||||||
|
// the License. You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
{ |
||||||
|
"apiKey": 72, |
||||||
|
"type": "request", |
||||||
|
"listeners": ["broker"], |
||||||
|
"name": "PushTelemetryRequest", |
||||||
|
"validVersions": "0", |
||||||
|
"flexibleVersions": "0+", |
||||||
|
// The Telemetry APIs are added as part of KIP-714 and are still under |
||||||
|
// development. Hence, the APIs are not exposed by default unless explicitly |
||||||
|
// enabled. |
||||||
|
"latestVersionUnstable": true, |
||||||
|
"fields": [ |
||||||
|
{ |
||||||
|
"name": "ClientInstanceId", "type": "uuid", "versions": "0+", |
||||||
|
"about": "Unique id for this client instance." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "SubscriptionId", "type": "int32", "versions": "0+", |
||||||
|
"about": "Unique identifier for the current subscription." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "Terminating", "type": "bool", "versions": "0+", |
||||||
|
"about": "Client is terminating the connection." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "CompressionType", "type": "int8", "versions": "0+", |
||||||
|
"about": "Compression codec used to compress the metrics." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "Metrics", "type": "bytes", "versions": "0+", |
||||||
|
"about": "Metrics encoded in OpenTelemetry MetricsData v1 protobuf format." |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
// contributor license agreements. See the NOTICE file distributed with |
||||||
|
// this work for additional information regarding copyright ownership. |
||||||
|
// The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
// (the "License"); you may not use this file except in compliance with |
||||||
|
// the License. You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
{ |
||||||
|
"apiKey": 72, |
||||||
|
"type": "response", |
||||||
|
"name": "PushTelemetryResponse", |
||||||
|
"validVersions": "0", |
||||||
|
"flexibleVersions": "0+", |
||||||
|
"fields": [ |
||||||
|
{ |
||||||
|
"name": "ThrottleTimeMs", "type": "int32", "versions": "0+", |
||||||
|
"about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "ErrorCode", "type": "int16", "versions": "0+", |
||||||
|
"about": "The error code, or 0 if there was no error." |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.GetTelemetrySubscriptionsRequestData; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||||
|
|
||||||
|
public class GetTelemetrySubscriptionsRequestTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetErrorResponse() { |
||||||
|
GetTelemetrySubscriptionsRequest req = new GetTelemetrySubscriptionsRequest(new GetTelemetrySubscriptionsRequestData(), (short) 0); |
||||||
|
GetTelemetrySubscriptionsResponse response = req.getErrorResponse(0, Errors.CLUSTER_AUTHORIZATION_FAILED.exception()); |
||||||
|
assertEquals(Collections.singletonMap(Errors.CLUSTER_AUTHORIZATION_FAILED, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.GetTelemetrySubscriptionsResponseData; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||||
|
|
||||||
|
public class GetTelemetrySubscriptionsResponseTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testErrorCountsReturnsNoneWhenNoErrors() { |
||||||
|
GetTelemetrySubscriptionsResponseData data = new GetTelemetrySubscriptionsResponseData() |
||||||
|
.setErrorCode(Errors.NONE.code()); |
||||||
|
GetTelemetrySubscriptionsResponse response = new GetTelemetrySubscriptionsResponse(data); |
||||||
|
assertEquals(Collections.singletonMap(Errors.NONE, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testErrorCountsReturnsOneError() { |
||||||
|
GetTelemetrySubscriptionsResponseData data = new GetTelemetrySubscriptionsResponseData() |
||||||
|
.setErrorCode(Errors.CLUSTER_AUTHORIZATION_FAILED.code()); |
||||||
|
data.setErrorCode(Errors.INVALID_CONFIG.code()); |
||||||
|
|
||||||
|
GetTelemetrySubscriptionsResponse response = new GetTelemetrySubscriptionsResponse(data); |
||||||
|
assertEquals(Collections.singletonMap(Errors.INVALID_CONFIG, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.PushTelemetryRequestData; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||||
|
|
||||||
|
public class PushTelemetryRequestTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetErrorResponse() { |
||||||
|
PushTelemetryRequest req = new PushTelemetryRequest(new PushTelemetryRequestData(), (short) 0); |
||||||
|
PushTelemetryResponse response = req.getErrorResponse(0, Errors.CLUSTER_AUTHORIZATION_FAILED.exception()); |
||||||
|
assertEquals(Collections.singletonMap(Errors.CLUSTER_AUTHORIZATION_FAILED, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.kafka.common.requests; |
||||||
|
|
||||||
|
import org.apache.kafka.common.message.PushTelemetryResponseData; |
||||||
|
import org.apache.kafka.common.protocol.Errors; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||||
|
|
||||||
|
public class PushTelemetryResponseTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testErrorCountsReturnsNoneWhenNoErrors() { |
||||||
|
PushTelemetryResponseData data = new PushTelemetryResponseData() |
||||||
|
.setErrorCode(Errors.NONE.code()); |
||||||
|
PushTelemetryResponse response = new PushTelemetryResponse(data); |
||||||
|
assertEquals(Collections.singletonMap(Errors.NONE, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testErrorCountsReturnsOneError() { |
||||||
|
PushTelemetryResponseData data = new PushTelemetryResponseData() |
||||||
|
.setErrorCode(Errors.CLUSTER_AUTHORIZATION_FAILED.code()); |
||||||
|
data.setErrorCode(Errors.INVALID_CONFIG.code()); |
||||||
|
|
||||||
|
PushTelemetryResponse response = new PushTelemetryResponse(data); |
||||||
|
assertEquals(Collections.singletonMap(Errors.INVALID_CONFIG, 1), response.errorCounts()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue