-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathexecute.ps1
93 lines (77 loc) · 4.18 KB
/
execute.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
###########################################################
# Start - Initialization - Invocation, Logging etc
###########################################################
$VerbosePreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
& "$scriptDir\..\scripts\init.ps1"
if(-not $?)
{
throw "Initialization failure."
}
###########################################################
# End - Initialization - Invocation, Logging etc
###########################################################
$configFile = Join-Path $scriptDir "run\configurations.properties"
$config = & "$scriptDir\..\scripts\config\ReadConfig.ps1" $configFile
Select-AzureSubscription -SubscriptionName $config["AZURE_SUBSCRIPTION_NAME"]
###########################################################
# Event Generation
###########################################################
$failure = $false
$javaExe = "java.exe"
Write-InfoLog "Starting DocDbGen process" (Get-ScriptName) (Get-ScriptLineNumber)
$javaArgs = "-cp ""$scriptDir\docdbgen\target\docdbgen-1.0-jar-with-dependencies.jar"" com.microsoft.hdinsight.storm.examples.DocDbGen ""$scriptDir\run\docdb.config"" ""$scriptDir\vehiclevin.txt"""
$javaProcess = Start-Process -FilePath $javaExe -ArgumentList $javaArgs
if($javaProcess -ne $null)
{
$javaProcess | Wait-Process
}
if((-not $?) -or ($LASTEXITCODE -ne 0))
{
Write-ErrorLog "DocDbGen Process failed ($?) with non-zero exit code: $LASTEXITCODE" (Get-ScriptName) (Get-ScriptLineNumber)
$failure = $true
}
Write-InfoLog "Starting EventGen process" (Get-ScriptName) (Get-ScriptLineNumber)
$javaArgs = "-jar ""$scriptDir\eventgen\target\eventgen-1.0-jar-with-dependencies.jar"" ""$scriptDir\run\eventhubs.config"" ""$scriptDir\vehiclevin.txt"" 200"
$javaProcess = Start-Process -FilePath $javaExe -ArgumentList $javaArgs
if($javaProcess -ne $null)
{
$javaProcess | Wait-Process
}
if((-not $?) -or ($LASTEXITCODE -ne 0))
{
Write-ErrorLog "EvenGen Process failed ($?) with non-zero exit code: $LASTEXITCODE" (Get-ScriptName) (Get-ScriptLineNumber)
$failure = $true
}
if($failure)
{
Write-ErrorLog "One or more event generation processes failed." (Get-ScriptName) (Get-ScriptLineNumber)
throw "One or more event generation processes failed."
}
###########################################################
# IoT Topology
###########################################################
$localJarPath = "$scriptDir\iot\target\iot-1.0.jar"
$blobPath = "Storm/SubmittedJars/iot-1.0.jar"
$jarPath = "{0}{1}" -f "/",$blobPath
$className = "com.microsoft.hdinsight.storm.examples.IotTopology"
$classArgs = "IotTopology"
Write-SpecialLog "Starting Storm topology for IoT" (Get-ScriptName) (Get-ScriptLineNumber)
if($config["STORM_CLUSTER_OS_TYPE"] -like "Windows")
{
$result = & "$scriptDir\..\scripts\azure\Storage\UploadFileToStorageARM.ps1" $config["AZURE_RESOURCE_GROUP"] $config["WASB_ACCOUNT_NAME"] $config["WASB_CONTAINER"] $localJarPath $blobPath
$result = & "$scriptDir\..\scripts\storm\SubmitStormTopology.ps1" $config["STORM_CLUSTER_OS_TYPE"] $config["STORM_CLUSTER_URL"] $config["STORM_CLUSTER_USERNAME"] $config["STORM_CLUSTER_PASSWORD"] $jarPath $className $classArgs
}
else
{
$sshUrl = $config["STORM_CLUSTER_URL"].Replace("https://", "").Replace(".azurehdinsight.net", "-ssh.azurehdinsight.net")
$sshUsername = "ssh" + $config["STORM_CLUSTER_USERNAME"]
$result = & "$scriptDir\..\scripts\storm\SubmitStormTopology.ps1" $config["STORM_CLUSTER_OS_TYPE"] $sshUrl $sshUsername $config["STORM_CLUSTER_PASSWORD"] $localJarPath $className $classArgs
}
Write-InfoLog "Waiting for a short while for topologies to get started ..." (Get-ScriptName) (Get-ScriptLineNumber)
sleep -s 15
& "$scriptDir\..\scripts\storm\GetStormSummary.ps1" $config["STORM_CLUSTER_URL"] $config["STORM_CLUSTER_USERNAME"] $config["STORM_CLUSTER_PASSWORD"]
& "$scriptDir\..\scripts\storm\LaunchStormUI.ps1" $config["STORM_CLUSTER_URL"] $config["STORM_CLUSTER_USERNAME"] $config["STORM_CLUSTER_PASSWORD"] $config["STORM_CLUSTER_OS_TYPE"]
Write-SpecialLog "If you notice throttling errors from DocumentDB make sure to increase your scale factor." (Get-ScriptName) (Get-ScriptLineNumber)