Japan's prime minister has imposed a mandatory quarantine on all visitors from South Korea and China, triggering warnings of countermeasures.