In general relativity, one of the most interesting ways to construct notions of energy is the method of Hamiltonian analysis. For asymptotically flat spacetimes, this approach yields the well-known ADM mass. In order to define quasi-local energy/mass for compact initial data sets, one would like to apply the Hamiltonian analysis of GR on compact spacetimes with time-like boundary. Traditionally, this has been done based on fixing the Dirichlet boundary condition of the spacetimes — one of the most well-known work along this thread is the Brown-York quasi-local mass. In this talk we will discuss in detail the relation between the study of initial boundary value problem for vacuum Einstein equations and the Hamiltonian analysis on compact spacetimes. Then we will construct a notion of quasi-local Hamiltonian (energy) based on a well-posed initial boundary value problem.