ZStack is an open-source IaaS platform for datacenter management via APIs. It uses a plugin-based architecture where core orchestration is extensible without impacting existing code. Key frameworks:
- CloudBus: Asynchronous messaging system for inter-component communication (see
core/src/main/java/org/zstack/core/cloudbus/) - Workflow Engine: Manages complex operations with rollback on failure (see
core/src/main/java/org/zstack/core/workflow/) - Cascade Framework: Propagates operations across dependent resources (see
core/src/main/java/org/zstack/core/cascade/) - Plugin System: Everything is a plugin; use
PluginRegistryfor extensions (seecore/src/main/java/org/zstack/core/plugin/)
Major components are organized as Maven modules: core, compute, storage, network, plugin/*, etc.
- Build: Use Maven; run
./runMavenProfile premiumfor enterprise features ormvn clean installfor standard build - Database: Deploy schema with
./runMavenProfile deploydb; uses Hibernate ORM - Testing: Three-tier system - unit tests in modules, integration tests in
test/, system tests intestlib/ - Debugging: Simulator module (
simulator/) mocks hypervisors for local testing - Deployment: WAR file deployment to Tomcat; scripts in
build/for automation
- Java 8 with Spring Framework 5.x, Hibernate 5.x
- Packages:
org.zstack.*; core incore/, compute logic incompute/ - Flows for Operations: VM operations use
Flowinterface with rollback (e.g.,VmStartOnHypervisorFlow.java) - Messages: Async via CloudBus; extend
Messagefor requests,MessageReplyfor responses - Extensions: Use
PluginRegistry.getExtensionList()for plugin hooks (e.g.,VmBeforeStartOnHypervisorExtensionPoint) - Error Handling: Use
ErrorCodeandCloudRuntimeException; avoid checked exceptions - Logging:
CLoggerfromUtils.getLogger() - Database: JPA entities with
@Entity; queries viaDatabaseFacade
- Plugin Implementation: Create module under
plugin/, implementPluginDriverinterface - API Messages: Extend
APIMessagefor user-facing APIs, handle in managers (e.g.,VmInstanceManagerImpl) - Resource Allocation: Use workflow chains for multi-step allocations (e.g., host, storage, network)
- State Machines: Built-in for resource states; use
Platform.createStateMachine() - Global Config: Use
GlobalPropertyfor runtime configurations
- External Services: RabbitMQ for CloudBus, Ansible for automation
- Hypervisors: KVM plugin in
plugin/kvm/, others like Ceph, NFS - Networking: NFV-based; virtual routers as appliances
- Storage: Primary/backup storage abstraction; plugins for different backends
Reference: README.md for overview, pom.xml for dependencies, runMavenProfile for dev scripts.