Skip to content

Instantly share code, notes, and snippets.

View lenadroid's full-sized avatar

Lena lenadroid

View GitHub Profile
System.Net.WebException: The remote name could not be resolved: 'www.someunknownaddress'
at Microsoft.FSharp.Control.WebExtensions.AsyncGetResponse@2036-1.Invoke(Exception _arg1)
at [email protected](AsyncParams`1 args)
at Cloud.Parallel[T](seq<Cloud<T>> computations)
--- End of stack trace from previous location where exception was thrown ---
в Microsoft.FSharp.Core.Operators.Raise[T](Exception exn)
в <StartupCode$MBrace-Azure-Client>[email protected](Result`1 _arg2)
в C:\Users\developer001\Source\Repos\MBrace.Azure\src\MBrace.Azure.Client\Process.fs:строка 116
в [email protected](a a)
at MBrace.Continuation.ExceptionDispatchInfoUtils.Async.RunSync[T](FSharpAsync`1 workflow, FSharpOption`1 cancellationToken)
let maxContentLength = cloud {
let lengthsJob = [|"https://github.com"; "https://www.microsoft.com"; "http://www.someunknownaddress"|]
|> Array.map (getContentLenght >> Cloud.OfAsync)
let! lengths = Cloud.Parallel lengthsJob
return Array.max lengths
}
interface ICloudDisposable with
member d.Dispose () = CloudDirectory.Delete(d, recursiveDelete = true)
/// Denotes handle to a distributable resource that can be disposed of.
type ICloudDisposable =
/// Releases any storage resources used by this object.
abstract Dispose : unit -> Local<unit>
// initial creation of channel and ports
let channel = cluster.StoreClient.Channel
let sendPort1, receivePort1 = channel.Create<string>()
let sendPort2, receivePort2 = channel.Create<string>()
// cloud job gets incoming messaages from the receive port, does something
// with received messages and sends the results to the send port
let replicateMessage (receive : IReceivePort<string>) (send : ISendPort<string>) =
cloud {
while true do
let directory = cluster.StoreClient.FileStore.Directory.Create()
let songFileNames = [|...|] // url addresses to the lyrics of the songs
let download (url : string) = async {
let http = new System.Net.WebClient()
return! http.AsyncDownloadString(Uri url)
}
// to create new cloud file storing song's lyrics
let songFiles =
// url addresses to song lyrics are there
// full sample here https://github.com/lenadroid/dotnetfringe/blob/master/azure/NetFringe/CloudFlows.fsx
[| ... |]
|> CloudFlow.ofArray
|> CloudFlow.map download
|> CloudFlow.filter (fun s -> s.Length > 300)
|> CloudFlow.map (fun s -> s.Substring(0, s.IndexOf("\n") - 1))
|> CloudFlow.toArray
|> cluster.CreateProcess
let atomicValue = CloudAtom.New(42) |> cluster.Run
let readAtomValue = atomicValue |> CloudAtom.Read |> cluster.Run
cloud {
do!
[ for i in 1..1000 -> cloud { return! CloudAtom.Update (atomicValue, fun i -> i + 1) }]
|> Cloud.Parallel
|> Cloud.Ignore
return! CloudAtom.Read atomicValue
@lenadroid
lenadroid / CloudVectors.fs
Created May 18, 2015 16:11
CloudVectors.fs
let vectorOfData = [| for i in 0 .. 1000 do for j in 0 .. i do yield (i,j) |]
let cloudVector = CloudVector.New(vectorOfData,100000L) |> cluster.Run
cloudVector.PartitionCount
let lengthsJob =
cloudVector
|> CloudFlow.ofCloudVector
|> CloudFlow.map (fun (a,b) -> a+b)
@lenadroid
lenadroid / cloudcell.fs
Created May 18, 2015 16:08
cloudcell.fs
let data = "Some data"
let cloudData = data |> CloudCell.New |> cluster.Run
let lengthOfData =
cloud { let! data = CloudCell.Read cloudData
return data.Length }
|> cluster.Run