-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add mesh rule route * add mesh rule check
- Loading branch information
Showing
43 changed files
with
2,558 additions
and
4 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
105 changes: 105 additions & 0 deletions
105
dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/MeshRouteController.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,105 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.controller; | ||
|
||
import org.apache.dubbo.admin.annotation.Authority; | ||
import org.apache.dubbo.admin.common.exception.ParamValidationException; | ||
import org.apache.dubbo.admin.common.exception.ResourceNotFoundException; | ||
import org.apache.dubbo.admin.common.util.Constants; | ||
import org.apache.dubbo.admin.model.dto.MeshRouteDTO; | ||
import org.apache.dubbo.admin.service.MeshRouteService; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Authority(needLogin = true) | ||
@RestController | ||
@RequestMapping("/api/{env}/rules/route/mesh") | ||
public class MeshRouteController { | ||
|
||
private final MeshRouteService meshRouteService; | ||
|
||
@Autowired | ||
public MeshRouteController(MeshRouteService meshRouteService) { | ||
this.meshRouteService = meshRouteService; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.POST) | ||
@ResponseStatus(HttpStatus.CREATED) | ||
public boolean createMeshRoute(@RequestBody MeshRouteDTO meshRoute, @PathVariable String env) { | ||
String app = meshRoute.getApplication(); | ||
if (StringUtils.isEmpty(app)) { | ||
throw new ParamValidationException("app is Empty!"); | ||
} | ||
// todo check appName | ||
|
||
return meshRouteService.createMeshRule(meshRoute); | ||
} | ||
|
||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) | ||
public boolean updateRule(@PathVariable String id, @RequestBody MeshRouteDTO meshRoute, @PathVariable String env) { | ||
id = id.replace(Constants.ANY_VALUE, Constants.PATH_SEPARATOR); | ||
if (meshRouteService.findMeshRoute(id) == null) { | ||
throw new ResourceNotFoundException("can not find mesh route, Id: " + id); | ||
} | ||
meshRoute.setId(id); | ||
return meshRouteService.updateMeshRule(meshRoute); | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.GET) | ||
public List<MeshRouteDTO> searchRoutes(@RequestParam String application, @PathVariable String env) { | ||
if (StringUtils.isBlank(application)) { | ||
throw new ParamValidationException("application is required."); | ||
} | ||
List<MeshRouteDTO> result = new ArrayList<>(); | ||
|
||
MeshRouteDTO meshRoute = meshRouteService.findMeshRoute(application); | ||
if (meshRoute != null) { | ||
result.add(meshRoute); | ||
} | ||
return result; | ||
} | ||
|
||
@RequestMapping(value = "/{id}", method = RequestMethod.GET) | ||
public MeshRouteDTO detailRoute(@PathVariable String id, @PathVariable String env) { | ||
id = id.replace(Constants.ANY_VALUE, Constants.PATH_SEPARATOR); | ||
MeshRouteDTO meshRoute = meshRouteService.findMeshRoute(id); | ||
if (meshRoute == null) { | ||
throw new ResourceNotFoundException("Unknown ID!"); | ||
} | ||
return meshRoute; | ||
} | ||
|
||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) | ||
public boolean deleteRoute(@PathVariable String id, @PathVariable String env) { | ||
id = id.replace(Constants.ANY_VALUE, Constants.PATH_SEPARATOR); | ||
return meshRouteService.deleteMeshRule(id); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/dto/MeshRouteDTO.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,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.model.dto; | ||
|
||
public class MeshRouteDTO extends BaseDTO{ | ||
|
||
private String meshRule; | ||
|
||
public String getMeshRule() { | ||
return meshRule; | ||
} | ||
|
||
public void setMeshRule(String meshRule) { | ||
this.meshRule = meshRule; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/store/mesh/BaseRule.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,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.model.store.mesh; | ||
|
||
import java.util.Map; | ||
|
||
|
||
public class BaseRule { | ||
private String apiVersion; | ||
private String kind; | ||
private Map<String,String> metadata; | ||
|
||
public String getApiVersion() { | ||
return apiVersion; | ||
} | ||
|
||
public void setApiVersion(String apiVersion) { | ||
this.apiVersion = apiVersion; | ||
} | ||
|
||
public String getKind() { | ||
return kind; | ||
} | ||
|
||
public void setKind(String kind) { | ||
this.kind = kind; | ||
} | ||
|
||
public Map<String, String> getMetadata() { | ||
return metadata; | ||
} | ||
|
||
public void setMetadata(Map<String, String> metadata) { | ||
this.metadata = metadata; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BaseRule{" + | ||
"apiVersion='" + apiVersion + '\'' + | ||
", kind='" + kind + '\'' + | ||
", metadata=" + metadata + | ||
'}'; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...dmin-server/src/main/java/org/apache/dubbo/admin/model/store/mesh/VsDestinationGroup.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,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.model.store.mesh; | ||
|
||
|
||
import org.apache.dubbo.admin.model.store.mesh.destination.DestinationRule; | ||
import org.apache.dubbo.admin.model.store.mesh.virtualservice.VirtualServiceRule; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class VsDestinationGroup { | ||
private String appName; | ||
private List<VirtualServiceRule> virtualServiceRuleList = new ArrayList<>(); | ||
private List<DestinationRule> destinationRuleList = new ArrayList<>(); | ||
|
||
public String getAppName() { | ||
return appName; | ||
} | ||
|
||
public void setAppName(String appName) { | ||
this.appName = appName; | ||
} | ||
|
||
public List<VirtualServiceRule> getVirtualServiceRuleList() { | ||
return virtualServiceRuleList; | ||
} | ||
|
||
public void setVirtualServiceRuleList(List<VirtualServiceRule> virtualServiceRuleList) { | ||
this.virtualServiceRuleList = virtualServiceRuleList; | ||
} | ||
|
||
public List<DestinationRule> getDestinationRuleList() { | ||
return destinationRuleList; | ||
} | ||
|
||
public void setDestinationRuleList(List<DestinationRule> destinationRuleList) { | ||
this.destinationRuleList = destinationRuleList; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...main/java/org/apache/dubbo/admin/model/store/mesh/destination/ConnectionPoolSettings.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,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.model.store.mesh.destination; | ||
|
||
|
||
public class ConnectionPoolSettings { | ||
} |
41 changes: 41 additions & 0 deletions
41
...er/src/main/java/org/apache/dubbo/admin/model/store/mesh/destination/DestinationRule.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,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dubbo.admin.model.store.mesh.destination; | ||
|
||
|
||
import org.apache.dubbo.admin.model.store.mesh.BaseRule; | ||
|
||
public class DestinationRule extends BaseRule { | ||
private DestinationRuleSpec spec; | ||
|
||
public DestinationRuleSpec getSpec() { | ||
return spec; | ||
} | ||
|
||
public void setSpec(DestinationRuleSpec spec) { | ||
this.spec = spec; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DestinationRule{" + | ||
"base=" + super.toString() + | ||
", spec=" + spec + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.