com.zeroturnaround.liverebel.api.impl
Class CommandCenterImpl

java.lang.Object
  extended by com.zeroturnaround.liverebel.api.impl.CommandCenterImpl
All Implemented Interfaces:
CommandCenter

public class CommandCenterImpl
extends Object
implements CommandCenter

Author:
Rein Raudjärv, Oleg Šelajev
See Also:
CommandCenter, CommandCenterFactory

Constructor Summary
CommandCenterImpl(String url, String username, String password, boolean verbose)
           
 
Method Summary
 void addDatabaseConf(String serverId, Long databaseDriverId, String jdbcUrl, String schemaName)
          Adds database configuration to given database server
 boolean addGroupChild(String groupName, String childGroupName)
           
 boolean addServersToGroup(String groupName, Collection<String> serverIds)
           
 boolean cancelUpdate(Long updateId)
          Cancels manual update by id.
 boolean checkPrimaryAlive()
           
 DiffResult compare(String _applicationId, String _fromVersionId, String _toVersionId, boolean full)
          Compares two versions of the given application.
 int countSeats()
           
 String createDatabaseProxy(com.zeroturnaround.liverebel.util.DatabaseServerExecutionMode execMode, String targetServerId)
          Sets up database server proxy.
 boolean createGroup(String name, String description, Collection<String> serverIds)
           
 int deleteAllLicenses()
           
 boolean deleteGroup(String name)
           
 ConfigurableDeploy deploy(String applicationId, String versionId)
          Prepare to deploy a given application version.
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers)
           
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups)
           
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups, String virtualHostName)
          Deploy application to specified servers.
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups, String virtualHostName, boolean disableScripts, File scriptDescriptionFile)
           
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups, String virtualHostName, boolean disableScripts, File scriptDescriptionFile, File scriptEntriesArchive)
           
 Long deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, String proxyTargetServerId, List<Long> schemaIds)
           
 Long deploy(String applicationId, String versionId, String ctxPath, String fileServerDeploymentPath, Collection<String> servers, Collection<String> groups, String virtualHostName, boolean disableScripts, File scriptDescriptionFile, File scriptEntriesArchive)
           
 Long deploy(String applicationId, String versionId, String ctxPath, String fileServerDeploymentPath, Collection<String> servers, Collection<String> groups, String virtualHostName, boolean disableScripts, File scriptDescriptionFile, File scriptEntriesArchive, String proxyTargetServerId, List<Long> schemaIds)
           
 Long deployToFileServers(String applicationId, String versionId, String fileServerDeploymentPath)
           
 ApplicationInfo enableNinjaMode(String serverId, String applicationId)
          Enables inplace edit mode (ninja) for given application on a given server
 List<ServerInfo> expandGroup(String groupName)
           
 FailoverOperations failoverOperations()
           
 ApplicationInfo finishEditMode(String serverId, String applicationId, String versionId)
          Finishes in-place edit mode on given server for given application.
 ApplicationInfo finishNinjaUpdate(String serverId, String applicationId, String versionId)
          Finishes inplace edit (ninja) update on given server for given application.
 List<ServerGroup> getAllGroups()
           
 ApplicationInfo getApplication(String applicationId)
          Returns current info about an application.
 Map<String,ApplicationInfo> getApplications()
          Lists all applications.
 CommandCenterUpdate getCommandCenterUpdate()
           
 Long getDatabaseServerSchemaId(String serverId)
           
 List<ServerGroup> getGroups(String name)
           
 Collection<InstallerExecution> getInstallerExecutions()
           
 Date getLastFailoverSyncTime()
           
 Collection<String> getLogLines(Long taskId)
          Retrieved the log for given task.
 String getMetadata(String applicationId, String versionId)
          Deprecated. 
 PausedUpdate getPausedUpdate(Long id)
          Returns a paused update by its Id.
 List<Long> getRunningPausedUpdateIds()
           
 ServerInfo getServer(String serverId)
          Returns current info about a server.
 Map<String,ServerInfo> getServers()
          Lists all servers.
 String getTrace(String applicationId, String versionId)
           
 boolean getVerbose()
           
 String getVersion()
           
 boolean isAlive()
           
 ManagedConfOperations manageConfiguration()
           
 boolean registerAsFailover(String primaryHost, int primaryPort, String token)
           
 void remove(String applicationId)
          Removes app from command center.
 boolean removeGroupChild(String groupName, String childGroupName)
           
 void removeServer(String serverId)
          Removes a server.
 boolean removeServersFromGroup(String groupName, Collection<String> serverIds)
           
 void removeVersion(String applicationId, String versionId)
          Removes application version from command center.
 boolean restartServer(String serverId)
          Restart server (asynchronously)
 boolean resumeUpdate(Long updateId)
          Resumes manual update by id.
 boolean setHotpatchingEnabled(String serverId, boolean enabled)
          Enable/disable hotpatching update for specified server
 ApplicationInfo startEditMode(String serverId, String applicationId)
          Enables in-place edit mode for given application on a given server
 void syncWithFailover()
           
 ConfigurableUndeploy undeploy(String applicationId)
          Prepare to undeploy a given application.
 Long undeploy(String applicationId, Collection<String> servers)
          Undeploy application from specified servers.
 Long undeploy(String applicationId, Collection<String> servers, Collection<String> groups)
          Undeploy application from specified servers.
 Long undeploy(String applicationId, Collection<String> servers, Collection<String> groups, boolean disableScripts, File scriptDescriptionFile)
          file and archive type scripts are expected to be in the local filesystem
 Long undeploy(String applicationId, Collection<String> servers, Collection<String> groups, boolean disableScripts, File scriptDescriptionFile, File scriptEntriesArchive)
           
 Long undeploy(String applicationId, Collection<String> servers, Collection<String> groups, boolean disableScripts, File scriptDescriptionFile, File scriptEntriesArchive, String proxyTargetServerId, List<Long> schemaIds)
           
 Long undeploy(String applicationId, Collection<String> servers, String proxyTargetServerId, List<Long> schemaIds)
          Undeploy application from specified servers and schemas
 ConfigurableUpdate update(String applicationId, String versionId)
          Start updating an application to a given version.
 AgentUpdate updateAgent()
           
 UploadInfo upload(File file)
          Uploads new version of an application.
 UploadInfo upload(String applicationId, String fromVersion, File diff)
          Uploads new version of an application.
 Long uploadDatabaseDriver(File jar)
           
 boolean uploadLicense(File license)
           
 boolean uploadMetadata(File file, String applicationId, String versionId)
          Deprecated. 
 boolean uploadTrace(File file, String applicationId, String versionId)
           
 Upload uploadVersion(File file)
          Prepares the upload of new version of an application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandCenterImpl

