In the existing three layers multi-granularity optical switching network based on code group routing entity (CGRE), network nodes can not only achieve the switching of fiber granularity, wavelength granularity, and optical code granularity, but also bundle the associated optical codes into CGRE to transmit in the CGRE pipes. In multi-domain optical networks based on this switching system, the research of routing and optical code allocation is a key point. In the process of optical path establishment and optical codes selection, there is still a phenomenon of network delay and optical code allocation conflict by the traditional serial processing. In order to solve the above problems, based on stateful PCE (Path Computation Element) technology, this paper proposes a strategy for build CGRE pipes (B-CGREP) module and a mechanism for optical code allocation element (OCAE), and introduces the architecture of hierarchical stateful PCE (H-SPCE) in multi-domain network, the architecture consists of a main stateful PCE and multiple sub-stateful PCEs. Add a B-CGREP module to main stateful PCE, and each sub-stateful PCEs is equipped with an OCAE. On the basis of the interaction between the B-CGREP module in the main stateful PCE and the OCAE of each sub-domain, every domain can perform the intra-domain signaling process independently and parallel to achieve fast allocation of cross-domain optical paths and avoid optical code allocation conflicts among domains, as a result, improving the performance of multi-domain intelligent optical networks.