org.ow2.jasmine.jadort.service.implementation
Class JadortServiceImpl

java.lang.Object
  extended by org.ow2.jasmine.jadort.service.implementation.JadortServiceImpl
All Implemented Interfaces:
org.ow2.jasmine.jadort.api.IJadortService

public class JadortServiceImpl
extends java.lang.Object
implements org.ow2.jasmine.jadort.api.IJadortService

This class provides default implementations for the IJadortService interface.

Author:
Malek Chahine, Remy Bresson, S. Ali Tokmen

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ow2.jasmine.jadort.api.IJadortService
org.ow2.jasmine.jadort.api.IJadortService.OperationType
 
Field Summary
protected  javax.persistence.EntityManager em
           
protected  javax.jms.QueueConnection qc
           
protected  javax.jms.Queue queue
           
protected  javax.jms.QueueSession session
           
 
Fields inherited from interface org.ow2.jasmine.jadort.api.IJadortService
EJB_JNDI_NAME
 
Constructor Summary
JadortServiceImpl()
           
 
Method Summary
 void abortServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
          
 void abortWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
          
protected  boolean checkApplication(org.ow2.jasmine.jadort.api.entities.deployment.ServerProgressBean serverProgress, org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean application, java.lang.String state, java.lang.String policy)
          Checks if an application is already deployed on the server, or if has a bad policy, or if has a bad state
 boolean checkServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
          
 boolean checkWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
          
protected  org.ow2.jasmine.jadort.api.entities.topology.ConnectorBean createJMXConnectorBean(URLConnector urlConnector)
           
 void createNewOperation(java.lang.String newOperationName)
          
 void deleteOperation(org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean selectedOperation)
          
 org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean getCurrentOperation()
          
 org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean.Step getCurrentStep()
          

IMPORTANT: Avoid calling this method from inside other methods of the JadortServiceImpl class (it will be costly)
 java.util.List<org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean> getOperationsList()
          
 void ignoreServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
          
 void ignoreWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
          
protected  void initialize()
           
protected  boolean isSameApplication(org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean a1, org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean a2)
          Compares two application, tests if a two applications are equal).
protected  void loadDeployMETopology(java.io.File xmlTopoFile)
           
protected  void loadJadortSpecificTopology(java.io.File xmlTopoFile)
           
