CLAM: cross-layer adaptation manager for service-based applications