Skip to content

Commit

Permalink
Merge branch 'release/1.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Apr 14, 2015
2 parents 162c9e8 + c162615 commit bf3c4fd
Show file tree
Hide file tree
Showing 32 changed files with 398 additions and 149 deletions.
4 changes: 1 addition & 3 deletions include/leo_gateway.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% LeoFS Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -40,7 +40,6 @@
-endif.



%% @pending
%% -define(MSG_INCOMPLETE_BODY, {400, 'incomplete body' }).
%% -define(MSG_INVALID_ARGUMENT, {400, 'invalid argument' }).
Expand Down Expand Up @@ -382,4 +381,3 @@
]}
})
end).

48 changes: 46 additions & 2 deletions include/leo_http.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo S3 HTTP
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -37,6 +37,9 @@
-define(BIN_SLASH, <<"/">>).
-define(BIN_EMPTY, <<>>).

-undef(DEF_SEPARATOR).
-define(DEF_SEPARATOR, <<"\n">>).

-define(ERR_TYPE_INTERNAL_ERROR, internal_server_error).

%% HTTP HEADER
Expand Down Expand Up @@ -80,6 +83,7 @@
-define(HTTP_QS_BIN_PART_NUMBER, <<"partNumber">>).
-define(HTTP_QS_BIN_MARKER, <<"marker">>).
-define(HTTP_QS_BIN_MAXKEYS, <<"max-keys">>).
-define(HTTP_QS_BIN_MULTI_DELETE,<<"delete">>).

-define(HTTP_ST_OK, 200).
-define(HTTP_ST_NO_CONTENT, 204).
Expand Down Expand Up @@ -134,6 +138,8 @@
-define(XML_ERROR_CODE_SlowDown, "SlowDown").
-define(XML_ERROR_CODE_BucketAlreadyExists, "BucketAlreadyExists").
-define(XML_ERROR_CODE_BucketAlreadyOwnedByYou, "BucketAlreadyOwnedByYou").
-define(XML_ERROR_CODE_MalformedXML, "MalformedXML").
-define(XML_ERROR_CODE_BadDigest, "BadDigest").

%% error messages used in a error response
-define(XML_ERROR_MSG_EntityTooLarge, "Your proposed upload exceeds the maximum allowed object size.").
Expand All @@ -146,6 +152,8 @@
-define(XML_ERROR_MSG_SlowDown, "Please reduce your request rate.").
-define(XML_ERROR_MSG_BucketAlreadyExists, "Please select a different name and try again.").
-define(XML_ERROR_MSG_BucketAlreadyOwnedByYou, "Your previous request to create the named bucket succeeded and you already own it.").
-define(XML_ERROR_MSG_MalformedXML, "The XML you provided was not well-formed or did not alidate against our published schema").
-define(XML_ERROR_MSG_BadDigest, "The Content-MD5 you specified did not match what we received.").

%% Macros
-define(reply_ok(_H,_R), cowboy_req:reply(?HTTP_ST_OK, _H,_R)). %% 200
Expand Down Expand Up @@ -200,6 +208,16 @@
io_lib:format(?XML_ERROR, [?XML_ERROR_CODE_SlowDown,
?XML_ERROR_MSG_SlowDown,
xmerl_lib:export_text(_Key), _ReqId]), _R)).
-define(reply_malformed_xml(_H, _R),
cowboy_req:reply(?HTTP_ST_OK, _H,
io_lib:format(?XML_ERROR_2, [?XML_ERROR_CODE_MalformedXML,
?XML_ERROR_MSG_MalformedXML,
"", ""]), _R)).
-define(reply_bad_digest(_H, _Key, _ReqId, _R),
cowboy_req:reply(?HTTP_ST_BAD_REQ, _H,
io_lib:format(?XML_ERROR, [?XML_ERROR_CODE_BadDigest,
?XML_ERROR_MSG_BadDigest,
xmerl_lib:export_text(_Key), _ReqId]), _R)).

-define(http_header(_R, _K), case cowboy_req:header(_K, _R) of
{undefined, _} -> ?BIN_EMPTY;
Expand Down Expand Up @@ -278,6 +296,15 @@
"<RequestId>~s</RequestId>",
"</Error>"])).

-define(XML_ERROR_2,
lists:append(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<Error>",
"<Code>~s</Code>",
"<Message>~s</Message>",
"<RequestId>~s</RequestId>",
"<HostId>~s</HostId>",
"</Error>"])).

-define(XML_ACL_POLICY,
lists:append(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<AccessControlPolicy xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">",
Expand All @@ -296,6 +323,23 @@
"<Permission>~s</Permission>",
"</Grant>"])).

-define(XML_MULTIPLE_DELETE,
lists:append(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<DeleteResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">",
"~s",
"~s",
"</DeleteResult>"])).

-define(XML_MULTIPLE_DELETE_SUCCESS_ELEM,
lists:append(["<Deleted><Key>",
"~s",
"</Key></Deleted>"])).

-define(XML_MULTIPLE_DELETE_ERROR_ELEM,
lists:append(["<Error><Key>",
"~s",
"</Key><Code>AccessDenied</Code><Message>Access Denied</Message></Error>"])).

%% Records
-record(http_options, {
%% for basic
Expand Down Expand Up @@ -346,6 +390,7 @@
has_inner_cache = false :: boolean(), %% has inner-cache?
is_cached = false :: boolean(), %% is cached?
is_dir = false :: boolean(), %% is directory?
is_multi_delete = false :: boolean(), %% is multi delete request?
%% for large-object
is_upload = false :: boolean(), %% is upload operation? (for multipart upload)
is_acl = false :: boolean(), %% is acl operation?
Expand Down Expand Up @@ -374,4 +419,3 @@
content_types = [] :: list() | undefined, %% like ["image/png", "image/gif", "image/jpeg"]
path_patterns = [] :: list() | undefined %% compiled regular expressions
}).

10 changes: 5 additions & 5 deletions priv/leo_gateway.schema
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%%
%% LeoFS
%%
%% Copyright (c) 2012-2013 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -122,7 +122,7 @@
"leo_gateway.system_version",
[
{datatype, string},
{default, "1.2.7"}
{default, "1.2.8"}
]}.


Expand Down Expand Up @@ -545,7 +545,7 @@
]}.


%% @doc
%% @doc Monitoring target paths
{mapping,
"watchdog.disk.target_paths",
"leo_watchdog.disk_target_paths",
Expand Down Expand Up @@ -621,8 +621,8 @@
]}.


%% @doc Threshold disk write kb/sec
%% default:262144(KB) - 256MB
%% @doc Monitoring target devices
%%
{mapping,
"watchdog.disk.target_devices",
"leo_watchdog.disk_target_devices",
Expand Down
12 changes: 6 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
{leo_cache, ".*", {git, "https://github.com/leo-project/leo_cache.git", {tag, "0.6.3"}}},
{leo_commons, ".*", {git, "https://github.com/leo-project/leo_commons.git", {tag, "1.1.1"}}},
{leo_logger, ".*", {git, "https://github.com/leo-project/leo_logger.git", {tag, "1.1.5"}}},
{leo_object_storage, ".*", {git, "https://github.com/leo-project/leo_object_storage.git", {tag, "1.2.4"}}},
{leo_redundant_manager, ".*", {git, "https://github.com/leo-project/leo_redundant_manager.git", {tag, "1.9.8"}}},
{leo_statistics, ".*", {git, "https://github.com/leo-project/leo_statistics.git", {tag, "1.1.0"}}},
{leo_s3_libs, ".*", {git, "https://github.com/leo-project/leo_s3_libs.git", {tag, "1.1.6"}}},
{leo_watchdog, ".*", {git, "https://github.com/leo-project/leo_watchdog.git", {tag, "0.6.3"}}},
{savanna_agent, ".*", {git, "https://github.com/leo-project/savanna_agent.git", {tag, "0.4.5"}}},
{leo_object_storage, ".*", {git, "https://github.com/leo-project/leo_object_storage.git", {tag, "1.2.5"}}},
{leo_redundant_manager, ".*", {git, "https://github.com/leo-project/leo_redundant_manager.git", {tag, "1.9.10"}}},
{leo_statistics, ".*", {git, "https://github.com/leo-project/leo_statistics.git", {tag, "1.1.2"}}},
{leo_s3_libs, ".*", {git, "https://github.com/leo-project/leo_s3_libs.git", {tag, "1.1.7"}}},
{leo_watchdog, ".*", {git, "https://github.com/leo-project/leo_watchdog.git", {tag, "0.6.4"}}},
{savanna_agent, ".*", {git, "https://github.com/leo-project/savanna_agent.git", {tag, "0.4.6"}}},
{erpcgen, ".*", {git, "https://github.com/leo-project/erpcgen.git", {tag, "0.2.3"}}},
{nfs_rpc_server, ".*", {git, "https://github.com/leo-project/nfs_rpc_server.git", {tag, "0.2.3"}}},
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "1.0.0"}}},
Expand Down
53 changes: 39 additions & 14 deletions rebar.config.develop
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
{require_otp_vsn, "R14B04|R15B01"}.
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%%======================================================================
%%
%% Leo Gateway
%%
%% Copyright (c) 2012-2013 Rakuten, Inc.
%%
%% This file is provided 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.
%%
%%======================================================================
{require_otp_vsn, "R16B*|17"}.

