This phase II trial studies how well ensartinib works in treating patients with solid tumors, non-Hodgkin lymphoma, or histiocytic disorders with ALK or ROS1 genomic alterations that have come back or do not respond to treatment and have spread to other places in the body. Ensartinib may stop the growth of tumor cells by blocking some of the enzymes needed for cell growth.