@@ -76,20 +76,26 @@ public void testBuildConnectionProfile() {
7676 builder .addConnections (1 , TransportRequestOptions .Type .BULK );
7777 builder .addConnections (2 , TransportRequestOptions .Type .STATE , TransportRequestOptions .Type .RECOVERY );
7878 builder .addConnections (3 , TransportRequestOptions .Type .PING );
79+ builder .addConnections (0 , TransportRequestOptions .Type .STREAM );
80+
7981 IllegalStateException illegalStateException = expectThrows (IllegalStateException .class , builder ::build );
80- assertEquals ("not all types are added for this connection profile - missing types: [REG]" , illegalStateException .getMessage ());
82+ assertEquals (
83+ "not all types are added for this connection profile - missing types: [REG, STREAM]" ,
84+ illegalStateException .getMessage ()
85+ );
8186
8287 IllegalArgumentException illegalArgumentException = expectThrows (
8388 IllegalArgumentException .class ,
8489 () -> builder .addConnections (4 , TransportRequestOptions .Type .REG , TransportRequestOptions .Type .PING )
8590 );
8691 assertEquals ("type [PING] is already registered" , illegalArgumentException .getMessage ());
8792 builder .addConnections (4 , TransportRequestOptions .Type .REG );
93+ builder .addConnections (1 , TransportRequestOptions .Type .STREAM );
8894 ConnectionProfile build = builder .build ();
8995 if (randomBoolean ()) {
9096 build = new ConnectionProfile .Builder (build ).build ();
9197 }
92- assertEquals (10 , build .getNumConnections ());
98+ assertEquals (11 , build .getNumConnections ());
9399 if (setConnectTimeout ) {
94100 assertEquals (connectTimeout , build .getConnectTimeout ());
95101 } else {
@@ -114,12 +120,12 @@ public void testBuildConnectionProfile() {
114120 assertNull (build .getPingInterval ());
115121 }
116122
117- List <Integer > list = new ArrayList <>(10 );
118- for (int i = 0 ; i < 10 ; i ++) {
123+ List <Integer > list = new ArrayList <>(11 );
124+ for (int i = 0 ; i < 11 ; i ++) {
119125 list .add (i );
120126 }
121127 final int numIters = randomIntBetween (5 , 10 );
122- assertEquals (4 , build .getHandles ().size ());
128+ assertEquals (5 , build .getHandles ().size ());
123129 assertEquals (0 , build .getHandles ().get (0 ).offset );
124130 assertEquals (1 , build .getHandles ().get (0 ).length );
125131 assertEquals (EnumSet .of (TransportRequestOptions .Type .BULK ), build .getHandles ().get (0 ).getTypes ());
@@ -155,11 +161,20 @@ public void testBuildConnectionProfile() {
155161 assertThat (channel , Matchers .anyOf (Matchers .is (6 ), Matchers .is (7 ), Matchers .is (8 ), Matchers .is (9 )));
156162 }
157163
164+ assertEquals (10 , build .getHandles ().get (4 ).offset );
165+ assertEquals (1 , build .getHandles ().get (4 ).length );
166+ assertEquals (EnumSet .of (TransportRequestOptions .Type .STREAM ), build .getHandles ().get (4 ).getTypes ());
167+ channel = build .getHandles ().get (4 ).getChannel (list );
168+ for (int i = 0 ; i < numIters ; i ++) {
169+ assertEquals (10 , channel .intValue ());
170+ }
171+
158172 assertEquals (3 , build .getNumConnectionsPerType (TransportRequestOptions .Type .PING ));
159173 assertEquals (4 , build .getNumConnectionsPerType (TransportRequestOptions .Type .REG ));
160174 assertEquals (2 , build .getNumConnectionsPerType (TransportRequestOptions .Type .STATE ));
161175 assertEquals (2 , build .getNumConnectionsPerType (TransportRequestOptions .Type .RECOVERY ));
162176 assertEquals (1 , build .getNumConnectionsPerType (TransportRequestOptions .Type .BULK ));
177+ assertEquals (1 , build .getNumConnectionsPerType (TransportRequestOptions .Type .STREAM ));
163178 }
164179
165180 public void testNoChannels () {
@@ -169,7 +184,8 @@ public void testNoChannels() {
169184 TransportRequestOptions .Type .BULK ,
170185 TransportRequestOptions .Type .STATE ,
171186 TransportRequestOptions .Type .RECOVERY ,
172- TransportRequestOptions .Type .REG
187+ TransportRequestOptions .Type .REG ,
188+ TransportRequestOptions .Type .STREAM
173189 );
174190 builder .addConnections (0 , TransportRequestOptions .Type .PING );
175191 ConnectionProfile build = builder .build ();
@@ -188,6 +204,7 @@ public void testConnectionProfileResolve() {
188204 builder .addConnections (randomIntBetween (0 , 5 ), TransportRequestOptions .Type .REG );
189205 builder .addConnections (randomIntBetween (0 , 5 ), TransportRequestOptions .Type .STATE );
190206 builder .addConnections (randomIntBetween (0 , 5 ), TransportRequestOptions .Type .PING );
207+ builder .addConnections (randomIntBetween (0 , 5 ), TransportRequestOptions .Type .STREAM );
191208
192209 final boolean connectionTimeoutSet = randomBoolean ();
193210 if (connectionTimeoutSet ) {
@@ -235,6 +252,7 @@ public void testDefaultConnectionProfile() {
235252 assertEquals (1 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STATE ));
236253 assertEquals (2 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .RECOVERY ));
237254 assertEquals (3 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .BULK ));
255+ assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STREAM ));
238256 assertEquals (TransportSettings .CONNECT_TIMEOUT .get (Settings .EMPTY ), profile .getConnectTimeout ());
239257 assertEquals (TransportSettings .CONNECT_TIMEOUT .get (Settings .EMPTY ), profile .getHandshakeTimeout ());
240258 assertEquals (TransportSettings .TRANSPORT_COMPRESS .get (Settings .EMPTY ), profile .getCompressionEnabled ());
@@ -247,6 +265,7 @@ public void testDefaultConnectionProfile() {
247265 assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STATE ));
248266 assertEquals (2 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .RECOVERY ));
249267 assertEquals (3 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .BULK ));
268+ assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STREAM ));
250269
251270 profile = ConnectionProfile .buildDefaultConnectionProfile (nonDataNode ());
252271 assertEquals (11 , profile .getNumConnections ());
@@ -255,6 +274,7 @@ public void testDefaultConnectionProfile() {
255274 assertEquals (1 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STATE ));
256275 assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .RECOVERY ));
257276 assertEquals (3 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .BULK ));
277+ assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STREAM ));
258278
259279 profile = ConnectionProfile .buildDefaultConnectionProfile (
260280 removeRoles (
@@ -267,5 +287,6 @@ public void testDefaultConnectionProfile() {
267287 assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STATE ));
268288 assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .RECOVERY ));
269289 assertEquals (3 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .BULK ));
290+ assertEquals (0 , profile .getNumConnectionsPerType (TransportRequestOptions .Type .STREAM ));
270291 }
271292}
0 commit comments