16
16
import com .google .common .base .Strings ;
17
17
import com .google .inject .Inject ;
18
18
import io .trino .gateway .ha .clustermonitor .ClusterStats ;
19
- import io .trino .gateway .ha .config .HaGatewayConfiguration ;
20
- import io .trino .gateway .ha .config .ProxyBackendConfiguration ;
21
- import io .trino .gateway .ha .config .RulesType ;
22
- import io .trino .gateway .ha .config .UIConfiguration ;
19
+ import io .trino .gateway .ha .config .*;
23
20
import io .trino .gateway .ha .domain .Result ;
24
21
import io .trino .gateway .ha .domain .RoutingRule ;
25
22
import io .trino .gateway .ha .domain .TableData ;
@@ -74,10 +71,10 @@ public class GatewayWebAppResource
74
71
private final QueryHistoryManager queryHistoryManager ;
75
72
private final BackendStateManager backendStateManager ;
76
73
private final ResourceGroupsManager resourceGroupsManager ;
74
+ private final RoutingRulesConfiguration routingRules ;
77
75
// TODO Avoid putting mutable objects in fields
78
76
private final UIConfiguration uiConfiguration ;
79
77
private final RoutingRulesManager routingRulesManager ;
80
- private final HaGatewayConfiguration haGatewayConfiguration ;
81
78
82
79
@ Inject
83
80
public GatewayWebAppResource (
@@ -94,7 +91,7 @@ public GatewayWebAppResource(
94
91
this .resourceGroupsManager = requireNonNull (resourceGroupsManager , "resourceGroupsManager is null" );
95
92
this .uiConfiguration = configuration .getUiConfiguration ();
96
93
this .routingRulesManager = requireNonNull (routingRulesManager , "routingRulesManager is null" );
97
- this .haGatewayConfiguration = configuration ;
94
+ this .routingRules = configuration . getRoutingRules () ;
98
95
}
99
96
100
97
@ POST
@@ -163,7 +160,7 @@ public Response getDistribution(QueryDistributionRequest query)
163
160
Map <String , List <DistributionResponse .LineChart >> lineChartMap = lineChart .stream ().collect (Collectors .groupingBy (DistributionResponse .LineChart ::getName ));
164
161
List <DistributionResponse .DistributionChart > distributionChart = lineChartMap .values ().stream ().map (d -> {
165
162
DistributionResponse .DistributionChart dc = new DistributionResponse .DistributionChart ();
166
- DistributionResponse .LineChart lc = d .getFirst ( );
163
+ DistributionResponse .LineChart lc = d .get ( 0 );
167
164
long sum = d .stream ().collect (Collectors .summarizingLong (DistributionResponse .LineChart ::getQueryCount )).getSum ();
168
165
dc .setQueryCount (sum );
169
166
dc .setBackendUrl (lc .getBackendUrl ());
@@ -449,7 +446,7 @@ public Response readExactMatchSourceSelector()
449
446
public Response getRoutingRules ()
450
447
throws IOException
451
448
{
452
- if (haGatewayConfiguration . getRoutingRules (). isRulesEngineEnabled () && haGatewayConfiguration . getRoutingRules () .getRulesType () == RulesType .EXTERNAL ) {
449
+ if (routingRules . isRulesEngineEnabled () && routingRules .getRulesType () == RulesType .EXTERNAL ) {
453
450
return Response .status (Response .Status .NO_CONTENT )
454
451
.entity (Result .fail ("Routing rules are managed by an external service" )).build ();
455
452
}
0 commit comments