code optimization
diff --git a/src/de_id_count.erl b/src/de_id_count.erl
index be07d1b..42da3cf 100644
--- a/src/de_id_count.erl
+++ b/src/de_id_count.erl
@@ -167,11 +167,11 @@
%%% Internal functions
%%%===================================================================
init_table()->
- try ets:new(de_id_count_table, [public,named_table]) of
- de_id_count_table ->
+ try ets:new(?INDEX_ETS_TABLE, [public,named_table]) of
+ ?INDEX_ETS_TABLE ->
ets:insert(?INDEX_ETS_TABLE,{cur_index,1}),
ok
catch
_Type:Reason ->
- io:format("error init auto inc table reason:~p~n",[Reason])
+ logger:error("[DUBBO] error init auto inc table reason:~p",[Reason])
end.
\ No newline at end of file
diff --git a/src/de_type_transfer.erl b/src/de_type_transfer.erl
index 6be3d17..ac734cb 100644
--- a/src/de_type_transfer.erl
+++ b/src/de_type_transfer.erl
@@ -43,35 +43,10 @@
java_to_native(#list{values = ForeignData}=Data,State)->
ForeignDataNew = [java_to_native(ValueItem,State) || ValueItem <-ForeignData ],
ForeignDataNew;
-%% case hessianDecode2:get_deftype(Data#list.refNo,State) of
-%% #type_def{fieldnames = ObjectFields,foreign_type = ForeignType } ->
-%% case get_deftype(ForeignType) of
-%% false->
-%% error;
-%% #type_def{fieldnames = NativeFields,native_type = NativeTupeName}->
-%% logger:debug("test ForeignType ~p NativeTupeName ~p",[ForeignType,NativeTupeName]),
-%%%% AsDict = dict:from_list(lists:zip(ObjectFields,ForeignDataNew)),
-%%%% NativeData = [dict:fetch(atom_to_binary(Key,utf8),AsDict) || Key <- NativeFields],
-%%%% list_to_tuple( [NativeTupeName] ++ NativeData)
-%% ForeignDataNew
-%% end;
-%% Info ->
-%% logger:warning("java_to_native list error:~p",[Info]),
-%% error
-%% end;
java_to_native(Data,_)->
logger:debug("java_to_native unkonw type ~p",[Data]),
Data.
-%%get_deftype([Item |DefTypeList],ForeignType)->
-%% if
-%% Item#type_def.foreign_type == ForeignType -> Item;
-%% true ->
-%% get_deftype(DefTypeList,ForeignType)
-%% end;
-%%get_deftype([],_ForeignType)->
-%% false.
-
get_deftype(ForeignType)->
case type_register:lookup_foreign_type(ForeignType) of
@@ -90,15 +65,5 @@
Type = #type_def{native_type = NativeType,foreign_type = ForeignType,fieldnames = FieldsNames},
%% Type2=type_decoding:hash_store(Type),
type_register:regiest_foreign_native(Type),
- logger:debug("pre_process_typedef ~p,~p",[NativeType,ForeignType]).
-%% case type_decoding:resolve_native_type(ForeignType) of
-%% undefined ->
-%%%% Type = #type_def{native_type = NativeType, foreign_type = ForeignType, fieldnames = record_info(fields,NativeType)},
-%% Type = #type_def{native_type = NativeType,foreign_type = ForeignType,fieldnames = FieldsNames},
-%% Type2=type_decoding:hash_store(Type),
-%%
-%% logger:debug("pre_process_typedef ~p,~p",[NativeType,ForeignType]);
-%% type_decoding:store_typepool(Type2);
-%% _->
-%% ok
-%% end.
\ No newline at end of file
+ logger:debug("pre_process_typedef ~p,~p",[NativeType,ForeignType]),
+ ok.
\ No newline at end of file
diff --git a/src/dubbo_directory.erl b/src/dubbo_directory.erl
deleted file mode 100644
index 7551d2f..0000000
--- a/src/dubbo_directory.erl
+++ /dev/null
@@ -1,146 +0,0 @@
-%%%-------------------------------------------------------------------
-%%% @author dlive
-%%% @copyright (C) 2017, <COMPANY>
-%%% @doc
-%%%
-%%% @end
-%%% Created : 26. Feb 2017 10:27 PM
-%%%-------------------------------------------------------------------
--module(dubbo_directory).
--author("dlive").
-
--behaviour(gen_server).
-
-%% API
--export([start_link/0]).
-
-%% gen_server callbacks
--export([init/1,
- handle_call/3,
- handle_cast/2,
- handle_info/2,
- terminate/2,
- code_change/3]).
-
--define(SERVER, ?MODULE).
-
--record(state, {}).
-
-%%%===================================================================
-%%% API
-%%%===================================================================
-
-%%--------------------------------------------------------------------
-%% @doc
-%% Starts the server
-%%
-%% @end
-%%--------------------------------------------------------------------
--spec(start_link() ->
- {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
-start_link() ->
- gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
-
-%%%===================================================================
-%%% gen_server callbacks
-%%%===================================================================
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% Initializes the server
-%%
-%% @spec init(Args) -> {ok, State} |
-%% {ok, State, Timeout} |
-%% ignore |
-%% {stop, Reason}
-%% @end
-%%--------------------------------------------------------------------
--spec(init(Args :: term()) ->
- {ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
- {stop, Reason :: term()} | ignore).
-init([]) ->
- {ok, #state{}}.
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% Handling call messages
-%%
-%% @end
-%%--------------------------------------------------------------------
--spec(handle_call(Request :: term(), From :: {pid(), Tag :: term()},
- State :: #state{}) ->
- {reply, Reply :: term(), NewState :: #state{}} |
- {reply, Reply :: term(), NewState :: #state{}, timeout() | hibernate} |
- {noreply, NewState :: #state{}} |
- {noreply, NewState :: #state{}, timeout() | hibernate} |
- {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
- {stop, Reason :: term(), NewState :: #state{}}).
-handle_call(_Request, _From, State) ->
- {reply, ok, State}.
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% Handling cast messages
-%%
-%% @end
-%%--------------------------------------------------------------------
--spec(handle_cast(Request :: term(), State :: #state{}) ->
- {noreply, NewState :: #state{}} |
- {noreply, NewState :: #state{}, timeout() | hibernate} |
- {stop, Reason :: term(), NewState :: #state{}}).
-handle_cast(_Request, State) ->
- {noreply, State}.
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% Handling all non call/cast messages
-%%
-%% @spec handle_info(Info, State) -> {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State}
-%% @end
-%%--------------------------------------------------------------------
--spec(handle_info(Info :: timeout() | term(), State :: #state{}) ->
- {noreply, NewState :: #state{}} |
- {noreply, NewState :: #state{}, timeout() | hibernate} |
- {stop, Reason :: term(), NewState :: #state{}}).
-handle_info(_Info, State) ->
- {noreply, State}.
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% This function is called by a gen_server when it is about to
-%% terminate. It should be the opposite of Module:init/1 and do any
-%% necessary cleaning up. When it returns, the gen_server terminates
-%% with Reason. The return value is ignored.
-%%
-%% @spec terminate(Reason, State) -> void()
-%% @end
-%%--------------------------------------------------------------------
--spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
- State :: #state{}) -> term()).
-terminate(_Reason, _State) ->
- ok.
-
-%%--------------------------------------------------------------------
-%% @private
-%% @doc
-%% Convert process state when code is changed
-%%
-%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}
-%% @end
-%%--------------------------------------------------------------------
--spec(code_change(OldVsn :: term() | {down, term()}, State :: #state{},
- Extra :: term()) ->
- {ok, NewState :: #state{}} | {error, Reason :: term()}).
-code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
-
-%%%===================================================================
-%%% Internal functions
-%%%===================================================================
diff --git a/src/dubbo_netty_client.erl b/src/dubbo_netty_client.erl
index 7f7f0dc..1fbdcf6 100644
--- a/src/dubbo_netty_client.erl
+++ b/src/dubbo_netty_client.erl
@@ -68,12 +68,6 @@
{stop, Reason :: term()} | ignore).
init([HostFlag,ProviderConfig,Index]) ->
erlang:process_flag(min_bin_vheap_size, 1024*1024),
-%% erlang:process_flag(min_heap_size, 1024*1024),
-%% BindScheduler = (Index rem erlang:system_info(schedulers_online))+1,
-%% logger:info("will bind to scheduler ~p",[BindScheduler]),
-%% erlang:process_flag(scheduler, BindScheduler),
-%% erlang:process_flag(priority, high),
-
#provider_config{host = Host,port = Port}=ProviderConfig,
State = case open(Host,Port) of
{ok,Socket} ->
diff --git a/src/dubbo_node_config_util.erl b/src/dubbo_node_config_util.erl
index e2cec44..f28e162 100644
--- a/src/dubbo_node_config_util.erl
+++ b/src/dubbo_node_config_util.erl
@@ -17,7 +17,7 @@
parse_provider_info(binary_to_list(ProviderStr));
parse_provider_info(ProviderStr)->
case http_uri:parse(http_uri:decode(ProviderStr),[{scheme_defaults,[{dubbo,20880}]}]) of
- {ok, {Scheme, UserInfo, Host, Port, Path, Query}} ->
+ {ok, {Scheme, _UserInfo, Host, Port, _Path, Query}} ->
QueryStr = case lists:prefix("?",Query) of
true ->
[_|Query2] = Query,