From 9f80e604365a761f8902c30445450e3854db0753 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 23 Jun 2023 18:06:05 +0900 Subject: [PATCH] Refresh -> Renew --- cpp/src/arrow/flight/client.cc | 8 ++-- cpp/src/arrow/flight/client.h | 14 +++--- .../flight_integration_test.cc | 4 +- .../integration_tests/test_integration.cc | 44 +++++++++---------- cpp/src/arrow/flight/sql/client.h | 10 ++--- cpp/src/arrow/flight/sql/server.cc | 14 +++--- cpp/src/arrow/flight/sql/server.h | 8 ++-- cpp/src/arrow/flight/sql/server_test.cc | 4 +- cpp/src/arrow/flight/types.cc | 8 ++-- cpp/src/arrow/flight/types.h | 2 +- dev/archery/archery/integration/runner.py | 4 +- go/arrow/flight/client.go | 12 ++--- go/arrow/flight/flightsql/client.go | 4 +- go/arrow/flight/flightsql/client_test.go | 12 ++--- go/arrow/flight/flightsql/server.go | 18 ++++---- go/arrow/flight/flightsql/server_test.go | 8 ++-- go/arrow/flight/server.go | 6 +-- .../internal/flight_integration/scenario.go | 42 +++++++++--------- .../ExpirationTimeListActionsScenario.java | 2 +- .../tests/ExpirationTimeProducer.java | 8 ++-- ...ationTimeRenewFlightEndpointScenario.java} | 16 +++---- .../flight/integration/tests/Scenarios.java | 2 +- .../integration/tests/IntegrationTest.java | 4 +- 23 files changed, 127 insertions(+), 127 deletions(-) rename java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/{ExpirationTimeRefreshFlightEndpointScenario.java => ExpirationTimeRenewFlightEndpointScenario.java} (78%) diff --git a/cpp/src/arrow/flight/client.cc b/cpp/src/arrow/flight/client.cc index dbdd1672a0cb3..51e5ece334cc6 100644 --- a/cpp/src/arrow/flight/client.cc +++ b/cpp/src/arrow/flight/client.cc @@ -581,16 +581,16 @@ arrow::Result FlightClient::CancelFlightInfo( return std::move(cancel_result); } -arrow::Result FlightClient::RefreshFlightEndpoint( +arrow::Result FlightClient::RenewFlightEndpoint( const FlightCallOptions& options, const FlightEndpoint& endpoint) { ARROW_ASSIGN_OR_RAISE(auto body, endpoint.SerializeToString()); - Action action{ActionType::kRefreshFlightEndpoint.type, Buffer::FromString(body)}; + Action action{ActionType::kRenewFlightEndpoint.type, Buffer::FromString(body)}; ARROW_ASSIGN_OR_RAISE(auto stream, DoAction(options, action)); ARROW_ASSIGN_OR_RAISE(auto result, stream->Next()); - ARROW_ASSIGN_OR_RAISE(auto refreshed_endpoint, + ARROW_ASSIGN_OR_RAISE(auto renewed_endpoint, FlightEndpoint::Deserialize(std::string_view(*result->body))); ARROW_RETURN_NOT_OK(stream->Drain()); - return std::move(refreshed_endpoint); + return std::move(renewed_endpoint); } Status FlightClient::CloseFlightInfo(const FlightCallOptions& options, diff --git a/cpp/src/arrow/flight/client.h b/cpp/src/arrow/flight/client.h index 426aa63dcf266..70e917260cca6 100644 --- a/cpp/src/arrow/flight/client.h +++ b/cpp/src/arrow/flight/client.h @@ -267,16 +267,16 @@ class ARROW_FLIGHT_EXPORT FlightClient { Status CloseFlightInfo(const FlightCallOptions& options, const FlightInfo& info); Status CloseFlightInfo(const FlightInfo& info) { return CloseFlightInfo({}, info); } - /// \brief Perform the RefreshFlightEndpoint action, returning a refreshed + /// \brief Perform the RenewFlightEndpoint action, returning a renewed /// FlightEndpoint /// /// \param[in] options Per-RPC options - /// \param[in] endpoint The FlightEndpoint to be refreshed - /// \return Arrow result with a refreshed FlightEndpoint - arrow::Result RefreshFlightEndpoint(const FlightCallOptions& options, - const FlightEndpoint& endpoint); - arrow::Result RefreshFlightEndpoint(const FlightEndpoint& endpoint) { - return RefreshFlightEndpoint({}, endpoint); + /// \param[in] endpoint The FlightEndpoint to be renewed + /// \return Arrow result with a renewed FlightEndpoint + arrow::Result RenewFlightEndpoint(const FlightCallOptions& options, + const FlightEndpoint& endpoint); + arrow::Result RenewFlightEndpoint(const FlightEndpoint& endpoint) { + return RenewFlightEndpoint({}, endpoint); } /// \brief Retrieve a list of available Action types diff --git a/cpp/src/arrow/flight/integration_tests/flight_integration_test.cc b/cpp/src/arrow/flight/integration_tests/flight_integration_test.cc index e00879f69e5e5..a5c05b13a7934 100644 --- a/cpp/src/arrow/flight/integration_tests/flight_integration_test.cc +++ b/cpp/src/arrow/flight/integration_tests/flight_integration_test.cc @@ -71,8 +71,8 @@ TEST(FlightIntegration, ExpirationTimeCloseFlightInfo) { ASSERT_OK(RunScenario("expiration_time:close_flight_info")); } -TEST(FlightIntegration, ExpirationTimeRefreshFlightEndpoint) { - ASSERT_OK(RunScenario("expiration_time:refresh_flight_endpoint")); +TEST(FlightIntegration, ExpirationTimeRenewFlightEndpoint) { + ASSERT_OK(RunScenario("expiration_time:renew_flight_endpoint")); } TEST(FlightIntegration, FlightSql) { ASSERT_OK(RunScenario("flight_sql")); } diff --git a/cpp/src/arrow/flight/integration_tests/test_integration.cc b/cpp/src/arrow/flight/integration_tests/test_integration.cc index 4f27fc5f5863f..1cebb55b6e337 100644 --- a/cpp/src/arrow/flight/integration_tests/test_integration.cc +++ b/cpp/src/arrow/flight/integration_tests/test_integration.cc @@ -433,7 +433,7 @@ class OrderedScenario : public Scenario { /// even within 3 seconds after the action. /// /// The client can extend the expiration time of a FlightEndpoint in -/// a returned FlightInfo by pre-defined RefreshFlightEndpoint +/// a returned FlightInfo by pre-defined RenewFlightEndpoint /// action. The client can read data from endpoints multiple times /// within more 10 seconds after the action. /// @@ -543,14 +543,14 @@ class ExpirationTimeServer : public FlightServerBase { auto index = *index_result; statuses_[index].closed = true; } - } else if (action.type == ActionType::kRefreshFlightEndpoint.type) { + } else if (action.type == ActionType::kRenewFlightEndpoint.type) { ARROW_ASSIGN_OR_RAISE(auto endpoint, FlightEndpoint::Deserialize(std::string_view(*action.body))); ARROW_ASSIGN_OR_RAISE(auto index, ExtractIndexFromTicket(endpoint.ticket.ticket)); if (statuses_[index].cancelled) { return Status::Invalid("Invalid flight: canceled: ", endpoint.ticket.ticket); } - endpoint.ticket.ticket += ": refreshed (+ 10 seconds)"; + endpoint.ticket.ticket += ": renewed (+ 10 seconds)"; endpoint.expiration_time = Timestamp::clock::now() + std::chrono::seconds{10}; statuses_[index].expiration_time = endpoint.expiration_time.value(); ARROW_ASSIGN_OR_RAISE(auto serialized, endpoint.SerializeToString()); @@ -567,7 +567,7 @@ class ExpirationTimeServer : public FlightServerBase { *actions = { ActionType::kCancelFlightInfo, ActionType::kCloseFlightInfo, - ActionType::kRefreshFlightEndpoint, + ActionType::kRenewFlightEndpoint, }; return Status::OK(); } @@ -680,7 +680,7 @@ class ExpirationTimeListActionsScenario : public Scenario { std::vector expected_action_types = { "CancelFlightInfo", "CloseFlightInfo", - "RefreshFlightEndpoint", + "RenewFlightEndpoint", }; if (actual_action_types != expected_action_types) { return Status::Invalid( @@ -752,12 +752,12 @@ class ExpirationTimeCloseFlightInfoScenario : public Scenario { } }; -/// \brief The expiration time scenario - RefreshFlightEndpoint. +/// \brief The expiration time scenario - RenewFlightEndpoint. /// -/// This tests that the client can refresh a FlightEndpoint and read -/// data in refreshed expiration time even when the original +/// This tests that the client can renew a FlightEndpoint and read +/// data in renewed expiration time even when the original /// expiration time is over. -class ExpirationTimeRefreshFlightEndpointScenario : public Scenario { +class ExpirationTimeRenewFlightEndpointScenario : public Scenario { Status MakeServer(std::unique_ptr* server, FlightServerOptions* options) override { *server = std::make_unique(); @@ -769,23 +769,23 @@ class ExpirationTimeRefreshFlightEndpointScenario : public Scenario { Status RunClient(std::unique_ptr client) override { ARROW_ASSIGN_OR_RAISE(auto info, client->GetFlightInfo(FlightDescriptor::Command("expiration"))); - // Refresh all endpoints that have expiration time + // Renew all endpoints that have expiration time for (const auto& endpoint : info->endpoints()) { if (!endpoint.expiration_time.has_value()) { continue; } const auto& expiration_time = endpoint.expiration_time.value(); - ARROW_ASSIGN_OR_RAISE(auto refreshed_endpoint, - client->RefreshFlightEndpoint(endpoint)); - if (!refreshed_endpoint.expiration_time.has_value()) { - return Status::Invalid("Refreshed endpoint must have expiration time: ", - refreshed_endpoint.ToString()); + ARROW_ASSIGN_OR_RAISE(auto renewed_endpoint, + client->RenewFlightEndpoint(endpoint)); + if (!renewed_endpoint.expiration_time.has_value()) { + return Status::Invalid("Renewed endpoint must have expiration time: ", + renewed_endpoint.ToString()); } - const auto& refreshed_expiration_time = refreshed_endpoint.expiration_time.value(); - if (refreshed_expiration_time <= expiration_time) { - return Status::Invalid("Refreshed endpoint must have newer expiration time\n", - "Original:\n", endpoint.ToString(), "Refreshed:\n", - refreshed_endpoint.ToString()); + const auto& renewed_expiration_time = renewed_endpoint.expiration_time.value(); + if (renewed_expiration_time <= expiration_time) { + return Status::Invalid("Renewed endpoint must have newer expiration time\n", + "Original:\n", endpoint.ToString(), "Renewed:\n", + renewed_endpoint.ToString()); } } return Status::OK(); @@ -1870,8 +1870,8 @@ Status GetScenario(const std::string& scenario_name, std::shared_ptr* } else if (scenario_name == "expiration_time:close_flight_info") { *out = std::make_shared(); return Status::OK(); - } else if (scenario_name == "expiration_time:refresh_flight_endpoint") { - *out = std::make_shared(); + } else if (scenario_name == "expiration_time:renew_flight_endpoint") { + *out = std::make_shared(); return Status::OK(); } else if (scenario_name == "flight_sql") { *out = std::make_shared(); diff --git a/cpp/src/arrow/flight/sql/client.h b/cpp/src/arrow/flight/sql/client.h index 009970933c0f7..b2c5bf04e13f4 100644 --- a/cpp/src/arrow/flight/sql/client.h +++ b/cpp/src/arrow/flight/sql/client.h @@ -362,11 +362,11 @@ class ARROW_FLIGHT_SQL_EXPORT FlightSqlClient { /// \brief Extends the expiration of a FlightEndpoint. /// /// \param[in] options RPC-layer hints for this call. - /// \param[in] endpoint The FlightEndpoint to refresh. - /// \return Arrow result with a refreshed FlightEndpoint - ::arrow::Result RefreshFlightEndpoint(const FlightCallOptions& options, - const FlightEndpoint& endpoint) { - return impl_->RefreshFlightEndpoint(options, endpoint); + /// \param[in] endpoint The FlightEndpoint to renew. + /// \return Arrow result with a renewed FlightEndpoint + ::arrow::Result RenewFlightEndpoint(const FlightCallOptions& options, + const FlightEndpoint& endpoint) { + return impl_->RenewFlightEndpoint(options, endpoint); } /// \brief Explicitly shut down and clean up the client. diff --git a/cpp/src/arrow/flight/sql/server.cc b/cpp/src/arrow/flight/sql/server.cc index e79f23c0bf693..26efc5395a432 100644 --- a/cpp/src/arrow/flight/sql/server.cc +++ b/cpp/src/arrow/flight/sql/server.cc @@ -762,7 +762,7 @@ Status FlightSqlServerBase::ListActions(const ServerCallContext& context, *actions = { ActionType::kCancelFlightInfo, ActionType::kCloseFlightInfo, - ActionType::kRefreshFlightEndpoint, + ActionType::kRenewFlightEndpoint, FlightSqlServerBase::kBeginSavepointActionType, FlightSqlServerBase::kBeginTransactionActionType, FlightSqlServerBase::kCancelQueryActionType, @@ -790,12 +790,12 @@ Status FlightSqlServerBase::DoAction(const ServerCallContext& context, std::string_view body(*action.body); ARROW_ASSIGN_OR_RAISE(auto info, FlightInfo::Deserialize(body)); ARROW_RETURN_NOT_OK(CloseFlightInfo(context, *info)); - } else if (action.type == ActionType::kRefreshFlightEndpoint.type) { + } else if (action.type == ActionType::kRenewFlightEndpoint.type) { std::string_view body(*action.body); ARROW_ASSIGN_OR_RAISE(auto endpoint, FlightEndpoint::Deserialize(body)); - ARROW_ASSIGN_OR_RAISE(auto refreshed_result, - RefreshFlightEndpoint(context, endpoint)); - ARROW_ASSIGN_OR_RAISE(auto packed_result, PackActionResult(refreshed_result)); + ARROW_ASSIGN_OR_RAISE(auto renewed_result, + RenewFlightEndpoint(context, endpoint)); + ARROW_ASSIGN_OR_RAISE(auto packed_result, PackActionResult(renewed_result)); results.push_back(std::move(packed_result)); } else { @@ -1101,9 +1101,9 @@ Status FlightSqlServerBase::CloseFlightInfo(const ServerCallContext& context, return Status::NotImplemented("CloseFlightInfo not implemented"); } -arrow::Result FlightSqlServerBase::RefreshFlightEndpoint( +arrow::Result FlightSqlServerBase::RenewFlightEndpoint( const ServerCallContext& context, const FlightEndpoint& info) { - return Status::NotImplemented("CancelFlightEndpoint not implemented"); + return Status::NotImplemented("RenewFlightEndpoint not implemented"); } arrow::Result diff --git a/cpp/src/arrow/flight/sql/server.h b/cpp/src/arrow/flight/sql/server.h index 6bbb4ee1a6a06..1b318cb42d8a7 100644 --- a/cpp/src/arrow/flight/sql/server.h +++ b/cpp/src/arrow/flight/sql/server.h @@ -621,11 +621,11 @@ class ARROW_FLIGHT_SQL_EXPORT FlightSqlServerBase : public FlightServerBase { virtual Status CloseFlightInfo(const ServerCallContext& context, const FlightInfo& info); - /// \brief Attempt to explicitly refresh a FlightEndpoint. + /// \brief Attempt to explicitly renew a FlightEndpoint. /// \param[in] context The call context. - /// \param[in] endpoint The FlightEndpoint to refresh. - /// \return The refresh result. - virtual arrow::Result RefreshFlightEndpoint( + /// \param[in] endpoint The FlightEndpoint to renew. + /// \return The renew result. + virtual arrow::Result RenewFlightEndpoint( const ServerCallContext& context, const FlightEndpoint& endpoint); /// @} diff --git a/cpp/src/arrow/flight/sql/server_test.cc b/cpp/src/arrow/flight/sql/server_test.cc index a1716958e7397..960190ae4a5d7 100644 --- a/cpp/src/arrow/flight/sql/server_test.cc +++ b/cpp/src/arrow/flight/sql/server_test.cc @@ -780,11 +780,11 @@ TEST_F(TestFlightSqlServer, CloseFlightInfo) { ASSERT_RAISES(NotImplemented, sql_client->CloseFlightInfo({}, *flight_info)); } -TEST_F(TestFlightSqlServer, RefreshFlightEndpoint) { +TEST_F(TestFlightSqlServer, RenewFlightEndpoint) { // Not supported ASSERT_OK_AND_ASSIGN(auto flight_info, sql_client->GetSqlInfo({}, {})); ASSERT_RAISES(NotImplemented, - sql_client->RefreshFlightEndpoint({}, flight_info->endpoints()[0])); + sql_client->RenewFlightEndpoint({}, flight_info->endpoints()[0])); } TEST_F(TestFlightSqlServer, Transactions) { diff --git a/cpp/src/arrow/flight/types.cc b/cpp/src/arrow/flight/types.cc index cd81669097cd9..cc6b7ebe9f0d7 100644 --- a/cpp/src/arrow/flight/types.cc +++ b/cpp/src/arrow/flight/types.cc @@ -525,11 +525,11 @@ const ActionType ActionType::kCloseFlightInfo = "Close the given FlightInfo explicitly.\n" "Request Message: FlightInfo to be closed\n" "Response Message: N/A"}; -const ActionType ActionType::kRefreshFlightEndpoint = - ActionType{"RefreshFlightEndpoint", +const ActionType ActionType::kRenewFlightEndpoint = + ActionType{"RenewFlightEndpoint", "Extend expiration time of the given FlightEndpoint.\n" - "Request Message: FlightEndpoint to be refreshed\n" - "Response Message: Refreshed FlightEndpoint"}; + "Request Message: FlightEndpoint to be renewed\n" + "Response Message: Renewed FlightEndpoint"}; bool ActionType::Equals(const ActionType& other) const { return type == other.type && description == other.description; diff --git a/cpp/src/arrow/flight/types.h b/cpp/src/arrow/flight/types.h index 49d2d7cd3da18..e6bdbf85ca590 100644 --- a/cpp/src/arrow/flight/types.h +++ b/cpp/src/arrow/flight/types.h @@ -180,7 +180,7 @@ struct ARROW_FLIGHT_EXPORT ActionType { static const ActionType kCancelFlightInfo; static const ActionType kCloseFlightInfo; - static const ActionType kRefreshFlightEndpoint; + static const ActionType kRenewFlightEndpoint; }; /// \brief Opaque selection criteria for ListFlights RPC diff --git a/dev/archery/archery/integration/runner.py b/dev/archery/archery/integration/runner.py index db69e60a30488..fc0bcfb6c2a88 100644 --- a/dev/archery/archery/integration/runner.py +++ b/dev/archery/archery/integration/runner.py @@ -461,9 +461,9 @@ def run_all_tests(with_cpp=True, with_java=True, with_js=True, skip={"JS", "C#", "Rust"}, ), Scenario( - "expiration_time:refresh_flight_endpoint", + "expiration_time:renew_flight_endpoint", description=("Ensure FlightEndpoint.expiration_time and " - "RefreshFlightEndpoint are working as expected."), + "RenewFlightEndpoint are working as expected."), skip={"JS", "C#", "Rust"}, ), Scenario( diff --git a/go/arrow/flight/client.go b/go/arrow/flight/client.go index 683ba006b566e..08a8e8befb660 100644 --- a/go/arrow/flight/client.go +++ b/go/arrow/flight/client.go @@ -69,7 +69,7 @@ type Client interface { CancelFlightInfo(ctx context.Context, info *FlightInfo, opts ...grpc.CallOption) (CancelFlightInfoResult, error) Close() error CloseFlightInfo(ctx context.Context, info *FlightInfo, opts ...grpc.CallOption) error - RefreshFlightEndpoint(ctx context.Context, endpoint *FlightEndpoint, opts ...grpc.CallOption) (*FlightEndpoint, error) + RenewFlightEndpoint(ctx context.Context, endpoint *FlightEndpoint, opts ...grpc.CallOption) (*FlightEndpoint, error) // join the interface from the FlightServiceClient instead of re-defining all // the endpoints here. FlightServiceClient @@ -409,10 +409,10 @@ func (c *client) CloseFlightInfo(ctx context.Context, info *FlightInfo, opts ... return ReadUntilEOF(stream) } -func (c *client) RefreshFlightEndpoint(ctx context.Context, endpoint *FlightEndpoint, opts ...grpc.CallOption) (*FlightEndpoint, error) { +func (c *client) RenewFlightEndpoint(ctx context.Context, endpoint *FlightEndpoint, opts ...grpc.CallOption) (*FlightEndpoint, error) { var err error var action flight.Action - action.Type = RefreshFlightEndpointActionType + action.Type = RenewFlightEndpointActionType action.Body, err = proto.Marshal(endpoint) if err != nil { return nil, err @@ -425,8 +425,8 @@ func (c *client) RefreshFlightEndpoint(ctx context.Context, endpoint *FlightEndp if err != nil { return nil, err } - var refreshedEndpoint FlightEndpoint - err = proto.Unmarshal(res.Body, &refreshedEndpoint) + var renewedEndpoint FlightEndpoint + err = proto.Unmarshal(res.Body, &renewedEndpoint) if err != nil { return nil, err } @@ -434,5 +434,5 @@ func (c *client) RefreshFlightEndpoint(ctx context.Context, endpoint *FlightEndp if err != nil { return nil, err } - return &refreshedEndpoint, nil + return &renewedEndpoint, nil } diff --git a/go/arrow/flight/flightsql/client.go b/go/arrow/flight/flightsql/client.go index 8e49277864add..205e60c57154f 100644 --- a/go/arrow/flight/flightsql/client.go +++ b/go/arrow/flight/flightsql/client.go @@ -542,8 +542,8 @@ func (c *Client) CloseFlightInfo(ctx context.Context, info *flight.FlightInfo, o return c.Client.CloseFlightInfo(ctx, info, opts...) } -func (c *Client) RefreshFlightEndpoint(ctx context.Context, endpoint *flight.FlightEndpoint, opts ...grpc.CallOption) (*flight.FlightEndpoint, error) { - return c.Client.RefreshFlightEndpoint(ctx, endpoint, opts...) +func (c *Client) RenewFlightEndpoint(ctx context.Context, endpoint *flight.FlightEndpoint, opts ...grpc.CallOption) (*flight.FlightEndpoint, error) { + return c.Client.RenewFlightEndpoint(ctx, endpoint, opts...) } func (c *Client) BeginTransaction(ctx context.Context, opts ...grpc.CallOption) (*Txn, error) { diff --git a/go/arrow/flight/flightsql/client_test.go b/go/arrow/flight/flightsql/client_test.go index 6744ba6a21dcb..a9823909041a0 100644 --- a/go/arrow/flight/flightsql/client_test.go +++ b/go/arrow/flight/flightsql/client_test.go @@ -69,7 +69,7 @@ func (m *FlightServiceClientMock) CloseFlightInfo(ctx context.Context, info *fli return m.Called(info, opts).Error(0) } -func (m *FlightServiceClientMock) RefreshFlightEndpoint(ctx context.Context, endpoint *flight.FlightEndpoint, opts ...grpc.CallOption) (*flight.FlightEndpoint, error) { +func (m *FlightServiceClientMock) RenewFlightEndpoint(ctx context.Context, endpoint *flight.FlightEndpoint, opts ...grpc.CallOption) (*flight.FlightEndpoint, error) { args := m.Called(endpoint, opts) return args.Get(0).(*flight.FlightEndpoint), args.Error(1) } @@ -645,7 +645,7 @@ func (s *FlightSqlClientSuite) TestCloseFlightInfo() { s.NoError(s.sqlClient.CloseFlightInfo(context.TODO(), info, s.callOpts...)) } -func (s *FlightSqlClientSuite) TestRefreshFlightEndpoint() { +func (s *FlightSqlClientSuite) TestRenewFlightEndpoint() { query := "SELECT * FROM data" cmd := &pb.CommandStatementQuery{Query: query} desc := getDesc(cmd) @@ -657,11 +657,11 @@ func (s *FlightSqlClientSuite) TestRefreshFlightEndpoint() { info, err := s.sqlClient.Execute(context.Background(), query, s.callOpts...) s.NoError(err) s.Equal(&mockedInfo, info) - var mockedRefreshedEndpoint flight.FlightEndpoint - s.mockClient.On("RefreshFlightEndpoint", &mockedEndpoint, s.callOpts).Return(&mockedRefreshedEndpoint, nil) - refreshedEndpoint, err := s.sqlClient.RefreshFlightEndpoint(context.TODO(), info.Endpoint[0], s.callOpts...) + var mockedRenewedEndpoint flight.FlightEndpoint + s.mockClient.On("RenewFlightEndpoint", &mockedEndpoint, s.callOpts).Return(&mockedRenewedEndpoint, nil) + renewedEndpoint, err := s.sqlClient.RenewFlightEndpoint(context.TODO(), info.Endpoint[0], s.callOpts...) s.NoError(err) - s.Equal(&mockedRefreshedEndpoint, refreshedEndpoint) + s.Equal(&mockedRenewedEndpoint, renewedEndpoint) } func TestFlightSqlClient(t *testing.T) { diff --git a/go/arrow/flight/flightsql/server.go b/go/arrow/flight/flightsql/server.go index fa1390618ed7a..111a571d18b8d 100644 --- a/go/arrow/flight/flightsql/server.go +++ b/go/arrow/flight/flightsql/server.go @@ -524,8 +524,8 @@ func (BaseServer) CloseFlightInfo(context.Context, *flight.FlightInfo) error { return status.Error(codes.Unimplemented, "CloseFlightInfo not implemented") } -func (BaseServer) RefreshFlightEndpoint(context.Context, *flight.FlightEndpoint) (*flight.FlightEndpoint, error) { - return nil, status.Error(codes.Unimplemented, "RefreshFlightEndpoint not implemented") +func (BaseServer) RenewFlightEndpoint(context.Context, *flight.FlightEndpoint) (*flight.FlightEndpoint, error) { + return nil, status.Error(codes.Unimplemented, "RenewFlightEndpoint not implemented") } func (BaseServer) EndTransaction(context.Context, ActionEndTransactionRequest) error { @@ -656,8 +656,8 @@ type Server interface { CancelFlightInfo(context.Context, *flight.FlightInfo) (flight.CancelFlightInfoResult, error) // CloseFlightInfo attempts to explicitly close a FlightInfo CloseFlightInfo(context.Context, *flight.FlightInfo) error - // RefreshFlightEndpoint attempts to extend the expiration of a FlightEndpoint - RefreshFlightEndpoint(context.Context, *flight.FlightEndpoint) (*flight.FlightEndpoint, error) + // RenewFlightEndpoint attempts to extend the expiration of a FlightEndpoint + RenewFlightEndpoint(context.Context, *flight.FlightEndpoint) (*flight.FlightEndpoint, error) mustEmbedBaseServer() } @@ -928,7 +928,7 @@ func (f *flightSqlServer) ListActions(_ *flight.Empty, stream flight.FlightServi actions := []string{ flight.CancelFlightInfoActionType, flight.CloseFlightInfoActionType, - flight.RefreshFlightEndpointActionType, + flight.RenewFlightEndpointActionType, CreatePreparedStatementActionType, ClosePreparedStatementActionType, BeginSavepointActionType, @@ -1022,23 +1022,23 @@ func (f *flightSqlServer) DoAction(cmd *flight.Action, stream flight.FlightServi } return f.srv.CloseFlightInfo(stream.Context(), &info) - case flight.RefreshFlightEndpointActionType: + case flight.RenewFlightEndpointActionType: var ( endpoint flight.FlightEndpoint err error ) if err = proto.Unmarshal(cmd.Body, &endpoint); err != nil { - return status.Errorf(codes.InvalidArgument, "unable to unmarshal FlightEndpoint for RefreshFlightEndpoint: %s", err.Error()) + return status.Errorf(codes.InvalidArgument, "unable to unmarshal FlightEndpoint for RenewFlightEndpoint: %s", err.Error()) } - refreshedEndpoint, err := f.srv.RefreshFlightEndpoint(stream.Context(), &endpoint) + renewedEndpoint, err := f.srv.RenewFlightEndpoint(stream.Context(), &endpoint) if err != nil { return err } out := &pb.Result{} - out.Body, err = proto.Marshal(refreshedEndpoint) + out.Body, err = proto.Marshal(renewedEndpoint) if err != nil { return err } diff --git a/go/arrow/flight/flightsql/server_test.go b/go/arrow/flight/flightsql/server_test.go index 9f2fdfee7bc14..8507ca56fb53a 100644 --- a/go/arrow/flight/flightsql/server_test.go +++ b/go/arrow/flight/flightsql/server_test.go @@ -380,14 +380,14 @@ func (s *UnimplementedFlightSqlServerSuite) TestCloseFlightInfo() { s.Equal("CloseFlightInfo not implemented", st.Message()) } -func (s *UnimplementedFlightSqlServerSuite) TestRefreshFlightEndpoint() { +func (s *UnimplementedFlightSqlServerSuite) TestRenewFlightEndpoint() { endpoint := flight.FlightEndpoint{} - refreshedEndpoint, err := s.cl.RefreshFlightEndpoint(context.TODO(), &endpoint) - s.Nil(refreshedEndpoint) + renewedEndpoint, err := s.cl.RenewFlightEndpoint(context.TODO(), &endpoint) + s.Nil(renewedEndpoint) st, ok := status.FromError(err) s.True(ok) s.Equal(codes.Unimplemented, st.Code()) - s.Equal("RefreshFlightEndpoint not implemented", st.Message()) + s.Equal("RenewFlightEndpoint not implemented", st.Message()) } func TestBaseServer(t *testing.T) { diff --git a/go/arrow/flight/server.go b/go/arrow/flight/server.go index 637d35b279b1d..596d0c3cbe5e8 100644 --- a/go/arrow/flight/server.go +++ b/go/arrow/flight/server.go @@ -56,9 +56,9 @@ type ( // Constants for Action types const ( - CancelFlightInfoActionType = "CancelFlightInfo" - CloseFlightInfoActionType = "CloseFlightInfo" - RefreshFlightEndpointActionType = "RefreshFlightEndpoint" + CancelFlightInfoActionType = "CancelFlightInfo" + CloseFlightInfoActionType = "CloseFlightInfo" + RenewFlightEndpointActionType = "RenewFlightEndpoint" ) // Constants for CancelStatus diff --git a/go/arrow/internal/flight_integration/scenario.go b/go/arrow/internal/flight_integration/scenario.go index 3ed3e41a05025..10e80769b4909 100644 --- a/go/arrow/internal/flight_integration/scenario.go +++ b/go/arrow/internal/flight_integration/scenario.go @@ -68,8 +68,8 @@ func GetScenario(name string, args ...string) Scenario { return &expirationTimeCancelFlightInfoScenarioTester{} case "expiration_time:close_flight_info": return &expirationTimeCloseFlightInfoScenarioTester{} - case "expiration_time:refresh_flight_endpoint": - return &expirationTimeRefreshFlightEndpointScenarioTester{} + case "expiration_time:renew_flight_endpoint": + return &expirationTimeRenewFlightEndpointScenarioTester{} case "flight_sql": return &flightSqlScenarioTester{} case "flight_sql:extension": @@ -827,7 +827,7 @@ func (tester *expirationTimeScenarioTester) ListActions(_ *flight.Empty, stream actions := []string{ flight.CancelFlightInfoActionType, flight.CloseFlightInfoActionType, - flight.RefreshFlightEndpointActionType, + flight.RenewFlightEndpointActionType, } for _, a := range actions { @@ -901,7 +901,7 @@ func (tester *expirationTimeScenarioTester) DoAction(cmd *flight.Action, stream tester.statuses[index] = st } return nil - case flight.RefreshFlightEndpointActionType: + case flight.RenewFlightEndpointActionType: var endpoint flight.FlightEndpoint if err := proto.Unmarshal(cmd.Body, &endpoint); err != nil { return status.Errorf(codes.InvalidArgument, "unable to parse command: %s", err.Error()) @@ -912,11 +912,11 @@ func (tester *expirationTimeScenarioTester) DoAction(cmd *flight.Action, stream if err != nil { return err } - endpoint.Ticket.Ticket = []byte(string(endpoint.Ticket.Ticket) + ": refreshed (+ 10 seconds)") - refreshedExpirationTime := time.Now().Add(time.Second * 10) - endpoint.ExpirationTime = timestamppb.New(refreshedExpirationTime) + endpoint.Ticket.Ticket = []byte(string(endpoint.Ticket.Ticket) + ": renewed (+ 10 seconds)") + renewedExpirationTime := time.Now().Add(time.Second * 10) + endpoint.ExpirationTime = timestamppb.New(renewedExpirationTime) st := tester.statuses[index] - st.expirationTime = &refreshedExpirationTime + st.expirationTime = &renewedExpirationTime tester.statuses[index] = st out, err := packActionResult(&endpoint) if err != nil { @@ -1059,7 +1059,7 @@ func (tester *expirationTimeListActionsScenarioTester) RunClient(addr string, op expectedActionTypeNames := []string{ "CancelFlightInfo", "CloseFlightInfo", - "RefreshFlightEndpoint", + "RenewFlightEndpoint", } if !reflect.DeepEqual(actionTypeNames, expectedActionTypeNames) { return fmt.Errorf("action types aren't expected\n"+ @@ -1149,11 +1149,11 @@ func (tester *expirationTimeCloseFlightInfoScenarioTester) RunClient(addr string return nil } -type expirationTimeRefreshFlightEndpointScenarioTester struct { +type expirationTimeRenewFlightEndpointScenarioTester struct { expirationTimeScenarioTester } -func (tester *expirationTimeRefreshFlightEndpointScenarioTester) RunClient(addr string, opts ...grpc.DialOption) error { +func (tester *expirationTimeRenewFlightEndpointScenarioTester) RunClient(addr string, opts ...grpc.DialOption) error { client, err := flight.NewClientWithMiddleware(addr, nil, nil, opts...) if err != nil { return err @@ -1166,25 +1166,25 @@ func (tester *expirationTimeRefreshFlightEndpointScenarioTester) RunClient(addr return err } - // Refresh all endpoints that have expiration time + // Renew all endpoints that have expiration time for _, ep := range info.Endpoint { if ep.ExpirationTime == nil { continue } expirationTime := ep.ExpirationTime.AsTime() - refreshedEndpoint, err := client.RefreshFlightEndpoint(ctx, ep) + renewedEndpoint, err := client.RenewFlightEndpoint(ctx, ep) if err != nil { return err } - if refreshedEndpoint.ExpirationTime == nil { - return fmt.Errorf("refreshed endpoint must have expiration time: %s", - refreshedEndpoint) + if renewedEndpoint.ExpirationTime == nil { + return fmt.Errorf("renewed endpoint must have expiration time: %s", + renewedEndpoint) } - refreshedExpirationTime := refreshedEndpoint.ExpirationTime.AsTime() - if refreshedExpirationTime.Sub(expirationTime) <= 0 { - return fmt.Errorf("refreshed endpoint must have newer expiration time\n"+ - "Original: %s\nRefreshed: %s", - ep, refreshedEndpoint) + renewedExpirationTime := renewedEndpoint.ExpirationTime.AsTime() + if renewedExpirationTime.Sub(expirationTime) <= 0 { + return fmt.Errorf("renewed endpoint must have newer expiration time\n"+ + "Original: %s\nRenewed: %s", + ep, renewedEndpoint) } } diff --git a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeListActionsScenario.java b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeListActionsScenario.java index bd234825cc170..e6966bb959961 100644 --- a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeListActionsScenario.java +++ b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeListActionsScenario.java @@ -51,7 +51,7 @@ public void client(BufferAllocator allocator, Location location, FlightClient cl IntegrationAssertions.assertTrue("Expected 3 actions", actions.hasNext()); action = actions.next(); - IntegrationAssertions.assertEquals(FlightConstants.REFRESH_FLIGHT_ENDPOINT.getType(), action.getType()); + IntegrationAssertions.assertEquals(FlightConstants.RENEW_FLIGHT_ENDPOINT.getType(), action.getType()); IntegrationAssertions.assertFalse("Expected 3 actions", actions.hasNext()); } diff --git a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java index 0ee68adf8b70c..b58127a85f745 100644 --- a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java +++ b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java @@ -69,7 +69,7 @@ * even within 3 seconds after the action. *

* The client can extend the expiration time of a FlightEndpoint in - * a returned FlightInfo by pre-defined RefreshFlightEndpoint + * a returned FlightInfo by pre-defined RenewFlightEndpoint * action. The client can read data from endpoints multiple times * within more 10 seconds after the action. *

@@ -163,7 +163,7 @@ public void doAction(CallContext context, Action action, StreamListener int index = parseIndexFromTicket(endpoint.getTicket()); statuses.get(index).closed = true; } - } else if (action.getType().equals(FlightConstants.REFRESH_FLIGHT_ENDPOINT.getType())) { + } else if (action.getType().equals(FlightConstants.RENEW_FLIGHT_ENDPOINT.getType())) { FlightEndpoint endpoint = FlightEndpoint.deserialize(ByteBuffer.wrap(action.getBody())); int index = parseIndexFromTicket(endpoint.getTicket()); EndpointStatus status = statuses.get(index); @@ -175,7 +175,7 @@ public void doAction(CallContext context, Action action, StreamListener } String ticketBody = new String(endpoint.getTicket().getBytes(), StandardCharsets.UTF_8); - ticketBody += ": refreshed (+ 10 seconds)"; + ticketBody += ": renewed (+ 10 seconds)"; Ticket ticket = new Ticket(ticketBody.getBytes(StandardCharsets.UTF_8)); Instant expiration = Instant.now().plus(10, ChronoUnit.SECONDS); status.expirationTime = expiration; @@ -199,7 +199,7 @@ public void doAction(CallContext context, Action action, StreamListener public void listActions(CallContext context, StreamListener listener) { listener.onNext(FlightConstants.CANCEL_FLIGHT_INFO); listener.onNext(FlightConstants.CLOSE_FLIGHT_INFO); - listener.onNext(FlightConstants.REFRESH_FLIGHT_ENDPOINT); + listener.onNext(FlightConstants.RENEW_FLIGHT_ENDPOINT); listener.onCompleted(); } diff --git a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRefreshFlightEndpointScenario.java b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRenewFlightEndpointScenario.java similarity index 78% rename from java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRefreshFlightEndpointScenario.java rename to java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRenewFlightEndpointScenario.java index 1d1f6b79b7242..e923cb167b5b0 100644 --- a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRefreshFlightEndpointScenario.java +++ b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeRenewFlightEndpointScenario.java @@ -30,8 +30,8 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.util.AutoCloseables; -/** Test RefreshFlightEndpoint. */ -final class ExpirationTimeRefreshFlightEndpointScenario implements Scenario { +/** Test RenewFlightEndpoint. */ +final class ExpirationTimeRenewFlightEndpointScenario implements Scenario { @Override public FlightProducer producer(BufferAllocator allocator, Location location) throws Exception { return new ExpirationTimeProducer(allocator); @@ -45,18 +45,18 @@ public void buildServer(FlightServer.Builder builder) { public void client(BufferAllocator allocator, Location location, FlightClient client) throws Exception { FlightInfo info = client.getInfo(FlightDescriptor.command("expiration".getBytes(StandardCharsets.UTF_8))); - // Refresh all endpoints with expiration time + // Renew all endpoints with expiration time for (FlightEndpoint endpoint : info.getEndpoints()) { if (!endpoint.getExpirationTime().isPresent()) { continue; } Instant expiration = endpoint.getExpirationTime().get(); - FlightEndpoint refreshed = client.refreshFlightEndpoint(endpoint); + FlightEndpoint renewed = client.renewFlightEndpoint(endpoint); - IntegrationAssertions.assertTrue("Refreshed FlightEndpoint must have expiration time", - refreshed.getExpirationTime().isPresent()); - IntegrationAssertions.assertTrue("Refreshed FlightEndpoint must have newer expiration time", - refreshed.getExpirationTime().get().isAfter(expiration)); + IntegrationAssertions.assertTrue("Renewed FlightEndpoint must have expiration time", + renewed.getExpirationTime().isPresent()); + IntegrationAssertions.assertTrue("Renewed FlightEndpoint must have newer expiration time", + renewed.getExpirationTime().get().isAfter(expiration)); } } diff --git a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/Scenarios.java b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/Scenarios.java index d9cd70c5f59b0..a0bb671606a42 100644 --- a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/Scenarios.java +++ b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/Scenarios.java @@ -42,7 +42,7 @@ private Scenarios() { scenarios.put("auth:basic_proto", AuthBasicProtoScenario::new); scenarios.put("expiration_time:cancel_flight_info", ExpirationTimeCancelFlightInfoScenario::new); scenarios.put("expiration_time:close_flight_info", ExpirationTimeCloseFlightInfoScenario::new); - scenarios.put("expiration_time:refresh_flight_endpoint", ExpirationTimeRefreshFlightEndpointScenario::new); + scenarios.put("expiration_time:renew_flight_endpoint", ExpirationTimeRenewFlightEndpointScenario::new); scenarios.put("expiration_time:do_get", ExpirationTimeDoGetScenario::new); scenarios.put("expiration_time:list_actions", ExpirationTimeListActionsScenario::new); scenarios.put("middleware", MiddlewareScenario::new); diff --git a/java/flight/flight-integration-tests/src/test/java/org/apache/arrow/flight/integration/tests/IntegrationTest.java b/java/flight/flight-integration-tests/src/test/java/org/apache/arrow/flight/integration/tests/IntegrationTest.java index 083de1cbdc12a..4054cd017229d 100644 --- a/java/flight/flight-integration-tests/src/test/java/org/apache/arrow/flight/integration/tests/IntegrationTest.java +++ b/java/flight/flight-integration-tests/src/test/java/org/apache/arrow/flight/integration/tests/IntegrationTest.java @@ -54,8 +54,8 @@ void expirationTimeListActions() throws Exception { } @Test - void expirationTimeRefreshFlightEndpoint() throws Exception { - testScenario("expiration_time:refresh_flight_endpoint"); + void expirationTimeRenewFlightEndpoint() throws Exception { + testScenario("expiration_time:renew_flight_endpoint"); } @Test