Shogun by James Clavell. It is a work of historical fiction set in the early 1600's in Japan, just before a huge war was about to break out which in fact resulted in the Tokugawa Shogunate (Toranaga in the book).
The protagonist in the book is John Blackthorn, and Englishman who was shipwrecked on the shores of Japan and becomes close to the warlord who would eventually become the Shogun, even becoming a samurai along the way.
The book is based on a real life person named Will Adams who was indeed shipwrecked in Japan, became close to Ieyasu Tokugawa and become a samurai. My previous post on Will Adams may be read here.
Before Admiral Perry opened up Japan, a teenaged Japanese boy was fishing far off shore when his shipped was wrecked and was picked up by an American whaler. At that time anyone who left Japan and tried to come back would immediately be executed.
Manjiro Nakahama undertook many adventures in his lifetime, eventually making his way back to Japan where he eventually became a samurai in direct service to the Shogun, was an interpreter when Admiral Perry arrived and continued to serve Japan with distinction in it's affairs in the new world with which it found itself.
Here are links to a couple of books. This one is a biography written for young readers, and this one is a work of historical fiction based on the life and times of Manjiro Nakahama.