use of com.azure.cosmos.examples.common.CustomPOJO in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method PerformanceTipsJavaSDKv4NeedsSchedulerAsync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips-java-sdk-v4-sql
* Performance tips - needs scheduler
* Async only
*/
/**
* Performance tips - needs scheduler
*/
public static void PerformanceTipsJavaSDKv4NeedsSchedulerAsync() {
CosmosAsyncContainer asyncContainer = null;
CustomPOJO item = null;
// <PerformanceNeedsSchedulerAsync>
Mono<CosmosItemResponse<CustomPOJO>> createItemPub = asyncContainer.createItem(item);
createItemPub.subscribe(itemResponse -> {
// this is executed on eventloop IO netty thread.
// the eventloop thread is shared and is meant to return back quickly.
//
// DON'T do this on eventloop IO netty thread.
veryCpuIntensiveWork();
});
// </PerformanceNeedsSchedulerAsync>
}
use of com.azure.cosmos.examples.common.CustomPOJO in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method PerformanceTipsJavaSDKv4AddSchedulerSync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips-java-sdk-v4-sql
* Performance tips - add scheduler
* Async only
*/
/**
* Performance tips - add scheduler
*/
public static void PerformanceTipsJavaSDKv4AddSchedulerSync() {
CosmosAsyncContainer asyncContainer = null;
CustomPOJO item = null;
// <PerformanceAddSchedulerAsync>
Mono<CosmosItemResponse<CustomPOJO>> createItemPub = asyncContainer.createItem(item);
createItemPub.subscribeOn(Schedulers.elastic()).subscribe(itemResponse -> {
// this is executed on eventloop IO netty thread.
// the eventloop thread is shared and is meant to return back quickly.
//
// DON'T do this on eventloop IO netty thread.
veryCpuIntensiveWork();
});
// </PerformanceAddSchedulerAsync>
}
use of com.azure.cosmos.examples.common.CustomPOJO in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SampleDocumentationSnippets method PerformanceTipsJavaSDKv4AddPKSpecSync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips-java-sdk-v4-sql
* Performance tips - add partition key in point-writes
*/
/**
* Performance tips - add partition key in point-writes
*/
public static void PerformanceTipsJavaSDKv4AddPKSpecSync() {
CosmosContainer syncContainer = null;
CustomPOJO item = null;
// <PerformanceAddPKSync>
syncContainer.createItem(item);
// </PerformanceAddPKSync>
}
use of com.azure.cosmos.examples.common.CustomPOJO in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method TroubleshootingGuideJavaSDKv4CustomSchedulerAsync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/troubleshoot-java-sdk-v4-sql
* Troubleshooting guide - custom scheduler
* Async only
*/
/**
* Troubleshooting guide - custom scheduler
*/
public static void TroubleshootingGuideJavaSDKv4CustomSchedulerAsync() {
CosmosAsyncContainer container = null;
CustomPOJO item = null;
// <TroubleshootCustomSchedulerAsync>
// Have a singleton instance of an executor and a scheduler.
ExecutorService ex = Executors.newFixedThreadPool(30);
Scheduler customScheduler = Schedulers.fromExecutor(ex);
// </TroubleshootCustomSchedulerAsync>
}
use of com.azure.cosmos.examples.common.CustomPOJO in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SalesOrder method PerformanceTipsJavaSDKv4RequestChargeSpecAsync.
/**
* https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips-java-sdk-v4-sql
* Performance tips - get request charge
*/
/**
* Performance tips - get request charge
*/
public static void PerformanceTipsJavaSDKv4RequestChargeSpecAsync() {
CosmosAsyncContainer asyncContainer = null;
CustomPOJO item = null;
String pk = "pk_value";
// <PerformanceRequestChargeAsync>
CosmosItemResponse<CustomPOJO> response = asyncContainer.createItem(item).block();
response.getRequestCharge();
// </PerformanceRequestChargeAsync>
}
Aggregations