format code
diff --git a/include/dubboerl.hrl b/include/dubboerl.hrl
index 7c8b1af..deb3d5a 100644
--- a/include/dubboerl.hrl
+++ b/include/dubboerl.hrl
@@ -24,7 +24,7 @@
-record(dubbo_url, {
scheme :: binary() ,
- user_info :: binary(),
+ user_info :: binary() | undefined,
host:: binary(),
port::integer(),
path:: binary(),
diff --git a/samples/dubbo-sample-service/src/main/java/org/apache/dubbo/erlang/sample/service/AppListMain.java b/samples/dubbo-sample-service/src/main/java/org/apache/dubbo/erlang/sample/service/AppListMain.java
index 81ee14e..1a1f7c1 100644
--- a/samples/dubbo-sample-service/src/main/java/org/apache/dubbo/erlang/sample/service/AppListMain.java
+++ b/samples/dubbo-sample-service/src/main/java/org/apache/dubbo/erlang/sample/service/AppListMain.java
@@ -20,6 +20,8 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
public class AppListMain {
@@ -28,6 +30,9 @@
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "applicationProvider.xml" });
context.start();
+ RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
+ System.out.println(runtimeMXBean.getName());
+ System.out.println("current process pid "+ Integer.valueOf(runtimeMXBean.getName().split("@")[0]));
System.out.println("按任意键退出");
System.in.read();
diff --git a/samples/dubbo-sample-service/src/main/resources/applicationConsumer.xml b/samples/dubbo-sample-service/src/main/resources/applicationConsumer.xml
index 296bc83..d83a62c 100644
--- a/samples/dubbo-sample-service/src/main/resources/applicationConsumer.xml
+++ b/samples/dubbo-sample-service/src/main/resources/applicationConsumer.xml
@@ -21,7 +21,7 @@
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="hello-world"/><!-- 注册地址 -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181" check="false" />
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:reference id="userInterface" interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" retries="0" />
diff --git a/src/dubbo_cluster_failfast.erl b/src/dubbo_cluster_failfast.erl
index 48809f8..e6f6e8b 100644
--- a/src/dubbo_cluster_failfast.erl
+++ b/src/dubbo_cluster_failfast.erl
@@ -19,7 +19,7 @@
-include("dubbo.hrl").
%% API
--export([invoke/2, do_response/2]).
+-export([invoke/2, on_response/2]).
invoke(#dubbo_rpc_invocation{className = Interface, loadbalance = LoadBalance} = Invocation, Acc) ->
@@ -53,5 +53,5 @@
Connection = LoadBalance:select(ConnectionList),
Connection.
-do_response(Invocation, Result) ->
+on_response(Invocation, Result) ->
{ok, Invocation, Result}.
diff --git a/src/dubbo_codec.erl b/src/dubbo_codec.erl
index c3e241f..9a6cdbe 100644
--- a/src/dubbo_codec.erl
+++ b/src/dubbo_codec.erl
@@ -46,8 +46,8 @@
false -> Header2
end,
Header22 = case Request#dubbo_request.is_event of
- true -> Header21 bor 32;
- false -> Header21
+ false -> Header21;
+ true -> Header21 bor 32
end,
RequestId = Request#dubbo_request.mid,
Header = <<?DUBBO_MEGIC:16, Header22:8, RequestState:8, RequestId:64, DataLen:32>>,
@@ -82,8 +82,8 @@
false -> Header2
end,
Header22 = case Response#dubbo_response.is_event of
- true -> Header21 bor 32;
- false -> Header21
+ false -> Header21;
+ true -> Header21 bor 32
end,
RequestId = Response#dubbo_response.mid,
Header = <<?DUBBO_MEGIC:16, Header22:8, ResponseState:8, RequestId:64, DataLen:32>>,
diff --git a/src/dubbo_common_fun.erl b/src/dubbo_common_fun.erl
index e0db828..fff65bb 100644
--- a/src/dubbo_common_fun.erl
+++ b/src/dubbo_common_fun.erl
@@ -94,13 +94,9 @@
list_to_binary(Value).
format_path(<< ?URL_PATH_SEPARATOR:8,Rest/binary>>) ->
Rest;
-format_path([?URL_PATH_SEPARATOR|Rest]) ->
- Rest;
format_path(Value) ->
Value.
-format_parameter(undefined) ->
- "";
format_parameter(Parameter) when is_map(Parameter) ->
KeyValues = maps:to_list(Parameter),
format_parameter(KeyValues);
diff --git a/src/dubbo_directory.erl b/src/dubbo_directory.erl
index cec107b..0bfe487 100644
--- a/src/dubbo_directory.erl
+++ b/src/dubbo_directory.erl
@@ -86,14 +86,14 @@
refresh_invoker(UrlList) ->
case pick_interface(UrlList) of
- {error, Reason} ->
+ {error, _Reason} ->
fail;
{<<"empty">>, Interface,_} ->
OldProviderHosts = dubbo_provider_consumer_reg_table:get_interface_provider_node(Interface),
dubbo_provider_consumer_reg_table:clean_invalid_provider(OldProviderHosts),
todo_destroy;
- {Schame, Interface, LoadBalance} ->
- ProtocolModule = binary_to_existing_atom(<<<<"dubbo_protocol_">>/binary, Schame/binary>>, latin1),
+ {Scheme, Interface, LoadBalance} ->
+ ProtocolModule = binary_to_existing_atom(<<<<"dubbo_protocol_">>/binary, Scheme/binary>>, latin1),
logger:info("[DUBBO] refresh invoker for interface ~p loadbalance ~p protocol ~p", [Interface, LoadBalance, ProtocolModule]),
OldProviderHosts = dubbo_provider_consumer_reg_table:get_interface_provider_node(Interface),
@@ -107,12 +107,8 @@
NewHostConnections = dubbo_provider_consumer_reg_table:query_node_connections(NewHosts),
dubbo_provider_consumer_reg_table:update_consumer_connections(Interface, NewHostConnections)
end, NewProviderHosts),
-
-
-%% dubbo_provider_consumer_reg_table:update_connection_info(#interface_info{interface = Interface,loadbalance = LoadBalance})
dubbo_provider_consumer_reg_table:update_interface_info(#interface_info{interface = Interface, loadbalance = LoadBalance, protocol = ProtocolModule})
end.
-%% OldProviderHosts =
refresh_invoker([], Acc) ->
Acc;
@@ -154,7 +150,7 @@
{stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
{stop, Reason :: term(), NewState :: #state{}}).
handle_call({subscribe, RegistryName, SubcribeUrl}, _From, State) ->
- NotifyFun = fun dubbo_directory:notify/1,
+ NotifyFun = fun dubbo_directory:notify/2,
apply(RegistryName, subscribe, [SubcribeUrl, NotifyFun]),
{reply, ok, State};
handle_call(_Request, _From, State) ->
diff --git a/src/dubbo_extension.erl b/src/dubbo_extension.erl
index e6f4394..4a92338 100644
--- a/src/dubbo_extension.erl
+++ b/src/dubbo_extension.erl
@@ -3,7 +3,7 @@
%% 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 not use this file e34rg 56yujxcept in compliance with
%% the License. You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
@@ -121,15 +121,6 @@
do_invoke(Rest, HookName, Fun, [Args2], NewAcc2)
end.
-
-%% @doc retrieve the lists of registered functions for an hook.
--spec find(HookName :: atom()) -> {ok, [{atom(), atom()}]} | error.
-find(HookName) ->
- case find_hooks(HookName) of
- no_hook -> error;
- Hooks -> {ok, Hooks}
- end.
-
%% @hidden
start_link() ->
_ = init_tabs(),
diff --git a/src/dubbo_invoker.erl b/src/dubbo_invoker.erl
index 9981f2d..e9bbc4d 100644
--- a/src/dubbo_invoker.erl
+++ b/src/dubbo_invoker.erl
@@ -84,7 +84,7 @@
end.
invoke_response(Invocation, Result) ->
- Result2 = dubbo_extension:invoke_foldr(filter, do_response, [Invocation], Result),
+ Result2 = dubbo_extension:invoke_foldr(filter, on_response, [Invocation], Result),
gen_server:cast(Invocation#dubbo_rpc_invocation.source_pid, {response_process, Invocation#dubbo_rpc_invocation.call_ref, Invocation#dubbo_rpc_invocation.attachments, Result2}),
ok.
diff --git a/src/dubbo_node_config_util.erl b/src/dubbo_node_config_util.erl
index 59fef4b..b2e82c1 100644
--- a/src/dubbo_node_config_util.erl
+++ b/src/dubbo_node_config_util.erl
@@ -46,8 +46,6 @@
Config#provider_config{methods = MethodList};
parse_parameter(<<"side">>, Value, Config) ->
Config#provider_config{side = Value};
-parse_parameter(<<"interface">>, Value, Config) ->
- Config#provider_config{interface = Value};
parse_parameter(_, _, Config) ->
Config.
diff --git a/src/dubbo_protocol_dubbo.erl b/src/dubbo_protocol_dubbo.erl
index ae76035..21470a5 100644
--- a/src/dubbo_protocol_dubbo.erl
+++ b/src/dubbo_protocol_dubbo.erl
@@ -37,7 +37,6 @@
do_refer(UrlInfo) ->
case dubbo_node_config_util:parse_provider_info(UrlInfo) of
{ok, ProviderConfig} ->
-%% OldHostList = dubbo_provider_consumer_reg_table:get_interface_provider_node(ProviderConfig#provider_config.interface),
case getClients(ProviderConfig) of
{ok, ConnectionInfoList} ->
dubbo_provider_consumer_reg_table:update_node_conections(ProviderConfig#provider_config.interface, ConnectionInfoList),
diff --git a/src/dubbo_service_config.erl b/src/dubbo_service_config.erl
index d59f38d..3fb2a89 100644
--- a/src/dubbo_service_config.erl
+++ b/src/dubbo_service_config.erl
@@ -63,15 +63,6 @@
Para.
get_export_info(ProviderInfo) ->
- %%dubbo://127.0.0.1:20880/org.apache.dubbo.erlang.sample.service.facade.UserOperator?
- %% anyhost=true&
- %% application=hello-world&
- %% bean.name=org.apache.dubbo.erlang.sample.service.facade.UserOperator&
- %% bind.ip=127.0.0.1&bind.port=20880&default.deprecated=false&
- %% default.dynamic=false&default.register=true&deprecated=false&dubbo=2.0.2&
- %% dynamic=false&generic=false&
- %% interface=org.apache.dubbo.erlang.sample.service.facade.UserOperator&
- %% methods=queryUserInfo,queryUserList,genUserId,getUserInfo&pid=90956®ister=true&release=2.7.1&side=provider×tamp=1562725983984
Para = [
{"anyhost", "true"},
{"application", ProviderInfo#provider_config.application},
diff --git a/src/dubbo_time_util.erl b/src/dubbo_time_util.erl
index ea013cb..1e54c3d 100644
--- a/src/dubbo_time_util.erl
+++ b/src/dubbo_time_util.erl
@@ -34,7 +34,7 @@
io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w", [Year, Month, Day, Hour, Min, Second]).
get_cur_date() ->
- {{Year, Month, Day}, {Hour, Min, Second}} = calendar:now_to_local_time(os:timestamp()),
+ {{Year, Month, Day}, {_Hour, _Min, _Second}} = calendar:now_to_local_time(os:timestamp()),
io_lib:format("~4..0w-~2..0w-~2..0w", [Year, Month, Day]).
get_cur_time({{Year, Month, Day}, {Hour, Min, Second}}) ->
diff --git a/src/dubboerl_app.erl b/src/dubboerl_app.erl
index d27b690..225da69 100644
--- a/src/dubboerl_app.erl
+++ b/src/dubboerl_app.erl
@@ -47,14 +47,25 @@
dubbo_extension:register(protocol, dubbo_protocol_dubbo, 10),
dubbo_extension:register(protocol_wapper, dubbo_protocol_registry, 10),
dubbo_extension:register(filter, application:get_env(dubboerl, cluster, dubbo_cluster_failfast), 1),
+ init_filter_hooks(),
ok.
+
+init_filter_hooks() ->
+ FilterList = application:get_env(dubboerl, filter, []),
+ lists:mapfoldl(
+ fun(Filter,Acc) ->
+ dubbo_extension:register(filter, Filter, Acc),
+ Acc +1
+ end,100,FilterList
+ ),
+ ok.
+
env_init() ->
ets:new(?PROVIDER_IMPL_TABLE, [public, named_table]),
ets:new(?SERVICE_EXPORT_TABLE, [public, named_table]),
dubbo_traffic_control:init(),
dubbo_type_register:init(),
register_type_list().
-%% type_decoding:init().
register_type_list() ->
diff --git a/test/dubbo_common_fun_tests.erl b/test/dubbo_common_fun_tests.erl
index 9e74ab4..ce38852 100644
--- a/test/dubbo_common_fun_tests.erl
+++ b/test/dubbo_common_fun_tests.erl
@@ -35,4 +35,9 @@
list_dup_test() ->
R = dubbo_lists_util:del_duplicate([a, b, a]),
- ?assertEqual(length(R), 2).
\ No newline at end of file
+ ?assertEqual(length(R), 2).
+
+
+ip_v4_test()->
+ Result = dubbo_network_tools:local_ipv4(),
+ ?assertEqual(true,is_list(Result)).
\ No newline at end of file
diff --git a/test/dubbo_extension_tests.erl b/test/dubbo_extension_tests.erl
new file mode 100644
index 0000000..04d5726
--- /dev/null
+++ b/test/dubbo_extension_tests.erl
@@ -0,0 +1,35 @@
+%%------------------------------------------------------------------------------
+%% 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.
+%%------------------------------------------------------------------------------
+-module(dubbo_extension_tests).
+
+
+-include_lib("eunit/include/eunit.hrl").
+-include("dubbo.hrl").
+
+invoker_test()->
+ {ok,_Pid} = dubbo_extension:start_link(),
+
+ ok = dubbo_extension:register(filter, dubbo_filter_test1, 100),
+ Invocation = #dubbo_rpc_invocation{},
+ Ref = make_ref(),
+ {ok,Ref} = dubbo_extension:invoke(filter, invoke, [Invocation], {ok, Ref}, []),
+ ok.
+
+%%on_response_test() ->
+
+
+
diff --git a/test/dubbo_filter_test1.erl b/test/dubbo_filter_test1.erl
new file mode 100644
index 0000000..d333bf6
--- /dev/null
+++ b/test/dubbo_filter_test1.erl
@@ -0,0 +1,29 @@
+%%------------------------------------------------------------------------------
+%% 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.
+%%------------------------------------------------------------------------------
+-module(dubbo_filter_test1).
+-behaviour(dubbo_filter).
+
+%% API
+-export([invoke/2, on_response/2]).
+
+invoke(Invocation, Acc) ->
+ io:format(user,"test filter invoke sucess~n",[]),
+ {ok, Invocation, Acc}.
+
+on_response(Invocation, Result) ->
+ io:format(user,"test filter on_response sucess~n",[]),
+ {ok, Invocation, Result}.
\ No newline at end of file