RemotePeerImpl implements RemotePeer { @RolesAllowed( "Environment-Management|Delete" ) @Override public void destroyContainer( final ContainerId containerId ) throws PeerException { Preconditions.checkNotNull( containerId, "Container id is null" ); Preconditions.checkArgument( containerId.getPeerId().getId().equals( peerInfo.getId() ) ); environmentWebClient.destroyContainer( containerId ); } RemotePeerImpl( String localPeerId, SecurityManager securityManager, final PeerInfo peerInfo,
                           final Messenger messenger, CommandResponseListener commandResponseListener,
                           MessageResponseListener messageResponseListener, Object provider,
                           final PeerManagerImpl peerManager ); void checkRelation(); @Override String getId(); @Override PeerInfo check(); @Override void excludePeerFromEnvironment( final String environmentId, final String peerId ); @Override void excludeContainerFromEnvironment( final String environmentId, final String containerId ); @Override void updateContainerHostname( final String environmentId, final String containerId, final String hostname ); @Override void placeEnvironmentInfoByContainerId( final String environmentId, final String containerId ); @Override boolean isOnline(); @Override boolean isLocal(); @Override String getName(); @Override String getOwnerId(); @Override PeerInfo getPeerInfo(); @Override RegistrationStatus getStatus(); @RolesAllowed( "Environment-Management|Update" ) @Override void startContainer( final ContainerId containerId ); @RolesAllowed( "Environment-Management|Update" ) @Override void stopContainer( final ContainerId containerId ); @RolesAllowed( "Environment-Management|Read" ) @Override Snapshots listContainerHostSnapshots( final ContainerId containerId ); @RolesAllowed( "Environment-Management|Update" ) @Override void removeContainerSnapshot( final ContainerId containerId, final String partition, final String label ); @RolesAllowed( "Environment-Management|Update" ) @Override void rollbackToContainerSnapshot( final ContainerId containerId, final String partition, final String label,
                                             final boolean force ); @RolesAllowed( "Environment-Management|Update" ) @Override void addContainerSnapshot( final ContainerId containerId, final String partition, final String label,
                                      final boolean stopContainer ); @RolesAllowed( "Environment-Management|Delete" ) @Override void destroyContainer( final ContainerId containerId ); @RolesAllowed( "Environment-Management|Delete" ) @Override boolean isConnected( final HostId hostId ); @Override ContainerHostState getContainerState( final ContainerId containerId ); @Override Quota getRawQuota( final ContainerId containerId ); @Override Containers getEnvironmentContainers( final EnvironmentId environmentId ); @RolesAllowed( "Environment-Management|Update" ) @Override SshKeys readOrCreateSshKeysForEnvironment( final EnvironmentId environmentId,
                                                      final SshEncryptionType sshKeyType ); @RolesAllowed( "Environment-Management|Update" ) @Override Containers configureSshInEnvironment( final EnvironmentId environmentId, final SshKeys sshKeys ); @Override void addToAuthorizedKeys( final EnvironmentId environmentId, final String sshPublicKey ); @Override SshKeys getSshKeys( final EnvironmentId environmentId, final SshEncryptionType sshEncryptionType ); @Override SshKeys getContainerAuthorizedKeys( final ContainerId containerId ); @Override SshKey createSshKey( final EnvironmentId environmentId, final ContainerId containerId,
                                final SshEncryptionType sshEncryptionType ); @Override void removeFromAuthorizedKeys( final EnvironmentId environmentId, final String sshPublicKey ); @RolesAllowed( "Environment-Management|Update" ) @Override void configureHostsInEnvironment( final EnvironmentId environmentId, final HostAddresses hostAddresses ); @Override ContainerQuota getQuota( final ContainerId containerId ); @Override void setQuota( final ContainerId containerId, final ContainerQuota containerQuota ); @Override CommandResult execute( final RequestBuilder requestBuilder, final Host host ); @Override CommandResult execute( final RequestBuilder requestBuilder, final Host host, final CommandCallback callback ); @Override void executeAsync( final RequestBuilder requestBuilder, final Host host, final CommandCallback callback ); @Override void executeAsync( final RequestBuilder requestBuilder, final Host host ); @Override V sendRequest( final T request, final String recipient, final int requestTimeout,
                                 Class<V> responseType, int responseTimeout, final Map<String, String> headers ); @Override void sendRequest( final T request, final String recipient, final int requestTimeout,
                                 final Map<String, String> headers ); @RolesAllowed( "Environment-Management|Read" ) @Override boolean canAccommodate( final Nodes nodes ); @RolesAllowed( "Environment-Management|Write" ) @Override CreateEnvironmentContainersResponse createEnvironmentContainers(
            final CreateEnvironmentContainersRequest request ); @RolesAllowed( "Environment-Management|Write" ) @Override PrepareTemplatesResponse prepareTemplates( final PrepareTemplatesRequest request ); @Override UsedNetworkResources getUsedNetworkResources(); @RolesAllowed( "Environment-Management|Write" ) @Override void setupTunnels( final P2pIps p2pIps, final EnvironmentId environmentId ); @Override PublicKeyContainer createPeerEnvironmentKeyPair( RelationLinkDto envLink ); @Override void updatePeerEnvironmentPubKey( final EnvironmentId environmentId, final PGPPublicKeyRing publicKeyRing ); @Override void addPeerEnvironmentPubKey( final String keyId, final PGPPublicKeyRing pek ); @Override Integer reserveNetworkResource( final NetworkResourceImpl networkResource ); @Override void updateEtcHostsWithNewContainerHostname( final EnvironmentId environmentId, final String oldHostname,
                                                        final String newHostname ); @Override void removeHostnamesFromEtcHosts( final EnvironmentId environmentId, final HostAddresses hostAddresses ); @Override void updateAuthorizedKeysWithNewContainerHostname( final EnvironmentId environmentId,
                                                              final String oldHostname, final String newHostname,
                                                              final SshEncryptionType sshEncryptionType ); @Override void resetSwarmSecretKey( final P2PCredentials p2PCredentials ); @Override void joinP2PSwarm( final P2PConfig config ); @Override void joinOrUpdateP2PSwarm( final P2PConfig config ); @Override void cleanupEnvironment( final EnvironmentId environmentId ); @Override HostId getResourceHostIdByContainerId( final ContainerId containerId ); @Override ResourceHostMetrics getResourceHostMetrics(); @Override void alert( final AlertEvent alert ); @Override String getHistoricalMetrics( final HostId hostId, final Date startTime, final Date endTime ); @Override HistoricalMetrics getMetricsSeries( final HostId hostId, final Date startTime, final Date endTime ); @Override PeerResources getResourceLimits( final PeerId peerId ); @Override void setContainerHostname( final ContainerId containerId, final String hostname ); @Override PeerTemplatesDownloadProgress getTemplateDownloadProgress( final EnvironmentId environmentId ); @Override boolean equals( final Object o ); @Override int hashCode(); @Override String getLinkId(); @Override String getUniqueIdentifier(); @Override String getClassPath(); @Override String getContext(); @Override String getKeyId();  }
@Test( expected = PeerException.class ) public void testDestroyContainer() throws Exception { remotePeer.destroyContainer( containerHost.getContainerId() ); remotePeer.destroyContainer( containerHost.getContainerId() ); }