public CommandCenterImpl(String url,
                         String username,
                         String password,
                         boolean verbose)
Method Detail

isAlive

public boolean isAlive()
Specified by:
isAlive in interface CommandCenter
Returns:
true if the Command Center is alive.

getServers

public Map<String,ServerInfo> getServers()
Description copied from interface: CommandCenter
Lists all servers.

Specified by:
getServers in interface CommandCenter
Returns:
all servers by their Id.

getServer

public ServerInfo getServer(String serverId)
Description copied from interface: CommandCenter
Returns current info about a server.

Specified by:
getServer in interface CommandCenter
Parameters:
serverId - server Id.
Returns:
server info.

restartServer

public boolean restartServer(String serverId)
Description copied from interface: CommandCenter
Restart server (asynchronously)

Specified by:
restartServer in interface CommandCenter
Parameters:
serverId - server id
Returns:
true if request successes

setHotpatchingEnabled

public boolean setHotpatchingEnabled(String serverId,
                                     boolean enabled)
Description copied from interface: CommandCenter
Enable/disable hotpatching update for specified server

Specified by:
setHotpatchingEnabled in interface CommandCenter
Parameters:
serverId - server id
enabled - true to enable hotpatching, false to disable it
Returns:
true if request success

removeServer

public void removeServer(String serverId)
Description copied from interface: CommandCenter
Removes a server.

Specified by:
removeServer in interface CommandCenter
Parameters:
serverId - server Id.

getApplications

public Map<String,ApplicationInfo> getApplications()
Description copied from interface: CommandCenter
Lists all applications.

Specified by:
getApplications in interface CommandCenter
Returns:
all applications by their Id.

getApplication

public ApplicationInfo getApplication(String applicationId)
Description copied from interface: CommandCenter
Returns current info about an application.

Specified by:
getApplication in interface CommandCenter
Parameters:
applicationId - application Id.
Returns:
application info.

upload

public UploadInfo upload(File file)
Description copied from interface: CommandCenter
Uploads new version of an application.

Specified by:
upload in interface CommandCenter
Parameters:
file - archive file.
Returns:
uploaded application version.

compare

public DiffResult compare(String _applicationId,
                          String _fromVersionId,
                          String _toVersionId,
                          boolean full)
Description copied from interface: CommandCenter
Compares two versions of the given application.

