/// <summary> /// Initializes a new instance of the DryadLinqContext class for a specified cluster. /// </summary> /// <param name="cluster">The cluster to run DryadLINQ jobs</param> public DryadLinqContext(DryadLinqCluster cluster) { // Verify that the head node is set if (String.IsNullOrEmpty(cluster.HeadNode)) { throw new DryadLinqException(DryadLinqErrorCode.ClusterNameMustBeSpecified, SR.ClusterNameMustBeSpecified); } this.CommonInit(); this._platformKind = cluster.Kind; this._headNode = cluster.HeadNode; this._clusterDetails = cluster; if (cluster.Kind == DryadLinq.PlatformKind.YARN_NATIVE) { this._storageSetScheme = DataPath.HDFS_URI_SCHEME; // make an Azure subscriptions object just in case we want to access azure streams from the native yarn cluster this._azureSubscriptions = new AzureSubscriptions(); } else if (cluster.Kind == DryadLinq.PlatformKind.YARN_AZURE) { this._storageSetScheme = DataPath.AZUREBLOB_URI_SCHEME; DryadLinqAzureCluster azureCluster = cluster as DryadLinqAzureCluster; this._azureSubscriptions = azureCluster.Subscriptions; } }
/// <summary> /// Initializes a new instance of the <see cref="Platform"/> struct. /// </summary> /// <param name="kind"><see cref="PlatformKind"/></param> /// <param name="version">version</param> /// <param name="byParameterCount">boolean</param> public Platform(PlatformKind kind, string version = null, bool byParameterCount = false) { Kind = kind; Version = version; ByParameterCount = byParameterCount; switch (kind) { case PlatformKind.Unchecked: if (version != null) { throw new ArgumentException("No version expected"); } break; case PlatformKind.Uwp: break; case PlatformKind.ExtensionSDK: if (version != null) { throw new ArgumentException("Don't specify versions for extension SDKs"); } break; } if (byParameterCount && kind != PlatformKind.Uwp) { throw new ArgumentException("Only UWP can be distinguished by parameter count"); } }
/// <summary> /// Initializes a new instance of the DryadLinqContext class for local execution. /// </summary> /// <param name="numProcesses">The number of local worker processes that should be started.</param> /// <param name="storageSetScheme">The default scheme for storage. Defaults to partitioned file</param> public DryadLinqContext(int numProcesses, string storageSetScheme = null) { this.CommonInit(); this._platformKind = PlatformKind.LOCAL; this._localExecution = true; this._headNode = "LocalExecution"; this._storageSetScheme = storageSetScheme; if (String.IsNullOrEmpty(this._storageSetScheme)) { this._storageSetScheme = DataPath.PARTFILE_URI_SCHEME; } this._jobMinNodes = numProcesses; // make an Azure subscriptions object just in case we want to access azure streams from local execution this._azureSubscriptions = new AzureSubscriptions(); }
public override bool IsPlatformKind(PlatformKind platformKind) { switch (platformKind) { case PlatformKind.Desktop: case PlatformKind.Mobile: return(true); case PlatformKind.Console: case PlatformKind.Server: return(false); } throw new ArgumentOutOfRangeException(nameof(platformKind)); }
private static DryadLinqCluster MakeCluster(string clusterName, PlatformKind kind) { if (kind == PlatformKind.LOCAL) { throw new DryadLinqException("Can't make a cluster of kind LOCAL"); } else if (kind == PlatformKind.YARN_NATIVE) { return(new DryadLinqYarnCluster(clusterName)); } else if (kind == PlatformKind.YARN_AZURE) { return(new DryadLinqAzureCluster(clusterName)); } else { throw new DryadLinqException("Unknown cluster kind " + kind); } }
static Platform() { PortableExecutableKinds peKinds; typeof(object).Module.GetPEKind(out peKinds, out Architecture); Version osVersion; switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: // Win9x supported? case PlatformID.Win32S: // Win16 NTVDM on Win x86? case PlatformID.Win32NT: // Windows NT Kind = PlatformKind.Win32; Name = PlatformName.Windows; /* osVersion = Environment.OSVersion.Version; * if (osVersion.Major <= 4) { * // WinNT 4 * } else if (osVersion.Major <= 5) { * // Win2000, WinXP * } else if (osVersion.Major <= 6) { * // WinVista, Win7, Win8.x * if (osVersion.Major == 0) { * } * } else { * // info: technet .. msdn .. microsoft research * * } */ break; case PlatformID.WinCE: // case PlatformID.Xbox: Kind = PlatformKind.Win32; Name = PlatformName.Windows; break; case PlatformID.Unix: // note: current Mono versions still indicate Unix for Mac OS X Kind = PlatformKind.Posix; Name = PlatformName.Posix; break; case PlatformID.MacOSX: Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; break; default: if ((int)Environment.OSVersion.Platform == 128) { // Mono formerly used 128 for MacOSX Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } break; } // TODO: Detect and distinguish available Compilers and Runtimes /* switch (Kind) { * * case PlatformKind.Windows: * LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat; * OpenPtr = Platform.Windows.OpenPtr; * LoadProcedure = Platform.Windows.LoadProcedure; * ReleasePtr = Platform.Windows.ReleasePtr; * GetLastLibraryError = Platform.Windows.GetLastLibraryError; * break; * * case PlatformKind.Posix: * LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat; * OpenPtr = Platform.Posix.OpenPtr; * LoadProcedure = Platform.Posix.LoadProcedure; * ReleasePtr = Platform.Posix.ReleasePtr; * GetLastLibraryError = Platform.Posix.GetLastLibraryError; * break; * * case PlatformKind.Unknown: * default: * throw new PlatformNotSupportedException (); * } */ IsMono = Type.GetType("Mono.Runtime") != null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); IsMonoTouch = assemblies.Any(a => a.GetName().Name.Equals("MonoTouch", StringComparison.InvariantCultureIgnoreCase)); IsMonoMac = assemblies.Any(a => a.GetName().Name.Equals("MonoMac", StringComparison.InvariantCultureIgnoreCase)); IsXamarinIOS = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.iOS", StringComparison.InvariantCultureIgnoreCase)); IsXamarinAndroid = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.Android", StringComparison.InvariantCultureIgnoreCase)); if (IsMonoMac) { Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } if (Name == PlatformName.Posix) { // check again if this might be Mac OS X var info = new ProcessStartInfo(); info.FileName = "sh"; info.Arguments = "-c \"sw_vers -productName\""; info.UseShellExecute = false; info.CreateNoWindow = true; info.RedirectStandardOutput = true; info.RedirectStandardError = true; using (var p = Process.Start(info)) { var output = p.StandardOutput.ReadToEnd(); // TODO: use Trace.WriteLine instead? System.Console.WriteLine("Output of sw_vers was: " + output); if (output.StartsWith("Mac OS X")) { Name = PlatformName.MacOSX; } } } if (IsXamarinIOS || IsMonoTouch) { // Kind = PlatformKind.__Internal; // Name = PlatformName.__Internal; Is__Internal = true; } SetupImplementation(typeof(Platform)); }
/// <summary> /// Initializes a new instance of the DryadLinqContext class for a YARN cluster. /// </summary> /// <param name="clusterName">The head node of the cluster and DFS</param> /// <param name="platform">The service platform to run DryadLINQ jobs. Defaults to YARN Azure</param> public DryadLinqContext(string clusterName, PlatformKind platform = PlatformKind.YARN_AZURE) : this(MakeCluster(clusterName, platform)) { }
static Platform() { PortableExecutableKinds peKinds; typeof(object).Module.GetPEKind(out peKinds, out Architecture); Version osVersion; switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: // Win9x supported? case PlatformID.Win32S: // Win16 NTVDM on Win x86? case PlatformID.Win32NT: // Windows NT Kind = PlatformKind.Win32; Name = PlatformName.Windows; /* osVersion = Environment.OSVersion.Version; * if (osVersion.Major <= 4) { * // WinNT 4 * } else if (osVersion.Major <= 5) { * // Win2000, WinXP * } else if (osVersion.Major <= 6) { * // WinVista, Win7, Win8.x * if (osVersion.Major == 0) { * } * } else { * // info: technet .. msdn .. microsoft research * * } */ break; case PlatformID.WinCE: // case PlatformID.Xbox: Kind = PlatformKind.Win32; Name = PlatformName.Windows; break; case PlatformID.Unix: // note: current Mono versions still indicate Unix for Mac OS X Kind = PlatformKind.Posix; Name = PlatformName.Posix; break; case PlatformID.MacOSX: Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; break; default: if ((int)Environment.OSVersion.Platform == 128) { // Mono formerly used 128 for MacOSX Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } break; } // TODO: Detect and distinguish available Compilers and Runtimes /* switch (Kind) { * * case PlatformKind.Windows: * LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat; * OpenPtr = Platform.Windows.OpenPtr; * LoadProcedure = Platform.Windows.LoadProcedure; * ReleasePtr = Platform.Windows.ReleasePtr; * GetLastLibraryError = Platform.Windows.GetLastLibraryError; * break; * * case PlatformKind.Posix: * LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat; * OpenPtr = Platform.Posix.OpenPtr; * LoadProcedure = Platform.Posix.LoadProcedure; * ReleasePtr = Platform.Posix.ReleasePtr; * GetLastLibraryError = Platform.Posix.GetLastLibraryError; * break; * * case PlatformKind.Unknown: * default: * throw new PlatformNotSupportedException (); * } */ IsMono = Type.GetType("Mono.Runtime") != null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); IsMonoTouch = assemblies.Any(a => a.GetName().Name.Equals("MonoTouch", StringComparison.InvariantCultureIgnoreCase)); IsMonoMac = assemblies.Any(a => a.GetName().Name.Equals("MonoMac", StringComparison.InvariantCultureIgnoreCase)); IsXamarinIOS = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.iOS", StringComparison.InvariantCultureIgnoreCase)); IsXamarinAndroid = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.Android", StringComparison.InvariantCultureIgnoreCase)); if (IsMonoMac) { Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } if (Name == PlatformName.Posix && File.Exists("/System/Library/CoreServices/SystemVersion.plist")) { Name = PlatformName.MacOSX; } if (IsXamarinIOS || IsMonoTouch) { // Kind = PlatformKind.__Internal; // Name = PlatformName.__Internal; Is__Internal = true; } SetupImplementation(typeof(Platform)); }
static Platform() { PortableExecutableKinds peKinds; typeof(object).Module.GetPEKind(out peKinds, out Architecture); Version osVersion; switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: // Win9x supported? case PlatformID.Win32S: // Win16 NTVDM on Win x86? case PlatformID.Win32NT: // Windows NT Kind = PlatformKind.Win32; Name = PlatformName.Windows; /* osVersion = Environment.OSVersion.Version; if (osVersion.Major <= 4) { // WinNT 4 } else if (osVersion.Major <= 5) { // Win2000, WinXP } else if (osVersion.Major <= 6) { // WinVista, Win7, Win8.x if (osVersion.Major == 0) { } } else { // info: technet .. msdn .. microsoft research } */ break; case PlatformID.WinCE: // case PlatformID.Xbox: Kind = PlatformKind.Win32; Name = PlatformName.Windows; break; case PlatformID.Unix: // TODO: older MS.NET frameworks say Unix for MacOSX ? Kind = PlatformKind.Posix; Name = PlatformName.Posix; break; case PlatformID.MacOSX: Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; break; default: if ((int)Environment.OSVersion.Platform == 128) { // Mono formerly used 128 for MacOSX Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } break; } // TODO: Detect and distinguish available Compilers and Runtimes /* switch (Kind) { case PlatformKind.Windows: LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat; OpenPtr = Platform.Windows.OpenPtr; LoadProcedure = Platform.Windows.LoadProcedure; ReleasePtr = Platform.Windows.ReleasePtr; GetLastLibraryError = Platform.Windows.GetLastLibraryError; break; case PlatformKind.Posix: LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat; OpenPtr = Platform.Posix.OpenPtr; LoadProcedure = Platform.Posix.LoadProcedure; ReleasePtr = Platform.Posix.ReleasePtr; GetLastLibraryError = Platform.Posix.GetLastLibraryError; break; case PlatformKind.Unknown: default: throw new PlatformNotSupportedException (); } */ IsMono = Type.GetType("Mono.Runtime") != null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); IsMonoTouch = assemblies.Any(a => a.GetName().Name.Equals("MonoTouch", StringComparison.InvariantCultureIgnoreCase)); IsMonoMac = assemblies.Any(a => a.GetName().Name.Equals("MonoMac", StringComparison.InvariantCultureIgnoreCase)); IsXamarinIOS = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.iOS", StringComparison.InvariantCultureIgnoreCase)); IsXamarinAndroid = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.Android", StringComparison.InvariantCultureIgnoreCase)); if (IsMonoMac) { Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } if (IsXamarinIOS || IsMonoTouch) { // Kind = PlatformKind.__Internal; // Name = PlatformName.__Internal; Is__Internal = true; } SetupImplementation(typeof(Platform)); }
static Platform() { PortableExecutableKinds peKinds; typeof(object).Module.GetPEKind(out peKinds, out Architecture); Version osVersion; switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: // Win9x supported? case PlatformID.Win32S: // Win16 NTVDM on Win x86? case PlatformID.Win32NT: // Windows NT Kind = PlatformKind.Win32; Name = PlatformName.Windows; /* osVersion = Environment.OSVersion.Version; * if (osVersion.Major <= 4) { * // WinNT 4 * } else if (osVersion.Major <= 5) { * // Win2000, WinXP * } else if (osVersion.Major <= 6) { * // WinVista, Win7, Win8.x * if (osVersion.Major == 0) { * } * } else { * // info: technet .. msdn .. microsoft research * * } */ break; case PlatformID.WinCE: // case PlatformID.Xbox: Kind = PlatformKind.Win32; Name = PlatformName.Windows; break; case PlatformID.Unix: Kind = PlatformKind.Posix; // TODO: older MS.NET frameworks say Unix for MacOSX ? Name = PlatformName.Unix; break; case PlatformID.MacOSX: Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; break; default: if ((int)Environment.OSVersion.Platform == 128) { // Mono formerly used 128 for MacOSX Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } break; } // TODO: Detect and distinguish available Compilers and Runtimes /* switch (Kind) { * * case PlatformKind.Windows: * LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat; * OpenPtr = Platform.Windows.OpenPtr; * LoadProcedure = Platform.Windows.LoadProcedure; * ReleasePtr = Platform.Windows.ReleasePtr; * GetLastLibraryError = Platform.Windows.GetLastLibraryError; * break; * * case PlatformKind.Posix: * LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat; * OpenPtr = Platform.Posix.OpenPtr; * LoadProcedure = Platform.Posix.LoadProcedure; * ReleasePtr = Platform.Posix.ReleasePtr; * GetLastLibraryError = Platform.Posix.GetLastLibraryError; * break; * * case PlatformKind.Unknown: * default: * throw new PlatformNotSupportedException (); * } */ SetupPlatformImplementation(typeof(Platform)); }
/// <summary> /// To signed some type of data /// </summary> /// <param name="data">String with the data you want to sign</param> /// <param name="callback"></param> /// <param name="platform"></param> /// <param name="signature"></param> public void SignData(string data, Action <bool, string, string, string> callback = null, PlatformKind platform = PlatformKind.Phantasma, SignatureKind signature = SignatureKind.Ed25519) { if (!Enabled) { callback(true, "not logged in", "", ""); return; } if (data == null) { callback(true, "invalid data, sorry :(", "", ""); return; } if (data.Length >= 1024) { callback(true, "data too big, sorry :(", "", ""); return; } var dataConverted = Base16.Encode(Encoding.UTF8.GetBytes(data)); SendLinkRequest($"signData/{dataConverted}/{signature}/{platform}", (result) => { var success = result.GetBool("success"); if (success) { var random = result.GetString("random"); var signedData = result.GetString("signature"); callback?.Invoke(false, signedData, random, dataConverted); } else { var msg = result.GetString("message"); callback?.Invoke(true, "transaction rejected: " + msg, "", ""); } }); }
/// <summary> /// Send Transaction. /// </summary> /// <param name="chain"></param> /// <param name="script"></param> /// <param name="payload"></param> /// <param name="callback"></param> public void SendTransaction(string chain, byte[] script, byte[] payload, Action <Hash, string> callback = null, PlatformKind platform = PlatformKind.Phantasma, SignatureKind signature = SignatureKind.Ed25519) { SetMessage("Relaying transaction..."); if (script.Length >= 8192) { callback(Hash.Null, "script too big"); return; } var hexScript = Base16.Encode(script); var hexPayload = payload != null && payload.Length > 0 ? Base16.Encode(payload) : ""; // is empty string for payload ok? var requestStr = $"{chain}/{hexScript}/{hexPayload}"; if (Version >= 2) { requestStr = $"{requestStr}/{signature}/{platform}"; } else { requestStr = $"{this.Nexus}/{requestStr}"; } SendLinkRequest($"signTx/{requestStr}", (result) => { var success = result.GetBool("success"); if (success) { var hashStr = result.GetString("hash"); var hash = Hash.Parse(hashStr); callback?.Invoke(hash, null); } else { var msg = result.GetString("message"); callback?.Invoke(Hash.Null, "transaction rejected: " + msg); } }); }
static Platform() { PortableExecutableKinds peKinds; typeof(object).Module.GetPEKind(out peKinds, out Architecture); Version osVersion; switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: // Win9x supported? case PlatformID.Win32S: // Win16 NTVDM on Win x86? case PlatformID.Win32NT: // Windows NT Kind = PlatformKind.Win32; Name = PlatformName.Windows; /* osVersion = Environment.OSVersion.Version; if (osVersion.Major <= 4) { // WinNT 4 } else if (osVersion.Major <= 5) { // Win2000, WinXP } else if (osVersion.Major <= 6) { // WinVista, Win7, Win8.x if (osVersion.Major == 0) { } } else { // info: technet .. msdn .. microsoft research } */ break; case PlatformID.WinCE: // case PlatformID.Xbox: Kind = PlatformKind.Win32; Name = PlatformName.Windows; break; case PlatformID.Unix: Kind = PlatformKind.Posix; // TODO: older MS.NET frameworks say Unix for MacOSX ? Name = PlatformName.Posix; break; case PlatformID.MacOSX: Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; break; default: if ((int)Environment.OSVersion.Platform == 128) { // Mono formerly used 128 for MacOSX Kind = PlatformKind.Posix; Name = PlatformName.MacOSX; } break; } // TODO: Detect and distinguish available Compilers and Runtimes /* switch (Kind) { case PlatformKind.Windows: LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat; OpenPtr = Platform.Windows.OpenPtr; LoadProcedure = Platform.Windows.LoadProcedure; ReleasePtr = Platform.Windows.ReleasePtr; GetLastLibraryError = Platform.Windows.GetLastLibraryError; break; case PlatformKind.Posix: LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat; OpenPtr = Platform.Posix.OpenPtr; LoadProcedure = Platform.Posix.LoadProcedure; ReleasePtr = Platform.Posix.ReleasePtr; GetLastLibraryError = Platform.Posix.GetLastLibraryError; break; case PlatformKind.Unknown: default: throw new PlatformNotSupportedException (); } */ SetupPlatformImplementation(typeof(Platform)); }
public abstract bool IsPlatformKind(PlatformKind platformKind);
public override bool IsPlatformKind(PlatformKind platformKind) { return(true); }