comment stringlengths 1 45k | method_body stringlengths 23 281k | target_code stringlengths 0 5.16k | method_body_after stringlengths 12 281k | context_before stringlengths 8 543k | context_after stringlengths 8 543k |
|---|---|---|---|---|---|
nit: we've followed the pattern where the sync APIs call their next max overloads -> this sync API should call the sync API overload with Context.NONE. | public PagedIterable<String> query(String query) {
return new PagedIterable<>(digitalTwinsAsyncClient.query(query));
} | return new PagedIterable<>(digitalTwinsAsyncClient.query(query)); | public PagedIterable<String> query(String query) {
return query(query, Context.NONE);
} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A {@link DigitalTwinsResponse} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A {@link DigitalTwinsResponse} |
It does not need it but no harm in passing it as well. To keep it consistent with .net, I will remove it here. | public PagedFlux<String> query(String query) {
return new PagedFlux<>(
() -> withContext(context -> queryFirstPage(query, context)),
nextLink -> withContext(context -> queryNextPage(query, nextLink, context)));
} | nextLink -> withContext(context -> queryNextPage(query, nextLink, context))); | public PagedFlux<String> query(String query) {
return new PagedFlux<>(
() -> withContext(context -> queryFirstPage(query, context)),
nextLink -> withContext(context -> queryNextPage(nextLink, context)));
} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @return A {@link DigitalTwinsResponse} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @return A {@link DigitalTwinsResponse} |
From the .NET client, it looks like all we need to supply to the service is the cont. token, we don't need to pass in the query string again: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs#L1360-L1363 Also, what is our testing strategy with thi... | Mono<PagedResponse<String>> queryNextPage(String query, String nextLink, Context context) {
QuerySpecification querySpecification = new QuerySpecification();
querySpecification
.setQuery(query)
.setContinuationToken(nextLink);
return protocolLayer
.getQueries()
.queryTwinsWithResponseAsync(querySpecification, context)
... | .setQuery(query) | new QuerySpecification().setQuery(query);
return protocolLayer
.getQueries()
.queryTwinsWithResponseAsync(querySpecification, context)
.map(objectPagedResponse -> new PagedResponseBase<>(
objectPagedResponse.getRequest(),
objectPagedResponse.getStatusCode(),
objectPagedResponse.getHeaders(),
objectPagedResponse.getValu... | class to convert the query response to.
* @param <T> The generic type to convert the query response to.
* @return A {@link PagedFlux} | class to convert the query response to.
* @param <T> The generic type to convert the query response to.
* @return A {@link PagedFlux} |
yes that is what I replied to your earlier comment. You don't need to pass it but there is no harm in passing it. But to keep consistency I removed it here. The page size is not configurable but we will follow the same strategy as we have in .net. I will look at it as I start implementing samples. | Mono<PagedResponse<String>> queryNextPage(String query, String nextLink, Context context) {
QuerySpecification querySpecification = new QuerySpecification();
querySpecification
.setQuery(query)
.setContinuationToken(nextLink);
return protocolLayer
.getQueries()
.queryTwinsWithResponseAsync(querySpecification, context)
... | .setQuery(query) | new QuerySpecification().setQuery(query);
return protocolLayer
.getQueries()
.queryTwinsWithResponseAsync(querySpecification, context)
.map(objectPagedResponse -> new PagedResponseBase<>(
objectPagedResponse.getRequest(),
objectPagedResponse.getStatusCode(),
objectPagedResponse.getHeaders(),
objectPagedResponse.getValu... | class to convert the query response to.
* @param <T> The generic type to convert the query response to.
* @return A {@link PagedFlux} | class to convert the query response to.
* @param <T> The generic type to convert the query response to.
* @return A {@link PagedFlux} |
This can be `return query(query, Context.NONE)` instead. We can call the sync overload directly, instead of calling the async overload and creating a new PagedIterable. | public PagedIterable<String> query(String query) {
return new PagedIterable<>(digitalTwinsAsyncClient.query(query, Context.NONE));
} | return new PagedIterable<>(digitalTwinsAsyncClient.query(query, Context.NONE)); | public PagedIterable<String> query(String query) {
return query(query, Context.NONE);
} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A {@link DigitalTwinsResponse} | class to deserialize the application/json component into.
* @param <T> The generic type to deserialize the component to.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A {@link DigitalTwinsResponse} |
Nit: `validSharedKey` sounds like the shared key value is valid to the service. Suggest something like "includesSharedKeyValue" | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | boolean validSharedKey = sharedAccessKeyName != null && sharedAccessKeyValue != null; | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... |
Using constructor overloads work well. How about using a different sub class of `TokenCredential`, like `EventHubSharedAccessSignatureCredential`, or the shorter version `EventHubSASCredential`? It's cleaner to user two separate classes. Maybe someday the shared access signature will support new behaviors like token re... | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessSignature()); | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... |
This is similar to what .NET is doing. I am not sure we should introduce too many credential types when the token returned for both types of connection strings are the same. | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessSignature()); | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... |
Updated name to `hasSharedKeyAndValue`. | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | boolean validSharedKey = sharedAccessKeyName != null && sharedAccessKeyValue != null; | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... |
This value should be culture agnostic, I would use the culture invariant locale. | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | && value.toLowerCase(Locale.getDefault()).startsWith(SAS_VALUE_PREFIX)) { | public ConnectionStringProperties(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw new IllegalArgumentException("'connectionString' cannot be an empty string.");
}
final String[] tokenValuePairs = connectionString.split(TO... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... | class ConnectionStringProperties {
private final ClientLogger logger = new ClientLogger(ConnectionStringProperties.class);
private static final String TOKEN_VALUE_SEPARATOR = "=";
private static final String ENDPOINT_SCHEME_SB_PREFIX = "sb:
private static final String ENDPOINT_SCHEME_HTTP_PREFIX = "http:
private static... |
This is all internal. So I don't have very strong opinion to use separate classes. Let's go ahead with this. | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessSignature()); | private TokenCredential getTokenCredential(ConnectionStringProperties properties) {
TokenCredential tokenCredential;
if (properties.getSharedAccessSignature() == null) {
tokenCredential = new EventHubSharedKeyCredential(properties.getSharedAccessKeyName(),
properties.getSharedAccessKey(), ClientConstants.TOKEN_VALIDITY... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... | class EventHubClientBuilder {
static final int DEFAULT_PREFETCH_COUNT = 500;
static final int DEFAULT_PREFETCH_COUNT_FOR_SYNC_CLIENT = 1;
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
/**
* The minimum value allowed for th... |
Any possibility that `logOptions` is `null`? | private static UserAgentPolicy getUserAgentPolicy(Configuration configuration, HttpLogOptions logOptions) {
configuration = (configuration == null) ? Configuration.NONE : configuration;
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "Unk... | return new UserAgentPolicy(logOptions.getApplicationId(), clientName, clientVersion, | private static UserAgentPolicy getUserAgentPolicy(Configuration configuration, HttpLogOptions logOptions) {
configuration = (configuration == null) ? Configuration.NONE : configuration;
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "Unk... | class BuilderHelper {
private static final Map<String, String> PROPERTIES =
CoreUtils.getProperties("azure-storage-blob.properties");
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
/**
* Constructs a {@link HttpPipeline} from values passed from a builder.
*
* @param ... | class BuilderHelper {
private static final Map<String, String> PROPERTIES =
CoreUtils.getProperties("azure-storage-blob.properties");
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
/**
* Constructs a {@link HttpPipeline} from values passed from a builder.
*
* @param ... |
This method is only called by our builders where we set logOptions to default log options, so I think it is safe. | private static UserAgentPolicy getUserAgentPolicy(Configuration configuration, HttpLogOptions logOptions) {
configuration = (configuration == null) ? Configuration.NONE : configuration;
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "Unk... | return new UserAgentPolicy(logOptions.getApplicationId(), clientName, clientVersion, | private static UserAgentPolicy getUserAgentPolicy(Configuration configuration, HttpLogOptions logOptions) {
configuration = (configuration == null) ? Configuration.NONE : configuration;
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "Unk... | class BuilderHelper {
private static final Map<String, String> PROPERTIES =
CoreUtils.getProperties("azure-storage-blob.properties");
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
/**
* Constructs a {@link HttpPipeline} from values passed from a builder.
*
* @param ... | class BuilderHelper {
private static final Map<String, String> PROPERTIES =
CoreUtils.getProperties("azure-storage-blob.properties");
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
/**
* Constructs a {@link HttpPipeline} from values passed from a builder.
*
* @param ... |
1. Can we add one more example where user give bad date time format for example `202012-31T13:37:45Z` | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | + "&se=se=2020-12-31T13:37:45Z" | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... |
What if user give a space, will it be valid for example `& se =1599537084` ? | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | + "&se=1599537084" | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... |
Should we log here in case of `logger.verbose("Could not parse .... ")` to give user information that something might be wrong in their string and they have a chance to fix the formatting issue in their string? But at same time, we do not want to fill logs. | private OffsetDateTime getExpirationTime(String sharedAccessSignature) {
String[] parts = sharedAccessSignature.split("&");
return Arrays.stream(parts)
.map(part -> part.split("="))
.filter(pair -> pair.length == 2 && pair[0].equalsIgnoreCase("se"))
.findFirst()
.map(pair -> pair[1])
.map(expirationTimeStr -> {
try {
l... | return OffsetDateTime.MAX; | private OffsetDateTime getExpirationTime(String sharedAccessSignature) {
String[] parts = sharedAccessSignature.split("&");
return Arrays.stream(parts)
.map(part -> part.split("="))
.filter(pair -> pair.length == 2 && pair[0].equalsIgnoreCase("se"))
.findFirst()
.map(pair -> pair[1])
.map(expirationTimeStr -> {
try {
l... | class ServiceBusSharedKeyCredential implements TokenCredential {
private static final String SHARED_ACCESS_SIGNATURE_FORMAT = "SharedAccessSignature sr=%s&sig=%s&se=%s&skn=%s";
private static final String HASH_ALGORITHM = "HMACSHA256";
private final ClientLogger logger = new ClientLogger(ServiceBusSharedKeyCredential.c... | class ServiceBusSharedKeyCredential implements TokenCredential {
private static final String SHARED_ACCESS_SIGNATURE_FORMAT = "SharedAccessSignature sr=%s&sig=%s&se=%s&skn=%s";
private static final String HASH_ALGORITHM = "HMACSHA256";
private final ClientLogger logger = new ClientLogger(ServiceBusSharedKeyCredential.c... |
We do not validate the contents of the SAS token. The service will throw an exception if there are unnecessary chars in the token. | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | + "&se=1599537084" | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... |
Any non-integer format will be ignored and this test is covering that. | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | + "&se=se=2020-12-31T13:37:45Z" | private static Stream<Arguments> getSas() {
String validSas = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.servicebus.windows.net%2F"
+ "&sig=encodedsignature%3D"
+ "&se=1599537084"
+ "&skn=test-sas-key";
String validSasWithNoExpirationTime = "SharedAccessSignature "
+ "sr=https%3A%2F%2Fentity-name.serviceb... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... | class ServiceBusSharedKeyCredentialTest {
@ParameterizedTest
@MethodSource("getSas")
public void testSharedAccessSignatureCredential(String sas, OffsetDateTime expectedExpirationTime) {
ServiceBusSharedKeyCredential serviceBusSharedKeyCredential = new ServiceBusSharedKeyCredential(sas);
StepVerifier.create(serviceBusSh... |
Nice! Although, I haven't observed duplicates here generally but this is a nice improvement! | public Flux<AmqpEndpointState> getEndpointStates() {
return endpointStates.distinct();
} | return endpointStates.distinct(); | public Flux<AmqpEndpointState> getEndpointStates() {
return endpointStates.distinct();
} | class ReactorReceiver implements AmqpReceiveLink {
private final AtomicBoolean hasAuthorized = new AtomicBoolean(true);
private final String entityPath;
private final Receiver receiver;
private final ReceiveLinkHandler handler;
private final TokenManager tokenManager;
private final ReactorDispatcher dispatcher;
private... | class ReactorReceiver implements AmqpReceiveLink {
private final AtomicBoolean hasAuthorized = new AtomicBoolean(true);
private final String entityPath;
private final Receiver receiver;
private final ReceiveLinkHandler handler;
private final TokenManager tokenManager;
private final ReactorDispatcher dispatcher;
private... |
nit: "update" not "upDate" | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | DigitalTwinsResponse<Void> upDateComponentResponse = client.updateComponentWithResponse( | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ModelsTestBase.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
To preserve the full stacktrace, how about: ```java throw new AssertionFailedError("Test clean up failed", ex) ``` | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | fail("Test clean up failed: " + ex.getMessage()); | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ModelsTestBase.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
I can split it into a separate test if you feel strongly about it; I added it in here because of the convenience (the models are twins were already created). | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | |
Try to preserve the stacktrace here, too | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_... | fail("Test clean up failed: " + ex.getMessage()); | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_... | class ComponentsAsyncTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ModelsAsyncTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class ComponentsAsyncTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ComponentsAsyncTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
:)) good catch ! | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | DigitalTwinsResponse<Void> upDateComponentResponse = client.updateComponentWithResponse( | public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String wifiComponentName = "wifiAccessPoint";
String roomWithWifiTwinId = UniqueIdHelper.getUniqueDigitalTwinId(TestAssetDefaults.ROOM_WITH_WIFI_TWIN_... | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ModelsTestBase.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class ComponentsTests extends ComponentsTestBase {
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
Looks like the service caused a regression. It went from allowing api-version as header to blocking it. We are fixing it on the service side to accept header again. | public SchemaRegistryClientBuilder() {
this.policies = new ArrayList<>();
this.httpLogOptions = new HttpLogOptions();
this.maxSchemaMapSize = null;
this.typeParserMap = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
this.httpClient = null;
this.credential = null;
this.retryPolicy = new RetryPolicy("retry-a... | headers.put("api-version", "2020-09-01-preview"); | public SchemaRegistryClientBuilder() {
this.policies = new ArrayList<>();
this.httpLogOptions = new HttpLogOptions();
this.maxSchemaMapSize = null;
this.typeParserMap = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
this.httpClient = null;
this.credential = null;
this.retryPolicy = new RetryPolicy("retry-a... | class SchemaRegistryClientBuilder {
private final ClientLogger logger = new ClientLogger(SchemaRegistryClientBuilder.class);
private static final String DEFAULT_SCOPE = "https:
private static final String CLIENT_PROPERTIES = "azure-data-schemaregistry-client.properties";
private static final String NAME = "name";
priva... | class SchemaRegistryClientBuilder {
private final ClientLogger logger = new ClientLogger(SchemaRegistryClientBuilder.class);
private static final String DEFAULT_SCOPE = "https:
private static final String CLIENT_PROPERTIES = "azure-data-schemaregistry-client.properties";
private static final String NAME = "name";
priva... |
is this intended? | public static void main(final String[] args) {
FormRecognizerAsyncClient client = new FormRecognizerClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("https:
.buildAsyncClient();
PollerFlux<FormRecognizerOperationResult, List<FormPage>> recognizeContentPoller =
client.beginRecognizeContentFromUrl(... | client.beginRecognizeContentFromUrl("https: | public static void main(final String[] args) {
FormRecognizerAsyncClient client = new FormRecognizerClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("https:
.buildAsyncClient();
PollerFlux<FormRecognizerOperationResult, List<FormPage>> recognizeContentPoller =
client.beginRecognizeContentFromUrl(... | class RecognizeContentFromUrlAsync {
/**
* Main method to invoke this demo.
*
* @param args Unused. Arguments to the program.
*/
} | class RecognizeContentFromUrlAsync {
/**
* Main method to invoke this demo.
*
* @param args Unused. Arguments to the program.
*/
} |
Could this be split out into a separate test? | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | |
Could this be split out into a separate test? This test is already quite long | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | |
I thought about that, but that would require that we create the model and twins again. Since they were already available as a part of this lifecycle test, I added this assertion in here directly. | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | public void relationshipLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = getUniqueModelId(FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId = getUniqueModelId(ROOM_MOD... | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class DigitalTwinsRelationshipTest extends DigitalTwinsRelationshipTestBase {
private final ClientLogger logger = new ClientLogger(DigitalTwinsRelationshipTest.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | |
don't we need it everywhere in this file? | public static String getUniqueModelId(String baseName, DigitalTwinsAsyncClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator);
} | return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator); | public static String getUniqueModelId(String baseName, DigitalTwinsAsyncClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator);
} | class UniqueIdHelper {
public static String getUniqueModelId(String baseName, DigitalTwinsClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> client.getModel(modelId).getId()), randomIntegerStringGenerator);
}
public static String getUniqueDigitalTwinId(Stri... | class UniqueIdHelper {
public static String getUniqueModelId(String baseName, DigitalTwinsClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> client.getModel(modelId).getId()), randomIntegerStringGenerator);
}
public static String getUniqueDigitalTwinId(Stri... |
the required non-null check? I added it here because intellij recommended that I do; we should go through our code to see if it makes sense to add it elsewhere as well. | public static String getUniqueModelId(String baseName, DigitalTwinsAsyncClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator);
} | return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator); | public static String getUniqueModelId(String baseName, DigitalTwinsAsyncClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> Objects.requireNonNull(client.getModel(modelId).block()).getId()), randomIntegerStringGenerator);
} | class UniqueIdHelper {
public static String getUniqueModelId(String baseName, DigitalTwinsClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> client.getModel(modelId).getId()), randomIntegerStringGenerator);
}
public static String getUniqueDigitalTwinId(Stri... | class UniqueIdHelper {
public static String getUniqueModelId(String baseName, DigitalTwinsClient client, Function<Integer, String> randomIntegerStringGenerator) {
return getUniqueId(baseName, (modelId -> client.getModel(modelId).getId()), randomIntegerStringGenerator);
}
public static String getUniqueDigitalTwinId(Stri... |
why the empty spaces? if you intend to tab in , use \t ? | public static void main(String[] args) {
SamplesArguments parsedArguments = new SamplesArguments(args);
client = new DigitalTwinsClientBuilder()
.credential(
new ClientSecretCredentialBuilder()
.tenantId(parsedArguments.getTenantId())
.clientId(parsedArguments.getClientId())
.clientSecret(parsedArguments.getClientSecre... | ConsoleLogger.print(String.format(" EventRouteId: %s", existingEventRoute.getId())); | public static void main(String[] args) {
SamplesArguments parsedArguments = new SamplesArguments(args);
client = new DigitalTwinsClientBuilder()
.credential(
new ClientSecretCredentialBuilder()
.tenantId(parsedArguments.getTenantId())
.clientId(parsedArguments.getClientId())
.clientSecret(parsedArguments.getClientSecre... | class EventRoutesSyncSamples {
private static DigitalTwinsClient client;
} | class EventRoutesSyncSamples {
private static DigitalTwinsClient client;
} |
Ah, good thinking. I'll just \t instead | public static void main(String[] args) {
SamplesArguments parsedArguments = new SamplesArguments(args);
client = new DigitalTwinsClientBuilder()
.credential(
new ClientSecretCredentialBuilder()
.tenantId(parsedArguments.getTenantId())
.clientId(parsedArguments.getClientId())
.clientSecret(parsedArguments.getClientSecre... | ConsoleLogger.print(String.format(" EventRouteId: %s", existingEventRoute.getId())); | public static void main(String[] args) {
SamplesArguments parsedArguments = new SamplesArguments(args);
client = new DigitalTwinsClientBuilder()
.credential(
new ClientSecretCredentialBuilder()
.tenantId(parsedArguments.getTenantId())
.clientId(parsedArguments.getClientId())
.clientSecret(parsedArguments.getClientSecre... | class EventRoutesSyncSamples {
private static DigitalTwinsClient client;
} | class EventRoutesSyncSamples {
private static DigitalTwinsClient client;
} |
how do you feel about using assertj's fluent assertions here? | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | assertEquals(expectedId, actual.getId()); | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... |
I'm not sure that would simplify anything in this case. Am I missing something though? | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | assertEquals(expectedId, actual.getId()); | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... |
I feel it is more readable, and adds better context to the assertion being done. | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | assertEquals(expectedId, actual.getId()); | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... |
You could also do something like: ```java assertThat(actual).extracting("id", "endpointName", "filter") .doesNotContainNull() .containsExactly(expectedId, expected.getEndpointName(), expected.getFilter()); ``` | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | assertEquals(expectedId, actual.getId()); | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... |
FYI - https://stackoverflow.com/questions/47969970/assertj-for-a-pojo-how-to-check-each-nested-property-field-in-one-chained-sente?answertab=votes#tab-top | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | assertEquals(expectedId, actual.getId()); | protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) {
assertEquals(expectedId, actual.getId());
assertEquals(expected.getEndpointName(), actual.getEndpointName());
assertEquals(expected.getFilter(), actual.getFilter());
} | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... | class EventRoutesTestBase extends DigitalTwinsTestBase {
private final ClientLogger logger = new ClientLogger(EventRoutesTestBase.class);
static final String EVENT_ROUTE_ENDPOINT_NAME = "someEventHubEndpoint";
static final String FILTER = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycl... |
The above uses monoError. Why is this line different? | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | throw logger.logExceptionAsError(new IllegalArgumentException("'message.getLockToken()' cannot be empty.")); | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
Same question. The above uses monoError. This overload uses logger.logExceptionAsError(). | public Mono<Void> renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
throw logger.logExceptionAsError(new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewMessageLock")));
} else if (Objects.isNull(message)) {
throw logger... | throw logger.logExceptionAsError(new IllegalStateException( | public Mono<Void> renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(log... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
same question | public Mono<Void> renewSessionLock(String sessionId, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
throw logger.logExceptionAsError(new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewSessionLock")));
} else if (!receiverOptions.isSessionReceiver()) {
throw logger.log... | throw logger.logExceptionAsError(new IllegalStateException( | public Mono<Void> renewSessionLock(String sessionId, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewSessionLock")));
} else if (!receiverOptions.isSessionReceiver()) {
return monoError(logger,... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
Good catch. I've replaced all instances | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | throw logger.logExceptionAsError(new IllegalArgumentException("'message.getLockToken()' cannot be empty.")); | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
Although logically `lockToken` will always be there but we should check for `null` value also. | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | } else if (message.getLockToken().isEmpty()) { | public Mono<OffsetDateTime> renewMessageLock(ServiceBusReceivedMessage message) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(logger, new NullPointerException(... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
null check for message.getLockToken() | public Mono<Void> renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(log... | String.format("Cannot renew message lock [%s] for a session receiver.", message.getLockToken()))); | public Mono<Void> renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "getAutoRenewMessageLock")));
} else if (Objects.isNull(message)) {
return monoError(log... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final String TRANSACTION_LINK_NAME = "coordinator";
private final LockContainer<LockRenewalOperation> renewalContainer;
private final AtomicBoolean ... |
Please install `java maven` in this file: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/spring/azure-spring-boot-test-keyvault/install_java.sh | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | commands.add("apt-get install git"); | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... |
Can we use `current` branch instead of `master` branch? Refs: https://stackoverflow.com/questions/49106104/get-current-git-branch-inside-a-java-test | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | commands.add("git pull origin master"); | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... |
We need update `origin` too. Refs: https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | commands.add("git remote add origin https: | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... |
So why do we choose to pull the project from GitHub instead of pushing it? | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | commands.add("git remote add origin https: | public void keyVaultWithVirtualMachineMSI() {
final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List<String> commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME)... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... | class KeyVaultIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultIT.class);
private static final String AZURE_KEYVAULT_URI = System.getenv("AZURE_KEYVAULT_URI");
private static final String KEY_VAULT_SECRET_VALUE = System.getenv("KEY_VAULT_SECRET_VALUE");
private static final String KEY_VAULT_SEC... |
I like this, we should split the test-setup part in other tests as well | public void publishTelemetryLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient client = getAsyncClient(httpClient, serviceVersion);
String wifiModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.WIFI_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
S... | createModelsAndTwins(client, wifiModelId, roomWithWifiModelId, roomWithWifiTwinId); | public void publishTelemetryLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient client = getAsyncClient(httpClient, serviceVersion);
String wifiModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.WIFI_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
S... | class PublishTelemetryAsyncTests extends PublishTelemetryTestBase {
private final ClientLogger logger = new ClientLogger(PublishTelemetryAsyncTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
private void createModelsAndTwins(DigitalTwin... | class PublishTelemetryAsyncTests extends PublishTelemetryTestBase {
private final ClientLogger logger = new ClientLogger(PublishTelemetryAsyncTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
private void createModelsAndTwins(DigitalTwin... |
I am planning to do another round of cleanup to make things a bit more consistent , I will address this later during the code cleanup ;) | public void publishTelemetryLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient client = getAsyncClient(httpClient, serviceVersion);
String wifiModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.WIFI_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
S... | createModelsAndTwins(client, wifiModelId, roomWithWifiModelId, roomWithWifiTwinId); | public void publishTelemetryLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient client = getAsyncClient(httpClient, serviceVersion);
String wifiModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.WIFI_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
S... | class PublishTelemetryAsyncTests extends PublishTelemetryTestBase {
private final ClientLogger logger = new ClientLogger(PublishTelemetryAsyncTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
private void createModelsAndTwins(DigitalTwin... | class PublishTelemetryAsyncTests extends PublishTelemetryTestBase {
private final ClientLogger logger = new ClientLogger(PublishTelemetryAsyncTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
private void createModelsAndTwins(DigitalTwin... |
Did we remove the extra deserialization to Object that was happening in the CL for these APIs? | public static void runPublishTelemetrySample() throws JsonProcessingException {
ConsoleLogger.printHeader("Telemetry Samples");
String componentModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.TEMPORARY_COMPONENT_MODEL_PREFIX, client, randomIntegerStringGenerator);
String modelId = UniqueIdHelper.getUniqueMod... | telemetryStringPayload, | public static void runPublishTelemetrySample() throws JsonProcessingException {
ConsoleLogger.printHeader("Telemetry Samples");
String componentModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.TEMPORARY_COMPONENT_MODEL_PREFIX, client, randomIntegerStringGenerator);
String modelId = UniqueIdHelper.getUniqueMod... | class PublishTelemetrySyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(ran... | class PublishTelemetrySyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(ran... |
Nope, seems I have forgotten all about it | public static void runPublishTelemetrySample() throws JsonProcessingException {
ConsoleLogger.printHeader("Telemetry Samples");
String componentModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.TEMPORARY_COMPONENT_MODEL_PREFIX, client, randomIntegerStringGenerator);
String modelId = UniqueIdHelper.getUniqueMod... | telemetryStringPayload, | public static void runPublishTelemetrySample() throws JsonProcessingException {
ConsoleLogger.printHeader("Telemetry Samples");
String componentModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.TEMPORARY_COMPONENT_MODEL_PREFIX, client, randomIntegerStringGenerator);
String modelId = UniqueIdHelper.getUniqueMod... | class PublishTelemetrySyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(ran... | class PublishTelemetrySyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(ran... |
Clarification: Scheduling is to unblock timer-wheel right? Thought: Leaving the choice to consumers is error prone, is it possible to force timer wheel it-self own and schedule on them (Of-course follow-up)? | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | |
BacklogItem: gate the validation and detect future regressions. Its a generic comments not just spcific to this change. | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | requestExpirator.execute(record::expire); | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... |
Is this check required? Wouldn't something other than the accepted response code generate an exception? | public static void runRelationshipsSample() throws JsonProcessingException {
ConsoleLogger.printHeader("RELATIONSHIP SAMPLE");
String sampleBuildingModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.BUILDING_MODEL_ID, client, randomIntegerStringGenerator);
String sampleFloorModelId = UniqueIdHelper.getUniqueMod... | if (getRelationshipRepsonse.getStatusCode() == HttpURLConnection.HTTP_OK) { | public static void runRelationshipsSample() throws JsonProcessingException {
ConsoleLogger.printHeader("RELATIONSHIP SAMPLE");
String sampleBuildingModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.BUILDING_MODEL_ID, client, randomIntegerStringGenerator);
String sampleFloorModelId = UniqueIdHelper.getUniqueMod... | class RelationshipsSyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(randIn... | class RelationshipsSyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(randIn... |
Is the move to do-while for readability? | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | } while (--channelsAvailable> 0); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
nit: (style) space before > | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | } while (--channelsAvailable> 0); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Is this same as above ensureInEventLoop? | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | this.ensureInEventLoop(); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Its very easy to slip stream changes violating the assumptions. We need a mechanism to guard/detect (in order of preference) for these critical aspects. How about fail in our gates/CTL/perf runs at-least? How about doing all our current validations with fail semantics? | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | this.ensureInEventLoop(); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
its error trace and I am not seeing them at-least in my runs. --- In reply to: [487800413](https://github.com/Azure/azure-sdk-for-java/pull/15157#discussion_r487800413) [](ancestors = 487800413) | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | this.ensureInEventLoop(); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Clarification(non-blocking): Any idea if netty duplex channel support timeout OOB? | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | requestExpirator.execute(record::expire); | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... |
RntbdClientChannelPool is a ChannelPool. So far my understanding is its an abstraction facilitating the pooling mechanism. Haven't seen it coupled with the core netty Channels or handlers. The attribute is a way of correlating it with the pool. Below mechanism is to purely ensure that release done on the same pool. ... | private void releaseChannel(final Channel channel, final Promise<Void> promise) {
checkState(channel.eventLoop().inEventLoop());
final ChannelPool pool = channel.attr(POOL_KEY).getAndSet(null);
final boolean acquired = this.acquiredChannels.get(channel) != null;
if (acquired && pool == this) {
try {
if (this.releaseHea... | private void releaseChannel(final Channel channel, final Promise<Void> promise) {
checkState(channel.eventLoop().inEventLoop());
final ChannelPool pool = channel.attr(POOL_KEY).getAndSet(null);
final boolean acquired = this.acquiredChannels.get(channel) != null;
if (acquired && pool == this) {
try {
if (this.releaseHea... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | |
Did it help in any scenario or is it a defensive programming? | private void releaseAndOfferChannel(final Channel channel, final Promise<Void> promise) {
this.ensureInEventLoop();
try {
this.acquiredChannels.remove(channel);
if (this.offerChannel(channel)) {
this.poolHandler.channelReleased(channel);
promise.setSuccess(null);
} else {
final IllegalStateException error = new Stackle... | this.acquiredChannels.remove(channel); | private void releaseAndOfferChannel(final Channel channel, final Promise<Void> promise) {
this.ensureInEventLoop();
try {
if (this.acquiredChannels.remove(channel) == null) {
logger.warn(
"Unexpected race condition - releaseChannel called twice for the same channel [{} -> {}]",
channel.id(),
this.remoteAddress());
prom... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Please add comments on reason for "false' choice. | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | if (this.isChannelServiceable(first, false)) { | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Clarification: Any idea on why the first channel short circuit has a different pre-condition (isClosed())? Or why can't it be a simple loop and pick the one which is available? | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | if (next.isActive()) { | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
ACK - but I think we all agree that making the changes to fail fast will result in additional risk and need for validation (probably with changes to test infrastructure) - so IMO this is something we should do after releasing the hot fix. Makes sense? | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | this.ensureInEventLoop(); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Agreed. Removed the TODO. | private void releaseChannel(final Channel channel, final Promise<Void> promise) {
checkState(channel.eventLoop().inEventLoop());
final ChannelPool pool = channel.attr(POOL_KEY).getAndSet(null);
final boolean acquired = this.acquiredChannels.get(channel) != null;
if (acquired && pool == this) {
try {
if (this.releaseHea... | private void releaseChannel(final Channel channel, final Promise<Void> promise) {
checkState(channel.eventLoop().inEventLoop());
final ChannelPool pool = channel.attr(POOL_KEY).getAndSet(null);
final boolean acquired = this.acquiredChannels.get(channel) != null;
if (acquired && pool == this) {
try {
if (this.releaseHea... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | |
Added comments | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | if (this.isChannelServiceable(first, false)) { | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
nit: too much happening in this 1 statement - add, new & null checks. Breaking it down probably makes it easier to read. | public JsonPatchDocument appendCopy(String from, String path) {
operations.add(new JsonPatchOperation(JsonPatchOperationKind.COPY,
Objects.requireNonNull(path, "'path' cannot be null."),
Objects.requireNonNull(from, "'from' cannot be null."), null));
return this;
} | Objects.requireNonNull(from, "'from' cannot be null."), null)); | public JsonPatchDocument appendCopy(String from, String path) {
Objects.requireNonNull(from, "'from' cannot be null.");
Objects.requireNonNull(path, "'path' cannot be null.");
operations.add(new JsonPatchOperation(JsonPatchOperationKind.COPY, path, from, null));
return this;
} | class JsonPatchDocument {
private static final ObjectMapper MAPPER = ((JacksonAdapter) JacksonAdapter.createDefaultSerializerAdapter())
.serializer();
private final ClientLogger logger = new ClientLogger(JsonPatchDocument.class);
private final List<JsonPatchOperation> operations;
/**
* Creates a new JSON Patch document... | class JsonPatchDocument {
private static final ObjectMapper MAPPER = ((JacksonAdapter) JacksonAdapter.createDefaultSerializerAdapter())
.serializer();
private final ClientLogger logger = new ClientLogger(JsonPatchDocument.class);
private final List<JsonPatchOperation> operations;
/**
* Creates a new JSON Patch document... |
The is a comment in the short-circuit above already - to avoid an infinite loop in the close code sequence. | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | if (next.isActive()) { | private Channel pollChannel() {
ensureInEventLoop();
final Channel first = this.availableChannels.pollLast();
if (first == null) {
return null;
}
if (this.isClosed()) {
return first;
}
if (this.isChannelServiceable(first, false)) {
return first;
}
this.availableChannels.offer(first);
for (Channel next = this.availableC... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
+1 to this pattern. earlier might look okey as poolHandler notification is very light weight and almost doesn't fail, but this is a pattern we should force in reviews. Thanks, | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | this.connecting.set(false); | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
nit: new line before. | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | this.acquiredChannels.compute(channel, (ignored, acquiredChannel) -> { | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Fixed | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | this.acquiredChannels.compute(channel, (ignored, acquiredChannel) -> { | private void notifyChannelConnect(final ChannelFuture future, final Promise<Channel> promise) {
ensureInEventLoop();
reportIssueUnless(logger, this.connecting.get(), this, "connecting: false");
try {
if (future.isSuccess()) {
final Channel channel = future.channel();
try {
this.poolHandler.channelAcquired(channel);
} c... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Yes - removed the comment. There was one scenario where we ended up leaving a channel in acquiredChannels and availableChannels. This was part of the fix to make sure we don't establish more connections than MaxChannels... | private void releaseAndOfferChannel(final Channel channel, final Promise<Void> promise) {
this.ensureInEventLoop();
try {
this.acquiredChannels.remove(channel);
if (this.offerChannel(channel)) {
this.poolHandler.channelReleased(channel);
promise.setSuccess(null);
} else {
final IllegalStateException error = new Stackle... | this.acquiredChannels.remove(channel); | private void releaseAndOfferChannel(final Channel channel, final Promise<Void> promise) {
this.ensureInEventLoop();
try {
if (this.acquiredChannels.remove(channel) == null) {
logger.warn(
"Unexpected race condition - releaseChannel called twice for the same channel [{} -> {}]",
channel.id(),
this.remoteAddress());
prom... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Can be discussed offline. | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | requestExpirator.execute(record::expire); | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... |
ACK - but let's please track this in work items - not in this PR. We need to make progress on this PR quickly to ship the hotfix. | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | requestExpirator.execute(record::expire); | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... |
No - it is intentionally executing at least once (even if no channels available to allow for more eager connection initiation. Worst case we pull one pendingAcquisition task from the head and re-enqueue it at the tail. Can result in some unfairness - but from test tests we ran and the discussions/analysis in the last c... | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | } while (--channelsAvailable> 0); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Correct | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | private RntbdRequestRecord addPendingRequestRecord(final ChannelHandlerContext context, final RntbdRequestRecord record) {
return this.pendingRequests.compute(record.transportRequestId(), (id, current) -> {
reportIssueUnless(current == null, context, "id: {}, current: {}, request: {}", record);
final Timeout pendingReq... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | class RntbdRequestManager implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final ClosedChannelException ON_CHANNEL_UNREGISTERED =
ThrowableUtil.unknownStackTrace(new ClosedChannelException(), RntbdRequestManager.class, "channelUnregistered");
private static final ClosedChannelEx... | |
Separated out all `Objects.requireNonNull` to their own lines. | public JsonPatchDocument appendCopy(String from, String path) {
operations.add(new JsonPatchOperation(JsonPatchOperationKind.COPY,
Objects.requireNonNull(path, "'path' cannot be null."),
Objects.requireNonNull(from, "'from' cannot be null."), null));
return this;
} | Objects.requireNonNull(from, "'from' cannot be null."), null)); | public JsonPatchDocument appendCopy(String from, String path) {
Objects.requireNonNull(from, "'from' cannot be null.");
Objects.requireNonNull(path, "'path' cannot be null.");
operations.add(new JsonPatchOperation(JsonPatchOperationKind.COPY, path, from, null));
return this;
} | class JsonPatchDocument {
private static final ObjectMapper MAPPER = ((JacksonAdapter) JacksonAdapter.createDefaultSerializerAdapter())
.serializer();
private final ClientLogger logger = new ClientLogger(JsonPatchDocument.class);
private final List<JsonPatchOperation> operations;
/**
* Creates a new JSON Patch document... | class JsonPatchDocument {
private static final ObjectMapper MAPPER = ((JacksonAdapter) JacksonAdapter.createDefaultSerializerAdapter())
.serializer();
private final ClientLogger logger = new ClientLogger(JsonPatchDocument.class);
private final List<JsonPatchOperation> operations;
/**
* Creates a new JSON Patch document... |
Fixed | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | this.ensureInEventLoop(); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Fixed | private void runTasksInPendingAcquisitionQueue() {
ensureInEventLoop();
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
if (timeoutFut... | } while (--channelsAvailable> 0); | private void runTasksInPendingAcquisitionQueue() {
this.ensureInEventLoop();
int channelsAvailable = this.availableChannels.size();
do {
final AcquireTask task = this.pendingAcquisitions.poll();
if (task == null) {
break;
}
task.acquired(true);
this.acquire(task.promise);
} while (--channelsAvailable > 0);
} | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
not really a check but a sample code on how to check status codes ... we don't really need it for the sample to function | public static void runRelationshipsSample() throws JsonProcessingException {
ConsoleLogger.printHeader("RELATIONSHIP SAMPLE");
String sampleBuildingModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.BUILDING_MODEL_ID, client, randomIntegerStringGenerator);
String sampleFloorModelId = UniqueIdHelper.getUniqueMod... | if (getRelationshipRepsonse.getStatusCode() == HttpURLConnection.HTTP_OK) { | public static void runRelationshipsSample() throws JsonProcessingException {
ConsoleLogger.printHeader("RELATIONSHIP SAMPLE");
String sampleBuildingModelId = UniqueIdHelper.getUniqueModelId(SamplesConstants.BUILDING_MODEL_ID, client, randomIntegerStringGenerator);
String sampleFloorModelId = UniqueIdHelper.getUniqueMod... | class RelationshipsSyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(randIn... | class RelationshipsSyncSamples {
private static DigitalTwinsClient client;
private static final ObjectMapper mapper = new ObjectMapper();
public static Function<Integer, String> randomIntegerStringGenerator = (maxLength) -> {
int randInt = new Random().nextInt((int)Math.pow(10, 8) - 1) + 1;
return String.valueOf(randIn... |
No retry - that is why we chose this exception vs. GoneException. We don't want retries in this scenario | public RntbdRequestRecord request(final RntbdRequestArgs args) {
this.throwIfClosed();
int concurrentRequestSnapshot = this.concurrentRequests.incrementAndGet();
if (concurrentRequestSnapshot > this.maxConcurrentRequests) {
return FailFastRntbdRequestRecord.createAndFailFast(
args,
concurrentRequestSnapshot,
concurrent... | return FailFastRntbdRequestRecord.createAndFailFast( | public RntbdRequestRecord request(final RntbdRequestArgs args) {
this.throwIfClosed();
int concurrentRequestSnapshot = this.concurrentRequests.incrementAndGet();
if (concurrentRequestSnapshot > this.maxConcurrentRequests) {
try {
return FailFastRntbdRequestRecord.createAndFailFast(
args,
concurrentRequestSnapshot,
metr... | class RntbdServiceEndpoint implements RntbdEndpoint {
private static final String TAG_NAME = RntbdServiceEndpoint.class.getSimpleName();
private static final long QUIET_PERIOD = 2_000_000_000L;
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger... | class RntbdServiceEndpoint implements RntbdEndpoint {
private static final String TAG_NAME = RntbdServiceEndpoint.class.getSimpleName();
private static final long QUIET_PERIOD = 2_000_000_000L;
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger... |
IoT Hub query tests add a buffer or retry to account for any sort of propagation delay between when a twin is created and when query can find it. Does this test pass reliably? | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, asyncClient, randomIntegerStringGenerator);
... | StepVerifier.create(asyncClient.query(queryString, BasicDigitalTwin.class)) | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, asyncClient, randomIntegerStringGenerator);
... | class QueryAsyncTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class QueryAsyncTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
Yes it does. If we see flakiness later we can add some idle time. | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, asyncClient, randomIntegerStringGenerator);
... | StepVerifier.create(asyncClient.query(queryString, BasicDigitalTwin.class)) | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, asyncClient, randomIntegerStringGenerator);
... | class QueryAsyncTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class QueryAsyncTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
You can move the try down until the digital twin is created successfully. If the finally block executes before the digital twin is created, the thrown exception will just be "Failed to delete digital twin" rather than the exception that caused the pre-mature finally block | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId =... | try { | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId =... | class QueryTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class QueryTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
yes, but then if the digitaltwin fails to create it will not get to the finally block that will delete the model ... | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId =... | try { | public void validQuerySucceeds(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) {
DigitalTwinsClient client = getClient(httpClient, serviceVersion);
String floorModelId = UniqueIdHelper.getUniqueModelId(TestAssetDefaults.FLOOR_MODEL_ID_PREFIX, client, randomIntegerStringGenerator);
String roomModelId =... | class QueryTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} | class QueryTests extends QueryTestBase{
private final ClientLogger logger = new ClientLogger(ComponentsTests.class);
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.digitaltwins.core.TestHelper
@Override
} |
Seems just `indexable.id()`? | private Mono<ServicePrincipal> submitRolesAsync(final ServicePrincipal servicePrincipal) {
Mono<ServicePrincipal> create;
if (rolesToCreate.isEmpty()) {
create = Mono.just(servicePrincipal);
} else {
create =
Flux
.fromIterable(rolesToCreate.entrySet())
.flatMap(
roleEntry ->
manager()
.roleAssignments()
.define(this.m... | cachedRoleAssignments.put((indexable).id(), indexable)) | private Mono<ServicePrincipal> submitRolesAsync(final ServicePrincipal servicePrincipal) {
Mono<ServicePrincipal> create;
if (rolesToCreate.isEmpty()) {
create = Mono.just(servicePrincipal);
} else {
create =
Flux
.fromIterable(rolesToCreate.entrySet())
.flatMap(
roleEntry ->
manager()
.roleAssignments()
.define(this.m... | class ServicePrincipalImpl extends CreatableUpdatableImpl<ServicePrincipal, ServicePrincipalInner, ServicePrincipalImpl>
implements ServicePrincipal,
ServicePrincipal.Definition,
ServicePrincipal.Update,
HasCredential<ServicePrincipalImpl> {
private AuthorizationManager manager;
private Map<String, PasswordCredential> ... | class ServicePrincipalImpl extends CreatableUpdatableImpl<ServicePrincipal, ServicePrincipalInner, ServicePrincipalImpl>
implements ServicePrincipal,
ServicePrincipal.Definition,
ServicePrincipal.Update,
HasCredential<ServicePrincipalImpl> {
private AuthorizationManager manager;
private Map<String, PasswordCredential> ... |
Likely this `if` is no longer needed? | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | if (indexable instanceof WebApp) { | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... |
Yes, there are lots of `if` not needed, but I don't want to change so much. | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | if (indexable instanceof WebApp) { | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... |
done | private Mono<ServicePrincipal> submitRolesAsync(final ServicePrincipal servicePrincipal) {
Mono<ServicePrincipal> create;
if (rolesToCreate.isEmpty()) {
create = Mono.just(servicePrincipal);
} else {
create =
Flux
.fromIterable(rolesToCreate.entrySet())
.flatMap(
roleEntry ->
manager()
.roleAssignments()
.define(this.m... | cachedRoleAssignments.put((indexable).id(), indexable)) | private Mono<ServicePrincipal> submitRolesAsync(final ServicePrincipal servicePrincipal) {
Mono<ServicePrincipal> create;
if (rolesToCreate.isEmpty()) {
create = Mono.just(servicePrincipal);
} else {
create =
Flux
.fromIterable(rolesToCreate.entrySet())
.flatMap(
roleEntry ->
manager()
.roleAssignments()
.define(this.m... | class ServicePrincipalImpl extends CreatableUpdatableImpl<ServicePrincipal, ServicePrincipalInner, ServicePrincipalImpl>
implements ServicePrincipal,
ServicePrincipal.Definition,
ServicePrincipal.Update,
HasCredential<ServicePrincipalImpl> {
private AuthorizationManager manager;
private Map<String, PasswordCredential> ... | class ServicePrincipalImpl extends CreatableUpdatableImpl<ServicePrincipal, ServicePrincipalInner, ServicePrincipalImpl>
implements ServicePrincipal,
ServicePrincipal.Definition,
ServicePrincipal.Update,
HasCredential<ServicePrincipalImpl> {
private AuthorizationManager manager;
private Map<String, PasswordCredential> ... |
fixed, it cause spotbugs error | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | if (indexable instanceof WebApp) { | public static boolean runSample(final Azure azure) {
final String suffix = ".azurewebsites.net";
final String app1Name = azure.sdkContext().randomResourceName("webapp1-", 20);
final String app2Name = azure.sdkContext().randomResourceName("webapp2-", 20);
final String app3Name = azure.sdkContex... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... | class ManageWebAppSourceControlAsync {
/**
* Main function which runs the actual sample.
* @param azure instance of the azure client
* @return true if sample runs successfully
*/
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final AzureProfile profile = new Azure... |
I suspect this failure/assertion doesn't have any effect as this is happening on a different thread which is not joined. | public void addressResolutionStatistics() {
CosmosClient client = null;
try {
client = new CosmosClientBuilder()
.endpoint(TestConfigurations.HOST)
.key(TestConfigurations.MASTER_KEY)
.contentResponseOnWriteEnabled(true)
.directMode()
.buildClient();
CosmosContainer container =
client.getDatabase(cosmosAsyncContainer.g... | fail(e.getMessage()); | public void addressResolutionStatistics() {
CosmosClient client1 = null;
CosmosClient client2 = null;
String databaseId = DatabaseForTest.generateId();
String containerId = UUID.randomUUID().toString();
CosmosDatabase cosmosDatabase = null;
CosmosContainer cosmosContainer = null;
try {
client1 = new CosmosClientBuilder... | class CosmosDiagnosticsTest extends TestSuiteBase {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final DateTimeFormatter RESPONSE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss" + ".SSS").withLocale(Locale.US).withZone(ZoneOffset.UTC);
private CosmosClient gat... | class CosmosDiagnosticsTest extends TestSuiteBase {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final DateTimeFormatter RESPONSE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss" + ".SSS").withLocale(Locale.US).withZone(ZoneOffset.UTC);
private CosmosClient gat... |
you don't need to catch exception. and fail. the test will fail regardless of this. if the exception is thrown. | public void addressResolutionStatistics() {
CosmosClient client = null;
try {
client = new CosmosClientBuilder()
.endpoint(TestConfigurations.HOST)
.key(TestConfigurations.MASTER_KEY)
.contentResponseOnWriteEnabled(true)
.directMode()
.buildClient();
CosmosContainer container =
client.getDatabase(cosmosAsyncContainer.g... | fail("This test should not throw exception"); | public void addressResolutionStatistics() {
CosmosClient client1 = null;
CosmosClient client2 = null;
String databaseId = DatabaseForTest.generateId();
String containerId = UUID.randomUUID().toString();
CosmosDatabase cosmosDatabase = null;
CosmosContainer cosmosContainer = null;
try {
client1 = new CosmosClientBuilder... | class CosmosDiagnosticsTest extends TestSuiteBase {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final DateTimeFormatter RESPONSE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss" + ".SSS").withLocale(Locale.US).withZone(ZoneOffset.UTC);
private CosmosClient gat... | class CosmosDiagnosticsTest extends TestSuiteBase {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final DateTimeFormatter RESPONSE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss" + ".SSS").withLocale(Locale.US).withZone(ZoneOffset.UTC);
private CosmosClient gat... |
For the entityPath and hostName values, do we want to update the `ServiceBusSenderAsyncClient` or we should be able to retrieve it some other way? | private Mono<Void> sendInternal(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext) {
if (Objects.isNull(batch)) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
}
final boolean isTracingEnabled = tracerProvider.isEnabled();
final AtomicReference<Context> paren... | .addData(HOST_NAME_KEY, "hostName") | private Mono<Void> sendInternal(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext) {
if (Objects.isNull(batch)) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
}
final boolean isTracingEnabled = tracerProvider.isEnabled();
final AtomicReference<Context> paren... | class ServiceBusSenderAsyncClient implements AutoCloseable {
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final String TRANSACTION_LINK_NAME = "coordinator";
private static final String AZ_TRACING_NAMESPACE_VALUE = ... | class ServiceBusSenderAsyncClient implements AutoCloseable {
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final String TRANSACTION_LINK_NAME = "coordinator";
private static final String AZ_TRACING_NAMESPACE_VALUE = ... |
There is an `entityName` you can use for `entityPath`. I'm sure fullyqualifedDomainName is also exposed in this class. | private Mono<Void> sendInternal(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext) {
if (Objects.isNull(batch)) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
}
final boolean isTracingEnabled = tracerProvider.isEnabled();
final AtomicReference<Context> paren... | .addData(HOST_NAME_KEY, "hostName") | private Mono<Void> sendInternal(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext) {
if (Objects.isNull(batch)) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
}
final boolean isTracingEnabled = tracerProvider.isEnabled();
final AtomicReference<Context> paren... | class ServiceBusSenderAsyncClient implements AutoCloseable {
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final String TRANSACTION_LINK_NAME = "coordinator";
private static final String AZ_TRACING_NAMESPACE_VALUE = ... | class ServiceBusSenderAsyncClient implements AutoCloseable {
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final String TRANSACTION_LINK_NAME = "coordinator";
private static final String AZ_TRACING_NAMESPACE_VALUE = ... |
Isn't null value a bug? Or when is it expected. | public RequestTimeoutException(String message, HttpHeaders headers, SocketAddress remoteAddress) {
super(message,
null,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.REQUEST_TIMEOUT,
remoteAddress != null
? remoteAddress.toString()
: null);
} | remoteAddress != null | public RequestTimeoutException(String message, HttpHeaders headers, SocketAddress remoteAddress) {
super(message,
null,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.REQUEST_TIMEOUT,
remoteAddress != null
? remoteAddress.toString()
: null);
} | class RequestTimeoutException extends CosmosException {
/**
* Instantiates a new Request timeout exception.
*/
public RequestTimeoutException() {
this(RMResources.RequestTimeout, null);
}
/**
* Instantiates a new Request timeout exception.
*
* @param cosmosError the cosmos error
* @param lsn the lsn
* @param partitionK... | class RequestTimeoutException extends CosmosException {
/**
* Instantiates a new Request timeout exception.
*/
public RequestTimeoutException() {
this(RMResources.RequestTimeout, null);
}
/**
* Instantiates a new Request timeout exception.
*
* @param cosmosError the cosmos error
* @param lsn the lsn
* @param partitionK... |
Do upstream retries fail these or retry? (not a blocker now) | public RntbdRequestRecord request(final RntbdRequestArgs args) {
this.throwIfClosed();
int concurrentRequestSnapshot = this.concurrentRequests.incrementAndGet();
if (concurrentRequestSnapshot > this.maxConcurrentRequests) {
return FailFastRntbdRequestRecord.createAndFailFast(
args,
concurrentRequestSnapshot,
concurrent... | return FailFastRntbdRequestRecord.createAndFailFast( | public RntbdRequestRecord request(final RntbdRequestArgs args) {
this.throwIfClosed();
int concurrentRequestSnapshot = this.concurrentRequests.incrementAndGet();
if (concurrentRequestSnapshot > this.maxConcurrentRequests) {
try {
return FailFastRntbdRequestRecord.createAndFailFast(
args,
concurrentRequestSnapshot,
metr... | class RntbdServiceEndpoint implements RntbdEndpoint {
private static final String TAG_NAME = RntbdServiceEndpoint.class.getSimpleName();
private static final long QUIET_PERIOD = 2_000_000_000L;
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger... | class RntbdServiceEndpoint implements RntbdEndpoint {
private static final String TAG_NAME = RntbdServiceEndpoint.class.getSimpleName();
private static final long QUIET_PERIOD = 2_000_000_000L;
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger... |
Not expected - null check here to avoid NPE - and to be consistent with other overloads. So consumers of the RequestTimeoutException have to be aware that it can be null today already. Leaving it as is - please reactivate if you disagree. | public RequestTimeoutException(String message, HttpHeaders headers, SocketAddress remoteAddress) {
super(message,
null,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.REQUEST_TIMEOUT,
remoteAddress != null
? remoteAddress.toString()
: null);
} | remoteAddress != null | public RequestTimeoutException(String message, HttpHeaders headers, SocketAddress remoteAddress) {
super(message,
null,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.REQUEST_TIMEOUT,
remoteAddress != null
? remoteAddress.toString()
: null);
} | class RequestTimeoutException extends CosmosException {
/**
* Instantiates a new Request timeout exception.
*/
public RequestTimeoutException() {
this(RMResources.RequestTimeout, null);
}
/**
* Instantiates a new Request timeout exception.
*
* @param cosmosError the cosmos error
* @param lsn the lsn
* @param partitionK... | class RequestTimeoutException extends CosmosException {
/**
* Instantiates a new Request timeout exception.
*/
public RequestTimeoutException() {
this(RMResources.RequestTimeout, null);
}
/**
* Instantiates a new Request timeout exception.
*
* @param cosmosError the cosmos error
* @param lsn the lsn
* @param partitionK... |
Same here, should we check whether the logger.isDebugEnabled? | private void acquireChannel(final ChannelPromiseWithExpiryTime promise) {
this.ensureInEventLoop();
if (this.isClosed()) {
promise.setFailure(POOL_CLOSED_ON_ACQUIRE);
return;
}
try {
Channel candidate = this.pollChannel();
if (candidate != null) {
doAcquireChannel(promise, candidate);
return;
}
final int channelCount =... | logger.debug("Channel({} --> {}) closed", channel, this.remoteAddress()); | private void acquireChannel(final ChannelPromiseWithExpiryTime promise) {
this.ensureInEventLoop();
if (this.isClosed()) {
promise.setFailure(POOL_CLOSED_ON_ACQUIRE);
return;
}
try {
Channel candidate = this.pollChannel();
if (candidate != null) {
doAcquireChannel(promise, candidate);
return;
}
final int channelCount =... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... | class and should be pulled up to RntbdServiceEndpoint or
this.acquisitionTimeoutInNanos = config.connectionAcquisitionTimeoutInNanos();
this.allocatorMetric = config.allocator().metric();
this.maxChannels = config.maxChannelsPerEndpoint();
this.maxRequestsPerChannel = config.maxRequestsPerChannel();
this.maxPendingAcqu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.