forked from spring-cloud/spring-cloud-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request spring-cloud#28 from jhonyelink/gateway_4x_KM-836_opt
kylin 4x + kylin manager 2 + gateway 2.0.0
- Loading branch information
Showing
58 changed files
with
1,976 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
{"id":4, "backends":["10.1.2.56:7070"], "project":"p1", "resourceGroup":"common_query_1", "type":"ASYNC"} | ||
{"id":5, "backends":["10.1.2.56:7070"], "project":"p1", "resourceGroup":"common_query_2", "type":"CUBE"} | ||
{"id":6, "backends":["10.1.2.56:7070"], "project":"p2", "resourceGroup":"common_query_3", "order": 10 , "type":"CUBE"} | ||
{"id":1, "backends":["10.1.2.56:7070"], "resourceGroup":"default", "type":"GLOBAL"} | ||
|
||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "project":"p1", "resourceGroup":"1", "type":"BUILD"} | ||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "project":"p1", "resourceGroup":"1", "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "project":"p2", "resourceGroup":"1", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "project":"p3", "resourceGroup":"1", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.152:7071"], "project":"p3", "resourceGroup":"2", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "project":"p4", "resourceGroup":"1", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p5", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p6", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p7", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p8", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p9", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
{"cluster": "c1", "backends":["10.1.2.153:7071"], "project":"p10", "resourceGroup":"3", "order": 10 , "type":"QUERY"} | ||
|
||
|
||
{"cluster": "c1", "backends":["10.1.2.56:7070"], "resourceGroup":"0", "type":"GLOBAL"} | ||
|
34 changes: 34 additions & 0 deletions
34
...java/io/kyligence/kap/gateway/config/GatewayKylinLoadBalancerClientAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.kyligence.kap.gateway.config; | ||
|
||
import io.kyligence.kap.gateway.constant.KylinGatewayVersion; | ||
import io.kyligence.kap.gateway.filter.KylinLoadBalancerClientFilter; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; | ||
import org.springframework.cloud.gateway.config.LoadBalancerProperties; | ||
import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter; | ||
import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter; | ||
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.reactive.DispatcherHandler; | ||
|
||
@ConditionalOnProperty(name = "kylin.gateway.ke.version", havingValue = KylinGatewayVersion.KYLIN_4X) | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass({LoadBalancerClient.class, RibbonAutoConfiguration.class, | ||
DispatcherHandler.class}) | ||
@AutoConfigureAfter(RibbonAutoConfiguration.class) | ||
@EnableConfigurationProperties(LoadBalancerProperties.class) | ||
public class GatewayKylinLoadBalancerClientAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean({LoadBalancerClientFilter.class, | ||
ReactiveLoadBalancerClientFilter.class}) | ||
public LoadBalancerClientFilter loadBalancerClientFilter(LoadBalancerClient client, | ||
LoadBalancerProperties properties) { | ||
return new KylinLoadBalancerClientFilter(client, properties); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
kylin-gateway/src/main/java/io/kyligence/kap/gateway/config/GlobalConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.kyligence.kap.gateway.config; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import io.kyligence.kap.gateway.entity.KylinRouteRaw; | ||
import io.kyligence.kap.gateway.utils.TimeUtil; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Collection; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
@Slf4j | ||
@Scope(value = "singleton") | ||
@Component | ||
public class GlobalConfig { | ||
|
||
@Value(value = "${kylin.gateway.route.refresh-interval:3s}") | ||
private String refreshInterval; | ||
|
||
@Getter | ||
private ImmutableList<KylinRouteRaw> lastValidRawRouteTable = ImmutableList.of(); | ||
|
||
@Getter | ||
private final AtomicLong lastValidRawRouteTableMvcc = new AtomicLong(0); | ||
|
||
public long getRouteRefreshIntervalSeconds() { | ||
long refreshSeconds = 3; | ||
try { | ||
refreshSeconds = TimeUtil.timeStringAs(refreshInterval, TimeUnit.SECONDS); | ||
} catch (Exception e) { | ||
log.error("Failed to init route refresh-interval, use 3 seconds !", e); | ||
} | ||
return refreshSeconds; | ||
} | ||
|
||
public void setLastValidRawRouteTable(Collection<KylinRouteRaw> rawRouteTable) { | ||
this.lastValidRawRouteTable = ImmutableList.copyOf(rawRouteTable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...gateway/src/main/java/io/kyligence/kap/gateway/constant/Kylin3xResourceGroupTypeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.kyligence.kap.gateway.constant; | ||
|
||
public enum Kylin3xResourceGroupTypeEnum { | ||
|
||
GLOBAL, // default group, global request is routing to default group | ||
CUBE, // | ||
ASYNC; | ||
|
||
Kylin3xResourceGroupTypeEnum() { | ||
|
||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
kylin-gateway/src/main/java/io/kyligence/kap/gateway/constant/KylinGatewayVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.kyligence.kap.gateway.constant; | ||
|
||
public class KylinGatewayVersion { | ||
|
||
private KylinGatewayVersion() { | ||
|
||
} | ||
|
||
public static final String KYLIN_3X = "3x"; | ||
|
||
public static final String KYLIN_4X = "4x"; | ||
|
||
} |
15 changes: 10 additions & 5 deletions
15
...n-gateway/src/main/java/io/kyligence/kap/gateway/constant/KylinResourceGroupTypeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package io.kyligence.kap.gateway.constant; | ||
|
||
public enum KylinResourceGroupTypeEnum { | ||
// All reuqest | ||
DEFAULT, | ||
|
||
GLOBAL, // default group, global request is routing to default group | ||
CUBE, // | ||
ASYNC; | ||
// No project request | ||
GLOBAL, | ||
|
||
KylinResourceGroupTypeEnum() { | ||
// All request in a project | ||
QUERY, | ||
|
||
} | ||
// No request | ||
BUILD, | ||
|
||
VIP, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ public class KylinJdbcDataSource { | |
|
||
private String tableName; | ||
|
||
private String clusterId; | ||
|
||
} |
Oops, something went wrong.