Jin and Emperor Min of Jin, the empire was put into grave danger with the uprising of northern non-Han peoples collectively known as the Five Barbarians, when numerous nomadic tribal groups resettled in northern and northwestern China who had been heavily drafted into the military then exploited the civil wars to seize power. Their armies almost destroyed the dynasty in the Disaster of Yongjia of 311, when the Five Barbarians sacked Luoyang. Chang'an met a similar fate in 316. However, a scion of the imperial house, Sima Rui (Emperor Yuan of Jin) fled south of the Huai River and reestablished the dynasty, known in historiography as the Eastern Jin dynasty. Cementing their power in the south, the Eastern Jin established Jiankang on the existing site of Jianye (now Nanjing) as their new capital. In the north, the Five Barbarians established numerous short-lived dynasties, leading to the period known as the Sixteen Kingdoms in historiography. Eventually, the Northern Wei dynasty conquered the rest of the northern states in 439 and unified northern China. Although the Eastern Jin and successive southern dynasties were well-defended from the northern dynasties by their placement of naval fleets along the Yangtze, there were still various problems related to the creation and maintenance of military strength. The designation of specific households for military service in the tuntian system eventually led to a falling out in their social status, causing widespread desertion of troops on many occasions. Faced with shortage of troop numbers, Eastern Jin generals were often sent on campaigns to capture non-Han peoples in the south to draft them into the military. The Eastern Jin dynasty fell not because of external invasion, however, but because Liu Yu (Emperor Wu of Liu Song) seized the throne from the Emperor Gong of Jin and founded the Liu Song dynasty, which officially began the Northern and Southern dynasties period. Northern dynasties The Northern dynasties began in 439 when the Northern Wei conquered the Northern Liang to unite northern China and ended in 589 when the Sui dynasty extinguished the Chen dynasty. It can be divided into three time periods: Northern Wei; Eastern and Western Weis; Northern Qi and Northern Zhou. The Northern, Eastern, and Western Wei along with the Northern Zhou were established by the Xianbei people while the Northern Qi was established by ethnic Han. In the north, local ethnic Han gentry clans had consolidated themselves by constructing