or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

channel-management.mdhttp-server-transport.mdindex.mdplugin-framework.mdresource-management.mdtcp-transport.mdutilities.md

plugin-framework.mddocs/

0

# Plugin Framework

1

2

The plugin framework provides the core integration between Netty4 transport implementation and Elasticsearch's plugin system. The main `Netty4Plugin` class serves as the entry point for registering transport and HTTP server implementations.

3

4

## Capabilities

5

6

### Netty4Plugin Main Class

7

8

Primary plugin class that implements NetworkPlugin interface to provide Netty4-based transport implementations to Elasticsearch.

9

10

```java { .api }

11

/**

12

* Main plugin class providing Netty4 transport and HTTP transport implementations

13

*/

14

public class Netty4Plugin extends Plugin implements NetworkPlugin {

15

public static final String NETTY_TRANSPORT_NAME = "netty4";

16

public static final String NETTY_HTTP_TRANSPORT_NAME = "netty4";

17

}

18

```

19

20

### Plugin Configuration

21

22

Returns all configuration settings supported by the Netty4 transport and HTTP implementations.

23

24

```java { .api }

25

/**

26

* Returns list of all settings used by Netty4 transport and HTTP implementations

27

* @return List of Setting objects for configuration

28

*/

29

public List<Setting<?>> getSettings();

30

```

31

32

**Usage Example:**

33

34

```java

35

Netty4Plugin plugin = new Netty4Plugin();

36

List<Setting<?>> allSettings = plugin.getSettings();

37

38

// Settings include transport and HTTP configuration options:

39

// - Netty4Transport.WORKER_COUNT

40

// - Netty4Transport.NETTY_RECEIVE_PREDICTOR_SIZE

41

// - Netty4HttpServerTransport.SETTING_HTTP_WORKER_COUNT

42

// - Netty4HttpServerTransport.SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS

43

// And others...

44

```

45

46

### Default Settings Configuration

47

48

Provides default settings that configure Netty4 as the default transport and HTTP transport implementation.

49

50

```java { .api }

51

/**

52

* Returns default settings that set Netty4 as default transport and HTTP transport

53

* @return Settings object with default transport type configuration

54

*/

55

public Settings additionalSettings();

56

```

57

58

**Usage Example:**

59

60

```java

61

Netty4Plugin plugin = new Netty4Plugin();

62

Settings defaults = plugin.additionalSettings();

63

64

// Defaults include:

65

// NetworkModule.HTTP_DEFAULT_TYPE_SETTING = "netty4"

66

// NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING = "netty4"

67

```

68

69

### Transport Factory Registration

70

71

Registers the Netty4 transport implementation factory with Elasticsearch's transport system.

72

73

```java { .api }

74

/**

75

* Provides transport implementation factory for Netty4 TCP transport

76

* @param settings Node settings

77

* @param threadPool Thread pool for async operations

78

* @param pageCacheRecycler Page cache recycler for memory management

79

* @param circuitBreakerService Circuit breaker for resource protection

80

* @param namedWriteableRegistry Registry for serializable objects

81

* @param networkService Network service for address resolution

82

* @return Map containing "netty4" transport factory

83

*/

84

public Map<String, Supplier<Transport>> getTransports(

85

Settings settings,

86

ThreadPool threadPool,

87

PageCacheRecycler pageCacheRecycler,

88

CircuitBreakerService circuitBreakerService,

89

NamedWriteableRegistry namedWriteableRegistry,

90

NetworkService networkService

91

);

92

```

93

94

**Usage Example:**

95

96

```java

97

Netty4Plugin plugin = new Netty4Plugin();

98

Map<String, Supplier<Transport>> transports = plugin.getTransports(

99

settings, threadPool, pageCacheRecycler, circuitBreakerService,

100

namedWriteableRegistry, networkService

101

);

102

103

// Get the Netty4 transport instance

104

Transport netty4Transport = transports.get("netty4").get();

105

```

106

107

### HTTP Server Transport Factory Registration

108

109

Registers the Netty4 HTTP server transport implementation factory with Elasticsearch's HTTP system.

110

111

```java { .api }

112

/**

113

* Provides HTTP server transport implementation factory for Netty4 HTTP server

114

* @param settings Node settings

115

* @param threadPool Thread pool for async operations

116

* @param bigArrays Big arrays for large buffer management

117

* @param pageCacheRecycler Page cache recycler for memory management

118

* @param circuitBreakerService Circuit breaker for resource protection

119

* @param xContentRegistry Registry for content type handling

120

* @param networkService Network service for address resolution

121

* @param dispatcher HTTP request dispatcher

122

* @param perRequestThreadContext Per-request thread context handler

123

* @param clusterSettings Cluster settings for dynamic configuration

124

* @return Map containing "netty4" HTTP transport factory

125

*/

126

public Map<String, Supplier<HttpServerTransport>> getHttpTransports(

127

Settings settings,

128

ThreadPool threadPool,

129

BigArrays bigArrays,

130

PageCacheRecycler pageCacheRecycler,

131

CircuitBreakerService circuitBreakerService,

132

NamedXContentRegistry xContentRegistry,

133

NetworkService networkService,

134

HttpServerTransport.Dispatcher dispatcher,

135

BiConsumer<HttpPreRequest, ThreadContext> perRequestThreadContext,

136

ClusterSettings clusterSettings

137

);

138

```

139

140

**Usage Example:**

141

142

```java

143

Netty4Plugin plugin = new Netty4Plugin();

144

Map<String, Supplier<HttpServerTransport>> httpTransports = plugin.getHttpTransports(

145

settings, threadPool, bigArrays, pageCacheRecycler, circuitBreakerService,

146

xContentRegistry, networkService, dispatcher, perRequestThreadContext, clusterSettings

147

);

148

149

// Get the Netty4 HTTP server transport instance

150

HttpServerTransport httpTransport = httpTransports.get("netty4").get();

151

```

152

153

### Shared Resource Factory Access

154

155

Internal method for accessing shared EventLoopGroup factory used by both transport and HTTP implementations.

156

157

```java { .api }

158

/**

159

* Gets or creates shared EventLoopGroup factory for resource sharing

160

* @param settings Configuration settings

161

* @return SharedGroupFactory instance for managing Netty EventLoopGroups

162

*/

163

private SharedGroupFactory getSharedGroupFactory(Settings settings);

164

```

165

166

## Plugin Constants

167

168

```java { .api }

169

// Transport and HTTP implementation identifiers

170

public static final String NETTY_TRANSPORT_NAME = "netty4";

171

public static final String NETTY_HTTP_TRANSPORT_NAME = "netty4";

172

```

173

174

## Integration with Elasticsearch

175

176

The plugin integrates with Elasticsearch through several key mechanisms:

177

178

1. **Plugin Discovery**: Elasticsearch automatically discovers and loads the plugin via the plugin descriptor

179

2. **Setting Registration**: Settings from `getSettings()` are registered with Elasticsearch's settings system

180

3. **Default Configuration**: `additionalSettings()` configures Netty4 as the default transport implementation

181

4. **Factory Registration**: Transport and HTTP factories are registered with Elasticsearch's service system

182

5. **Resource Sharing**: SharedGroupFactory enables efficient resource sharing between transport and HTTP layers

183

184

The plugin follows Elasticsearch's plugin architecture patterns and integrates seamlessly with the node lifecycle and configuration system.