-
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.
* replace local constants with global constants * remove unnecessary declarations * create adapter for util method * remove unused imports * remove unnecessary code. issue #307
- Loading branch information
1 parent
45c0d41
commit 9f7aeea
Showing
11 changed files
with
163 additions
and
173 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
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
38 changes: 38 additions & 0 deletions
38
...rc/main/java/org/apache/dubbo/admin/model/adapter/BalancingDTO2OverrideConfigAdapter.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,38 @@ | ||
/* | ||
* 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.adapter; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.dubbo.admin.common.util.Constants; | ||
import org.apache.dubbo.admin.model.dto.BalancingDTO; | ||
import org.apache.dubbo.admin.model.store.OverrideConfig; | ||
|
||
public class BalancingDTO2OverrideConfigAdapter extends OverrideConfig { | ||
public BalancingDTO2OverrideConfigAdapter(BalancingDTO balancingDTO) { | ||
setType(Constants.BALANCING); | ||
setEnabled(true); | ||
setSide(Constants.CONSUMER_SIDE); | ||
Map<String, Object> parameters = new HashMap<>(); | ||
if (balancingDTO.getMethodName().equals("*")) { | ||
parameters.put("loadbalance", balancingDTO.getStrategy()); | ||
} else { | ||
parameters.put(balancingDTO.getMethodName() + ".loadbalance", balancingDTO.getStrategy()); | ||
} | ||
setParameters(parameters); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...c/main/java/org/apache/dubbo/admin/model/adapter/DynamicConfigDTO2OverrideDTOAdapter.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,36 @@ | ||
/* | ||
* 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.adapter; | ||
|
||
import org.apache.dubbo.admin.common.util.Constants; | ||
import org.apache.dubbo.admin.model.dto.DynamicConfigDTO; | ||
import org.apache.dubbo.admin.model.store.OverrideDTO; | ||
import org.apache.dubbo.common.utils.StringUtils; | ||
|
||
public class DynamicConfigDTO2OverrideDTOAdapter extends OverrideDTO { | ||
public DynamicConfigDTO2OverrideDTOAdapter(DynamicConfigDTO dynamicConfigDTO) { | ||
if (StringUtils.isNotEmpty(dynamicConfigDTO.getApplication())) { | ||
setScope(Constants.APPLICATION); | ||
setKey(dynamicConfigDTO.getApplication()); | ||
} else { | ||
setScope(Constants.SERVICE); | ||
setKey(dynamicConfigDTO.getService()); | ||
} | ||
setConfigVersion(dynamicConfigDTO.getConfigVersion()); | ||
setConfigs(dynamicConfigDTO.getConfigs()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...erver/src/main/java/org/apache/dubbo/admin/model/adapter/LoadBalance2OverrideAdapter.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,37 @@ | ||
/* | ||
* 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.adapter; | ||
|
||
import org.apache.dubbo.admin.model.domain.LoadBalance; | ||
import org.apache.dubbo.admin.model.domain.Override; | ||
import org.apache.dubbo.common.utils.StringUtils; | ||
|
||
public class LoadBalance2OverrideAdapter extends Override { | ||
public LoadBalance2OverrideAdapter(final LoadBalance loadBalance) { | ||
setId(loadBalance.getId()); | ||
setHash(loadBalance.getHash()); | ||
setService(loadBalance.getService()); | ||
setEnabled(true); | ||
String method = loadBalance.getMethod(); | ||
String strategy = loadBalance.getStrategy(); | ||
if (StringUtils.isEmpty(method) || method.equals("*")) { | ||
setParams("loadbalance=" + strategy); | ||
} else { | ||
setParams(method + ".loadbalance=" + strategy); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...in-server/src/main/java/org/apache/dubbo/admin/model/adapter/WeightToOverrideAdapter.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,31 @@ | ||
/* | ||
* 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.adapter; | ||
|
||
import org.apache.dubbo.admin.model.domain.Override; | ||
import org.apache.dubbo.admin.model.domain.Weight; | ||
|
||
public class WeightToOverrideAdapter extends Override { | ||
public WeightToOverrideAdapter(Weight weight) { | ||
setId(weight.getId()); | ||
setHash(weight.getHash()); | ||
setAddress(weight.getAddress()); | ||
setEnabled(true); | ||
setParams("weight=" + weight.getWeight()); | ||
setService(weight.getService()); | ||
} | ||
} |
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
Oops, something went wrong.