Specified by:
compare in interface CommandCenter
Parameters:
_applicationId - application Id.
_fromVersionId - current version Id.
_toVersionId - new version Id.
full - include all differences (otherwise only warnings and errors are included).

update

public ConfigurableUpdate update(String applicationId,
                                 String versionId)
Description copied from interface: CommandCenter
Start updating an application to a given version.

Specified by:
update in interface CommandCenter
Parameters:
applicationId - application Id.
versionId - version Id.

getPausedUpdate

public PausedUpdate getPausedUpdate(Long id)
Description copied from interface: CommandCenter
Returns a paused update by its Id.

Specified by:
getPausedUpdate in interface CommandCenter
Parameters:
id - update Id.
Returns:
the paused update or null if no such update found.
See Also:
PreparedPausableUpdate.executeWithPause()

failoverOperations

public FailoverOperations failoverOperations()
Specified by:
failoverOperations in interface CommandCenter
Returns:
interface that provides operations related to failover Command Center

registerAsFailover

public boolean registerAsFailover(String primaryHost,
                                  int primaryPort,
                                  String token)
Specified by:
registerAsFailover in interface CommandCenter

syncWithFailover

public void syncWithFailover()
Specified by:
syncWithFailover in interface CommandCenter

checkPrimaryAlive

public boolean checkPrimaryAlive()
Specified by:
checkPrimaryAlive in interface CommandCenter

getVerbose

public boolean getVerbose()
Specified by:
getVerbose in interface CommandCenter

deploy

public ConfigurableDeploy deploy(String applicationId,
                                 String versionId)
Description copied from interface: CommandCenter
Prepare to deploy a given application version. Configure additional parameters using the returned ConfigurableDeploy object. The deploy will be executed once PreparedDeploy.execute() is invoked. The archive of the given version must be available in the Command Center before this operation.

Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers)
Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers,
                   String proxyTargetServerId,
                   List<Long> schemaIds)
Specified by:
deploy in interface CommandCenter

deployToFileServers

public Long deployToFileServers(String applicationId,
                                String versionId,
                                String fileServerDeploymentPath)
Specified by:
deployToFileServers in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers,
                   Collection<String> groups)
Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers,
                   Collection<String> groups,
                   String virtualHostName)
Description copied from interface: CommandCenter
Deploy application to specified servers. Using initial deploy.

Specified by:
deploy in interface CommandCenter
Parameters:
applicationId - - application id
ctxPath - - context path for servers
servers - - server jvmid-s
virtualHostName - - name of the virtual host to be used for deploying
Returns:
task ID

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers,
                   Collection<String> groups,
                   String virtualHostName,
                   boolean disableScripts,
                   File scriptDescriptionFile)
Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   Collection<String> servers,
                   Collection<String> groups,
                   String virtualHostName,
                   boolean disableScripts,
                   File scriptDescriptionFile,
                   File scriptEntriesArchive)
Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   String fileServerDeploymentPath,
                   Collection<String> servers,
                   Collection<String> groups,
                   String virtualHostName,
                   boolean disableScripts,
                   File scriptDescriptionFile,
                   File scriptEntriesArchive)
Specified by:
deploy in interface CommandCenter

deploy

public Long deploy(String applicationId,
                   String versionId,
                   String ctxPath,
                   String fileServerDeploymentPath,
                   Collection<String> servers,
                   Collection<String> groups,
                   String virtualHostName,
                   boolean disableScripts,
                   File scriptDescriptionFile,
                   File scriptEntriesArchive,
                   String proxyTargetServerId,
                   List<Long> schemaIds)
Specified by:
deploy in interface CommandCenter

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers,
                     String proxyTargetServerId,
                     List<Long> schemaIds)
Description copied from interface: CommandCenter
Undeploy application from specified servers and schemas

Specified by:
undeploy in interface CommandCenter
Parameters:
applicationId - - application id
servers - - server jvmid-s
proxyTargetServerId - - proxy target server id
schemaIds - - schema ids
Returns:
task ID

undeploy

public ConfigurableUndeploy undeploy(String applicationId)
Description copied from interface: CommandCenter
Prepare to undeploy a given application. Configure additional parameters using the returned ConfigurableUndeploy object. The undeploy will be executed once PreparedUndeploy.execute() is invoked.

Specified by:
undeploy in interface CommandCenter

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers)
Description copied from interface: CommandCenter
Undeploy application from specified servers.

Specified by:
undeploy in interface CommandCenter
Parameters:
applicationId - - application id
servers - - server jvmid-s
Returns:
task ID

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers,
                     Collection<String> groups)
Description copied from interface: CommandCenter
Undeploy application from specified servers.

