|
|
@ -17,6 +17,7 @@ |
|
|
|
package org.springframework.cloud.netflix.turbine.stream; |
|
|
|
package org.springframework.cloud.netflix.turbine.stream; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -56,18 +57,33 @@ public class HystrixStreamAggregator { |
|
|
|
payload = payload.replace("\\\"", "\""); |
|
|
|
payload = payload.replace("\\\"", "\""); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
if (payload.startsWith("[")) { |
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
|
|
|
List<Map<String, Object>> list = this.objectMapper.readValue(payload, |
|
|
|
|
|
|
|
List.class); |
|
|
|
|
|
|
|
for (Map<String, Object> map : list) { |
|
|
|
|
|
|
|
sendMap(map); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
Map<String, Object> map = this.objectMapper.readValue(payload, Map.class); |
|
|
|
Map<String, Object> map = this.objectMapper.readValue(payload, Map.class); |
|
|
|
Map<String, Object> data = getPayloadData(map); |
|
|
|
sendMap(map); |
|
|
|
|
|
|
|
} |
|
|
|
log.debug("Received hystrix stream payload: " + data); |
|
|
|
|
|
|
|
this.subject.onNext(data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (IOException ex) { |
|
|
|
catch (IOException ex) { |
|
|
|
log.error("Error receiving hystrix stream payload: " + payload, ex); |
|
|
|
log.error("Error receiving hystrix stream payload: " + payload, ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void sendMap(Map<String, Object> map) { |
|
|
|
|
|
|
|
Map<String, Object> data = getPayloadData(map); |
|
|
|
|
|
|
|
if (log.isDebugEnabled()) { |
|
|
|
|
|
|
|
log.debug("Received hystrix stream payload: " + data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.subject.onNext(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> getPayloadData(Map<String, Object> jsonMap) { |
|
|
|
public static Map<String, Object> getPayloadData(Map<String, Object> jsonMap) { |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
Map<String, Object> origin = (Map<String, Object>) jsonMap.get("origin"); |
|
|
|
Map<String, Object> origin = (Map<String, Object>) jsonMap.get("origin"); |
|
|
|