Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Indexer
Commits
0ba0c4c6
Commit
0ba0c4c6
authored
5 years ago
by
Jagan Gottimukkula
Browse files
Options
Downloads
Patches
Plain Diff
removed config dependencies from storageserviceimpl
parent
43c9206d
No related branches found
No related tags found
1 merge request
!6
Trusted ibm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexer-service-root/src/main/java/org/opendes/indexer/service/StorageServiceImpl.java
+17
-6
17 additions, 6 deletions
.../java/org/opendes/indexer/service/StorageServiceImpl.java
with
17 additions
and
6 deletions
indexer-service-root/src/main/java/org/opendes/indexer/service/StorageServiceImpl.java
+
17
−
6
View file @
0ba0c4c6
...
...
@@ -26,7 +26,6 @@ import org.opendes.core.logging.JaxRsDpsLog;
import
org.opendes.core.model.RecordMetaAttribute
;
import
org.opendes.core.service.UrlFetchService
;
import
org.opendes.core.util.AppException
;
import
org.opendes.core.util.Config
;
import
org.opendes.indexer.model.*
;
import
org.opendes.indexer.util.IRequestInfo
;
import
org.opendes.indexer.util.JobStatus
;
...
...
@@ -61,13 +60,25 @@ public class StorageServiceImpl implements StorageService {
@Autowired
private
JaxRsDpsLog
log
;
@Value
(
"${STORAGE_SCHEMA_HOST}"
)
private
String
STORAGE_SCHEMA_HOST
;
@Value
(
"${STORAGE_QUERY_RECORD_HOST}"
)
private
String
STORAGE_QUERY_RECORD_HOST
;
@Value
(
"${STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST}"
)
private
String
STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST
;
@Value
(
"${STORAGE_RECORDS_BATCH_SIZE}"
)
private
String
STORAGE_RECORDS_BATCH_SIZE
;
@Override
public
Records
getStorageRecords
(
List
<
String
>
ids
)
throws
AppException
,
URISyntaxException
{
List
<
Records
.
Entity
>
valid
=
new
ArrayList
<>();
List
<
String
>
notFound
=
new
ArrayList
<>();
List
<
ConversionStatus
>
conversionStatuses
=
new
ArrayList
<>();
List
<
List
<
String
>>
batch
=
Lists
.
partition
(
ids
,
Config
.
getStorageRecordsBatchSize
(
));
List
<
List
<
String
>>
batch
=
Lists
.
partition
(
ids
,
Integer
.
parseInt
(
STORAGE_RECORDS_BATCH_SIZE
));
for
(
List
<
String
>
recordsBatch
:
batch
)
{
Records
storageOut
=
this
.
getRecords
(
recordsBatch
);
valid
.
addAll
(
storageOut
.
getRecords
());
...
...
@@ -84,7 +95,7 @@ public class StorageServiceImpl implements StorageService {
// Map<String, String> headers = this.requestInfo.getHeadersMap();
DpsHeaders
headers
=
this
.
requestInfo
.
getHeaders
();
headers
.
put
(
SLB_FRAME_OF_REFERENCE
,
SLB_FRAME_OF_REFERENCE_VALUE
);
HttpResponse
response
=
this
.
urlFetchService
.
sendRequest
(
HttpMethods
.
POST
,
Config
.
getStorageQueryRecordFoRConversionHostUrl
()
,
headers
,
null
,
body
);
HttpResponse
response
=
this
.
urlFetchService
.
sendRequest
(
HttpMethods
.
POST
,
STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST
,
headers
,
null
,
body
);
String
dataFromStorage
=
response
.
getBody
();
if
(
Strings
.
isNullOrEmpty
(
dataFromStorage
))
{
throw
new
AppException
(
HttpStatus
.
SC_NOT_FOUND
,
"Invalid request"
,
"Storage service cannot locate records"
);
...
...
@@ -117,7 +128,7 @@ public class StorageServiceImpl implements StorageService {
public
RecordQueryResponse
getRecordsByKind
(
RecordReindexRequest
request
)
throws
URISyntaxException
{
Map
<
String
,
String
>
queryParams
=
new
HashMap
<>();
queryParams
.
put
(
RecordMetaAttribute
.
KIND
.
getValue
(),
request
.
getKind
());
queryParams
.
put
(
"limit"
,
S
tring
.
valueOf
(
Config
.
getStorageRecordsBatchSize
())
);
queryParams
.
put
(
"limit"
,
S
TORAGE_RECORDS_BATCH_SIZE
);
if
(!
Strings
.
isNullOrEmpty
(
request
.
getCursor
()))
{
queryParams
.
put
(
"cursor"
,
request
.
getCursor
());
}
...
...
@@ -125,13 +136,13 @@ public class StorageServiceImpl implements StorageService {
if
(
requestInfo
==
null
)
throw
new
AppException
(
HttpStatus
.
SC_NO_CONTENT
,
"Invalid header"
,
"header can't be null"
);
HttpResponse
response
=
this
.
urlFetchService
.
sendRequest
(
HttpMethods
.
GET
,
Config
.
getStorageQueryRecordHostUrl
()
,
this
.
requestInfo
.
getHeaders
(),
queryParams
,
null
);
HttpResponse
response
=
this
.
urlFetchService
.
sendRequest
(
HttpMethods
.
GET
,
STORAGE_QUERY_RECORD_HOST
,
this
.
requestInfo
.
getHeaders
(),
queryParams
,
null
);
return
this
.
gson
.
fromJson
(
response
.
getBody
(),
RecordQueryResponse
.
class
);
}
@Override
public
String
getStorageSchema
(
String
kind
)
throws
URISyntaxException
,
UnsupportedEncodingException
{
String
url
=
String
.
format
(
"%s/%s"
,
Config
.
getStorageSchemaHostUrl
()
,
URLEncoder
.
encode
(
kind
,
"UTF-8"
));
String
url
=
String
.
format
(
"%s/%s"
,
STORAGE_SCHEMA_HOST
,
URLEncoder
.
encode
(
kind
,
"UTF-8"
));
HttpResponse
response
=
this
.
urlFetchService
.
sendRequest
(
HttpMethods
.
GET
,
url
,
this
.
requestInfo
.
getHeaders
(),
null
,
null
);
if
(
response
.
getResponseCode
()
!=
HttpStatus
.
SC_OK
)
return
null
;
return
response
.
getBody
();
...
...
This diff is collapsed.
Click to expand it.
Gokul Nagare
@gokul_nagare
mentioned in commit
d5255c23
·
4 years ago
mentioned in commit
d5255c23
mentioned in commit d5255c238ba67a6989a5a7dbc26c03b56b0b4f9e
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment