You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by dl...@apache.org on 2019/08/02 06:45:52 UTC

[dubbo-erlang] branch 0.4.0 updated (e91b05e -> 3ea0a22)

This is an automated email from the ASF dual-hosted git repository.

dlive pushed a change to branch 0.4.0
in repository https://gitbox.apache.org/repos/asf/dubbo-erlang.git.


    from e91b05e  optimize code & del unused code
     new c83956c  fixed match provider host info error
     new 3ea0a22  del unused code

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/dubbo_provider_consumer_reg_table.erl |  39 +-----
 src/dubbo_type_decoding.erl               | 212 ------------------------------
 src/dubbo_type_transfer.erl               |   1 -
 3 files changed, 1 insertion(+), 251 deletions(-)
 delete mode 100644 src/dubbo_type_decoding.erl


[dubbo-erlang] 02/02: del unused code

Posted by dl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dlive pushed a commit to branch 0.4.0
in repository https://gitbox.apache.org/repos/asf/dubbo-erlang.git

commit 3ea0a224c6146b90c26d564595d3bd697087364e
Author: DLive <xs...@163.com>
AuthorDate: Fri Aug 2 14:45:26 2019 +0800

    del unused code
---
 src/dubbo_provider_consumer_reg_table.erl |  37 ------
 src/dubbo_type_decoding.erl               | 212 ------------------------------
 src/dubbo_type_transfer.erl               |   1 -
 3 files changed, 250 deletions(-)

diff --git a/src/dubbo_provider_consumer_reg_table.erl b/src/dubbo_provider_consumer_reg_table.erl
index e307da3..2b9bd6e 100644
--- a/src/dubbo_provider_consumer_reg_table.erl
+++ b/src/dubbo_provider_consumer_reg_table.erl
@@ -221,43 +221,6 @@ get_interface_info(Interface) ->
 %%%===================================================================
 %%% Internal functions
 %%%===================================================================
