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 |
|---|---|---|---|---|---|
That is definitely another viable options to what I said in another comment. | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
Pinging @JonathanGiles as this will be a common occurrence moving forward as service update and change model types, what is the strategy for handle these scenarios. | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
Added a Javadoc detailing this | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
I don't entirely understand the question. Can someone please provide a bit more context? | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
@JonathanGiles This constructor is technically just there to be used by internal code but needs to be public (since it is used in the base package). The failedHandles parameter was recently added since GA (it will need to go into our next release) and this is the new constructor we use in internal code. Should we dep... | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
One option is: We could use as a general approach for such common occurrence moving forward, is to use Fluent API approach ( using setters returns Model itself ) , ref: https://dev.to/awwsmm/build-a-fluent-interface-in-java-in-less-than-5-minutes-m7e | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | this.failedHandles = 0; | public CloseHandlesInfo(Integer closedHandles) {
this.closedHandles = closedHandles;
this.failedHandles = 0;
} | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
*/
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers o... | class CloseHandlesInfo {
private final Integer closedHandles;
private final Integer failedHandles;
/**
* Creates an instance of information about close handles.
*
* @param closedHandles The numbers of handles closed.
* Note : Failed handles was added as a parameter, default value for failed handles is 0
*/
/**
* Create... |
Sync vs async we need to baseline its impact. | protected void performWorkload(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber, long i) throws InterruptedException {
int index = (int) (i % docsToRead.size());
Document doc = docsToRead.get(index);
String partitionKeyValue = doc.getId();
Mono<CosmosAsyncItemResponse> result = cosmosAsyncContainer.getItem(doc.ge... | concurrencyControlSemaphore.acquire(); | protected void performWorkload(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber, long i) throws InterruptedException {
int index = (int) (i % docsToRead.size());
Document doc = docsToRead.get(index);
String partitionKeyValue = doc.getId();
Mono<CosmosAsyncItemResponse> result = cosmosAsyncContainer.getItem(doc.ge... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber;
LatencySubscriber(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber;
LatencySubscriber(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
... |
Why use fully qualifed instead of importing this? | public void testMSIEndpointWithSystemAssignedAccessKeyVault() throws Exception {
org.junit.Assume.assumeNotNull(CONFIGURATION.get(Configuration.PROPERTY_MSI_ENDPOINT));
org.junit.Assume.assumeTrue(CONFIGURATION.get(Configuration.PROPERTY_AZURE_CLIENT_ID) == null);
org.junit.Assume.assumeNotNull(CONFIGURATION.get(AZURE_... | org.junit.Assume.assumeNotNull(CONFIGURATION.get(Configuration.PROPERTY_MSI_ENDPOINT)); | public void testMSIEndpointWithSystemAssignedAccessKeyVault() throws Exception {
org.junit.Assume.assumeNotNull(CONFIGURATION.get(Configuration.PROPERTY_MSI_ENDPOINT));
org.junit.Assume.assumeTrue(CONFIGURATION.get(Configuration.PROPERTY_AZURE_CLIENT_ID) == null);
org.junit.Assume.assumeNotNull(CONFIGURATION.get(AZURE_... | class ManagedIdentityCredentialLiveTest {
private static final String AZURE_VAULT_URL = "AZURE_VAULT_URL";
private static final String VAULT_SECRET_NAME = "secret";
private static final Configuration CONFIGURATION = Configuration.getGlobalConfiguration().clone();
@Test
public void testMSIEndpointWithSystemAssigned() th... | class ManagedIdentityCredentialLiveTest {
private static final String AZURE_VAULT_URL = "AZURE_VAULT_URL";
private static final String VAULT_SECRET_NAME = "secret";
private static final Configuration CONFIGURATION = Configuration.getGlobalConfiguration().clone();
@Test
public void testMSIEndpointWithSystemAssigned() th... |
sure on my list. | protected void performWorkload(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber, long i) throws InterruptedException {
int index = (int) (i % docsToRead.size());
Document doc = docsToRead.get(index);
String partitionKeyValue = doc.getId();
Mono<CosmosAsyncItemResponse> result = cosmosAsyncContainer.getItem(doc.ge... | concurrencyControlSemaphore.acquire(); | protected void performWorkload(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber, long i) throws InterruptedException {
int index = (int) (i % docsToRead.size());
Document doc = docsToRead.get(index);
String partitionKeyValue = doc.getId();
Mono<CosmosAsyncItemResponse> result = cosmosAsyncContainer.getItem(doc.ge... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber;
LatencySubscriber(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber;
LatencySubscriber(BaseSubscriber<CosmosAsyncItemResponse> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
... |
An empty string seems different than a collection with no items in it (which is what was returned before). Is this correct? It may account for why those JSON files are breaking. | public String getLabelFilter() {
return labelFilter == null ? "" : labelFilter;
} | return labelFilter == null ? "" : labelFilter; | public String getLabelFilter() {
return labelFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Thanks. It should be the reason | public String getLabelFilter() {
return labelFilter == null ? "" : labelFilter;
} | return labelFilter == null ? "" : labelFilter; | public String getLabelFilter() {
return labelFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Is this correct then? | public String getKeyFilter() {
return keyFilter == null ? "" : keyFilter;
} | return keyFilter == null ? "" : keyFilter; | public String getKeyFilter() {
return keyFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Let me double check with the feature team. The label is optional so it could be null. But the key should be required. | public String getKeyFilter() {
return keyFilter == null ? "" : keyFilter;
} | return keyFilter == null ? "" : keyFilter; | public String getKeyFilter() {
return keyFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
In this case, the behaviour is different because you returned an empty set before (nothing in it). But now, you're returning an empty string. Is it possible to have a key with an empty string? If it is possible, then you'll never get a "key is required" message, because users who don't specify a key, will get a configu... | public String getKeyFilter() {
return keyFilter == null ? "" : keyFilter;
} | return keyFilter == null ? "" : keyFilter; | public String getKeyFilter() {
return keyFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
You are right. https://github.com/Azure/AppConfiguration/blob/master/docs/REST/kv.md | public String getKeyFilter() {
return keyFilter == null ? "" : keyFilter;
} | return keyFilter == null ? "" : keyFilter; | public String getKeyFilter() {
return keyFilter;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Add a message when using Objects.requireNonNull or it'll throw a NullPointer with no indication of what happened. Also, update the javadocs with `@throws`. | public SettingSelector setKeyFilter(String keyFilter) {
Objects.requireNonNull(keyFilter);
this.keyFilter = keyFilter;
return this;
} | Objects.requireNonNull(keyFilter); | public SettingSelector setKeyFilter(String keyFilter) {
this.keyFilter = keyFilter;
return this;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Actually, looking at our SDK guidelines, we shouldn't be doing this verification at all and allowing the service to return a bad request. https://azure.github.io/azure-sdk/general_implementation.html#parameter-validation | public SettingSelector setKeyFilter(String keyFilter) {
Objects.requireNonNull(keyFilter);
this.keyFilter = keyFilter;
return this;
} | Objects.requireNonNull(keyFilter); | public SettingSelector setKeyFilter(String keyFilter) {
this.keyFilter = keyFilter;
return this;
} | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... | class SettingSelector {
private String keyFilter;
private String labelFilter;
private SettingFields[] fields;
private String acceptDatetime;
/**
* Creates a setting selector that will populate responses with all of the {@link ConfigurationSetting
* ConfigurationSetting's} properties and select all {@link ConfigurationS... |
Why are we acquiring the lock so early in the `performWorkload`? | protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscriber, long i) throws InterruptedException {
concurrencyControlSemaphore.acquire();
Flux<FeedResponse<Document>> obs;
Random r = new Random();
FeedOptions options = new FeedOptions();
if (configuration.getOperationType() == Configuration.Ope... | concurrencyControlSemaphore.acquire(); | protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscriber, long i) throws InterruptedException {
Flux<FeedResponse<Document>> obs;
Random r = new Random();
FeedOptions options = new FeedOptions();
if (configuration.getOperationType() == Configuration.Operation.QueryCross) {
int index = r.next... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<T> baseSubscriber;
LatencySubscriber(BaseSubscriber<T> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
super.hookOnSubscribe(subscription);
}
@Over... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<T> baseSubscriber;
LatencySubscriber(BaseSubscriber<T> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
super.hookOnSubscribe(subscription);
}
@Over... |
sure, moved down. DONE | protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscriber, long i) throws InterruptedException {
concurrencyControlSemaphore.acquire();
Flux<FeedResponse<Document>> obs;
Random r = new Random();
FeedOptions options = new FeedOptions();
if (configuration.getOperationType() == Configuration.Ope... | concurrencyControlSemaphore.acquire(); | protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscriber, long i) throws InterruptedException {
Flux<FeedResponse<Document>> obs;
Random r = new Random();
FeedOptions options = new FeedOptions();
if (configuration.getOperationType() == Configuration.Operation.QueryCross) {
int index = r.next... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<T> baseSubscriber;
LatencySubscriber(BaseSubscriber<T> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
super.hookOnSubscribe(subscription);
}
@Over... | class LatencySubscriber<T> extends BaseSubscriber<T> {
Timer.Context context;
BaseSubscriber<T> baseSubscriber;
LatencySubscriber(BaseSubscriber<T> baseSubscriber) {
this.baseSubscriber = baseSubscriber;
}
@Override
protected void hookOnSubscribe(Subscription subscription) {
super.hookOnSubscribe(subscription);
}
@Over... |
does it really starts a span? we'll start another one somewhere later - why do we need two? | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | Context sharedContext = isTracingEnabled ? tracerProvider.startSpan(parentContext.get(), ProcessKind.LINK) : | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
will this span reuse span builder we created before? | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | return messages.size() == 1 | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
Any particular reason to use 100_000 ? | private int fluxSequentialMergePrefetch(FeedOptions options, int numberOfPartitions, int pageSize, int fluxConcurrency) {
int maxBufferedItemCount = options.getMaxBufferedItemCount();
if (maxBufferedItemCount <= 0) {
maxBufferedItemCount = Math.min(Configs.CPU_CNT * numberOfPartitions * pageSize, 100_000);
}
int fluxPr... | maxBufferedItemCount = Math.min(Configs.CPU_CNT * numberOfPartitions * pageSize, 100_000); | private int fluxSequentialMergePrefetch(FeedOptions options, int numberOfPartitions, int pageSize, int fluxConcurrency) {
int maxBufferedItemCount = options.getMaxBufferedItemCount();
if (maxBufferedItemCount <= 0) {
maxBufferedItemCount = Math.min(Configs.getCPUCnt() * numberOfPartitions * pageSize, 100_000);
}
int fl... | class EmptyPagesFilterTransformer<T extends Resource>
implements Function<Flux<DocumentProducer<T>.DocumentProducerFeedResponse>, Flux<FeedResponse<T>>> {
private final RequestChargeTracker tracker;
private DocumentProducer<T>.DocumentProducerFeedResponse previousPage;
public EmptyPagesFilterTransformer(
RequestChargeT... | class EmptyPagesFilterTransformer<T extends Resource>
implements Function<Flux<DocumentProducer<T>.DocumentProducerFeedResponse>, Flux<FeedResponse<T>>> {
private final RequestChargeTracker tracker;
private DocumentProducer<T>.DocumentProducerFeedResponse previousPage;
public EmptyPagesFilterTransformer(
RequestChargeT... |
yes, the sharedContext on [this](https://github.com/Azure/azure-sdk-for-java/pull/6773/files#diff-afcf12d6b6264dbb96ae63baef89082dR402) line, should get us the span builder returned by the `ProcessKind.LINK`. | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | return messages.size() == 1 | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
no, it will just return a span builder created with "Azure.eventhubs.send" name. This one is just to get the builder that needs to be used for linking. Wanted to keep the naming consistent with the other methods and so used an existing one. | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | Context sharedContext = isTracingEnabled ? tracerProvider.startSpan(parentContext.get(), ProcessKind.LINK) : | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
I see. I understand the intention to stay in the existing public API boundaries, but it seems to be very misleading. startSpan sometimes start span, sometimes just creates a builder in the context: it's completely custom behavior for each kind. It seems very hard to read and maintain. Also I believe it makes almost im... | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | Context sharedContext = isTracingEnabled ? tracerProvider.startSpan(parentContext.get(), ProcessKind.LINK) : | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
should we rather just add a new method `getSpanBuilder(Span name)` instead? | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | Context sharedContext = isTracingEnabled ? tracerProvider.startSpan(parentContext.get(), ProcessKind.LINK) : | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
would it be better to throw an UnsupportedOperationException rather than return something that won't work? | public Context getSharedSpanBuilder(String spanName, Context context) {
return Context.NONE;
} | } | public Context getSharedSpanBuilder(String spanName, Context context) {
throw logger.logExceptionAsError(
new UnsupportedOperationException("This operation is not supported in OpenCensus"));
} | class OpenCensusTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = Tracing.getTracer();
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPOINT = "peer.address";
private final ClientL... | class OpenCensusTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = Tracing.getTracer();
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPOINT = "peer.address";
private final ClientL... |
this is an odd indent level | public void startSpanProcessKindSend() {
final SpanId parentSpanId = parentSpan.getContext().getSpanId();
final Span.Builder spanBuilder = tracer.spanBuilder(METHOD_NAME);
final Context traceContext = tracingContext.addData(ENTITY_PATH_KEY, ENTITY_PATH_VALUE)
.addData(HOST_NAME_KEY, HOSTNAME_VALUE).addData(SPAN_BUILDER... | .addData(HOST_NAME_KEY, HOSTNAME_VALUE).addData(SPAN_BUILDER_KEY, spanBuilder); | public void startSpanProcessKindSend() {
final SpanId parentSpanId = parentSpan.getContext().getSpanId();
final Span.Builder spanBuilder = tracer.spanBuilder(METHOD_NAME);
final Context traceContext = tracingContext.addData(ENTITY_PATH_KEY, ENTITY_PATH_VALUE)
.addData(HOST_NAME_KEY, HOSTNAME_VALUE).addData(SPAN_BUILDER... | class OpenTelemetryTracerTest {
private static final String METHOD_NAME = "Azure.eventhubs.send";
private static final String HOSTNAME_VALUE = "testEventDataNameSpace.servicebus.windows.net";
private static final String ENTITY_PATH_VALUE = "test";
private static final String COMPONENT_VALUE = "eventhubs";
private OpenT... | class OpenTelemetryTracerTest {
private static final String METHOD_NAME = "EventHubs.send";
private static final String HOSTNAME_VALUE = "testEventDataNameSpace.servicebus.windows.net";
private static final String ENTITY_PATH_VALUE = "test";
private static final String COMPONENT_VALUE = "EventHubs";
private OpenTelemet... |
this indentation is off | public Mono<EventDataBatch> createBatch(CreateBatchOptions options) {
if (options == null) {
return monoError(logger, new NullPointerException("'options' cannot be null."));
}
final String partitionKey = options.getPartitionKey();
final String partitionId = options.getPartitionId();
final int batchMaxSize = options.get... | final int maximumLinkSize = size > 0 | public Mono<EventDataBatch> createBatch(CreateBatchOptions options) {
if (options == null) {
return monoError(logger, new NullPointerException("'options' cannot be null."));
}
final String partitionKey = options.getPartitionKey();
final String partitionId = options.getPartitionId();
final int batchMaxSize = options.get... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
Consider using a `for` loop rather than the `stream().map()` so you don't need the "isFirst" variable and the parentContext and sharedContext do not have to be atomicreferences. | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | if (!CoreUtils.isNullOrEmpty(partitionKey)) { | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
I don't think we can avoid the `isFirst` because we don't want to send the request to `getSharedSpanBuilder` for every event, we can just do that for one event and use that shared builder for all others. Also, `parentContext ` would still have to be an AtomicReference as it is used [here](https://github.com/Azure/az... | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | if (!CoreUtils.isNullOrEmpty(partitionKey)) { | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
You'll have to throw this so you don't need to return context.none | public Context getSharedSpanBuilder(String spanName, Context context) {
logger.logExceptionAsError(
new UnsupportedOperationException("This operation is not supported in OpenCensus"));
return Context.NONE;
} | logger.logExceptionAsError( | public Context getSharedSpanBuilder(String spanName, Context context) {
throw logger.logExceptionAsError(
new UnsupportedOperationException("This operation is not supported in OpenCensus"));
} | class OpenCensusTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = Tracing.getTracer();
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPOINT = "peer.address";
private final ClientL... | class OpenCensusTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = Tracing.getTracer();
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPOINT = "peer.address";
private final ClientL... |
I'm fairly confident this works: ```java Context parentContext = null; Context sharedContext = null; List<Message> messages = new ArrayList<>(); for (int = 0; i < batch.getEvents().size(); i++) { final EventData = batch.getEvents().get(i); if (isTracingEnabled) { parentContext = event.getContext(); ... | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | if (!CoreUtils.isNullOrEmpty(partitionKey)) { | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
We are using sharedContext and parentContext in the lambda expressions below and so they need to be `effectively final`. | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | if (!CoreUtils.isNullOrEmpty(partitionKey)) { | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
Should this instantiate a new `DataLakeRequestConditions`? I'm seeing other places which instantiate instead of leaving it as `null`. | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = null;
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null, requestConditions, null, C... | DataLakeRequestConditions requestConditions = null; | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions();
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null,... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... |
Oh whoops thanks for catching that | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = null;
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null, requestConditions, null, C... | DataLakeRequestConditions requestConditions = null; | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions();
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null,... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... |
Done | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = null;
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null, requestConditions, null, C... | DataLakeRequestConditions requestConditions = null; | public PathInfo flush(long position, boolean overwrite) {
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions();
if (!overwrite) {
requestConditions = new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
}
return flushWithResponse(position, false, false, null,... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... | class DataLakeFileClient extends DataLakePathClient {
private final ClientLogger logger = new ClientLogger(DataLakeFileClient.class);
private final DataLakeFileAsyncClient dataLakeFileAsyncClient;
DataLakeFileClient(DataLakeFileAsyncClient pathAsyncClient, BlockBlobClient blockBlobClient) {
super(pathAsyncClient, block... |
for the sake of having the same naming format as other Azure SDKs, can we use '.' as a separator everywhere? E.g. 'Appconfig.getKey' rather than 'Appconfig/getKey' | private Context startTracingSpan(Method method, Context context) {
String spanName = String.format("%s/%s", interfaceParser.getServiceName(), method.getName());
context = TracerProxy.setSpanName(spanName, context);
return TracerProxy.start(spanName, context);
} | String spanName = String.format("%s/%s", interfaceParser.getServiceName(), method.getName()); | private Context startTracingSpan(Method method, Context context) {
String spanName = String.format("%s.%s", interfaceParser.getServiceName(), method.getName());
context = TracerProxy.setSpanName(spanName, context);
return TracerProxy.start(spanName, context);
} | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
private final Respon... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
private final Respon... |
this should be logged properly. in Certificate Properties too. | void unpackId(String id) {
if (id != null && id.length() > 0) {
this.id = id;
try {
URL url = new URL(id);
String[] tokens = url.getPath().split("/");
this.vaultUrl = (tokens.length >= 1 ? tokens[1] : null);
this.name = (tokens.length >= 3 ? tokens[2] : null);
} catch (MalformedURLException e) {
e.printStackTrace();
}
... | e.printStackTrace(); | void unpackId(String id) {
if (id != null && id.length() > 0) {
this.id = id;
try {
URL url = new URL(id);
String[] tokens = url.getPath().split("/");
this.vaultUrl = (tokens.length >= 2 ? tokens[1] : null);
this.name = (tokens.length >= 3 ? tokens[2] : null);
} catch (MalformedURLException e) {
throw logger.logExcepti... | class CertificateOperation {
/**
* URL for the Azure KeyVault service.
*/
private String vaultUrl;
/**
* The Certificate name.
*/
private String name;
/**
* The certificate id.
*/
@JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY)
private String id;
/**
* Name of the referenced issuer object or reserv... | class CertificateOperation {
private final ClientLogger logger = new ClientLogger(CertificateOperation.class);
/**
* URL for the Azure KeyVault service.
*/
private String vaultUrl;
/**
* The Certificate name.
*/
private String name;
/**
* The certificate id.
*/
@JsonProperty(value = "id", access = JsonProperty.Access.W... |
tokens.length >= 2 ? ..... | void unpackId(String id) {
if (id != null && id.length() > 0) {
this.id = id;
try {
URL url = new URL(id);
String[] tokens = url.getPath().split("/");
this.vaultUrl = (tokens.length >= 1 ? tokens[1] : null);
this.name = (tokens.length >= 3 ? tokens[2] : null);
this.version = (tokens.length >= 4 ? tokens[3] : null);
} c... | this.vaultUrl = (tokens.length >= 1 ? tokens[1] : null); | void unpackId(String id) {
if (id != null && id.length() > 0) {
this.id = id;
try {
URL url = new URL(id);
String[] tokens = url.getPath().split("/");
this.vaultUrl = (tokens.length >= 2 ? tokens[1] : null);
this.name = (tokens.length >= 3 ? tokens[2] : null);
this.version = (tokens.length >= 4 ? tokens[3] : null);
} c... | class CertificateProperties {
/**
* URL for the Azure KeyVault service.
*/
private String vaultUrl;
/**
* Determines whether the object is enabled.
*/
private Boolean enabled;
/**
* Not before date in UTC.
*/
private OffsetDateTime notBefore;
/**
* The certificate version.
*/
String version;
/**
* Expiry date in UTC.
*... | class CertificateProperties {
private final ClientLogger logger = new ClientLogger(CertificateProperties.class);
/**
* URL for the Azure KeyVault service.
*/
private String vaultUrl;
/**
* Determines whether the object is enabled.
*/
private Boolean enabled;
/**
* Not before date in UTC.
*/
private OffsetDateTime notBe... |
This is kind of heuristic but general idea is that if there are 100_000 documents of size 1KB, that means 100_000*1KB=100MB in memory which will start to put pressure on memory if we go beyond that. | private int fluxSequentialMergePrefetch(FeedOptions options, int numberOfPartitions, int pageSize, int fluxConcurrency) {
int maxBufferedItemCount = options.getMaxBufferedItemCount();
if (maxBufferedItemCount <= 0) {
maxBufferedItemCount = Math.min(Configs.CPU_CNT * numberOfPartitions * pageSize, 100_000);
}
int fluxPr... | maxBufferedItemCount = Math.min(Configs.CPU_CNT * numberOfPartitions * pageSize, 100_000); | private int fluxSequentialMergePrefetch(FeedOptions options, int numberOfPartitions, int pageSize, int fluxConcurrency) {
int maxBufferedItemCount = options.getMaxBufferedItemCount();
if (maxBufferedItemCount <= 0) {
maxBufferedItemCount = Math.min(Configs.getCPUCnt() * numberOfPartitions * pageSize, 100_000);
}
int fl... | class EmptyPagesFilterTransformer<T extends Resource>
implements Function<Flux<DocumentProducer<T>.DocumentProducerFeedResponse>, Flux<FeedResponse<T>>> {
private final RequestChargeTracker tracker;
private DocumentProducer<T>.DocumentProducerFeedResponse previousPage;
public EmptyPagesFilterTransformer(
RequestChargeT... | class EmptyPagesFilterTransformer<T extends Resource>
implements Function<Flux<DocumentProducer<T>.DocumentProducerFeedResponse>, Flux<FeedResponse<T>>> {
private final RequestChargeTracker tracker;
private DocumentProducer<T>.DocumentProducerFeedResponse previousPage;
public EmptyPagesFilterTransformer(
RequestChargeT... |
this should be return Mono.error(logger.logExceptionAsError(new Exception("Azure CL...... Would like to use a better exception class instead of just Exception. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | throw new Exception("Azure CLI not installed"); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
same here, return Mono.error(logger.logExceptionAsError(new Exception(..... Would like to use a better exception class instead of just Exception. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | throw new Exception(processOutput); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Is there a way to test opening a browser? | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | rt.exec("xdg-open " + url); | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... |
Okay, so, its being caught here. better to add here, Mono.error(logger.logExceptionAsError(e)), logger can be used from azure core | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | return Mono.error(e); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
This reader must be closed after use. Also, change name to `reader` instead of using a single char. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Use `process` instead of `p`. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | Process p = builder.start(); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Use string constants here. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | if(line.startsWith("'az' is not recognized") || line.matches("(.*)az:(.*)not found")) { | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Use string constants. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | starter = "cmd.exe"; | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
In the method `openUrl` of class `IdentityClient`, doing similar things with string, didn't use constants. Is it better to follow that way? | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | starter = "cmd.exe"; | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
In the method `openUrl` of class `IdentityClient`, doing similar things with string, didn't use constants. Is it better to follow that way? | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | if(line.startsWith("'az' is not recognized") || line.matches("(.*)az:(.*)not found")) { | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
I would suggest creating `private static final String WINDOWS_STARTER = "cmd.exe"` and then use `starter = WINDOWS_STARTER` here. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | starter = "cmd.exe"; | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
same as above. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | if(line.startsWith("'az' is not recognized") || line.matches("(.*)az:(.*)not found")) { | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Close should be done in `finally` block or use try-with-resources. | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | reader.close(); | public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
String azCommand = "az account get-access-token --output json --resource ";
StringBuilder command = new StringBuilder();
command.append(azCommand);
String scopes = ScopeUtil.scopesToResource(request.getScopes());
command.append(scopes);
Ac... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Probably should just print `The lease has been successfully broken.` given that they break immediately and are infinite so there is no remaining time on it. | public void breakLeaseWithResponseCodeSnippets() {
client.breakLeaseWithResponse().subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
} | System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue())); | public void breakLeaseWithResponseCodeSnippets() {
client.breakLeaseWithResponse().subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
} | class LeaseAsyncClientJavaDocCodeSnippets {
private ShareLeaseAsyncClient client = new ShareLeaseClientBuilder()
.fileAsyncClient(new ShareFileClientBuilder().resourcePath("file").buildFileAsyncClient())
.buildAsyncClient();
/**
* Code snippets for {@link ShareLeaseAsyncClient
*/
public void acquireLeaseCodeSnippet() {... | class LeaseAsyncClientJavaDocCodeSnippets {
private ShareLeaseAsyncClient client = new ShareLeaseClientBuilder()
.fileAsyncClient(new ShareFileClientBuilder().resourcePath("file").buildFileAsyncClient())
.buildAsyncClient();
/**
* Code snippets for {@link ShareLeaseAsyncClient
*/
public void acquireLeaseCodeSnippet() {... |
Same as the other codesnippet | public void breakLeaseCodeSnippet() {
client.breakLease().subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response));
} | System.out.printf("The broken lease has %d seconds remaining on the lease", response)); | public void breakLeaseCodeSnippet() {
client.breakLease().subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response));
} | class LeaseAsyncClientJavaDocCodeSnippets {
private ShareLeaseAsyncClient client = new ShareLeaseClientBuilder()
.fileAsyncClient(new ShareFileClientBuilder().resourcePath("file").buildFileAsyncClient())
.buildAsyncClient();
/**
* Code snippets for {@link ShareLeaseAsyncClient
*/
public void acquireLeaseCodeSnippet() {... | class LeaseAsyncClientJavaDocCodeSnippets {
private ShareLeaseAsyncClient client = new ShareLeaseClientBuilder()
.fileAsyncClient(new ShareFileClientBuilder().resourcePath("file").buildFileAsyncClient())
.buildAsyncClient();
/**
* Code snippets for {@link ShareLeaseAsyncClient
*/
public void acquireLeaseCodeSnippet() {... |
Probably should have a print statement similar to the `breakLease` codesnippet in this file. | public void breakLeaseWithResponseCodeSnippets() {
client.breakLeaseWithResponse(timeout, new Context(key, value));
} | client.breakLeaseWithResponse(timeout, new Context(key, value)); | public void breakLeaseWithResponseCodeSnippets() {
client.breakLeaseWithResponse(timeout, new Context(key, value));
} | class LeaseClientJavaDocCodeSnippets {
private ShareLeaseClient client = new ShareLeaseClientBuilder()
.fileClient(new ShareFileClientBuilder().resourcePath("file").buildFileClient())
.buildClient();
private Duration timeout = Duration.ofSeconds(30);
private String key = "key";
private String value = "value";
/**
* Cod... | class LeaseClientJavaDocCodeSnippets {
private ShareLeaseClient client = new ShareLeaseClientBuilder()
.fileClient(new ShareFileClientBuilder().resourcePath("file").buildFileClient())
.buildClient();
private Duration timeout = Duration.ofSeconds(30);
private String key = "key";
private String value = "value";
/**
* Cod... |
of non-localized String.toUpperCase() or String.toLowerCase() in com.azure.identity.implementation.IdentityClient.openUrl(String) [com.azure.identity.implementation.IdentityClient] At IdentityClient.java:[line 497] DM_CONVERT_CASE | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("nix") || os... | String os = System.getProperty("os.name").toLowerCase(); | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... |
Changed to `toLowerCase(Locale.ROOT)` | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("nix") || os... | String os = System.getProperty("os.name").toLowerCase(); | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... |
we need to look into finding a way to write and automate tests for these platform specific commands and browser end result. | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | rt.exec("xdg-open " + url); | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... |
JUnit offers attributes which can perform per test prerequisites, could look into that. https://keyholesoftware.com/2018/02/12/disabling-filtering-tests-junit-5/ | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | rt.exec("xdg-open " + url); | private void openUrl(String url) throws IOException {
Runtime rt = Runtime.getRuntime();
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("win")) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.contains("mac")) {
rt.exec("open " + url);
} else if (os.contains("... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(IdentityClient.class);
private final IdentityClientOptions options;
private final Pu... |
This should be logged as well. Use the monoError() helper method in FluxUtil instead. | Mono<BlobBatchOperationInfo> prepareBlobBatchSubmission() {
if (batchOperationQueue.isEmpty()) {
return Mono.error(new UnsupportedOperationException("Empty batch requests aren't allowed."));
}
BlobBatchOperationInfo operationInfo = new BlobBatchOperationInfo();
Deque<BlobBatchOperation<?>> operations = batchOperationQu... | return Mono.error(new UnsupportedOperationException("Empty batch requests aren't allowed.")); | Mono<BlobBatchOperationInfo> prepareBlobBatchSubmission() {
if (batchOperationQueue.isEmpty()) {
return monoError(logger, new UnsupportedOperationException("Empty batch requests aren't allowed."));
}
BlobBatchOperationInfo operationInfo = new BlobBatchOperationInfo();
Deque<BlobBatchOperation<?>> operations = batchOper... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String BATCH_OPERATION_RESPONSE = "Batch-Operation-Response";
private static final String BATCH_OPERATION_INFO = "Batch-Operation-Info";
privat... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String BATCH_OPERATION_RESPONSE = "Batch-Operation-Response";
private static final String BATCH_OPERATION_INFO = "Batch-Operation-Info";
privat... |
Is this done to reuse the BlobBatch object? If so, I am not sure if it's obvious to the user that a single instance of BlobBatch can be reused after each submission. Maybe adding documentation to `submitBatchWithResponse` will make this clear. The other option is to use this instance just once per submission and a ne... | Mono<BlobBatchOperationInfo> prepareBlobBatchSubmission() {
if (batchOperationQueue.isEmpty()) {
return Mono.error(new UnsupportedOperationException("Empty batch requests aren't allowed."));
}
BlobBatchOperationInfo operationInfo = new BlobBatchOperationInfo();
Deque<BlobBatchOperation<?>> operations = batchOperationQu... | batchOperationQueue = new ConcurrentLinkedDeque<>(); | Mono<BlobBatchOperationInfo> prepareBlobBatchSubmission() {
if (batchOperationQueue.isEmpty()) {
return monoError(logger, new UnsupportedOperationException("Empty batch requests aren't allowed."));
}
BlobBatchOperationInfo operationInfo = new BlobBatchOperationInfo();
Deque<BlobBatchOperation<?>> operations = batchOper... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String BATCH_OPERATION_RESPONSE = "Batch-Operation-Response";
private static final String BATCH_OPERATION_INFO = "Batch-Operation-Info";
privat... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String BATCH_OPERATION_RESPONSE = "Batch-Operation-Response";
private static final String BATCH_OPERATION_INFO = "Batch-Operation-Info";
privat... |
Add a comment as to why this header is filtered. | void addBatchOperation(BlobBatchOperationResponse<?> batchOperation, HttpRequest request) {
int contentId = this.contentId.getAndIncrement();
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNewline(batchRequestBuilder, BATCH_OPERATION_CONT... | .filter(header -> !X_MS_VERSION.equalsIgnoreCase(header.getName())) | void addBatchOperation(BlobBatchOperationResponse<?> batchOperation, HttpRequest request) {
int contentId = this.contentId.getAndIncrement();
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNewline(batchRequestBuilder, BATCH_OPERATION_CONT... | class BlobBatchOperationInfo {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_BOUNDARY_TEMPLATE = "batch_%s";
private static final String REQUEST_CONTENT_TYPE_TEMPLATE = "multipart/mixed; boundary=%s";
private static final String BATCH_OPERATION_CONTENT_TYPE = "Content-Type... | class BlobBatchOperationInfo {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_BOUNDARY_TEMPLATE = "batch_%s";
private static final String REQUEST_CONTENT_TYPE_TEMPLATE = "multipart/mixed; boundary=%s";
private static final String BATCH_OPERATION_CONTENT_TYPE = "Content-Type... |
Should we add a message to this RuntimeException before bubbling it up? Could be useful because often the first thing I do is "Ctrl+F" for the message in code. There is another instance. | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionCont... | throw logger.logExceptionAsError(new RuntimeException(throwable)); | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionCont... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... |
Added message to both exceptions. | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionCont... | throw logger.logExceptionAsError(new RuntimeException(throwable)); | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionCont... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... |
Curious why we are collecting these into a list? it only emits when the flux is complete. | private Mono<Void> loadBalance(final Tuple2<Map<String, PartitionOwnership>, List<String>> tuple) {
return Mono.fromRunnable(() -> {
logger.info("Starting load balancer");
Map<String, PartitionOwnership> partitionOwnershipMap = tuple.getT1();
List<String> partitionIds = tuple.getT2();
if (CoreUtils.isNullOrEmpty(partit... | .collect(Collectors.toList())) | private Mono<Void> loadBalance(final Tuple2<Map<String, PartitionOwnership>, List<String>> tuple) {
return Mono.fromRunnable(() -> {
logger.info("Starting load balancer");
Map<String, PartitionOwnership> partitionOwnershipMap = tuple.getT1();
List<String> partitionIds = tuple.getT2();
if (CoreUtils.isNullOrEmpty(partit... | class PartitionBasedLoadBalancer {
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(PartitionBasedLoadBalancer.class);
private final String eventHubName;
private final String consumerGroupName;
private final CheckpointStore checkpointStore;
private final EventHubAs... | class PartitionBasedLoadBalancer {
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(PartitionBasedLoadBalancer.class);
private final String eventHubName;
private final String consumerGroupName;
private final CheckpointStore checkpointStore;
private final EventHubAs... |
`checkpointStore.claimOwnership()` method takes a list of partition ownership instances. | private Mono<Void> loadBalance(final Tuple2<Map<String, PartitionOwnership>, List<String>> tuple) {
return Mono.fromRunnable(() -> {
logger.info("Starting load balancer");
Map<String, PartitionOwnership> partitionOwnershipMap = tuple.getT1();
List<String> partitionIds = tuple.getT2();
if (CoreUtils.isNullOrEmpty(partit... | .collect(Collectors.toList())) | private Mono<Void> loadBalance(final Tuple2<Map<String, PartitionOwnership>, List<String>> tuple) {
return Mono.fromRunnable(() -> {
logger.info("Starting load balancer");
Map<String, PartitionOwnership> partitionOwnershipMap = tuple.getT1();
List<String> partitionIds = tuple.getT2();
if (CoreUtils.isNullOrEmpty(partit... | class PartitionBasedLoadBalancer {
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(PartitionBasedLoadBalancer.class);
private final String eventHubName;
private final String consumerGroupName;
private final CheckpointStore checkpointStore;
private final EventHubAs... | class PartitionBasedLoadBalancer {
private static final Random RANDOM = new Random();
private final ClientLogger logger = new ClientLogger(PartitionBasedLoadBalancer.class);
private final String eventHubName;
private final String consumerGroupName;
private final CheckpointStore checkpointStore;
private final EventHubAs... |
since you are refactoring switch ` statistics.getErroneousDocumentsCount()` and `statistics.getValidDocumentsCount()` will resolve this issue #7072 I found while writing samples. | static TextDocumentBatchStatistics toBatchStatistics(RequestStatistics statistics) {
return new TextDocumentBatchStatistics(statistics.getDocumentsCount(), statistics.getErroneousDocumentsCount(),
statistics.getValidDocumentsCount(), statistics.getTransactionsCount());
} | return new TextDocumentBatchStatistics(statistics.getDocumentsCount(), statistics.getErroneousDocumentsCount(), | static TextDocumentBatchStatistics toBatchStatistics(RequestStatistics statistics) {
return new TextDocumentBatchStatistics(statistics.getDocumentsCount(), statistics.getValidDocumentsCount(),
statistics.getErroneousDocumentsCount(), statistics.getTransactionsCount());
} | class Transforms {
/**
* Given a list of inputs will apply the indexing function to it and return the updated list.
*
* @param textInputs the inputs to apply the mapping function to.
* @param mappingFunction the function which applies the index to the incoming input value.
* @param <T> the type of items being returned ... | class Transforms {
/**
* Given a list of inputs will apply the indexing function to it and return the updated list.
*
* @param textInputs the inputs to apply the mapping function to.
* @param mappingFunction the function which applies the index to the incoming input value.
* @param <T> the type of items being returned ... |
Surprisingly, it turns out the service actually will accept `x-ms-client-request-id` if `client-request-id` is not provided. This must be a case of the service having changed after this part of the Track 1 .NET SDK was written. We can remove this special case whenever is convenient (perhaps before GA). | public SearchIndexAsyncClient buildAsyncClient() {
policies.add(new AddHeadersPolicy(headers));
policies.add(new RequestIdPolicy("client-request-id"));
policies.add(new AddDatePolicy());
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy);
HttpPolicy... | policies.add(new RequestIdPolicy("client-request-id")); | public SearchIndexAsyncClient buildAsyncClient() {
policies.add(new AddHeadersPolicy(headers));
policies.add(new RequestIdPolicy("client-request-id"));
policies.add(new AddDatePolicy());
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy);
HttpPolicy... | class SearchIndexClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String SEARCH_PROPERTIES = "azure-search.properties";
private static final String NAME = "name";
private static final String VERSION = "version";
SearchApiKeyCredential searchApiKe... | class SearchIndexClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String SEARCH_PROPERTIES = "azure-search.properties";
private static final String NAME = "name";
private static final String VERSION = "version";
SearchApiKeyCredential searchApiKe... |
I liked the other one better. It shows an example of how it should look. | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResu... | .endpoint("<replace-with-your-text-analytics-endpoint-here>") | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResult sentimentResult = client.analyzeSentiment(text);
final TextSentime... | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze sentiment of a text input.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze the sentiment of an input text.
*
* @param args Unused arguments to the program.
*/
} |
what about this ``` .subscriptionKey("{subscription_key}") .endpoint("https://{servicename}.cognitiveservices.azure.com/") ``` | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResu... | .endpoint("<replace-with-your-text-analytics-endpoint-here>") | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResult sentimentResult = client.analyzeSentiment(text);
final TextSentime... | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze sentiment of a text input.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze the sentiment of an input text.
*
* @param args Unused arguments to the program.
*/
} |
Works for me | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResu... | .endpoint("<replace-with-your-text-analytics-endpoint-here>") | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
String text = "The hotel was dark and unclean.";
final AnalyzeSentimentResult sentimentResult = client.analyzeSentiment(text);
final TextSentime... | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze sentiment of a text input.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentiment {
/**
* Main method to invoke this demo about how to analyze the sentiment of an input text.
*
* @param args Unused arguments to the program.
*/
} |
You don't need to allocate a variable for this. `for (TextSentiment textSentiment : result.getSentenceSentiments()) {` would work since you only reference it once. | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildAsyncClient();
String text = "The hotel was dark and unclean.";
client.analyzeSe... | final List<TextSentiment> sentiments = result.getSentenceSentiments(); | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildAsyncClient();
String text = "The hotel was dark and unclean.";
client.analyzeSentiment(text).subscribe(
result -> {
final TextSentiment documentSent... | class AnalyzeSentimentAsync {
/**
* Main method to invoke this demo about how to analyze sentiment of a text input.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentimentAsync {
/**
* Main method to invoke this demo about how to analyze the sentiment of an input text.
*
* @param args Unused arguments to the program.
*/
} |
That seems like an odd way to check for error. I thought you had a `hasError()` method? | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentI... | if (documentSentiment == null) { | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", "The hotel was dark and unclean. The restaurant had amazing... | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze sentiment of a batch of text inputs.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze the sentiments of a batch input text.
*
* @param args Unused arguments to the program.
*/
} |
Do you use the response headers? I think for samples, we should show use-cases we expect the general populace to use.... analzeBatchSentiment() would be my usual use-case. | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentI... | client.analyzeBatchSentimentWithResponse(inputs, requestOptions).subscribe( | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", "The hotel was dark and unclean. The restaurant had amazing... | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze sentiment of a batch of text inputs.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze the sentiments of a batch input text.
*
* @param args Unused arguments to the program.
*/
} |
I'd reconsider the WithResponse calls. I thought we added this to encompass all use-cases, but I don't expect usual devs to care about the HTTP response. | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", ... | final DocumentResultCollection<ExtractKeyPhraseResult> extractedBatchResult = client.extractBatchKeyPhrasesWithResponse(inputs, requestOptions, Context.NONE).getValue(); | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", "My cat might need to see a veterinarian.", "en"),
new TextDocumentIn... | class ExtractKeyPhrasesBatchDocuments {
/**
* Main method to invoke this demo about how to extract key phrases of a batch of text inputs.
*
* @param args Unused arguments to the program.
*/
} | class ExtractKeyPhrasesBatchDocuments {
/**
* Main method to invoke this demo about how to extract the key phrases of a batch input text.
*
* @param args Unused arguments to the program.
*/
} |
nit: can we call this variable `detectedPrimaryLanguage` | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
String text = "hello world";
final DetectLanguageResult detectLanguageResul... | final DetectedLanguage detectedDocumentLanguage = detectLanguageResult.getPrimaryLanguage(); | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
String text = "hello world";
final DetectLanguageResult detectLanguageResult = client.detectLanguage(text, "US");
final DetectedLanguage detecte... | class HelloWorld {
/**
* Main method to invoke this demo about how to detect language of a text input.
*
* @param args Unused arguments to the program.
*/
} | class HelloWorld {
/**
* Main method to invoke this demo about how to detect the language of an input text.
*
* @param args Unused arguments to the program.
*/
} |
Currently, we don't have `analyzeBatchSentiment(inputs, requestOptions)` API. So we will add one if needed | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentI... | client.analyzeBatchSentimentWithResponse(inputs, requestOptions).subscribe( | public static void main(String[] args) {
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildAsyncClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", "The hotel was dark and unclean. The restaurant had amazing... | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze sentiment of a batch of text inputs.
*
* @param args Unused arguments to the program.
*/
} | class AnalyzeSentimentBatchDocumentsAsync {
/**
* Main method to invoke this demo about how to analyze the sentiments of a batch input text.
*
* @param args Unused arguments to the program.
*/
} |
same to the async case that I mentioned above. Either create another API like `extractBatchKeyPhrases(inputs, requestOptions)` or use `extractBatchKeyPhrases(inputs)` as example, I think we should show the user how to use `requestOptions` so I don't prefer the second way. | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("<replace-with-your-text-analytics-key-here>")
.endpoint("<replace-with-your-text-analytics-endpoint-here>")
.buildClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", ... | final DocumentResultCollection<ExtractKeyPhraseResult> extractedBatchResult = client.extractBatchKeyPhrasesWithResponse(inputs, requestOptions, Context.NONE).getValue(); | public static void main(String[] args) {
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("{subscription_key}")
.endpoint("https:
.buildClient();
List<TextDocumentInput> inputs = Arrays.asList(
new TextDocumentInput("1", "My cat might need to see a veterinarian.", "en"),
new TextDocumentIn... | class ExtractKeyPhrasesBatchDocuments {
/**
* Main method to invoke this demo about how to extract key phrases of a batch of text inputs.
*
* @param args Unused arguments to the program.
*/
} | class ExtractKeyPhrasesBatchDocuments {
/**
* Main method to invoke this demo about how to extract the key phrases of a batch input text.
*
* @param args Unused arguments to the program.
*/
} |
it would be easier to reason about if you chained `.addData(NAMESPACE...)` to the declaration above rather than here. | private Context startProcessTracingSpan(EventData eventData, String eventHubName, String fullyQualifiedNamespace) {
Object diagnosticId = eventData.getProperties().get(DIAGNOSTIC_ID_KEY);
if (diagnosticId == null || !tracerProvider.isEnabled()) {
return Context.NONE;
}
Context spanContext = tracerProvider.extractContex... | return tracerProvider.startSpan(spanContext.addData(AZ_NAMESPACE_KEY, AZ_NAMESPACE_VALUE), | private Context startProcessTracingSpan(EventData eventData, String eventHubName, String fullyQualifiedNamespace) {
Object diagnosticId = eventData.getProperties().get(DIAGNOSTIC_ID_KEY);
if (diagnosticId == null || !tracerProvider.isEnabled()) {
return Context.NONE;
}
Context spanContext = tracerProvider.extractContex... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... |
nit: It is a lot easier to understand all the method invocations by formatting it as: ```java finalSharedContext.addData(ENTITY_PATH_KEY, link.getEntityPath()) .addData(HOST_NAME_KEY, link.getHostname()) .addData(AZ_NAMESPACE_KEY, AZ_NAMESPACE_VALUE); ``` Same comment as the ones below. | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | ? new MessageAnnotations(new HashMap<>()) | public Mono<Void> send(EventDataBatch batch) {
if (batch == null) {
return monoError(logger, new NullPointerException("'batch' cannot be null."));
} else if (batch.getEvents().isEmpty()) {
logger.warning(Messages.CANNOT_SEND_EVENT_BATCH_EMPTY);
return Mono.empty();
}
if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... | class EventHubProducerAsyncClient implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final String SENDER_ENTITY_PATH_FORMAT = "%s/Partitions/%s";
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final CreateBatchOptions DEFAULT_BATCH_O... |
Should this add the attribute if the parsed name is `""`? It appear in the policy it doesn't. | public Context start(String spanName, Context context) {
Objects.requireNonNull(spanName, "'spanName' cannot be null.");
Objects.requireNonNull(context, "'context' cannot be null.");
Builder spanBuilder = getSpanBuilder(spanName, context);
Span span = spanBuilder.startSpan();
if (span.isRecording()) {
span.setAttribute... | AttributeValue.stringAttributeValue(HttpTraceUtil.parseNamespaceProvider(spanName))); | public Context start(String spanName, Context context) {
Objects.requireNonNull(spanName, "'spanName' cannot be null.");
Objects.requireNonNull(context, "'context' cannot be null.");
Builder spanBuilder = getSpanBuilder(spanName, context);
Span span = spanBuilder.startSpan();
if (span.isRecording()) {
String tracingNam... | class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry");
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPO... | class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry");
static final String AZ_NAMESPACE_KEY = "az.namespace";
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "m... |
updated it to not have the span attribute if it does not exist. | public Context start(String spanName, Context context) {
Objects.requireNonNull(spanName, "'spanName' cannot be null.");
Objects.requireNonNull(context, "'context' cannot be null.");
Builder spanBuilder = getSpanBuilder(spanName, context);
Span span = spanBuilder.startSpan();
if (span.isRecording()) {
span.setAttribute... | AttributeValue.stringAttributeValue(HttpTraceUtil.parseNamespaceProvider(spanName))); | public Context start(String spanName, Context context) {
Objects.requireNonNull(spanName, "'spanName' cannot be null.");
Objects.requireNonNull(context, "'context' cannot be null.");
Builder spanBuilder = getSpanBuilder(spanName, context);
Span span = spanBuilder.startSpan();
if (span.isRecording()) {
String tracingNam... | class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry");
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "message_bus.destination";
static final String PEER_ENDPO... | class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry");
static final String AZ_NAMESPACE_KEY = "az.namespace";
static final String COMPONENT = "component";
static final String MESSAGE_BUS_DESTINATION = "m... |
According to the design spec, null should throw NullPointerException and isEmpty should throw IllegalArgumentException. I'd split this into two steps. https://azure.github.io/azure-sdk/java_implementation.html#java-errors-system-errors | public ConfigurationClientBuilder connectionString(String connectionString) {
if (CoreUtils.isNullOrEmpty(connectionString)) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be null or an empty string."));
}
try {
this.credential = new ConfigurationClientCredentials(connection... | if (CoreUtils.isNullOrEmpty(connectionString)) { | public ConfigurationClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be an empty string."));
}
try {
this.c... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... |
You can replace this with connectionString.isEmpty(). No need to do another null check in CoreUtils. | public ConfigurationClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (CoreUtils.isNullOrEmpty(connectionString)) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be an empty string."));... | if (CoreUtils.isNullOrEmpty(connectionString)) { | public ConfigurationClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be an empty string."));
}
try {
this.c... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... |
Should we add in that the secret contained within the connection string is invalid? Right now this is too vague and being thrown from a black box scenario for anyone consuming this SDK. | public ConfigurationClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (CoreUtils.isNullOrEmpty(connectionString)) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be an empty string."));... | "The secret is invalid and cannot instantiate the HMAC-SHA256 algorithm.", err)); | public ConfigurationClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
if (connectionString.isEmpty()) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'connectionString' cannot be an empty string."));
}
try {
this.c... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... | class ConfigurationClientBuilder {
private static final String ECHO_REQUEST_ID_HEADER = "x-ms-return-client-request-id";
private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private static final String ACCEPT_HEADER = "Accept";
pri... |
Does the order of `subscribeOn()` matter? | private static Mono<Void> generateEvents(AtomicBoolean isRunning) {
final Logger logger = LoggerFactory.getLogger("Producer");
final Scheduler scheduler = Schedulers.elastic();
final Duration operationTimeout = Duration.ofSeconds(5);
final String[] machineIds = new String[]{"2A", "9B", "6C"};
final Random random = new ... | }).subscribeOn(scheduler) | private static Mono<Void> generateEvents(AtomicBoolean isRunning) {
final Logger logger = LoggerFactory.getLogger("Producer");
final Scheduler scheduler = Schedulers.elastic();
final Duration operationTimeout = Duration.ofSeconds(5);
final String[] machineIds = new String[]{"2A", "9B", "6C"};
final Random random = new ... | class EventProcessorClientAggregateEventsSample {
private static final Duration REPORTING_INTERVAL = Duration.ofSeconds(5);
private static final String EH_CONNECTION_STRING = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};"
+ "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
/**
* Main meth... | class EventProcessorClientAggregateEventsSample {
private static final Duration REPORTING_INTERVAL = Duration.ofSeconds(5);
private static final String EH_CONNECTION_STRING = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};"
+ "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
/**
* Main meth... |
According to this, order doesn't matter. https://stackoverflow.com/a/37986481/4220757 | private static Mono<Void> generateEvents(AtomicBoolean isRunning) {
final Logger logger = LoggerFactory.getLogger("Producer");
final Scheduler scheduler = Schedulers.elastic();
final Duration operationTimeout = Duration.ofSeconds(5);
final String[] machineIds = new String[]{"2A", "9B", "6C"};
final Random random = new ... | }).subscribeOn(scheduler) | private static Mono<Void> generateEvents(AtomicBoolean isRunning) {
final Logger logger = LoggerFactory.getLogger("Producer");
final Scheduler scheduler = Schedulers.elastic();
final Duration operationTimeout = Duration.ofSeconds(5);
final String[] machineIds = new String[]{"2A", "9B", "6C"};
final Random random = new ... | class EventProcessorClientAggregateEventsSample {
private static final Duration REPORTING_INTERVAL = Duration.ofSeconds(5);
private static final String EH_CONNECTION_STRING = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};"
+ "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
/**
* Main meth... | class EventProcessorClientAggregateEventsSample {
private static final Duration REPORTING_INTERVAL = Duration.ofSeconds(5);
private static final String EH_CONNECTION_STRING = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};"
+ "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
/**
* Main meth... |
usually errors are logged with the following pattern ``` logger.error("Error while parsing diagnostics", e) ``` any reason we are doing something else? | public String toString() {
try {
return objectMapper.writeValueAsString(this.clientSideRequestStatistics);
}catch (JsonProcessingException e) {
logger.error("Error while parsing diagnostics " + e.getOriginalMessage());
}
return StringUtils.EMPTY;
} | logger.error("Error while parsing diagnostics " + e.getOriginalMessage()); | public String toString() {
try {
return objectMapper.writeValueAsString(this.clientSideRequestStatistics);
}catch (JsonProcessingException e) {
logger.error("Error while parsing diagnostics " + e);
}
return StringUtils.EMPTY;
} | class CosmosResponseDiagnostics {
private static final Logger logger = LoggerFactory.getLogger(CosmosResponseDiagnostics.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private ClientSideRequestStatistics clientSideRequestStatistics;
CosmosResponseDiagnostics() {
this.clientSideRequestStati... | class CosmosResponseDiagnostics {
private static final Logger logger = LoggerFactory.getLogger(CosmosResponseDiagnostics.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private ClientSideRequestStatistics clientSideRequestStatistics;
CosmosResponseDiagnostics() {
this.clientSideRequestStati... |
same question which I had raised offline. I see that you have different way of capturing retry info in the direct mode, however here on the outer surface of the SDK we are again capturing the retry info, why do we need to capture the retry info in two different places? is this only applicable to GW mode if so it sho... | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | request.requestContext.updateRetryContext(documentClientRetryPolicy); | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... |
no specific reason , just trying to avoid priting whole error stack . I will move to logger.error("Error while parsing diagnostics", e) in next iteration | public String toString() {
try {
return objectMapper.writeValueAsString(this.clientSideRequestStatistics);
}catch (JsonProcessingException e) {
logger.error("Error while parsing diagnostics " + e.getOriginalMessage());
}
return StringUtils.EMPTY;
} | logger.error("Error while parsing diagnostics " + e.getOriginalMessage()); | public String toString() {
try {
return objectMapper.writeValueAsString(this.clientSideRequestStatistics);
}catch (JsonProcessingException e) {
logger.error("Error while parsing diagnostics " + e);
}
return StringUtils.EMPTY;
} | class CosmosResponseDiagnostics {
private static final Logger logger = LoggerFactory.getLogger(CosmosResponseDiagnostics.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private ClientSideRequestStatistics clientSideRequestStatistics;
CosmosResponseDiagnostics() {
this.clientSideRequestStati... | class CosmosResponseDiagnostics {
private static final Logger logger = LoggerFactory.getLogger(CosmosResponseDiagnostics.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private ClientSideRequestStatistics clientSideRequestStatistics;
CosmosResponseDiagnostics() {
this.clientSideRequestStati... |
Yes above is applicable to GW mode , and retry in gateway happens via BackoffRetry.executeRetry and at that place we dont have the access to DocumentServiceRequestContext | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | request.requestContext.updateRetryContext(documentClientRetryPolicy); | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... |
Discussed offline - "Lets take the example of ReadDocument() In Gateway mode ReadDocument() will keep calling readDocumentInternal() based on BackOffRetryUtility.executeRetry() ,and each retry will call the readDocumentInternal() again and update request.requestContext.updateRetryContext(documentClientRetryPolicy) eve... | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | request.requestContext.updateRetryContext(documentClientRetryPolicy); | private Flux<RxDocumentServiceResponse> read(RxDocumentServiceRequest request, DocumentClientRetryPolicy documentClientRetryPolicy) {
populateHeaders(request, HttpConstants.HttpMethods.GET);
if(request.requestContext != null && documentClientRetryPolicy.getRetryCount() > 0) {
documentClientRetryPolicy.updateEndTime();
... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... | class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider {
private final static ObjectMapper mapper = Utils.getSimpleObjectMapper();
private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class);
private final String masterKeyOrResourceToken;
private final URI serviceEn... |
Parametrized type -> `CompletableFuture<T>` | void run() throws Exception {
successMeter = metricsRegistry.meter("
failureMeter = metricsRegistry.meter("
switch (configuration.getOperationType()) {
case ReadLatency:
case Mixed:
latency = metricsRegistry.timer("Latency");
break;
default:
break;
}
reporter.start(configuration.getPrintingInterval(), TimeUnit.SECONDS)... | CompletableFuture futureResult = CompletableFuture.supplyAsync(() -> { | void run() throws Exception {
successMeter = metricsRegistry.meter("
failureMeter = metricsRegistry.meter("
switch (configuration.getOperationType()) {
case ReadLatency:
case Mixed:
latency = metricsRegistry.timer("Latency");
break;
default:
break;
}
reporter.start(configuration.getPrintingInterval(), TimeUnit.SECONDS)... | class LatencyListener<T> extends ResultHandler<T, Throwable> {
private final ResultHandler<T, Throwable> baseFunction;
Timer.Context context;
LatencyListener(ResultHandler<T, Throwable> baseFunction, Timer latency) {
this.baseFunction = baseFunction;
}
protected void init() {
super.init();
context = latency.time();
}
@... | class LatencyListener<T> extends ResultHandler<T, Throwable> {
private final ResultHandler<T, Throwable> baseFunction;
private final Timer latencyTimer;
Timer.Context context;
LatencyListener(ResultHandler<T, Throwable> baseFunction, Timer latencyTimer) {
this.baseFunction = baseFunction;
this.latencyTimer = latencyTim... |
addressed | void run() throws Exception {
successMeter = metricsRegistry.meter("
failureMeter = metricsRegistry.meter("
switch (configuration.getOperationType()) {
case ReadLatency:
case Mixed:
latency = metricsRegistry.timer("Latency");
break;
default:
break;
}
reporter.start(configuration.getPrintingInterval(), TimeUnit.SECONDS)... | CompletableFuture futureResult = CompletableFuture.supplyAsync(() -> { | void run() throws Exception {
successMeter = metricsRegistry.meter("
failureMeter = metricsRegistry.meter("
switch (configuration.getOperationType()) {
case ReadLatency:
case Mixed:
latency = metricsRegistry.timer("Latency");
break;
default:
break;
}
reporter.start(configuration.getPrintingInterval(), TimeUnit.SECONDS)... | class LatencyListener<T> extends ResultHandler<T, Throwable> {
private final ResultHandler<T, Throwable> baseFunction;
Timer.Context context;
LatencyListener(ResultHandler<T, Throwable> baseFunction, Timer latency) {
this.baseFunction = baseFunction;
}
protected void init() {
super.init();
context = latency.time();
}
@... | class LatencyListener<T> extends ResultHandler<T, Throwable> {
private final ResultHandler<T, Throwable> baseFunction;
private final Timer latencyTimer;
Timer.Context context;
LatencyListener(ResultHandler<T, Throwable> baseFunction, Timer latencyTimer) {
this.baseFunction = baseFunction;
this.latencyTimer = latencyTim... |
should we also remove the Model version log? Let us keep the codesnippet focus on the more valuable infor. | public void recognizeBatchEntities() {
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntit... | System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); | public void recognizeBatchEntities() {
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntit... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
private static final String SUBSCRIPTION_KEY = null;
private static final String ENDPOINT = null;
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The T... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
private static final String SUBSCRIPTION_KEY = null;
private static final String ENDPOINT = null;
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The T... |
removed | public void recognizeBatchEntities() {
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntit... | System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); | public void recognizeBatchEntities() {
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntit... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
private static final String SUBSCRIPTION_KEY = null;
private static final String ENDPOINT = null;
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The T... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
private static final String SUBSCRIPTION_KEY = null;
private static final String ENDPOINT = null;
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The T... |
Reactor might / will wrap the exception in ReactiveException. The safest way to check `throwable instanceOf CosmosClientException` is this. ``` final Throwable unwrappedThrowable = reactor.core.Exceptions.unwrap(throwable); if (unwrappedThrowable instanceof CosmosClientException) { ..... } ``` | public Mono<StoreResponse> invokeStoreAsync(final Uri addressUri, final RxDocumentServiceRequest request) {
logger.debug("RntbdTransportClient.invokeStoreAsync({}, {})", addressUri, request);
checkNotNull(addressUri, "expected non-null address");
checkNotNull(request, "expected non-null request");
this.throwIfClosed();... | } else if (throwable instanceof CosmosClientException) { | public Mono<StoreResponse> invokeStoreAsync(final Uri addressUri, final RxDocumentServiceRequest request) {
logger.debug("RntbdTransportClient.invokeStoreAsync({}, {})", addressUri, request);
checkNotNull(addressUri, "expected non-null address");
checkNotNull(request, "expected non-null request");
this.throwIfClosed();... | class RntbdTransportClient extends TransportClient {
private static final String TAG_NAME = RntbdTransportClient.class.getSimpleName();
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger(RntbdTransportClient.class);
private final AtomicBoolean ... | class RntbdTransportClient extends TransportClient {
private static final String TAG_NAME = RntbdTransportClient.class.getSimpleName();
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger(RntbdTransportClient.class);
private final AtomicBoolean ... |
@kushagraThapar `reactor.core.Exceptions.unwrap` should not be needed in this layer. right? | public Mono<StoreResponse> invokeStoreAsync(final Uri addressUri, final RxDocumentServiceRequest request) {
logger.debug("RntbdTransportClient.invokeStoreAsync({}, {})", addressUri, request);
checkNotNull(addressUri, "expected non-null address");
checkNotNull(request, "expected non-null request");
this.throwIfClosed();... | } else if (throwable instanceof CosmosClientException) { | public Mono<StoreResponse> invokeStoreAsync(final Uri addressUri, final RxDocumentServiceRequest request) {
logger.debug("RntbdTransportClient.invokeStoreAsync({}, {})", addressUri, request);
checkNotNull(addressUri, "expected non-null address");
checkNotNull(request, "expected non-null request");
this.throwIfClosed();... | class RntbdTransportClient extends TransportClient {
private static final String TAG_NAME = RntbdTransportClient.class.getSimpleName();
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger(RntbdTransportClient.class);
private final AtomicBoolean ... | class RntbdTransportClient extends TransportClient {
private static final String TAG_NAME = RntbdTransportClient.class.getSimpleName();
private static final AtomicLong instanceCount = new AtomicLong();
private static final Logger logger = LoggerFactory.getLogger(RntbdTransportClient.class);
private final AtomicBoolean ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.