Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
azure
OS Core Lib Azure
Commits
8b18ccdd
Commit
8b18ccdd
authored
May 17, 2021
by
Krishna Nikhil Vedurumudi
Browse files
CosmosBulkExecutor Factory to use Compute if absent
parent
49ff4514
Pipeline
#40311
passed with stages
in 10 minutes and 14 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/azure/cosmosdb/CosmosBulkExecutorFactoryImpl.java
View file @
8b18ccdd
...
...
@@ -75,14 +75,25 @@ public class CosmosBulkExecutorFactoryImpl implements ICosmosBulkExecutorFactory
return
this
.
cosmosClientMap
.
get
(
cacheKey
);
}
PartitionInfoAzure
pi
=
this
.
partitionService
.
getPartition
(
dataPartitionId
);
DocumentClient
client
=
getDocumentClient
(
pi
.
getCosmosEndpoint
(),
pi
.
getCosmosPrimaryKey
());
return
this
.
cosmosClientMap
.
computeIfAbsent
(
cacheKey
,
cosmosClient
->
createDocumentBulkExecutor
(
cosmosDBName
,
collectionName
,
dataPartitionId
));
}
String
collectionLink
=
String
.
format
(
unformattedCollectionLink
,
cosmosDBName
,
collectionName
);
/**
*
* @param cosmosDBName name of the cosmos db
* @param collectionName name of the cosmos collection
* @param dataPartitionId name of the data partition
* @return DocumentBulkExecutor
*/
private
DocumentBulkExecutor
createDocumentBulkExecutor
(
final
String
cosmosDBName
,
final
String
collectionName
,
final
String
dataPartitionId
)
{
try
{
PartitionInfoAzure
pi
=
this
.
partitionService
.
getPartition
(
dataPartitionId
);
DocumentClient
client
=
getDocumentClient
(
pi
.
getCosmosEndpoint
(),
pi
.
getCosmosPrimaryKey
());
String
collectionLink
=
String
.
format
(
unformattedCollectionLink
,
cosmosDBName
,
collectionName
);
DocumentCollection
collection
=
client
.
readCollection
(
collectionLink
,
null
).
getResource
();
DocumentBulkExecutor
executor
=
DocumentBulkExecutor
.
builder
().
from
(
client
,
...
...
@@ -92,8 +103,6 @@ public class CosmosBulkExecutorFactoryImpl implements ICosmosBulkExecutorFactory
bulkExecutorMaxRUs
).
build
();
cosmosClientMap
.
put
(
String
.
format
(
unformattedCosmosBulkExecutorCacheKey
,
dataPartitionId
,
cosmosDBName
,
collectionName
),
executor
);
// Set client retry options to 0 because retries are handled by DocumentBulkExecutor class.
client
.
getConnectionPolicy
().
getRetryOptions
().
setMaxRetryAttemptsOnThrottledRequests
(
0
);
client
.
getConnectionPolicy
().
getRetryOptions
().
setMaxRetryWaitTimeInSeconds
(
0
);
...
...
@@ -135,6 +144,4 @@ public class CosmosBulkExecutorFactoryImpl implements ICosmosBulkExecutorFactory
return
client
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment