Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 3c895d6

Browse files
Jinming-Huvinjiang
authored andcommitted
Add support for file lease
1 parent bef3af8 commit 3c895d6

File tree

9 files changed

+946
-329
lines changed

9 files changed

+946
-329
lines changed

Microsoft.WindowsAzure.Storage/includes/was/blob.h

Lines changed: 0 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -830,236 +830,6 @@ namespace azure { namespace storage {
830830
int64_t m_append_position;
831831
};
832832

833-
/// <summary>
834-
/// The lease state of a resource.
835-
/// </summary>
836-
enum class lease_state
837-
{
838-
/// <summary>
839-
/// The lease state is not specified.
840-
/// </summary>
841-
unspecified,
842-
843-
/// <summary>
844-
/// The lease is in the Available state.
845-
/// </summary>
846-
available,
847-
848-
/// <summary>
849-
/// The lease is in the Leased state.
850-
/// </summary>
851-
leased,
852-
853-
/// <summary>
854-
/// The lease is in the Expired state.
855-
/// </summary>
856-
expired,
857-
858-
/// <summary>
859-
/// The lease is in the Breaking state.
860-
/// </summary>
861-
breaking,
862-
863-
/// <summary>
864-
/// The lease is in the Broken state.
865-
/// </summary>
866-
broken,
867-
};
868-
869-
/// <summary>
870-
/// The lease status of a resource.
871-
/// </summary>
872-
enum class lease_status
873-
{
874-
/// <summary>
875-
/// The lease status is not specified.
876-
/// </summary>
877-
unspecified,
878-
879-
/// <summary>
880-
/// The resource is locked.
881-
/// </summary>
882-
locked,
883-
884-
/// <summary>
885-
/// The resource is available to be locked.
886-
/// </summary>
887-
unlocked
888-
};
889-
890-
/// <summary>
891-
/// Specifies the proposed duration of seconds that the lease should continue before it is broken.
892-
/// </summary>
893-
class lease_break_period
894-
{
895-
public:
896-
/// <summary>
897-
/// Initializes a new instance of the <see cref="azure::storage::lease_break_period" /> class that breaks
898-
/// a fixed-duration lease after the remaining lease period elapses, or breaks an infinite lease immediately.
899-
/// </summary>
900-
lease_break_period()
901-
: m_seconds(std::chrono::seconds::max())
902-
{
903-
}
904-
905-
/// <summary>
906-
/// Initializes a new instance of the <see cref="azure::storage::lease_break_period" /> class that breaks
907-
/// a lease after the proposed duration.
908-
/// </summary>
909-
/// <param name="seconds">The proposed duration, in seconds, for the lease before it is broken. Value may
910-
/// be between 0 and 60 seconds.</param>
911-
lease_break_period(const std::chrono::seconds& seconds)
912-
: m_seconds(seconds)
913-
{
914-
if (seconds != std::chrono::seconds::max())
915-
{
916-
utility::assert_in_bounds(_XPLATSTR("seconds"), seconds, protocol::minimum_lease_break_period, protocol::maximum_lease_break_period);
917-
}
918-
}
919-
920-
#if defined(_MSC_VER) && _MSC_VER < 1900
921-
// Compilers that fully support C++ 11 rvalue reference, e.g. g++ 4.8+, clang++ 3.3+ and Visual Studio 2015+,
922-
// have implicitly-declared move constructor and move assignment operator.
923-
924-
/// <summary>
925-
/// Initializes a new instance of the <see cref="azure::storage::lease_break_period" /> class based on an existing instance.
926-
/// </summary>
927-
/// <param name="other">An existing <see cref="azure::storage::lease_break_period" /> object.</param>
928-
lease_break_period(lease_break_period&& other)
929-
{
930-
*this = std::move(other);
931-
}
932-
933-
/// <summary>
934-
/// Returns a reference to an <see cref="azure::storage::lease_break_period" /> object.
935-
/// </summary>
936-
/// <param name="other">An existing <see cref="azure::storage::lease_break_period" /> object to use to set properties.</param>
937-
/// <returns>An <see cref="azure::storage::lease_break_period" /> object with properties set.</returns>
938-
lease_break_period& operator=(lease_break_period&& other)
939-
{
940-
if (this != &other)
941-
{
942-
m_seconds = std::move(other.m_seconds);
943-
}
944-
return *this;
945-
}
946-
#endif
947-
948-
/// <summary>
949-
/// Indicates whether the <see cref="azure::storage::lease_break_period" /> object is valid.
950-
/// </summary>
951-
/// <returns><c>true</c> if the <see cref="azure::storage::lease_break_period" /> object is valid; otherwise, <c>false</c>.</returns>
952-
bool is_valid() const
953-
{
954-
return m_seconds < std::chrono::seconds::max();
955-
}
956-
957-
/// <summary>
958-
/// Gets the proposed duration for the lease before it is broken.
959-
/// </summary>
960-
/// <returns>The proposed proposed duration for the lease before it is broken, in seconds.</returns>
961-
const std::chrono::seconds& seconds() const
962-
{
963-
return m_seconds;
964-
}
965-
966-
private:
967-
968-
std::chrono::seconds m_seconds;
969-
};
970-
971-
/// <summary>
972-
/// The lease duration for a Blob service resource.
973-
/// </summary>
974-
enum class lease_duration
975-
{
976-
/// <summary>
977-
/// The lease duration is not specified.
978-
/// </summary>
979-
unspecified,
980-
981-
/// <summary>
982-
/// The lease duration is finite.
983-
/// </summary>
984-
fixed,
985-
986-
/// <summary>
987-
/// The lease duration is infinite.
988-
/// </summary>
989-
infinite,
990-
};
991-
992-
/// <summary>
993-
/// Specifies the duration of the lease.
994-
/// </summary>
995-
class lease_time
996-
{
997-
public:
998-
/// <summary>
999-
/// Initializes a new instance of the <see cref="azure::storage::lease_time" /> class that never expires.
1000-
/// </summary>
1001-
lease_time()
1002-
: m_seconds(-1)
1003-
{
1004-
}
1005-
1006-
/// <summary>
1007-
/// Initializes a new instance of the <see cref="azure::storage::lease_time" /> class that expires after the
1008-
/// specified duration.
1009-
/// </summary>
1010-
/// <param name="seconds">The duration of the lease in seconds. For a non-infinite lease, this value can be
1011-
/// between 15 and 60 seconds.</param>
1012-
lease_time(const std::chrono::seconds& seconds)
1013-
: m_seconds(seconds)
1014-
{
1015-
if (seconds.count() != -1)
1016-
{
1017-
utility::assert_in_bounds(_XPLATSTR("seconds"), seconds, protocol::minimum_fixed_lease_duration, protocol::maximum_fixed_lease_duration);
1018-
}
1019-
}
1020-
1021-
#if defined(_MSC_VER) && _MSC_VER < 1900
1022-
// Compilers that fully support C++ 11 rvalue reference, e.g. g++ 4.8+, clang++ 3.3+ and Visual Studio 2015+,
1023-
// have implicitly-declared move constructor and move assignment operator.
1024-
1025-
/// <summary>
1026-
/// Initializes a new instance of the <see cref="azure::storage::lease_time" /> class based on an existing instance.
1027-
/// </summary>
1028-
/// <param name="other">An existing <see cref="azure::storage::lease_time" /> object.</param>
1029-
lease_time(lease_time&& other)
1030-
{
1031-
*this = std::move(other);
1032-
}
1033-
1034-
/// <summary>
1035-
/// Returns a reference to an <see cref="azure::storage::lease_time" /> object.
1036-
/// </summary>
1037-
/// <param name="other">An existing <see cref="azure::storage::lease_time" /> object to use to set properties.</param>
1038-
/// <returns>An <see cref="azure::storage::lease_time" /> object with properties set.</returns>
1039-
lease_time& operator=(lease_time&& other)
1040-
{
1041-
if (this != &other)
1042-
{
1043-
m_seconds = std::move(other.m_seconds);
1044-
}
1045-
return *this;
1046-
}
1047-
#endif
1048-
1049-
/// <summary>
1050-
/// Gets the duration of the lease in seconds for a non-infinite lease.
1051-
/// </summary>
1052-
/// <returns>The duration of the lease.</returns>
1053-
const std::chrono::seconds& seconds() const
1054-
{
1055-
return m_seconds;
1056-
}
1057-
1058-
private:
1059-
1060-
std::chrono::seconds m_seconds;
1061-
};
1062-
1063833
/// <summary>
1064834
/// The tier of the block blob on a standard storage account.
1065835
/// </summary>

0 commit comments

Comments
 (0)