-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #908 from ctripcorp/feature/redis_client_name_set
Add redis client name
- Loading branch information
Showing
21 changed files
with
555 additions
and
34 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
9 changes: 9 additions & 0 deletions
9
core/src/main/java/com/ctrip/xpipe/netty/commands/RedisNettyClient.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,9 @@ | ||
package com.ctrip.xpipe.netty.commands; | ||
|
||
public interface RedisNettyClient { | ||
|
||
boolean getDoAfterConnectedOver(); | ||
|
||
int getAfterConnectCommandTimeoutMill(); | ||
|
||
} |
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
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
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
7 changes: 7 additions & 0 deletions
7
.../redis-core/src/main/java/com/ctrip/xpipe/redis/core/client/AsyncConnectionCondition.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,7 @@ | ||
package com.ctrip.xpipe.redis.core.client; | ||
|
||
public interface AsyncConnectionCondition { | ||
|
||
boolean shouldDo(); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...dis-core/src/main/java/com/ctrip/xpipe/redis/core/client/NettyRedisPoolClientFactory.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 @@ | ||
package com.ctrip.xpipe.redis.core.client; | ||
|
||
import com.ctrip.xpipe.api.endpoint.Endpoint; | ||
import com.ctrip.xpipe.netty.commands.NettyClient; | ||
import com.ctrip.xpipe.netty.commands.NettyClientHandler; | ||
import com.ctrip.xpipe.netty.commands.NettyKeyedPoolClientFactory; | ||
import io.netty.channel.ChannelFuture; | ||
import org.apache.commons.pool2.PooledObject; | ||
import org.apache.commons.pool2.impl.DefaultPooledObject; | ||
|
||
public class NettyRedisPoolClientFactory extends NettyKeyedPoolClientFactory { | ||
|
||
private String clientName; | ||
|
||
private AsyncConnectionCondition asyncConnectionCondition; | ||
|
||
public NettyRedisPoolClientFactory(int eventLoopThreads, String clientName, AsyncConnectionCondition asyncConnectionCondition) { | ||
super(eventLoopThreads); | ||
this.clientName = clientName; | ||
this.asyncConnectionCondition = asyncConnectionCondition; | ||
} | ||
|
||
@Override | ||
public PooledObject<NettyClient> makeObject(Endpoint key) throws Exception { | ||
ChannelFuture f = b.connect(key.getHost(), key.getPort()); | ||
NettyClient nettyClient = new RedisAsyncNettyClient(f, key, clientName, asyncConnectionCondition); | ||
f.channel().attr(NettyClientHandler.KEY_CLIENT).set(nettyClient); | ||
return new DefaultPooledObject<NettyClient>(nettyClient); | ||
} | ||
|
||
} |
Oops, something went wrong.