Tonga was rocked by an earthquake which initial reports suggested could cause hazardous waves on its coastline.