-%%add_consumer([], RegisterList) ->
-%%    RegisterList;
-%%add_consumer([ProviderNodeInfo | ProviderList], RegisterList) ->
-%%    case dubbo_node_config_util:parse_provider_info(ProviderNodeInfo) of
-%%        {ok, ProviderConfig} ->
-%%            HostFlag = get_host_flag(ProviderConfig),
-%%            case ets:lookup(?PROVIDER_NODE_LIST_TABLE, HostFlag) of
-%%                [] ->
-%%                    ConnectionList = start_provider_process(HostFlag, 30, ProviderConfig),
-%%                    ok = update_connection_info(ProviderConfig#provider_config.interface, HostFlag, ConnectionList, true),
-%%                    ok;
-%%                List ->
-%%                    List2 = lists:map(fun(#provider_node_list{connection_info = ConnectionItem}) ->
-%%                        ConnectionItem
-%%                                      end, List),
-%%                    ok = update_connection_info(ProviderConfig#provider_config.interface, HostFlag, List2, false),
-%%                    ok
-%%            end,
-%%            add_consumer(ProviderList, [HostFlag] ++ RegisterList);
-%%        {error, R1} ->
-%%            logger:error("parse provider info error reason ~p", [R1]),
-%%            add_consumer(ProviderList, RegisterList)
-%%    end.
-%%
-%%start_provider_process(HostFlag, Weight, ProviderConfig) ->
-%%    ExecutesList = lists:seq(1, ProviderConfig#provider_config.executes),
-%%    ConnectionList = lists:map(fun(Item) ->
-%%        ConnectionFlag = <<HostFlag/binary, (integer_to_binary(Item))/binary>>,
-%%        ConnectionFlagTerm = binary_to_atom(ConnectionFlag, utf8),
-%%        AChild = {ConnectionFlagTerm, {dubbo_netty_client, start_link, [ConnectionFlagTerm, HostFlag, ProviderConfig, Item]}, permanent, 2000, worker, [dubbo_netty_client]},
-%%        {ok, Pid} = dubbo_transport_pool_sup:add_children(AChild),
-%%        logger:info("start provider ~p pid info ~p~n", [HostFlag, Pid]),
-%%        #connection_info{connection_id = ConnectionFlagTerm, pid = Pid, weight = Weight, host_flag = HostFlag}
-%%                               end, ExecutesList),
-%%    ConnectionList.
-
-
 update_node_conections(Interface, Connections) ->
     lists:map(
         fun(Item) ->
diff --git a/src/dubbo_type_decoding.erl b/src/dubbo_type_decoding.erl
deleted file mode 100644
index a861855..0000000
--- a/src/dubbo_type_decoding.erl
+++ /dev/null
@@ -1,212 +0,0 @@
-% ---------------------------------------------------------------------------
-%   Copyright (C) 2008 0x6e6562
-%
-%   Licensed 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_type_decoding).
--include("hessian.hrl").
-
-%% The encoding state contains all of the statically known tuple types.
-%% When a tuple is to be decoded at run-time, a lookup is performed against
-%% the hash value that the sender passes in.
-%% This must resolve to some type definition,
-%% otherwise no instance of the decoded type can be created.
--record(decoding_state, {type_pool = dict:new(), reference_pool = dict:new(), obj_define_no = 0}).
-
--export([init/0, init/1]).
--export([lookup_reference/2]).
--export([enlist/1, enlist/2]).
--export([hash_lookup/2, hash_store/2, hash_store/1, store_typepool/1]).
--export([visit/2]).
--export([resolve_native_type/2, resolve_native_type/1]).
--export([camel_case_to_erlang/1]).
--export([build_foreign_view/3]).
--export([project_native_view/3]).
-
--define(TYPEPOOL_TABLE, type_pool).
--define(REFERENCEPOOL_TABLE, reference_pool).
-
-camel_case_to_erlang(String) when is_binary(String) ->
-    AsList = binary_to_list(String),
-    AsErlang = lists:foldl(fun decamelize/2, [], AsList),
-    list_to_atom(AsErlang).
-
-decamelize(Element, Acc) when Element >= $A, Element =< $Z ->
-    lists:append(Acc, [$_, (Element + 16#20)]);
-decamelize(Element, Acc) -> lists:append(Acc, [Element]).
-
-%% Facility to register a particular type to the pool of known types.
-%% Adds the type to the pool of known types if it doesn't already exist.
-enlist(TypeDef) -> enlist(TypeDef, init()).
-enlist(TypeDef = #type_def{foreign_type = Key},
-    State = #decoding_state{type_pool = OldPool}) ->
-    ets:insert(?TYPEPOOL_TABLE, {Key, TypeDef}),
-    State.
-
-store_typepool(TypeDef = #type_def{foreign_type = Key}) ->
-    ets:insert(?TYPEPOOL_TABLE, {Key, TypeDef}),
-    TypeDef.
-
-
-
-build_foreign_view(ForeignType, FieldNames, State) ->
-    #type_def{native_type = Native} = resolve_native_type(ForeignType, State),
-    ForeignView = [camel_case_to_erlang(Fieldname) || Fieldname <- FieldNames],
-    DefineNo = State#decoding_state.obj_define_no,
-    {#type_def{
-        defineNo = State#decoding_state.obj_define_no,
-        native_type = Native,
-        foreign_type = ForeignType,
-        fieldnames = ForeignView}, State#decoding_state{obj_define_no = DefineNo}}.
-
-% Projects the native view over tuples that in foreign order
-project_native_view(ForeignView, ForeignData,
-    #type_def{native_type = NativeType, fieldnames = NativeView}) ->
-    AsDict = dict:from_list(lists:zip(ForeignView, ForeignData)),
-    NativeData = [dict:fetch(Key, AsDict) || Key <- NativeView],
-    list_to_tuple([NativeType] ++ NativeData).
-
-resolve_native_type(ForeignType, #decoding_state{type_pool = Pool}) ->
-    case ets:lookup(?TYPEPOOL_TABLE, ForeignType) of
-        [] ->
-            throw({cannot_resolve_type, ForeignType});
-        [{ForeignType, TypeDef}] ->
-            TypeDef
-    end.
-resolve_native_type(ForeignType) ->
-    case ets:lookup(?TYPEPOOL_TABLE, ForeignType) of
-        [] ->
-            undefined;
-        [{ForeignType, TypeDef}] ->
-            TypeDef
-    end.
-%%    case dict:fetch(ForeignType,Pool) of
-%%        error ->
-%%            throw({cannot_resolve_type,ForeignType});
-%%        TypeDef ->
-%%            TypeDef
-%%    end.
-
-%% Creates a reference for a type def that is unique within the
-%% current invocation context
-visit(TypeDef, State = #decoding_state{reference_pool = OldPool}) ->
-    Size = ets:info(?REFERENCEPOOL_TABLE, size),
-    ets:insert(?REFERENCEPOOL_TABLE, {Size, TypeDef#type_def{defineNo = Size}}),
-    State.
-%%    Size = dict:size(OldPool),
-%%    NewPool = dict:store(Size, TypeDef, OldPool),
-%%    State#decoding_state{reference_pool = NewPool}.
-
-%% Resolves a type def based on a reference that must be have set
-%% with the current invocation context
-lookup_reference(Ref, #decoding_state{reference_pool = Pool}) ->
-    case ets:lookup(?REFERENCEPOOL_TABLE, Ref) of
-        [] ->
-            throw("Lookup of unknown reference");
-        [{Ref, TypeDef}] ->
-            TypeDef
-    end.
-%?LOG(Pool),
-%?LOG(Ref),
-%%    case dict:fetch(Ref,Pool) of
-%%        error ->
-%%%%            ?ERROR(Ref, Pool),
-%%            throw("Lookup of unknown reference");
-%%        TypeDef ->
-%%            TypeDef
-%%    end.
-
-%% Does what it says on the tin.
-hash_lookup(Hash, _State) ->
-%%    init(false),
-    case ets:lookup(?REFERENCEPOOL_TABLE, Hash) of
-        [] ->
-            {not_found, Hash};
-        [{Hash, TypeDef}] ->
-            TypeDef
-    end.
-
-%% Does what it says on the tin.
-hash_store(#type_def{defineNo = Hash} = TypeDef, State) ->
-%%    init(false),
-    case Hash of
-        -1 ->
-            Size = ets:info(?REFERENCEPOOL_TABLE, size),
-            ets:insert(?REFERENCEPOOL_TABLE, {Size, TypeDef#type_def{defineNo = Size}});
-        _ ->
-            ets:insert(?REFERENCEPOOL_TABLE, {Hash, TypeDef})
-    end,
-    State.
-hash_store(#type_def{defineNo = Hash} = TypeDef) ->
-%%    init(false),
-    NewTypeDef = case Hash of
-                     -1 ->
-                         Size = ets:info(?REFERENCEPOOL_TABLE, size),
-                         TypeDef2 = TypeDef#type_def{defineNo = Size},
-                         TypeDef2;
-                     _ ->
-                         TypeDef
-                 end,
-    ets:insert(?REFERENCEPOOL_TABLE, {NewTypeDef#type_def.defineNo, NewTypeDef}),
-    NewTypeDef.
-
-init() -> init(false).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Non-API functions
-
-
-%% This creates a new ETS table for the types that have been received by
-%% this instance of Hessian
-init(Delete) when is_boolean(Delete) ->
-%%    case ets:info(hashes) of
-%%        undefined ->
-%%            io:format("init decoding table pid ~p~n",[self()]),
-%%            ets:new(hashes,[public,named_table]); %% public
-%%        EtsInfo ->
-%%%%            io:format("type decoding etsinfo ~p~n",[EtsInfo]),
-%%            if
-%%                Delete == true ->
-%%                    ets:delete(hashes),
-%%                    ets:new(hashes,[public,named_table]);
-%%                true ->
-%%                    ok
-%%            end
-%%    end,
-    case ets:info(?TYPEPOOL_TABLE) of
-        undefined ->
-            ets:new(?TYPEPOOL_TABLE, [public, named_table]); %% public
-        _ ->
-%%            io:format("type decoding etsinfo ~p~n",[EtsInfo]),
-            if
-                Delete == true ->
-                    ets:delete(?TYPEPOOL_TABLE),
-                    ets:new(?TYPEPOOL_TABLE, [public, named_table]);
-                true ->
-                    ok
-            end
-    end,
-    case ets:info(?REFERENCEPOOL_TABLE) of
-        undefined ->
-            ets:new(?REFERENCEPOOL_TABLE, [public, named_table]); %% public
-        _ ->
-            if
-                Delete == true ->
-                    ets:delete(?REFERENCEPOOL_TABLE),
-                    ets:new(?REFERENCEPOOL_TABLE, [public, named_table]);
-                true ->
-                    ok
-            end
-    end,
-    #decoding_state{}.
\ No newline at end of file
diff --git a/src/dubbo_type_transfer.erl b/src/dubbo_type_transfer.erl
index 3f1af96..d92221e 100644
--- a/src/dubbo_type_transfer.erl
+++ b/src/dubbo_type_transfer.erl
@@ -68,7 +68,6 @@ get_deftype(ForeignType) ->
 
 pre_process_typedef(NativeType, ForeignType, FieldsNames) ->
     Type = #type_def{native_type = NativeType, foreign_type = ForeignType, fieldnames = FieldsNames},
-%%            Type2=type_decoding:hash_store(Type),
     dubbo_type_register:regiest_foreign_native(Type),
     logger:debug("pre_process_typedef ~p,~p", [NativeType, ForeignType]),
     ok.


[dubbo-erlang] 01/02: fixed match provider host info error

Posted by dl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dlive pushed a commit to branch 0.4.0
in repository https://gitbox.apache.org/repos/asf/dubbo-erlang.git

commit c83956c3850f58baa44061a3eac3a90aeeaa4118
Author: DLive <xs...@163.com>
AuthorDate: Fri Aug 2 14:28:15 2019 +0800

    fixed match provider host info error
---
 src/dubbo_provider_consumer_reg_table.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dubbo_provider_consumer_reg_table.erl b/src/dubbo_provider_consumer_reg_table.erl
index 31c862b..e307da3 100644
--- a/src/dubbo_provider_consumer_reg_table.erl
+++ b/src/dubbo_provider_consumer_reg_table.erl
@@ -262,7 +262,7 @@ update_node_conections(Interface, Connections) ->
     lists:map(
         fun(Item) ->
             HostFlag = Item#connection_info.host_flag,
-            case ets:match_object(?PROVIDER_NODE_LIST_TABLE, #connection_info{host_flag = HostFlag, pid = Item#connection_info.pid, _ = "_"}) of
+            case ets:match_object(?PROVIDER_NODE_LIST_TABLE, #connection_info{host_flag = HostFlag, pid = Item#connection_info.pid, _ = '_'}) of
                 [] ->
                     I2 = ets:insert(?PROVIDER_NODE_LIST_TABLE, Item),
                     logger:debug("update_node_conections insert one record ~p result:~p", [HostFlag, I2]);