Specified by:
undeploy in interface CommandCenter
Parameters:
applicationId - - application id
servers - - server jvmid-s
groups - - server groups
Returns:
task ID

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers,
                     Collection<String> groups,
                     boolean disableScripts,
                     File scriptDescriptionFile)
Description copied from interface: CommandCenter
file and archive type scripts are expected to be in the local filesystem

Specified by:
undeploy in interface CommandCenter

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers,
                     Collection<String> groups,
                     boolean disableScripts,
                     File scriptDescriptionFile,
                     File scriptEntriesArchive)
Specified by:
undeploy in interface CommandCenter

undeploy

public Long undeploy(String applicationId,
                     Collection<String> servers,
                     Collection<String> groups,
                     boolean disableScripts,
                     File scriptDescriptionFile,
                     File scriptEntriesArchive,
                     String proxyTargetServerId,
                     List<Long> schemaIds)
Specified by:
undeploy in interface CommandCenter

remove

public void remove(String applicationId)
Description copied from interface: CommandCenter
Removes app from command center.

Specified by:
remove in interface CommandCenter

removeVersion

public void removeVersion(String applicationId,
                          String versionId)
Description copied from interface: CommandCenter
Removes application version from command center.

Specified by:
removeVersion in interface CommandCenter

getLastFailoverSyncTime

public Date getLastFailoverSyncTime()
Specified by:
getLastFailoverSyncTime in interface CommandCenter

resumeUpdate

public boolean resumeUpdate(Long updateId)
Description copied from interface: CommandCenter
Resumes manual update by id. Throws NotFound if no update with such id is found.

Specified by:
resumeUpdate in interface CommandCenter
Returns:
boolean if update was successful.

cancelUpdate

public boolean cancelUpdate(Long updateId)
Description copied from interface: CommandCenter
Cancels manual update by id. Throws NotFound if no update with such id is found.

Specified by:
cancelUpdate in interface CommandCenter
Returns:
if update cancellation was successful.

getRunningPausedUpdateIds

public List<Long> getRunningPausedUpdateIds()
Specified by:
getRunningPausedUpdateIds in interface CommandCenter
Returns:
List of ids of all paused updates that are currently in Command Center

upload

public UploadInfo upload(String applicationId,
                         String fromVersion,
                         File diff)
                  throws DuplicationException
Description copied from interface: CommandCenter
Uploads new version of an application.

Specified by:
upload in interface CommandCenter
Parameters:
applicationId - - application identificator
fromVersion - - version on which this diff is based
diff - archive file.
Returns:
uploaded application version.
Throws:
DuplicationException - if the given version already exists on the server.

startEditMode

public ApplicationInfo startEditMode(String serverId,
                                     String applicationId)
Description copied from interface: CommandCenter
Enables in-place edit mode for given application on a given server

Specified by:
startEditMode in interface CommandCenter

finishEditMode

public ApplicationInfo finishEditMode(String serverId,
                                      String applicationId,
                                      String versionId)
Description copied from interface: CommandCenter
Finishes in-place edit mode on given server for given application. The resulted version is given verId.

Specified by:
finishEditMode in interface CommandCenter

enableNinjaMode

public ApplicationInfo enableNinjaMode(String serverId,
                                       String applicationId)
Description copied from interface: CommandCenter
Enables inplace edit mode (ninja) for given application on a given server

Specified by:
enableNinjaMode in interface CommandCenter

finishNinjaUpdate

public ApplicationInfo finishNinjaUpdate(String serverId,
                                         String applicationId,
                                         String versionId)
Description copied from interface: CommandCenter
Finishes inplace edit (ninja) update on given server for given application. The resulted version is given verId.

Specified by:
finishNinjaUpdate in interface CommandCenter

countSeats

public int countSeats()
Specified by:
countSeats in interface CommandCenter
Returns:
licenses soft-limit, how many servers can connect.

uploadLicense

public boolean uploadLicense(File license)
Specified by:
uploadLicense in interface CommandCenter
Returns:
true if the license is uploaded and verified and working

deleteAllLicenses

public int deleteAllLicenses()
Specified by:
deleteAllLicenses in interface CommandCenter
Returns:
number of license files deleted

createGroup

public boolean createGroup(String name,
                           String description,
                           Collection<String> serverIds)
Specified by:
createGroup in interface CommandCenter

addServersToGroup

public boolean addServersToGroup(String groupName,
                                 Collection<String> serverIds)
Specified by:
addServersToGroup in interface CommandCenter

removeServersFromGroup

public boolean removeServersFromGroup(String groupName,
                                      Collection<String> serverIds)
