Ovirt 代码阅读分享

22
ovirt code reading share

Transcript of Ovirt 代码阅读分享

ovirt code reading share

discuss content

● jboss-as● ovirt-engine-backend● ovirt-engine-frontend

jboss-as

● an application server● implementing java ee spec

○ JSP (servlet)○ JAX-RS (rest api)○ EJB (serve business logic, persistent, transaction)○ 。。。

● each spec impl is modular via jboss as configuration file

----------------------------------------------------------------------------------------jboss-as

● jboss as confiuration file○ server

■ extensions● extension (define module)

■ profile● subsystem (module specific configuration)

■ socket-binding-group (bind interface config)

● configuration file is loaded by "jboss-modules" project

----------------------------------------------------------------------------------------jboss-as

ovirt 启动 jboss-as

● ./packaging/services/ovirt-engine/ovirt-engine.py start● 启动 jboss-as: java -D… -jar jboss-modules.jar -xxx -c ovirt-engine.xml

----------------------------------------------------------------------------------------jboss-as

ovirt-engine-frontend

● gwt rpc 框架:

------------------------------------------------------------------------ovirt-engine-frontend

● ovirt's implementation:

ServiceDefTarget

GenericApiGWTServiceAsync

RpcService

GenericApiGWTService GenericApiGWTServiceImpl

RpcServlet

GWT.create( GenericApiGWTService.class )

------------------------------------------------------------------------ovirt-engine-frontend

-----------------------------------------------------------------------ovirt-engine-frontend

GenericApiGWTServiceImpl

Backend

JNDI

GenericApiGWTServiceAsync

Frontend

VdcOperationManager

gwt-rpc

ovirt-engine-backend

ovirt backend architecture

------------------------------------------------------------------------ovirt-engine-backend

Backend(business logic)

rest api

database

vds broker

aaa

Frontend

。。。

ovirt backend logic start from EJB

● 寻找 javax.ejb 内的标签: @Local, @Singleton, @Startup …● 根据 @DependsOn({ “XXX" }) 先后加载● 加载时执行@PostConstruct标注的方法● example:

○ Backend.java○ InitBackendServicesOnStartupBean.java

------------------------------------------------------------------------ovirt-engine-backend

Backend business logic Services(EJB)

● AsyncTaskManager● ResourceManager● MacPoolManager● UserDomainsCacheManagerService● InMemoryLockManager● ...

------------------------------------------------------------------------ovirt-engine-backend

AsyncTaskManager

● what is async task?○ vdsm commands related to storage actions○ monitoring tasks from vdsm:"vdsClient -s 0 getAllTasks"

● timely check if task finished

------------------------------------------------------------------------ovirt-engine-backend

ResourceManager

● manage cluster○ schedule update from each vdsm in cluster

● manage storage pool (data center)○ schedule update from each spm in data center

------------------------------------------------------------------------ovirt-engine-backend

InMemoryLockManager

● entry point to acquire command’s lock● hold all commands’s locks

------------------------------------------------------------------------ovirt-engine-backend

ovirt backend Command

● bll command○ what? take care of a business logic○ how? interact with DAO(db), backend service, vds command

● vds command○ simple: invoke vdsm API

------------------------------------------------------------------------ovirt-engine-backend

bll command’s basic flow

● canDoAction● executeCommand● endAction (may not execute if no task)

------------------------------------------------------------------------ovirt-engine-backend

bll command & async task

● invoke vds command that contains async task● get a task id and hand it to AsyncTaskManager● endAction() is called when task is done

------------------------------------------------------------------------ovirt-engine-backend

bll command & monitoring

● step & job● monitoring step & job

○ add step/job○ end step/job

● frontend fetch from db timely●

------------------------------------------------------------------------ovirt-engine-backend

end