rename db_hash_reader to hash_reader, change inc_announce response field

This commit is contained in:
Kevin Lynx 2013-07-09 21:52:47 +08:00
parent b9130ec759
commit 46338b02c6
6 changed files with 15 additions and 17 deletions

View File

@ -1,6 +0,0 @@
[{start_port,6776},
{node_count,50},
{loglevel,3},
{dbconn, 5},
{dbhost,"localhost"},
{dbport,27017}].

View File

@ -115,8 +115,8 @@ inc_announce(Conn, Hash) when is_binary(Hash) ->
% damn, mongodb-erlang doesnot support update a field for an object, % damn, mongodb-erlang doesnot support update a field for an object,
% `findAndModify` works but it will change `announce' datatype to double % `findAndModify` works but it will change `announce' datatype to double
Cmd = {findAndModify, ?COLLNAME, query, {'_id', Hash}, Cmd = {findAndModify, ?COLLNAME, query, {'_id', Hash},
update, {'$inc', {announce, 1}}, update, {'$inc', {announce, 1}}, fields, {},
new, true}, new, false},
Ret = mongo_do(Conn, fun() -> Ret = mongo_do(Conn, fun() ->
mongo:command(Cmd) mongo:command(Cmd)
end), end),
@ -277,7 +277,7 @@ test_find_top() ->
end). end).
test_announce() -> test_announce() ->
Hash = "F79ED3E2BF29A5C4358202E88C9983AB479D7722", Hash = "6605993570A4A74C89FD02355333F3A86BEE6C1F",
test_content(fun(Conn) -> test_content(fun(Conn) ->
inc_announce(Conn, Hash) inc_announce(Conn, Hash)
end). end).

View File

@ -1,9 +1,9 @@
%% %%
%% db_hash_reader.erl %% hash_reader.erl
%% Kevin Lynx %% Kevin Lynx
%% 06.28.2013 %% 06.28.2013
%% %%
-module(db_hash_reader). -module(hash_reader).
-compile(export_all). -compile(export_all).
-include("vlog.hrl"). -include("vlog.hrl").
-behaviour(gen_server). -behaviour(gen_server).

View File

@ -1,9 +1,9 @@
%% %%
%% db_hash_reader_sup.erl %% hash_reader_sup.erl
%% Kevin Lynx %% Kevin Lynx
%% 06.29.2013 %% 06.29.2013
%% %%
-module(db_hash_reader_sup). -module(hash_reader_sup).
-behaviour(supervisor). -behaviour(supervisor).
-export([init/1]). -export([init/1]).
-export([start_link/3, -export([start_link/3,
@ -34,7 +34,7 @@ start_standalone(IP, Port, Size) ->
tor_download:start_global(), tor_download:start_global(),
config:start_link("hash_reader.config", fun() -> config_default() end), config:start_link("hash_reader.config", fun() -> config_default() end),
% NOTE: % NOTE:
Stats = {db_hash_reader_stats, {hash_reader_stats, start_link, [Size]}, permanent, 2000, worker, [hash_reader_stats]}, Stats = {hash_reader_stats, {hash_reader_stats, start_link, [Size]}, permanent, 2000, worker, [hash_reader_stats]},
DownloadStats = {tor_download_stats, {tor_download_stats, start_link, []}, permanent, 2000, worker, [tor_download_stats]}, DownloadStats = {tor_download_stats, {tor_download_stats, start_link, []}, permanent, 2000, worker, [tor_download_stats]},
Log = {vlog, {vlog, start_link, ["log/hash_reader.log", 3]}, permanent, 2000, worker, [vlog]}, Log = {vlog, {vlog, start_link, ["log/hash_reader.log", 3]}, permanent, 2000, worker, [vlog]},
start_link(IP, Port, Size, [DownloadStats, Stats, Log]). start_link(IP, Port, Size, [DownloadStats, Stats, Log]).
@ -59,11 +59,11 @@ init([PoolName, Size, OtherProcess]) ->
{ok, {Spec, Children}}. {ok, {Spec, Children}}.
create_child(PoolName, Index) -> create_child(PoolName, Index) ->
{child_id(Index), {db_hash_reader, start_link, [PoolName]}, {child_id(Index), {hash_reader, start_link, [PoolName]},
permanent, 1000, worker, dynamic}. permanent, 1000, worker, dynamic}.
child_id(Index) -> child_id(Index) ->
list_to_atom(lists:flatten(io_lib:format("db_hash_reader_~p", [Index]))). list_to_atom(lists:flatten(io_lib:format("hash_reader_~p", [Index]))).
config_default() -> config_default() ->
[{save_torrent, true}, [{save_torrent, true},

View File

@ -26,6 +26,10 @@ You can also compile the source code and run it manually. The source code is in
Also you can check more technique information at my blog site (Chinese) [codemacro.com](http://codemacro.com) Also you can check more technique information at my blog site (Chinese) [codemacro.com](http://codemacro.com)
## Source code
dhtcrawler is totally open source, and can be used in any purpose, but you should keep my name on, copyright by me please. You can checkout dhtcrawler2 source code in this git repo **src** branch.
## Config ## Config
Most config value is in `priv/dhtcrawler.config`, when you first run dhtcrawler, this file will be generated automatically. And the other config values are passed by arguments to erlang functions. In most case you don't need to change these config values, except these network addresses. Most config value is in `priv/dhtcrawler.config`, when you first run dhtcrawler, this file will be generated automatically. And the other config values are passed by arguments to erlang functions. In most case you don't need to change these config values, except these network addresses.

View File

@ -1 +1 @@
erl -pa ebin -noshell -run db_hash_reader_sup start_standalone localhost 27017 10 erl -pa ebin -noshell -run hash_reader_sup start_standalone localhost 27017 10