or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

base-sse-servlet.mdconfiguration-streaming.mdindex.mdlegacy-metrics-polling.mdmetrics-streaming.mdrequest-events-streaming.mdutilization-streaming.md

configuration-streaming.mddocs/

0

# Configuration Streaming

1

2

Servlet that streams Hystrix configuration information including command properties, thread pool settings, and collapser configuration in real-time.

3

4

## Capabilities

5

6

### HystrixConfigSseServlet

7

8

Servlet that streams Hystrix configuration data in text/event-stream format.

9

10

```java { .api }

11

/**

12

* Streams Hystrix config in text/event-stream format

13

* Provides real-time configuration information for commands, thread pools, and collapsers

14

*/

15

public class HystrixConfigSseServlet extends HystrixSampleSseServlet {

16

17

/**

18

* Default constructor using HystrixConfigurationStream and default delay

19

*/

20

public HystrixConfigSseServlet();

21

22

/**

23

* Package-private constructor for testing with custom stream and delay

24

* @param sampleStream Observable stream of configuration data

25

* @param pausePollerThreadDelayInMs Delay between polling cycles in milliseconds

26

*/

27

HystrixConfigSseServlet(Observable<HystrixConfiguration> sampleStream, int pausePollerThreadDelayInMs);

28

29

/**

30

* Returns maximum number of concurrent connections allowed

31

* @return Maximum concurrent connections (default: 5)

32

*/

33

protected int getMaxNumberConcurrentConnectionsAllowed();

34

35

/**

36

* Returns current number of active connections

37

* @return Current connection count

38

*/

39

protected int getNumberCurrentConnections();

40

41

/**

42

* Atomically increments and returns current concurrent connection count

43

* @return New connection count after increment

44

*/

45

protected int incrementAndGetCurrentConcurrentConnections();

46

47

/**

48

* Atomically decrements current concurrent connection count

49

*/

50

protected void decrementCurrentConcurrentConnections();

51

}

52

```

53

54

### HystrixConfigurationJsonStream (Deprecated)

55

56

Legacy utility for converting configuration objects to JSON format.

57

58

```java { .api }

59

/**

60

* Links HystrixConfigurationStream and JSON encoding

61

* @deprecated Since 1.5.4 - prefer mapping serialization on HystrixConfigurationStream.observe()

62

*/

63

@Deprecated

64

public class HystrixConfigurationJsonStream {

65

66

/**

67

* Default constructor using default configuration stream

68

*/

69

public HystrixConfigurationJsonStream();

70

71

/**

72

* Constructor with custom stream generator

73

* @param streamGenerator Function to generate configuration observable

74

*/

75

public HystrixConfigurationJsonStream(Func1<Integer, Observable<HystrixConfiguration>> streamGenerator);

76

77

/**

78

* Convert configuration object to JSON string

79

* @param config Configuration object to convert

80

* @return JSON string representation

81

* @throws IOException if JSON generation fails

82

*/

83

public static String convertToString(HystrixConfiguration config) throws IOException;

84

85

/**

86

* @deprecated Use HystrixConfigurationStream.observe() instead

87

*/

88

@Deprecated

89

public Observable<HystrixConfiguration> observe(int delay);

90

91

/**

92

* @deprecated Use HystrixConfigurationStream.observe() and convertToString() instead

93

*/

94

@Deprecated

95

public Observable<String> observeJson(int delay);

96

}

97

```

98

99

**Web.xml Configuration:**

100

101

```xml

102

<servlet>

103

<description></description>

104

<display-name>HystrixConfigSseServlet</display-name>

105

<servlet-name>HystrixConfigSseServlet</servlet-name>

106

<servlet-class>com.netflix.hystrix.contrib.sample.stream.HystrixConfigSseServlet</servlet-class>

107

</servlet>

108

<servlet-mapping>

109

<servlet-name>HystrixConfigSseServlet</servlet-name>

110

<url-pattern>/hystrix/config.stream</url-pattern>

111

</servlet-mapping>

112

```

113

114

**Usage Examples:**

115

116

```java

117

// Deploy servlet via web.xml configuration

118

// Access configuration stream

119

curl http://localhost:8080/app/hystrix/config.stream

120

121

// Using deprecated JSON stream API

122

HystrixConfigurationJsonStream stream = new HystrixConfigurationJsonStream();

123

stream.observe(1000).subscribe(config -> {

124

String json = HystrixConfigurationJsonStream.convertToString(config);

125

System.out.println("Config: " + json);

126

});

127

```

128

129

## Data Format

130

131

The servlet outputs comprehensive configuration information in JSON format:

132

133

### Configuration Structure

134

135