protected
<T> T
loadSchemaAndFile(java.lang.String xsdPath, java.lang.Class<T> rootClass, java.io.File xmlFile)
          Verifies an XML file against an XSD and instantiates it using a given class.
 void loadTopology(java.io.File xmlTopoFile)
          
 void next()
          
 void previous()
          
 void restartServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
          
 void restartWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
          
 void selectApplication(java.net.URL url)
          
 void selectGroup(org.ow2.jasmine.jadort.api.entities.topology.GroupBean selectedGroup)
          
 void selectOperation(org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean selectedOperation)
          
 void selectOperationType(org.ow2.jasmine.jadort.api.IJadortService.OperationType operationType)
          
 void selectServers(java.util.List<org.ow2.jasmine.jadort.api.entities.topology.ServerBean> selectedServers)
          
 void selectVMImage(org.ow2.jasmine.jadort.api.entities.deployment.VMImageBean selectedVMImage)
          
 void selectVMImage(org.ow2.jasmine.jadort.api.entities.deployment.VMImageBean selectedVMImage, org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
          
protected  void terminate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

em

protected javax.persistence.EntityManager em

qc

protected javax.jms.QueueConnection qc

session

protected javax.jms.QueueSession session

queue

protected javax.jms.Queue queue
Constructor Detail

JadortServiceImpl

public JadortServiceImpl()
Method Detail

initialize

protected void initialize()

terminate

protected void terminate()

getOperationsList

public java.util.List<org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean> getOperationsList()
                                                                                                    throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
getOperationsList in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the getOperationsList() method can not be called in the current step. (this method can be called only in SELECT_OPERATION step)

getCurrentOperation

public org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean getCurrentOperation()
                                                                                      throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
getCurrentOperation in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - If fetching fails.

loadTopology

public void loadTopology(java.io.File xmlTopoFile)
                  throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
loadTopology in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the loadTopology method is called outside the INITIALIZE_TOPOLOGY step,
  • if an error is occurred when parsing the .xml file

loadJadortSpecificTopology

protected void loadJadortSpecificTopology(java.io.File xmlTopoFile)
                                   throws javax.xml.bind.UnmarshalException,
                                          org.ow2.jasmine.jadort.api.JadortServiceException
Parameters:
xmlTopoFile - JaDOrT-specific topology XML file to load.
Throws:
javax.xml.bind.UnmarshalException
org.ow2.jasmine.jadort.api.JadortServiceException
See Also:
loadSchemaAndFile(String, Class, File)

loadDeployMETopology

protected void loadDeployMETopology(java.io.File xmlTopoFile)
                             throws javax.xml.bind.UnmarshalException,
                                    org.ow2.jasmine.jadort.api.JadortServiceException
Parameters:
xmlTopoFile - JASMINe Deploy ME topology XML file to load.
Throws:
javax.xml.bind.UnmarshalException
org.ow2.jasmine.jadort.api.JadortServiceException
See Also:
loadSchemaAndFile(String, Class, File)

loadSchemaAndFile

protected <T> T loadSchemaAndFile(java.lang.String xsdPath,
                                  java.lang.Class<T> rootClass,
                                  java.io.File xmlFile)
                       throws org.ow2.jasmine.jadort.api.JadortServiceException,
                              javax.xml.bind.UnmarshalException
Verifies an XML file against an XSD and instantiates it using a given class.

Parameters:
xsdPath - XSD file path.
rootClass - Root class used for instantiating JAXB.
xmlFile - XML to load.
Returns:
XML loaded using JAXB and the rootClass.
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - If loading fails.
javax.xml.bind.UnmarshalException - If parsing fails (file doesn't correspond to XSD).

createJMXConnectorBean

protected org.ow2.jasmine.jadort.api.entities.topology.ConnectorBean createJMXConnectorBean(URLConnector urlConnector)
Parameters:
urlConnector - URLConnector for which to create a JMXConnector bean.
Returns:
JMXConnector bean for the given urlConnector.

selectGroup

public void selectGroup(org.ow2.jasmine.jadort.api.entities.topology.GroupBean selectedGroup)
                 throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectGroup in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the selectedGroup method can not be called in the current step. (this method can be called only in SELECT_GROUP step)

selectOperationType

public void selectOperationType(org.ow2.jasmine.jadort.api.IJadortService.OperationType operationType)
                         throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectOperationType in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the selectedGroup method can not be called in the current step. (this method can be called only in SELECT_OPERATION_TYPE step)

restartServer

public void restartServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
                   throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
restartServer in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the restartServermethod can not be called in the current step. (this method can be called only in EXECUTING_MIGRATION_PART1, EXECUTING_MIGRATION_PART2, EXECUTING_MAINTENANCE_CLUSTER, EXECUTING_MAINTENANCE_NO_CLUSTER and DESTROY_OLD_VM_HOSTS steps)
  • if the server state is not in error state.

ignoreServer

public void ignoreServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
                  throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
ignoreServer in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the ignoreServer can not be called in the current step. (this method can be called only in Step.EXECUTING_MIGRATION_PART1, EXECUTING_MIGRATION_PART2 EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER steps)
  • if the server state is not in error state.

abortServer

public void abortServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
                 throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
abortServer in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - If the abortServer can not be called in the current step. (this method can be called only in Step.EXECUTING_MIGRATION_PART1, Step.EXECUTING_MIGRATION_PART2, EXECUTING_MAINTENANCE_CLUSTER, Step.EXECUTING_MAINTENANCE_NO_CLUSTER steps)

checkServer

public boolean checkServer(org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
                    throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
checkServer in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the checkServer can not be called in the current step. (this method can be called only in EXECUTING_MIGRATION_PART1, EXECUTING_MIGRATION_PART2, EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER steps)

checkWorker

public boolean checkWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
                    throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
checkWorker in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the checkWorker can not be called in the current step. (this method can be called only in EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER steps)

isSameApplication

protected boolean isSameApplication(org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean a1,
                                    org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean a2)
Compares two application, tests if a two applications are equal). The comparison is based on the name,and version of each application. the result is a true the two applications are the same. the result is false if the two applications are different.

Parameters:
a1 - the first application to be compared.
a2 - the second application to be compared.
Returns:
True the two applications are the same. False if the two applications are different.

checkApplication

protected boolean checkApplication(org.ow2.jasmine.jadort.api.entities.deployment.ServerProgressBean serverProgress,
                                   org.ow2.jasmine.jadort.api.entities.deployment.ApplicationBean application,
                                   java.lang.String state,
                                   java.lang.String policy)
Checks if an application is already deployed on the server, or if has a bad policy, or if has a bad state

Parameters:
serverProgress - serverProgress of the server on which the application will be checked.
application - the application to be checked
state - the state that the application should has.
policy - the policy that the application should has.
Returns:
true if no problem is found while checking the application false if a problem is found while checking the application

selectApplication

public void selectApplication(java.net.URL url)
                       throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectApplication in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the selectApplication can not be called in the current step. (this method can be called only in SELECT_APPLICATION step)

getCurrentStep

public org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean.Step getCurrentStep()


IMPORTANT: Avoid calling this method from inside other methods of the JadortServiceImpl class (it will be costly)

Specified by:
getCurrentStep in interface org.ow2.jasmine.jadort.api.IJadortService

next

public void next()
          throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
next in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if it is not allowed to go to the next step.

previous

public void previous()
              throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
previous in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if it is not allowed to go to the previous step.

selectOperation

public void selectOperation(org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean selectedOperation)
                     throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectOperation in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the selectOperation can not be called in the current step. (this method can be called only in SELECT_OPERATION step)

createNewOperation

public void createNewOperation(java.lang.String newOperationName)
                        throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
createNewOperation in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the selectOperation can not be called in the current step. (this method can be called only in SELECT_OPERATION step)

deleteOperation

public void deleteOperation(org.ow2.jasmine.jadort.api.entities.deployment.OperationStateBean selectedOperation)
                     throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
deleteOperation in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the selectOperation can not be called in the current step. (this method can be called only in SELECT_OPERATION step)
  • if the operation to delete is still in progress in a critical phase and therefore cannot be deleted

selectServers

public void selectServers(java.util.List<org.ow2.jasmine.jadort.api.entities.topology.ServerBean> selectedServers)
                   throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectServers in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - if the selectServers method can not be called in the current step (this method can be called only in SELECT_SERVERS step)

restartWorker

public void restartWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
                   throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
restartWorker in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the restartWorkermethod can not be called in the current step. (this method can be called only in EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER steps)
  • if the worker state is not in error state.

ignoreWorker

public void ignoreWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
                  throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
ignoreWorker in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException -
  • if the ignoreWorker can not be called in the current step. (this method can be called only in EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER steps)
  • if the worker state is not in error state.

abortWorker

public void abortWorker(org.ow2.jasmine.jadort.api.entities.topology.WorkerBean worker)
                 throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
abortWorker in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
org.ow2.jasmine.jadort.api.JadortServiceException - If the abortWorker can not be called in the current step. (this method can be called only in EXECUTING_MAINTENANCE_CLUSTER and EXECUTING_MAINTENANCE_NO_CLUSTER step)

selectVMImage

public void selectVMImage(org.ow2.jasmine.jadort.api.entities.deployment.VMImageBean selectedVMImage)
                   throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectVMImage in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
JadortServiceException
    -
  • if the selectVMImage can not be called in the current step. (this method can be called only in SELECT_VM_IMAGE_FOR_SERVER step)
  • or if selectedVMImage is not known
  • or if fetching fails
org.ow2.jasmine.jadort.api.JadortServiceException

selectVMImage

public void selectVMImage(org.ow2.jasmine.jadort.api.entities.deployment.VMImageBean selectedVMImage,
                          org.ow2.jasmine.jadort.api.entities.topology.ServerBean server)
                   throws org.ow2.jasmine.jadort.api.JadortServiceException

Specified by:
selectVMImage in interface org.ow2.jasmine.jadort.api.IJadortService
Throws:
JadortServiceException
    -
  • if the selectVMImage can not be called in the current step. (this method can be called only in SELECT_VM_IMAGE_FOR_SERVER step)
  • or if selectedVMImage is not known
  • or if server is not known
  • or if fetching fails
org.ow2.jasmine.jadort.api.JadortServiceException


Copyright © 2009 OW2 Consortium. All Rights Reserved.