mirror of https://github.com/longtai-cn/hippo4j
The RPC module is used to modify the invocation between server modes (#983)
* fix : Change the log level to debug * fix : ThreadPoolAdapterController WebThreadPoolController, WebThreadPoolRunStateController method in does not affect the use of the three interfaces of modify the calls for the use of RPC modulespull/986/head
parent
6f0889435b
commit
d0ab6c932d
@ -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 cn.hippo4j.adapter.base;
|
||||
|
||||
import cn.hippo4j.common.web.base.Result;
|
||||
|
||||
/**
|
||||
* Thread-pool adapter api.
|
||||
*/
|
||||
public interface ThreadPoolAdapterApi {
|
||||
|
||||
/**
|
||||
* Get thread pool information for the third-party framework
|
||||
*
|
||||
* @param requestParameter Third party frame identification and other info
|
||||
* @return thread pool info
|
||||
*/
|
||||
Result<ThreadPoolAdapterState> getAdapterThreadPool(ThreadPoolAdapterParameter requestParameter);
|
||||
|
||||
/**
|
||||
* Example Modify the thread pool information
|
||||
*
|
||||
* @param requestParameter update info
|
||||
*/
|
||||
Result<Void> updateAdapterThreadPool(ThreadPoolAdapterParameter requestParameter);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 cn.hippo4j.common.api;
|
||||
|
||||
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
|
||||
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
|
||||
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
|
||||
import cn.hippo4j.common.web.base.Result;
|
||||
|
||||
/**
|
||||
* Web thread pool api.
|
||||
*/
|
||||
public interface WebThreadPoolApi {
|
||||
|
||||
/**
|
||||
* Get thread pool information by identifying the mark
|
||||
*
|
||||
* @param mark Third party frame identification
|
||||
* @return thread pool info
|
||||
*/
|
||||
Result<ThreadPoolBaseInfo> getPoolBaseState(String mark);
|
||||
|
||||
/**
|
||||
* Get all thread pool information
|
||||
*
|
||||
* @return thread pool info
|
||||
*/
|
||||
Result<ThreadPoolRunStateInfo> getPoolRunState();
|
||||
|
||||
/**
|
||||
* Example Modify the thread pool information
|
||||
*
|
||||
* @param threadPoolParameterInfo update info
|
||||
*/
|
||||
Result<Void> updateWebThreadPool(ThreadPoolParameterInfo threadPoolParameterInfo);
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 cn.hippo4j.common.api;
|
||||
|
||||
import cn.hippo4j.common.model.ThreadDetailStateInfo;
|
||||
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
|
||||
import cn.hippo4j.common.web.base.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Web thread-pool run state api.
|
||||
*/
|
||||
public interface WebThreadPoolRunStateApi {
|
||||
|
||||
/**
|
||||
* Get the run state info of the web thread pool
|
||||
*
|
||||
* @param threadPoolId the thread pool id
|
||||
* @return the info
|
||||
*/
|
||||
Result<ThreadPoolRunStateInfo> getPoolRunState(String threadPoolId);
|
||||
|
||||
/**
|
||||
* Get the run state detail of the web thread pool
|
||||
*
|
||||
* @param threadPoolId the thread pool id
|
||||
* @return the detail
|
||||
*/
|
||||
Result<List<ThreadDetailStateInfo>> getThreadStateDetail(String threadPoolId);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 cn.hippo4j.springboot.starter.config;
|
||||
|
||||
import cn.hippo4j.adapter.base.ThreadPoolAdapterApi;
|
||||
import cn.hippo4j.common.api.WebThreadPoolApi;
|
||||
import cn.hippo4j.common.api.WebThreadPoolRunStateApi;
|
||||
import cn.hippo4j.rpc.discovery.ServerPort;
|
||||
import cn.hippo4j.rpc.discovery.SpringContextInstance;
|
||||
import cn.hippo4j.rpc.handler.NettyServerTakeHandler;
|
||||
import cn.hippo4j.rpc.server.NettyServerConnection;
|
||||
import cn.hippo4j.rpc.server.Server;
|
||||
import cn.hippo4j.rpc.support.NettyServerSupport;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class NettyServerConfiguration implements ApplicationRunner, EnvironmentAware {
|
||||
|
||||
Environment environment;
|
||||
|
||||
private static final Class<?>[] classes = {
|
||||
WebThreadPoolApi.class,
|
||||
ThreadPoolAdapterApi.class,
|
||||
WebThreadPoolRunStateApi.class
|
||||
};
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Integer port = environment.getProperty("spring.dynamic.thread-pool.local-server-port", Integer.class);
|
||||
ServerPort serverPort = () -> port == null ? 16691 : port;
|
||||
NettyServerTakeHandler handler = new NettyServerTakeHandler(new SpringContextInstance());
|
||||
try (
|
||||
NettyServerConnection connection = new NettyServerConnection(handler);
|
||||
Server server = new NettyServerSupport(serverPort, connection, classes)) {
|
||||
server.bind();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue