-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add LifeCycle component and refactor some code. (#113) * Make getAfterRun un-block avoid deadlock. (#107) (#109) * update readme * update version to 1.6.0-SNAPSHOT * 修改RpcClientDemoByMain 和RpcServerDemoByMain 的logger引用对象 (#112) * 修改日志引用的对象 * add lifecycle component * fix NPE in ReconnectManager and refactor some code * Refactor some components with LifeCycle interface. (#114) Refactor some components with LifeCycle interface. * Refactor RpcClient with LifeCycle interface and add option module. (#116) Refactor RpcClient with LifeCycle interface and add option module. * fix #131 (#132) * refactor DefaultConnectionManager to fix issue: #131 * refactory ConnectionManager to support start/shutdown operations (#135) * 重构ScheduledDisconnectStrategy实现 (#136) * refactory ConnectionManager to support start/shutdown operations * Reconnector class is used instead of ReconnectManager class * refactor ScheduledDisconnectStrategy * Support config strategy (#138) * support config user ConnectionSelectStrategy impl * add LifeCycle interface to RemotingServer * fix some code according to CR * fix #137 (#141) * update version 1.6.0-SNAPSHOT->1.6.0
- Loading branch information
Showing
51 changed files
with
2,186 additions
and
1,292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,27 +14,46 @@ | |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.remoting.config; | ||
package com.alipay.remoting; | ||
|
||
import com.alipay.remoting.config.BoltOption; | ||
import com.alipay.remoting.config.BoltOptions; | ||
import com.alipay.remoting.config.ConfigManager; | ||
import com.alipay.remoting.config.Configurable; | ||
import com.alipay.remoting.config.ConfigurableInstance; | ||
import com.alipay.remoting.config.configs.ConfigContainer; | ||
import com.alipay.remoting.config.configs.ConfigItem; | ||
import com.alipay.remoting.config.configs.ConfigType; | ||
import com.alipay.remoting.config.configs.DefaultConfigContainer; | ||
import com.alipay.remoting.config.switches.GlobalSwitch; | ||
|
||
/** | ||
* common implementation for a configurable instance | ||
* | ||
* @author tsui | ||
* @version $Id: AbstractConfigurableInstance.java, v 0.1 2018-07-30 21:11 tsui Exp $$ | ||
* @author chengyi ([email protected]) 2018-11-07 15:22 | ||
*/ | ||
public class AbstractConfigurableInstance implements ConfigurableInstance { | ||
private ConfigContainer configContainer = new DefaultConfigContainer(); | ||
private GlobalSwitch globalSwitch = new GlobalSwitch(); | ||
private ConfigType configType; | ||
public abstract class AbstractBoltClient extends AbstractLifeCycle implements BoltClient, | ||
ConfigurableInstance { | ||
|
||
private final BoltOptions options; | ||
private final ConfigType configType; | ||
private final GlobalSwitch globalSwitch; | ||
private final ConfigContainer configContainer; | ||
|
||
public AbstractBoltClient() { | ||
this.options = new BoltOptions(); | ||
this.configType = ConfigType.CLIENT_SIDE; | ||
this.globalSwitch = new GlobalSwitch(); | ||
this.configContainer = new DefaultConfigContainer(); | ||
} | ||
|
||
protected AbstractConfigurableInstance(ConfigType configType) { | ||
this.configType = configType; | ||
@Override | ||
public <T> T option(BoltOption<T> option) { | ||
return options.option(option); | ||
} | ||
|
||
@Override | ||
public <T> Configurable option(BoltOption<T> option, T value) { | ||
options.option(option, value); | ||
return this; | ||
} | ||
|
||
@Override | ||
|
@@ -55,23 +74,21 @@ public void initWriteBufferWaterMark(int low, int high) { | |
|
||
@Override | ||
public int netty_buffer_low_watermark() { | ||
if (null != configContainer | ||
&& configContainer.contains(configType, ConfigItem.NETTY_BUFFER_LOW_WATER_MARK)) { | ||
return (Integer) configContainer | ||
.get(configType, ConfigItem.NETTY_BUFFER_LOW_WATER_MARK); | ||
Object config = configContainer.get(configType, ConfigItem.NETTY_BUFFER_LOW_WATER_MARK); | ||
if (config != null) { | ||
return (Integer) config; | ||
} else { | ||
return ConfigManager.netty_buffer_low_watermark(); | ||
} | ||
} | ||
|
||
@Override | ||
public int netty_buffer_high_watermark() { | ||
if (null != configContainer | ||
&& configContainer.contains(configType, ConfigItem.NETTY_BUFFER_HIGH_WATER_MARK)) { | ||
return (Integer) configContainer.get(configType, | ||
ConfigItem.NETTY_BUFFER_HIGH_WATER_MARK); | ||
Object config = configContainer.get(configType, ConfigItem.NETTY_BUFFER_HIGH_WATER_MARK); | ||
if (config != null) { | ||
return (Integer) config; | ||
} else { | ||
return ConfigManager.netty_buffer_high_watermark(); | ||
} | ||
} | ||
} | ||
} |
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,50 @@ | ||
/* | ||
* 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 com.alipay.remoting; | ||
|
||
/** | ||
* @author chengyi ([email protected]) 2018-11-05 14:43 | ||
*/ | ||
public abstract class AbstractLifeCycle implements LifeCycle { | ||
|
||
private volatile boolean isStarted = false; | ||
|
||
@Override | ||
public void startup() throws LifeCycleException { | ||
if (!isStarted) { | ||
isStarted = true; | ||
return; | ||
} | ||
|
||
throw new LifeCycleException("this component has started"); | ||
} | ||
|
||
@Override | ||
public void shutdown() throws LifeCycleException { | ||
if (isStarted) { | ||
isStarted = false; | ||
return; | ||
} | ||
|
||
throw new LifeCycleException("this component has closed"); | ||
} | ||
|
||
@Override | ||
public boolean isStarted() { | ||
return isStarted; | ||
} | ||
} |
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
Oops, something went wrong.