8000 V3.0 develop add condition for console request handler by KomachiSion · Pull Request #13011 · alibaba/nacos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

V3.0 develop add condition for console request handler #13011

New issue
8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.nacos.console.handler.impl.inner;

import com.alibaba.nacos.sys.env.Constants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Using Inner handler to handle console API request.
*
* @author xiweng.yy
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ConditionalOnProperty(value = Constants.NACOS_DEPLOYMENT_TYPE, havingValue = Constants.NACOS_DEPLOYMENT_TYPE_MERGED)
public @interface EnabledInnerHandler {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,9 @@
* 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 com.alibaba.nacos.console.handler.inner;
package com.alibaba.nacos.console.handler.impl.inner;

import com.alibaba.nacos.api.model.v2.Result;
import com.alibaba.nacos.console.handler.HealthHandler;
Expand All @@ -29,6 +28,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class HealthInnerHandler implements HealthHandler {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,9 @@
* 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 com.alibaba.nacos.console.handler.inner;
package com.alibaba.nacos.console.handler.impl.inner;

import com.alibaba.nacos.console.handler.ServerStateHandler;
import com.alibaba.nacos.sys.env.EnvUtil;
Expand All @@ -38,6 +37,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class ServerStateInnerHandler implements ServerStateHandler {

private static final String ANNOUNCEMENT_FILE = "announcement.conf";
Expand Down
8000
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,9 @@
* 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 com.alibaba.nacos.console.handler.inner.config;
package com.alibaba.nacos.console.handler.impl.inner.config;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.model.v2.ErrorCode;
Expand Down Expand Up @@ -50,6 +49,7 @@
import com.alibaba.nacos.config.server.utils.YamlParserUtil;
import com.alibaba.nacos.config.server.utils.ZipUtils;
import com.alibaba.nacos.console.handler.config.ConfigHandler;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.core.namespace.repository.NamespacePersistService;
import com.alibaba.nacos.persistence.model.Page;
import com.alibaba.nacos.plugin.encryption.handler.EncryptionHandler;
Expand Down Expand Up @@ -81,6 +81,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class ConfigInnerHandler implements ConfigHandler {

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigInnerHandler.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,9 @@
* 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 com.alibaba.nacos.console.handler.inner.config;
package com.alibaba.nacos.console.handler.impl.inner.config;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.exception.api.NacosApiException;
Expand All @@ -24,6 +23,7 @@
import com.alibaba.nacos.config.server.model.ConfigInfoWrapper;
import com.alibaba.nacos.config.server.service.HistoryService;
import com.alibaba.nacos.console.handler.config.HistoryHandler;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.persistence.model.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
Expand All @@ -38,6 +38,7 @@
* @author zhangyukun on:2024/8/16
*/
@Service
@EnabledInnerHandler
public class HistoryInnerHandler implements HistoryHandler {

private final HistoryService historyService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,13 +12,13 @@
* 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 com.alibaba.nacos.console.handler.inner.core;
package com.alibaba.nacos.console.handler.impl.inner.core;

import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.console.handler.core.ClusterHandler;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.core.cluster.Member;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -33,6 +33,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class ClusterInnerHandler implements ClusterHandler {

private final ServerMemberManager memberManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,13 +12,13 @@
* 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 com.alibaba.nacos.console.handler.inner.core;
package com.alibaba.nacos.console.handler.impl.inner.core;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.console.handler.core.NamespaceHandler;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.core.namespace.model.Namespace;
import com.alibaba.nacos.core.namespace.model.form.NamespaceForm;
import com.alibaba.nacos.core.namespace.repository.NamespacePersistService;
Expand All @@ -33,6 +33,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class NamespaceInnerHandler implements NamespaceHandler {

private final NamespaceOperationService namespaceOperationService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,17 +12,17 @@
* 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 com.alibaba.nacos.console.handler.inner.naming;
package com.alibaba.nacos.console.handler.impl.inner.naming;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.common.notify.NotifyCenter;
import com.alibaba.nacos.common.trace.event.naming.UpdateInstanceTraceEvent;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.console.handler.naming.InstanceHandler;
import com.alibaba.nacos.naming.core.CatalogServiceV2Impl;
import com.alibaba.nacos.naming.core.InstanceOperatorClientImpl;
Expand All @@ -42,6 +42,7 @@
* @author zhangyukun
*/
@Service
@EnabledInnerHandler
public class InstanceInnerHandler implements InstanceHandler {

private final CatalogServiceV2Impl catalogServiceV2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,9 @@
* 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 com.alibaba.nacos.console.handler.inner.naming;
package com.alibaba.nacos.console.handler.impl.inner.naming;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.common.notify.NotifyCenter;
Expand All @@ -24,6 +23,7 @@
import com.alibaba.nacos.common.trace.event.naming.UpdateServiceTraceEvent;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler;
import com.alibaba.nacos.console.handler.naming.ServiceHandler;
import com.alibaba.nacos.naming.core.CatalogServiceV2Impl;
import com.alibaba.nacos.naming.core.ClusterOperatorV2Impl;
Expand All @@ -48,6 +48,7 @@
* @author zhangyukun
*/
@org.springframework.stereotype.Service
@EnabledInnerHandler
public class ServiceInnerHandler implements ServiceHandler {

private final ServiceOperatorV2Impl serviceOperatorV2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.nacos.console.handler.impl.remote;

import com.alibaba.nacos.sys.env.Constants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Using Remote handler to call Nacos Admin API to handle console API request.
*
* @author xiweng.yy
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ConditionalOnProperty(value = Constants.NACOS_DEPLOYMENT_TYPE, havingValue = Constants.NACOS_DEPLOYMENT_TYPE_CONSOLE)
public @interface EnabledRemoteHandler {

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@

package com.alibaba.nacos.console.proxy;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.model.v2.Result;
import com.alibaba.nacos.console.config.ConsoleWebConfig;
import com.alibaba.nacos.console.handler.HealthHandler;
import com.alibaba.nacos.console.handler.inner.HealthInnerHandler;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
* Proxy class for handling health check operations.
*
Expand All @@ -35,25 +29,18 @@
@Service
public class HealthProxy {

private final Map<String, HealthHandler> healthHandlerMap = new HashMap<>();

private final ConsoleWebConfig consoleConfig;
private final HealthHandler healthHandler;

public HealthProxy(HealthInnerHandler healthInnerHandler, ConsoleWebConfig consoleConfig) {
this.healthHandlerMap.put("merged", healthInnerHandler);
this.consoleConfig = consoleConfig;
public HealthProxy(HealthHandler healthHandler) {
this.healthHandler = healthHandler;
}

/**
* Perform readiness check to determine if Nacos is ready to handle requests.
*
* @return readiness result
*/
public Result<String> checkReadiness() throws NacosException {
HealthHandler healthHandler = healthHandlerMap.get(consoleConfig.getType());
if (healthHandler == null) {
throw new NacosException(NacosException.INVALID_PARAM, "Invalid deployment type");
}
public Result<String> checkReadiness() {
return healthHandler.checkReadiness();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package com.alibaba.nacos.console.proxy;

import com.alibaba.nacos.console.handler.ServerStateHandler;
import com.alibaba.nacos.console.handler.inner.ServerStateInnerHandler;
import org.springframework.stereotype.Service;

import java.util.Map;
Expand All @@ -33,7 +32,7 @@ public class ServerStateProxy {

private final ServerStateHandler serverStateHandler;

public ServerStateProxy(ServerStateInnerHandler serverStateHandler) {
public ServerStateProxy(ServerStateHandler serverStateHandler) {
this.serverStateHandler = serverStateHandler;
}

Expand Down
Loading
0