Specified by:
removeServersFromGroup in interface CommandCenter

getAllGroups

public List<ServerGroup> getAllGroups()
Specified by:
getAllGroups in interface CommandCenter
Returns:
all server groups + ungrouped servers "virtual server group"

getGroups

public List<ServerGroup> getGroups(String name)
Specified by:
getGroups in interface CommandCenter
Returns:
descendant groups under given group (includes group itself)

expandGroup

public List<ServerInfo> expandGroup(String groupName)
Specified by:
expandGroup in interface CommandCenter

deleteGroup

public boolean deleteGroup(String name)
Specified by:
deleteGroup in interface CommandCenter

addGroupChild

public boolean addGroupChild(String groupName,
                             String childGroupName)
Specified by:
addGroupChild in interface CommandCenter

removeGroupChild

public boolean removeGroupChild(String groupName,
                                String childGroupName)
Specified by:
removeGroupChild in interface CommandCenter

getCommandCenterUpdate

public CommandCenterUpdate getCommandCenterUpdate()
Specified by:
getCommandCenterUpdate in interface CommandCenter
Returns:
API for updating Command Center.

updateAgent

public AgentUpdate updateAgent()
Specified by:
updateAgent in interface CommandCenter
Returns:
API for updating Agents.

uploadTrace

public boolean uploadTrace(File file,
                           String applicationId,
                           String versionId)
Specified by:
uploadTrace in interface CommandCenter
Returns:
whether trace existed before and was replaced or not.

getTrace

public String getTrace(String applicationId,
                       String versionId)
Specified by:
getTrace in interface CommandCenter

uploadMetadata

@Deprecated
public boolean uploadMetadata(File file,
                                         String applicationId,
                                         String versionId)
Deprecated. 

Description copied from interface: CommandCenter
Replaced with CommandCenter.uploadTrace(File, String, String)

Specified by:
uploadMetadata in interface CommandCenter

getMetadata

@Deprecated
public String getMetadata(String applicationId,
                                     String versionId)
Deprecated. 

Description copied from interface: CommandCenter
Replaced with CommandCenter.getTrace(String, String)

Specified by:
getMetadata in interface CommandCenter

getVersion

public String getVersion()
Specified by:
getVersion in interface CommandCenter

uploadVersion

public Upload uploadVersion(File file)
Description copied from interface: CommandCenter
Prepares the upload of new version of an application.

Specified by:
uploadVersion in interface CommandCenter
Parameters:
file - archive file
Returns:
an object for configuring the upload

getLogLines

public Collection<String> getLogLines(Long taskId)
Description copied from interface: CommandCenter
Retrieved the log for given task.

Specified by:
getLogLines in interface CommandCenter
Parameters:
taskId - the task ID
Returns:
the task log splitted into lines

getInstallerExecutions

public Collection<InstallerExecution> getInstallerExecutions()
Specified by:
getInstallerExecutions in interface CommandCenter

manageConfiguration

public ManagedConfOperations manageConfiguration()
Specified by:
manageConfiguration in interface CommandCenter
Returns:
interface that provides operations related to managed configuration

addDatabaseConf

public void addDatabaseConf(String serverId,
                            Long databaseDriverId,
                            String jdbcUrl,
                            String schemaName)
Description copied from interface: CommandCenter
Adds database configuration to given database server

Specified by:
addDatabaseConf in interface CommandCenter
Parameters:
serverId - - database server id
databaseDriverId - - database driver id
jdbcUrl - - JDBC url
schemaName - - name of the schema

createDatabaseProxy

public String createDatabaseProxy(com.zeroturnaround.liverebel.util.DatabaseServerExecutionMode execMode,
                                  String targetServerId)
Description copied from interface: CommandCenter

Sets up database server proxy.

Note! Must be called before CommandCenter.addDatabaseConf(String, Long, String, String).

Specified by:
createDatabaseProxy in interface CommandCenter
Parameters:
execMode - execution mode, DatabaseServerExecutionMode.PROXY or DatabaseServerExecutionMode.PROXY_PROMPT
targetServerId - target server id
Returns:
id of the created proxy server

uploadDatabaseDriver

public Long uploadDatabaseDriver(File jar)
Specified by:
uploadDatabaseDriver in interface CommandCenter
Parameters:
jar - JDBC driver jar
Returns:
id of the uploaded driver

getDatabaseServerSchemaId

public Long getDatabaseServerSchemaId(String serverId)
Specified by:
getDatabaseServerSchemaId in interface CommandCenter
Parameters:
serverId - id of the database server
Returns:
first schema id associated with given database server


Copyright © 2013. All Rights Reserved.