Let $X$ be a projective variety over $\mathbb{C}$, then the effective curves module the numerical equivalence form a cone. For my understanding, if the extreme ray $[C]$ has the property that $[C]\cdot K_X > 0$$[C]\cdot K_X < 0$, then one can contract this extreme ray to get a morphism $f: X \to Y$.
I want to know if there is any restriction for the exceptional divisor $Exc(f)$ of this morphism. For example, could $Exc(f)$ be a Calabi-Yau variety (i.e. the canonical divisor is trivial)?
My knowledge about birational geometry is very limited, the "counter-example" I can think of is a a cone (this is $Y$ in the question) over a Calabi-Yau variety $D$ and $X$ is a blowup of $Y$ at the vertex. I think the exceptional divisor of $X \to Y$ is $D$, but I don't know if this is the contraction of extreme ray.
Any suggestions/references are very welcome!