```json

136

data: {

137

"type": "HystrixConfig",

138

"commands": {

139

"GetUser": {

140

"threadPoolKey": "GetUser",

141

"groupKey": "UserService",

142

"execution": {

143

"isolationStrategy": "THREAD",

144

"threadPoolKeyOverride": null,

145

"requestCacheEnabled": true,

146

"requestLogEnabled": true,

147

"timeoutEnabled": true,

148

"fallbackEnabled": true,

149

"timeoutInMilliseconds": 1000,

150

"semaphoreSize": 10,

151

"fallbackSemaphoreSize": 10,

152

"threadInterruptOnTimeout": true

153

},

154

"metrics": {

155

"healthBucketSizeInMs": 500,

156

"percentileBucketSizeInMilliseconds": 60000,

157

"percentileBucketCount": 6,

158

"percentileEnabled": true,

159

"counterBucketSizeInMilliseconds": 10000,

160

"counterBucketCount": 10

161

},

162

"circuitBreaker": {

163

"enabled": true,

164

"isForcedOpen": false,

165

"isForcedClosed": false,

166

"requestVolumeThreshold": 20,

167

"errorPercentageThreshold": 50,

168

"sleepInMilliseconds": 5000

169

}

170

}

171

},

172

"threadpools": {

173

"GetUser": {

174

"coreSize": 10,

175

"maximumSize": 10,

176

"actualMaximumSize": 10,

177

"maxQueueSize": -1,

178

"queueRejectionThreshold": 5,

179

"keepAliveTimeInMinutes": 1,

180

"allowMaximumSizeToDivergeFromCoreSize": false,

181

"counterBucketSizeInMilliseconds": 10000,

182

"counterBucketCount": 10

183

}

184

},

185

"collapsers": {

186

"UserDataCollapser": {

187

"maxRequestsInBatch": 100,

188

"timerDelayInMilliseconds": 10,

189

"requestCacheEnabled": true,

190

"metrics": {

191

"percentileBucketSizeInMilliseconds": 60000,

192

"percentileBucketCount": 6,

193

"percentileEnabled": true,

194

"counterBucketSizeInMilliseconds": 10000,

195

"counterBucketCount": 10

196

}

197

}

198

}

199

}

200

```

201

202

### Command Configuration Properties

203

204

**Execution Configuration:**

205

- `isolationStrategy` - THREAD or SEMAPHORE

206

- `threadPoolKeyOverride` - Custom thread pool key

207

- `requestCacheEnabled` - Whether request caching is enabled

208

- `requestLogEnabled` - Whether request logging is enabled

209

- `timeoutEnabled` - Whether execution timeout is enabled

210

- `fallbackEnabled` - Whether fallback is enabled

211

- `timeoutInMilliseconds` - Execution timeout in milliseconds

212

- `semaphoreSize` - Semaphore max concurrent requests

213

- `fallbackSemaphoreSize` - Fallback semaphore max concurrent requests

214

- `threadInterruptOnTimeout` - Whether to interrupt thread on timeout

215

216

**Metrics Configuration:**

217

- `healthBucketSizeInMs` - Health snapshot bucket size

218

- `percentileBucketSizeInMilliseconds` - Percentile bucket size

219

- `percentileBucketCount` - Number of percentile buckets

220

- `percentileEnabled` - Whether percentile tracking is enabled

221

- `counterBucketSizeInMilliseconds` - Counter bucket size

222

- `counterBucketCount` - Number of counter buckets

223

224

**Circuit Breaker Configuration:**

225

- `enabled` - Whether circuit breaker is enabled

226

- `isForcedOpen` - Whether circuit breaker is forced open

227

- `isForcedClosed` - Whether circuit breaker is forced closed (Note: Source has bug referencing isForceOpen() instead)

228

- `requestVolumeThreshold` - Minimum requests before circuit breaker trips

229

- `errorPercentageThreshold` - Error percentage threshold for tripping

230

- `sleepInMilliseconds` - Sleep window when circuit is open

231

232

### Thread Pool Configuration Properties

233

234

- `coreSize` - Core thread pool size

235

- `maximumSize` - Maximum thread pool size

236

- `actualMaximumSize` - Actual maximum size in use

237

- `maxQueueSize` - Maximum queue size (-1 for unbounded)

238

- `queueRejectionThreshold` - Queue size rejection threshold

239

- `keepAliveTimeInMinutes` - Thread keep-alive time

240

- `allowMaximumSizeToDivergeFromCoreSize` - Whether max size can exceed core size

241

- `counterBucketSizeInMilliseconds` - Metrics counter bucket size

242

- `counterBucketCount` - Number of metrics counter buckets

243

244

### Collapser Configuration Properties

245

246

- `maxRequestsInBatch` - Maximum requests per batch

247

- `timerDelayInMilliseconds` - Delay before executing batch

248

- `requestCacheEnabled` - Whether request caching is enabled

249

- `metrics` - Metrics configuration (similar to command metrics)

250

251

## Migration from Deprecated API

252

253

```java

254

// Old approach (deprecated)

255

HystrixConfigurationJsonStream jsonStream = new HystrixConfigurationJsonStream();

256

jsonStream.observeJson(1000).subscribe(json -> {

257

// process json

258

});

259

260

// New approach (recommended)

261

HystrixConfigurationStream.getInstance()

262

.observe()

263

.map(SerialHystrixConfiguration::toJsonString)

264

.subscribe(json -> {

265

// process json

266

});

267

```