use of com.oracle.bedrock.runtime.remote.DeployedArtifacts in project oracle-bedrock by coherence-community.
the class CurlHttpDeployerTest method shouldDeployEmptyArtifacts.
@Test
public void shouldDeployEmptyArtifacts() throws Exception {
Map<String, DeploymentArtifact> artifacts = new HashMap<>();
String destination = "/foo";
Platform platform = mock(Platform.class);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
OptionsByType optionsByType = OptionsByType.empty();
CurlHttpDeployer deploymentMethod = new CurlHttpDeployer();
DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
deploymentMethod.deployAllArtifacts(artifacts, destination, platform, address, optionsByType, deployedArtifacts);
verifyNoMoreInteractions(platform);
}
use of com.oracle.bedrock.runtime.remote.DeployedArtifacts in project oracle-bedrock by coherence-community.
the class CurlHttpDeployerTest method shouldDeployNullArtifacts.
@Test
public void shouldDeployNullArtifacts() throws Exception {
String destination = "/foo";
Platform platform = mock(Platform.class);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
OptionsByType optionsByType = OptionsByType.empty();
CurlHttpDeployer deploymentMethod = new CurlHttpDeployer();
DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
deploymentMethod.deployAllArtifacts(null, destination, platform, address, optionsByType, deployedArtifacts);
}
use of com.oracle.bedrock.runtime.remote.DeployedArtifacts in project oracle-bedrock by coherence-community.
the class WGetHttpDeployerTest method shouldDeployNullArtifacts.
@Test
public void shouldDeployNullArtifacts() throws Exception {
String destination = "/foo";
Platform platform = mock(Platform.class);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
OptionsByType optionsByType = OptionsByType.empty();
WGetHttpDeployer deploymentMethod = new WGetHttpDeployer();
DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
deploymentMethod.deployAllArtifacts(null, destination, platform, address, optionsByType, deployedArtifacts);
}
use of com.oracle.bedrock.runtime.remote.DeployedArtifacts in project oracle-bedrock by coherence-community.
the class HttpDeployer method deploy.
@Override
public DeployedArtifacts deploy(List<DeploymentArtifact> artifactsToDeploy, String remoteDirectory, Platform platform, Option... deploymentOptions) {
DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
if (artifactsToDeploy == null || artifactsToDeploy.isEmpty()) {
return deployedArtifacts;
}
OptionsByType optionsByType = OptionsByType.empty();
optionsByType.addAll(platform.getOptions());
optionsByType.addAll(deploymentOptions);
Map<String, DeploymentArtifact> artifactMap = new LinkedHashMap<>();
ExecutorService executor = createExecutor();
HttpServer server = null;
try {
for (DeploymentArtifact artifact : artifactsToDeploy) {
artifactMap.put("/" + UUID.randomUUID().toString(), artifact);
}
server = createServer(executor, artifactMap);
deployAllArtifacts(artifactMap, remoteDirectory, platform, server.getAddress(), optionsByType, deployedArtifacts);
} finally {
if (server != null) {
server.stop(0);
}
if (executor != null) {
executor.shutdownNow();
}
}
return deployedArtifacts;
}
use of com.oracle.bedrock.runtime.remote.DeployedArtifacts in project oracle-bedrock by coherence-community.
the class SftpDeployer method undeploy.
@Override
public DeployedArtifacts undeploy(DeployedArtifacts deployedArtifacts, Platform platform, Option... deploymentOptions) {
DeployedArtifacts failedArtifacts = new DeployedArtifacts();
if (!(platform instanceof RemotePlatform)) {
throw new IllegalArgumentException("The platform parameter must be an instance of RemotePlatform");
}
JSchSocketFactory socketFactory = new JSchSocketFactory();
RemotePlatform remotePlatform = (RemotePlatform) platform;
String userName = remotePlatform.getUserName();
Authentication authentication = remotePlatform.getAuthentication();
String hostName = remotePlatform.getAddress().getHostName();
int port = remotePlatform.getPort();
// create the deployment options
OptionsByType optionsByType = OptionsByType.empty();
// add the Platform options
optionsByType.addAll(platform.getOptions());
// override with specified Options
optionsByType.addAll(deploymentOptions);
// initially there's no session
Session session = null;
try {
// obtain the connected JSch Session
session = sessionFactory.createSession(hostName, port, userName, authentication, socketFactory, optionsByType);
if (deployedArtifacts.size() > 0) {
ChannelSftp sftpChannel = null;
try (DiagnosticsRecording diagnostics = DiagnosticsRecording.section("Remote Platform")) {
// open an sftp channel that we can use to copy over the artifacts
sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect(session.getTimeout());
for (File file : deployedArtifacts) {
try {
// attempt to delete the file
sftpChannel.rm(file.toString());
// include diagnostics
diagnostics.add(file.toString());
} catch (SftpException exception) {
try {
// attempt to remove the file as a directory
sftpChannel.rmdir(file.toString());
// include diagnostics (directory removed)
diagnostics.add(file.toString() + " (directory)");
} catch (SftpException e) {
// include diagnostics
diagnostics.add(file.toString() + " (failed to undeploy)");
failedArtifacts.add(file);
}
}
}
} finally {
if (sftpChannel != null) {
sftpChannel.disconnect();
}
}
}
} catch (JSchException e) {
throw new RuntimeException("Failed to undeploy application", e);
} finally {
if (session != null) {
session.disconnect();
}
}
return failedArtifacts;
}
Aggregations