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
 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()
           
 boolean createGroup(String name, String description, Collection<String> serverIds)
           
 int deleteAllLicenses()
           
 boolean deleteGroup(String name)
           
 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)
           
 ApplicationInfo enableNinjaMode(String serverId, String applicationId)
          Enables inplace edit mode (ninja) for given application on a given server
 List<ServerInfo> expandGroup(String groupName)
           
 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.
 ApplicationInfo getApplication(String applicationId)
          Returns current info about an application.
 Map<String,ApplicationInfo> getApplications()
          Lists all applications.
 CommandCenterUpdate getCommandCenterUpdate()
           
 List<ServerGroup> getGroups(String name)
           
 Collection<InstallerExecution> getInstallerExecutions()
           
 Date getLastFailoverSyncTime()
          Returns date of last time when this servers synced with failover server.
 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()
           
 boolean registerAsFailover(String primaryHost, int primaryPort, String token)
          Returns true is registration was OK.
 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()
          If this server has failover slave - this will schedule synchronizing in 3s.
 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)
           
 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.
 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()

registerAsFailover

public boolean registerAsFailover(String primaryHost,
                                  int primaryPort,
                                  String token)
Description copied from interface: CommandCenter
Returns true is registration was OK.

Specified by:
registerAsFailover in interface CommandCenter
Parameters:
primaryHost - - primary server host
primaryPort - - primary server port
token - - primary server user auth-token that will be used for initial authentication
Returns:

syncWithFailover

public void syncWithFailover()
Description copied from interface: CommandCenter
If this server has failover slave - this will schedule synchronizing in 3s. Otherwise, has no effect.

Specified by:
syncWithFailover in interface CommandCenter

checkPrimaryAlive

public boolean checkPrimaryAlive()
Specified by:
checkPrimaryAlive in interface CommandCenter
Returns:
true if primary is alive or this server is not configured as failover

getVerbose

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

deploy

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

deploy

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

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
See Also:
CommandCenter.deploy(String, String, String, Collection, Collection, String)

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
Returns:
See Also:
CommandCenter.deploy(String, String, String, Collection, Collection, String)

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
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

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()
Description copied from interface: CommandCenter
Returns date of last time when this servers synced with failover server.

Specified by:
getLastFailoverSyncTime in interface CommandCenter
Returns:

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

getGroups

public List<ServerGroup> getGroups(String name)
Specified by:
getGroups in interface CommandCenter

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


Copyright © 2013. All Rights Reserved.