{deps, [
{leo_commons, ".*", {git, "https://github.com/leo-project/leo_commons.git", "develop" }},
{leo_logger, ".*", {git, "https://github.com/leo-project/leo_logger.git", "develop" }},
{leo_object_storage, ".*", {git, "https://github.com/leo-project/leo_object_storage.git", "develop" }},
{leo_redundant_manager, ".*", {git, "https://github.com/leo-project/leo_redundant_manager.git", "develop" }},
{leo_statistics, ".*", {git, "https://github.com/leo-project/leo_statistics.git", "develop" }},
{leo_s3_libs, ".*", {git, "https://github.com/leo-project/leo_s3_libs.git", "develop" }},
{ecache, ".*", {git, "https://github.com/leo-project/ecache.git", "develop" }},
{cowboy, ".*", {git, "https://github.com/extend/cowboy.git", {branch, "master"}}},
{meck, ".*", {git, "https://github.com/eproxus/meck.git", {branch, "master"}}},
{proper, ".*", {git, "https://github.com/manopapad/proper.git", {branch, "master"}}}
]}.
{leo_cache, ".*", {git, "https://github.com/leo-project/leo_cache.git", {branch, "develop"}}},
{leo_commons, ".*", {git, "https://github.com/leo-project/leo_commons.git", {branch, "develop"}}},
{leo_logger, ".*", {git, "https://github.com/leo-project/leo_logger.git", {branch, "develop"}}},
{leo_object_storage, ".*", {git, "https://github.com/leo-project/leo_object_storage.git", {branch, "develop"}}},
{leo_redundant_manager, ".*", {git, "https://github.com/leo-project/leo_redundant_manager.git", {branch, "develop"}}},
{leo_statistics, ".*", {git, "https://github.com/leo-project/leo_statistics.git", {branch, "develop"}}},
{leo_s3_libs, ".*", {git, "https://github.com/leo-project/leo_s3_libs.git", {branch, "develop"}}},
{leo_watchdog, ".*", {git, "https://github.com/leo-project/leo_watchdog.git", {branch, "develop"}}},
{savanna_agent, ".*", {git, "https://github.com/leo-project/savanna_agent.git", {branch, "develop"}}},
{erpcgen, ".*", {git, "https://github.com/leo-project/erpcgen.git", {branch, "develop"}}},
{nfs_rpc_server, ".*", {git, "https://github.com/leo-project/nfs_rpc_server.git", {branch, "develop"}}},
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {branch, "develop"}}},
{cowlib, ".*", {git, "https://github.com/ninenines/cowlib.git", {branch, "develop"}}},
{meck, ".*", {git, "https://github.com/eproxus/meck.git", {branch, "develop"}}},
{proper, ".*", {git, "https://github.com/manopapad/proper.git", "7d535ac61e9c2a9a7616af4615c39595a3c5739f"}}
]}.

{erl_opts, [{d, 'NOTEST'},
warn_obsolete_guard,
%warn_unused_import,
warnings_as_errors,
warn_shadow_vars,
warn_export_vars,
warn_export_all]}.
Expand Down
4 changes: 2 additions & 2 deletions src/leo_gateway.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%%
%% LeoFS Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand All @@ -23,7 +23,7 @@
{application, leo_gateway,
[
{description, "LeoFS Gateway Server"},
{vsn, "1.2.7"},
{vsn, "1.2.8"},
{id, "leo_gateway"},
{registered, []},
{applications, [kernel, stdlib, crypto, ranch, asn1]},
Expand Down
2 changes: 1 addition & 1 deletion src/leo_gateway_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down
16 changes: 15 additions & 1 deletion src/leo_gateway_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -122,6 +122,20 @@ prep_stop(_State) ->
catch leo_redundant_manager_sup:stop(),
catch leo_mq_sup:stop(),
catch leo_logger_sup:stop(),

case get_options() of
{ok, HttpOptions} ->
case HttpOptions#http_options.handler of
?PROTO_HANDLER_S3 ->
leo_gateway_s3_api:stop();
?PROTO_HANDLER_REST ->
leo_gateway_rest_api:stop();
_ ->
void
end;
_ ->
void
end,
ok.

%% @spec stop(_State) -> ServerRet
Expand Down
2 changes: 1 addition & 1 deletion src/leo_gateway_cache_statistics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down
2 changes: 1 addition & 1 deletion src/leo_gateway_http_behaviour.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo Gateway
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down
Loading

0 comments on commit bf3c4fd

Please sign in to comment.