@@ -86,9 +86,6 @@ static final class ReadHealthWithHttpClientStep extends Step {
86
86
87
87
public ReadHealthWithHttpClientStep (V1Service service , Step next ) {
88
88
super (next );
89
- if (service == null ) {
90
- throw new IllegalArgumentException ("service cannot be null" );
91
- }
92
89
this .service = service ;
93
90
}
94
91
@@ -101,62 +98,63 @@ public NextAction apply(Packet packet) {
101
98
Domain dom = info .getDomain ();
102
99
103
100
String serviceURL = HttpClient .getServiceURL (service );
101
+ if (serviceURL != null ) {
102
+ String jsonResult =
103
+ httpClient
104
+ .executePostUrlOnServiceClusterIP (
105
+ getRetrieveHealthSearchUrl (),
106
+ serviceURL ,
107
+ getRetrieveHealthSearchPayload (),
108
+ true )
109
+ .getResponse ();
110
+
111
+ ObjectMapper mapper = new ObjectMapper ();
112
+ JsonNode root = mapper .readTree (jsonResult );
113
+
114
+ JsonNode state = null ;
115
+ JsonNode subsystemName = null ;
116
+ JsonNode symptoms = null ;
117
+ JsonNode overallHealthState = root .path ("overallHealthState" );
118
+ if (overallHealthState != null ) {
119
+ state = overallHealthState .path ("state" );
120
+ subsystemName = overallHealthState .path ("subsystemName" );
121
+ symptoms = overallHealthState .path ("symptoms" );
122
+ }
123
+ JsonNode activationTime = root .path ("activationTime" );
124
+
125
+ List <String > sym = new ArrayList <>();
126
+ if (symptoms != null ) {
127
+ Iterator <JsonNode > it = symptoms .elements ();
128
+ while (it .hasNext ()) {
129
+ sym .add (it .next ().asText ());
130
+ }
131
+ }
104
132
105
- String jsonResult =
106
- httpClient
107
- .executePostUrlOnServiceClusterIP (
108
- getRetrieveHealthSearchUrl (),
109
- serviceURL ,
110
- getRetrieveHealthSearchPayload (),
111
- true )
112
- .getResponse ();
113
-
114
- ObjectMapper mapper = new ObjectMapper ();
115
- JsonNode root = mapper .readTree (jsonResult );
116
-
117
- JsonNode state = null ;
118
- JsonNode subsystemName = null ;
119
- JsonNode symptoms = null ;
120
- JsonNode overallHealthState = root .path ("overallHealthState" );
121
- if (overallHealthState != null ) {
122
- state = overallHealthState .path ("state" );
123
- subsystemName = overallHealthState .path ("subsystemName" );
124
- symptoms = overallHealthState .path ("symptoms" );
125
- }
126
- JsonNode activationTime = root .path ("activationTime" );
127
-
128
- List <String > sym = new ArrayList <>();
129
- if (symptoms != null ) {
130
- Iterator <JsonNode > it = symptoms .elements ();
131
- while (it .hasNext ()) {
132
- sym .add (it .next ().asText ());
133
+ String subName = null ;
134
+ if (subsystemName != null ) {
135
+ String s = subsystemName .asText ();
136
+ if (s != null && !"null" .equals (s )) {
137
+ subName = s ;
138
+ }
133
139
}
134
- }
135
140
136
- String subName = null ;
137
- if (subsystemName != null ) {
138
- String s = subsystemName .asText ();
139
- if (s != null && !"null" .equals (s )) {
140
- subName = s ;
141
+ ServerHealth health =
142
+ new ServerHealth ()
143
+ .withOverallHealth (state != null ? state .asText () : null )
144
+ .withActivationTime (
145
+ activationTime != null ? new DateTime (activationTime .asLong ()) : null );
146
+ if (subName != null ) {
147
+ health
148
+ .getSubsystems ()
149
+ .add (new SubsystemHealth ().withSubsystemName (subName ).withSymptoms (sym ));
141
150
}
142
- }
143
151
144
- ServerHealth health =
145
- new ServerHealth ()
146
- .withOverallHealth (state != null ? state .asText () : null )
147
- .withActivationTime (
148
- activationTime != null ? new DateTime (activationTime .asLong ()) : null );
149
- if (subName != null ) {
150
- health
151
- .getSubsystems ()
152
- .add (new SubsystemHealth ().withSubsystemName (subName ).withSymptoms (sym ));
152
+ @ SuppressWarnings ("unchecked" )
153
+ ConcurrentMap <String , ServerHealth > serverHealthMap =
154
+ (ConcurrentMap <String , ServerHealth >)
155
+ packet .get (ProcessingConstants .SERVER_HEALTH_MAP );
156
+ serverHealthMap .put ((String ) packet .get (ProcessingConstants .SERVER_NAME ), health );
153
157
}
154
-
155
- @ SuppressWarnings ("unchecked" )
156
- ConcurrentMap <String , ServerHealth > serverHealthMap =
157
- (ConcurrentMap <String , ServerHealth >) packet .get (ProcessingConstants .SERVER_HEALTH_MAP );
158
- serverHealthMap .put ((String ) packet .get (ProcessingConstants .SERVER_NAME ), health );
159
-
160
158
return doNext (packet );
161
159
} catch (Throwable t ) {
162
160
// do not retry for health check
0 commit comments