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)
           
 void deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers)
           
 void deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups)
           
 void deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups, String virtualHostName)
          Deploy application to specified servers.
 void deploy(String applicationId, String versionId, String ctxPath, Collection<String> servers, Collection<String> groups, String virtualHostName, boolean disableScripts, File scriptDescriptionFile)
           
 ApplicationInfo enableNinjaMode(String serverId, String appId)
          Enables inplace edit mode (ninja) for given application on a given server
 List<ServerInfo> expandGroup(String groupName)
           
 ApplicationInfo finishNinjaUpdate(String serverId, String appId, String verId)
          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)
           
 Date getLastFailoverSyncTime()
          Returns date of last time when this servers synced with failover server.
 String getMetadata(String appId, String versionId)
           
 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.
 boolean getVerbose()
           
 String getVersion()
           
 boolean isAlive()
           
 boolean registerAsFailover(String primaryHost, int primaryPort, String token)
          Returns true is registration was OK.
 void remove(String appId)
          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 appId, String versionId)
          Removes application version from command center.
 boolean resumeUpdate(Long updateId)
          Resumes manual update by id.
 void syncWithFailover()
          If this server has failover slave - this will schedule synchronizing in 3s.
 void undeploy(String applicationId, Collection<String> servers)
          Undeploy application from specified servers.
 void undeploy(String applicationId, Collection<String> servers, Collection<String> groups)
          Undeploy application from specified servers.
 void undeploy(String applicationId, Collection<String> servers, Collection<String> groups, boolean disableScripts, File scriptDescriptionFile)
           
 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 appId, String versionId)
           
 
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.

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

deploy

public void 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)

undeploy

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

undeploy

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

undeploy

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

remove

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

Specified by:
remove in interface CommandCenter

removeVersion

public void removeVersion(String appId,
                          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
Returns:
uploaded application version.
Throws:
DuplicationException - if the given version already exists on the server.

enableNinjaMode

public ApplicationInfo enableNinjaMode(String serverId,
                                       String appId)
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 appId,
                                         String verId)
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.

uploadMetadata

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

getMetadata

public String getMetadata(String appId,
                          String versionId)
Specified by:
getMetadata in interface CommandCenter

getVersion

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


Copyright © 2012. All Rights Reserved.