Code Review
/
holmes
/
dsa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add the "timeout" Param into the Request Path
[holmes/dsa.git]
/
dmaap-dsa
/
src
/
main
/
java
/
org
/
onap
/
holmes
/
dsa
/
dmaappolling
/
Subscriber.java
diff --git
a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
index
3563b66
..
8b7c727
100644
(file)
--- a/
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
+++ b/
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
@@
-19,7
+19,6
@@
package org.onap.holmes.dsa.dmaappolling;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
@@
-28,14
+27,15
@@
import lombok.Getter;
import lombok.Setter;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.holmes.common.api.stat.VesAlarm;
import lombok.Setter;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.holmes.common.api.stat.VesAlarm;
+import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
@Getter
@Setter
public class Subscriber {
import org.onap.holmes.common.exception.CorrelationException;
@Getter
@Setter
public class Subscriber {
- @Inject
-
private DMaaPResponseUtil dMaaPResponseUtil
;
+ private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
+
.getService(DMaaPResponseUtil.class)
;
/**
* The number of milliseconds to wait for messages if none are immediately available. This
/**
* The number of milliseconds to wait for messages if none are immediately available. This
@@
-57,13
+57,18
@@
public class Subscriber {
private boolean secure;
private String topic;
private String url;
private boolean secure;
private String topic;
private String url;
- private String consumerGroup = "
g0
";
- private String consumer = "
u
1";
+ private String consumerGroup = "
homlesGroup1
";
+ private String consumer = "
homles
1";
private String authInfo;
private String authExpDate;
public List<VesAlarm> subscribe() throws CorrelationException {
private String authInfo;
private String authExpDate;
public List<VesAlarm> subscribe() throws CorrelationException {
- List<String> response = getDMaaPData();
+ List<String> response;
+ try {
+ response = getDMaaPData();
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to get DMapp data.", e);
+ }
try {
return extractVesAlarm(response);
} catch (Exception e) {
try {
return extractVesAlarm(response);
} catch (Exception e) {
@@
-73,12
+78,12
@@
public class Subscriber {
private List<String> getDMaaPData() {
Client client = ClientBuilder.newClient(new ClientConfig());
private List<String> getDMaaPData() {
Client client = ClientBuilder.newClient(new ClientConfig());
- WebTarget webTarget = client.target(url);
- Response response = webTarget.
path(topic).path(consumerGroup).path(consumer
).request().get();
+ WebTarget webTarget = client.target(url
+ "/" + consumerGroup + "/" + consumer
);
+ Response response = webTarget.
queryParam("timeout", timeout
).request().get();
return response.readEntity(List.class);
}
return response.readEntity(List.class);
}
- List<VesAlarm> extractVesAlarm(List<String> responseEntity) throws IOException {
+
private
List<VesAlarm> extractVesAlarm(List<String> responseEntity) throws IOException {
List<VesAlarm> vesAlarmList = new ArrayList<>();
for (String entity : responseEntity) {
vesAlarmList.add(dMaaPResponseUtil.convertJsonToVesAlarm(entity));
List<VesAlarm> vesAlarmList = new ArrayList<>();
for (String entity : responseEntity) {
vesAlarmList.add(dMaaPResponseUtil.convertJsonToVesAlarm(entity));