Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
6131f748
Commit
6131f748
authored
Jan 13, 2022
by
lixiaozhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
移除没用的自定义的为了做ip路由的dubboCluster相关类
parent
659a7473
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
99 deletions
+0
-99
core/src/main/java/com/wecloud/im/router/dubbo/ChannelAbstractClusterInvoker.java
+0
-84
core/src/main/java/com/wecloud/im/router/dubbo/ChannelRouterCluster.java
+0
-14
core/src/main/resources/MATA-INF/dubbo/org.apache.dubbo.rpc.cluster.Cluster
+0
-1
No files found.
core/src/main/java/com/wecloud/im/router/dubbo/ChannelAbstractClusterInvoker.java
deleted
100644 → 0
View file @
659a7473
package
com
.
wecloud
.
im
.
router
.
dubbo
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.dubbo.common.Version
;
import
org.apache.dubbo.common.utils.NetUtils
;
import
org.apache.dubbo.rpc.Invocation
;
import
org.apache.dubbo.rpc.Invoker
;
import
org.apache.dubbo.rpc.Result
;
import
org.apache.dubbo.rpc.RpcContext
;
import
org.apache.dubbo.rpc.RpcException
;
import
org.apache.dubbo.rpc.RpcInvocation
;
import
org.apache.dubbo.rpc.cluster.Directory
;
import
org.apache.dubbo.rpc.cluster.LoadBalance
;
import
org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker
;
import
org.apache.dubbo.rpc.support.RpcUtils
;
import
java.util.List
;
import
java.util.Map
;
public
class
ChannelAbstractClusterInvoker
<
T
>
extends
AbstractClusterInvoker
<
T
>
{
public
ChannelAbstractClusterInvoker
(
Directory
<
T
>
directory
)
{
super
(
directory
);
}
@Override
protected
Result
doInvoke
(
Invocation
invocation
,
List
<
Invoker
<
T
>>
invokers
,
LoadBalance
loadbalance
)
throws
RpcException
{
//1.查看是否设置了指定ip
String
ip
=
(
String
)
RpcContext
.
getContext
().
get
(
"ip"
);
if
(
StringUtils
.
isBlank
(
ip
))
{
throw
new
RuntimeException
(
"ip is blank "
);
}
//2.检查是否有可用invoker
checkInvokers
(
invokers
,
invocation
);
//3.根据指定ip获取对应invoker
Invoker
<
T
>
invoked
=
invokers
.
stream
().
filter
(
invoker
->
invoker
.
getUrl
().
getHost
().
equals
(
ip
))
.
findFirst
().
orElse
(
null
);
//4.检查是否有可用invoker
if
(
null
==
invoked
)
{
throw
new
RpcException
(
RpcException
.
NO_INVOKER_AVAILABLE_AFTER_FILTER
,
"Failed to invoke the method "
+
invocation
.
getMethodName
()
+
" in the service "
+
getInterface
().
getName
()
+
". No provider available for the service "
+
directory
.
getUrl
().
getServiceKey
()
+
" from ip "
+
ip
+
" on the consumer "
+
NetUtils
.
getLocalHost
()
+
" using the dubbo version "
+
Version
.
getVersion
()
+
". Please check if the providers have been started and registered."
);
}
//5.发起远程调用,失败则抛出异常
try
{
return
invoked
.
invoke
(
invocation
);
}
catch
(
Throwable
e
)
{
if
(
e
instanceof
RpcException
&&
((
RpcException
)
e
).
isBiz
())
{
// biz exception.
throw
(
RpcException
)
e
;
}
throw
new
RpcException
(
e
instanceof
RpcException
?
((
RpcException
)
e
).
getCode
()
:
0
,
"Fail invoke providers "
+
(
invoked
!=
null
?
invoked
.
getUrl
():
""
)+
" "
+
loadbalance
.
getClass
().
getSimpleName
()
+
" select from all providers "
+
invokers
+
" for service "
+
getInterface
().
getName
()
+
" method "
+
invocation
.
getMethodName
()
+
" on consumer "
+
NetUtils
.
getLocalHost
()
+
" use dubbo version "
+
Version
.
getVersion
()
+
", but no luck to perform the invocation. Last error is: "
+
e
.
getMessage
(),
e
.
getCause
()
!=
null
?
e
.
getCause
()
:
e
);
}
}
/**
* 覆盖父类,将负载均衡去除
* @param invocation
* @return
* @throws RpcException
*/
@Override
public
Result
invoke
(
final
Invocation
invocation
)
throws
RpcException
{
this
.
checkWhetherDestroyed
();
Map
<
String
,
Object
>
contextAttachments
=
RpcContext
.
getContext
().
getObjectAttachments
();
if
(
contextAttachments
!=
null
&&
contextAttachments
.
size
()
!=
0
)
{
((
RpcInvocation
)
invocation
).
addObjectAttachments
(
contextAttachments
);
}
List
<
Invoker
<
T
>>
invokers
=
this
.
list
(
invocation
);
LoadBalance
loadbalance
=
null
;
// this.initLoadBalance(invokers, invocation);
RpcUtils
.
attachInvocationIdIfAsync
(
this
.
getUrl
(),
invocation
);
return
this
.
doInvoke
(
invocation
,
invokers
,
loadbalance
);
}
}
core/src/main/java/com/wecloud/im/router/dubbo/ChannelRouterCluster.java
deleted
100644 → 0
View file @
659a7473
package
com
.
wecloud
.
im
.
router
.
dubbo
;
import
org.apache.dubbo.rpc.Invoker
;
import
org.apache.dubbo.rpc.RpcException
;
import
org.apache.dubbo.rpc.cluster.Cluster
;
import
org.apache.dubbo.rpc.cluster.Directory
;
public
class
ChannelRouterCluster
implements
Cluster
{
@Override
public
<
T
>
Invoker
<
T
>
join
(
Directory
<
T
>
directory
)
throws
RpcException
{
return
new
ChannelAbstractClusterInvoker
<>(
directory
);
}
}
core/src/main/resources/MATA-INF/dubbo/org.apache.dubbo.rpc.cluster.Cluster
deleted
100644 → 0
View file @
659a7473
channelRouterCluster=com.wecloud.im.router.dubbo.ChannelRouterCluster
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment