public class StreamUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TMP_DIR |
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendToRemoteFile(java.lang.String privateKey,
java.lang.String host,
java.lang.String dir,
java.lang.String fileName,
java.lang.String payload)
Appends the payload to an existing file on a remote EC2 Instance.
|
static void |
copyFileToRemote(java.lang.String privateKey,
java.lang.String host,
java.net.URI uri,
java.io.File file,
long waitTime)
Copy a file from test machine to remote machine.
|
static boolean |
createDataFileOnRemote(java.lang.String privateKey,
java.lang.String host,
java.lang.String dir,
java.lang.String fileName,
java.lang.String payload,
int retryTime)
Creates a file on a remote EC2 machine with the payload as its contents.
|
static boolean |
createRemoteDirectory(java.lang.String path,
java.lang.String host,
java.lang.String privateKey,
int waitTime)
Creates a directory on a remote machine.
|
static void |
destroyAllStreams(java.net.URL adminServer)
Removes all the streams from the cluster.
|
static boolean |
fileExists(java.lang.String host,
java.lang.String privateKey,
java.lang.String path)
Verifies the specified path exists on remote machine.
|
static java.util.Map<java.lang.String,java.lang.String> |
getAvailableContainers(java.net.URL adminServer)
Creates a map of container Id's and the associated host.
|
static java.lang.Integer[] |
getContainerPidsFromURL(java.net.URL url,
java.lang.String privateKey,
java.lang.String jpsCommand)
Retrieves the container pids for a remote machine.
|
static long |
getCount(java.net.URL adminServer,
java.lang.String name)
Retrieves the value for the counter
|
static java.util.List<org.jclouds.ec2.domain.RunningInstance> |
getEC2RunningInstances(java.lang.String awsAccessKey,
java.lang.String awsSecretKey,
java.lang.String awsRegion)
Returns a list of active instances from the specified ec2 region.
|
static java.lang.Integer[] |
getLocalContainerPids(java.lang.String jpsCommand)
Retrieves the container pids on the local machine.
|
static org.springframework.hateoas.PagedResources<ModuleMetadataResource> |
getRuntimeModules(java.net.URL adminServer)
Return a list of container id's where the module is deployed
|
static java.lang.String |
httpGet(java.net.URL url)
Executes a http get for the client and returns the results as a string
|
static boolean |
isStreamDeployed(java.lang.String streamName,
java.net.URL adminServer)
Checks to see if the specified stream is deployed on the XD cluster.
|
static java.net.URL |
replacePort(java.net.URL url,
int port)
Substitutes the port associated with the URL with another port.
|
static void |
stream(java.lang.String streamName,
java.lang.String streamDefinition,
java.net.URL adminServer)
Creates the stream definition and deploys it to the cluster being tested.
|
static java.lang.String |
transferResultsToLocal(java.lang.String privateKey,
java.net.URL url,
java.lang.String fileName)
Copies the specified file from a remote machine to local machine.
|
static void |
undeployStream(java.net.URL adminServer,
java.lang.String streamName)
Undeploys the specified stream name
|
static boolean |
waitForMetric(java.lang.String name,
java.net.URL adminServer,
int waitTime)
Waits up to the wait time for a metric to be created.
|
static boolean |
waitForStreamDeployment(java.lang.String streamName,
java.net.URL adminServer,
int waitTime)
Waits up to the wait time for a stream to be deployed.
|
public static final java.lang.String TMP_DIR
public static void stream(java.lang.String streamName,
java.lang.String streamDefinition,
java.net.URL adminServer)
streamName - The name of the streamstreamDefinition - The definition that needs to be deployed for this stream.adminServer - The admin server that this stream will be deployed against.public static java.lang.String httpGet(java.net.URL url)
url - The location to execute the get against.public static void destroyAllStreams(java.net.URL adminServer)
adminServer - The admin server that the command will be executed against.public static void undeployStream(java.net.URL adminServer,
java.lang.String streamName)
adminServer - The admin server that the command will be executed against.streamName - The name of the stream to undeploypublic static long getCount(java.net.URL adminServer,
java.lang.String name)
adminServer - the admin server for the cluster being tested.name - the name of the counter in the metric repo.public static java.lang.String transferResultsToLocal(java.lang.String privateKey,
java.net.URL url,
java.lang.String fileName)
privateKey - the ssh private key to the remote machineurl - The remote machine's url.fileName - The fully qualified file name of the file to be transferred.public static boolean createDataFileOnRemote(java.lang.String privateKey,
java.lang.String host,
java.lang.String dir,
java.lang.String fileName,
java.lang.String payload,
int retryTime)
privateKey - The ssh private key for the remote containerhost - The remote machine's ip.dir - The directory to write the filefileName - The fully qualified file name of the file to be created.payload - the data to write to the fileretryTime - the time in millis to retry to push data file to remote system.public static void copyFileToRemote(java.lang.String privateKey,
java.lang.String host,
java.net.URI uri,
java.io.File file,
long waitTime)
privateKey - The ssh private key for the remote containerhost - The remote machine's ip.uri - to the location where the file will be copied to remote machine.file - The file to migrate to remote machine.public static boolean createRemoteDirectory(java.lang.String path,
java.lang.String host,
java.lang.String privateKey,
int waitTime)
path - the directory that will be createdhost - the IP where the directory will be createdprivateKey - Private key to be used for signing onto remote machine.waitTime - The max time to try creating the directorypublic static void appendToRemoteFile(java.lang.String privateKey,
java.lang.String host,
java.lang.String dir,
java.lang.String fileName,
java.lang.String payload)
privateKey - The ssh private key for the remote containerhost - The remote machine's ip.dir - The directory to write the filefileName - The fully qualified file name of the file to be created.payload - the data to append to the filepublic static java.util.List<org.jclouds.ec2.domain.RunningInstance> getEC2RunningInstances(java.lang.String awsAccessKey,
java.lang.String awsSecretKey,
java.lang.String awsRegion)
awsAccessKey - the unique id of the ec2 user.awsSecretKey - the password of ec2 user.awsRegion - The aws region to inspect for acceptance test instances.public static java.net.URL replacePort(java.net.URL url,
int port)
url - The URL that needs a port replaced.port - The new port numberpublic static java.util.Map<java.lang.String,java.lang.String> getAvailableContainers(java.net.URL adminServer)
adminServer - The admin server to be queried.public static org.springframework.hateoas.PagedResources<ModuleMetadataResource> getRuntimeModules(java.net.URL adminServer)
adminServer - The admin server that will be queried.public static boolean waitForStreamDeployment(java.lang.String streamName,
java.net.URL adminServer,
int waitTime)
streamName - The name of the stream to be evaluated.adminServer - The admin server URL that will be queried.waitTime - the amount of time in millis to wait.public static boolean isStreamDeployed(java.lang.String streamName,
java.net.URL adminServer)
streamName - The name of the stream to be evaluated.adminServer - The admin server URL that will be queried.public static boolean waitForMetric(java.lang.String name,
java.net.URL adminServer,
int waitTime)
name - The name of the metric to be evaluated.adminServer - The admin server URL that will be queried.waitTime - the amount of time in millis to wait.public static java.lang.Integer[] getLocalContainerPids(java.lang.String jpsCommand)
jpsCommand - jps command that will reveal the pids.public static java.lang.Integer[] getContainerPidsFromURL(java.net.URL url,
java.lang.String privateKey,
java.lang.String jpsCommand)
url - The URL where the containers are deployed.privateKey - ssh private key credentialjpsCommand - The command to retrieve java processes on container machine.public static boolean fileExists(java.lang.String host,
java.lang.String privateKey,
java.lang.String path)
host - The host where the file exists.privateKey - ssh private key credentialpath - path to file or directory