The glassy state in arrays of superconducting junctions: the role of frustration and disorder in its formation