Energy harvesting and wireless energy transfer are capable of relieving the battery limitation of wireless devices. In this paper, an amplify-and-forward relay network (AF-RN) is considered, where an energy harvesting source node communicates with a destination node through an energy harvesting relay node. To further improve the performance, the relay is allowed to harvest energy from the radio frequency (RF) signals sent by the source node through a dedicated energy control channel. A joint power control and energy transfer scheme is investigated with the goal of maximizing the achievable sum rate by a deadline subject to energy causality constraints. The problem is challenging in that the objective function is non-convex, and a successive convex approximation approach is proposed to achieve the optimal power control and energy transfer solution. Finally, numerical examples are given to demonstrate the effectiveness of our proposed algorithm.