public async Task <string> ApplyUpdates(Delta delta) { Binding binding = WcfUtility.CreateTcpClientBinding(maxMessageSize: 1024 * 1024 * 1024); ServicePartitionResolver servicePartitionResolver = new ServicePartitionResolver(() => new FabricClient()); WcfCommunicationClientFactory <INetworkModelGDAContract> communicationClientFactory = new WcfCommunicationClientFactory <INetworkModelGDAContract>(binding, servicePartitionResolver: servicePartitionResolver); Uri uri = new Uri("fabric:/LoadFlowApplication/NMSGdaService"); NetworkModelGdaClient networkModelGdaClient = new NetworkModelGdaClient(communicationClientFactory, uri, new ServicePartitionKey(0)); string updateResult = "Apply Updates Report:\r\n"; System.Globalization.CultureInfo culture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); if ((delta != null) && (delta.NumberOfOperations != 0)) { //// NetworkModelService->ApplyUpdates //updateResult = GdaQueryProxy.ApplyUpdate(delta).ToString(); try { updateResult = (await networkModelGdaClient.InvokeWithRetryAsync(client => client.Channel.ApplyUpdate(delta))).ToString(); } catch (Exception e) { string message = e.Message; } } Thread.CurrentThread.CurrentCulture = culture; return(updateResult); }
public HelloProxy(string serviceUri) { factory = new WcfCommunicationClientFactory <IHelloContract>(clientBinding: WcfUtility.CreateTcpClientBinding(), servicePartitionResolver: resolver); proxy = new ServicePartitionClient <WcfCommunicationClient <IHelloContract> >( communicationClientFactory: factory, serviceUri: new Uri(serviceUri), listenerName: "WCFServiceEndpoint"); }
private WcfClient <IScadaStorageService> BuildClient() { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IScadaStorageService>(clientBinding: binding, servicePartitionResolver: partitionResolver); var ServiceUri = new Uri(_uri); var client = new WcfClient <IScadaStorageService>(wcfClientFactory, ServiceUri, new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(1)); return(client); }
public DuplexProxy(string serviceUri) { factory = new WcfCommunicationClientFactory <IDuplexContract>(clientBinding: WcfUtility.CreateTcpClientBinding(), servicePartitionResolver: resolver, callback: new WcfDuplexCallbackImplementation()); proxy = new ServicePartitionClient <WcfCommunicationClient <IDuplexContract> >( communicationClientFactory: factory, serviceUri: new Uri(serviceUri), listenerName: "WCFDuplexEndpoint"); }
public static WcfServiceFabricCommunicationClient <T> GetClient(Uri uri, Binding binding) { IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <T> (clientBinding: binding, servicePartitionResolver: partitionResolver); var client = new WcfServiceFabricCommunicationClient <T>(wcfClientFactory, uri, ServicePartitionKey.Singleton); return(client); }
private WcfClient <IFEPServiceAsync> BuildClient() { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IFEPServiceAsync>(clientBinding: binding, servicePartitionResolver: partitionResolver); var ServiceUri = new Uri(_uri); var client = new WcfClient <IFEPServiceAsync>(wcfClientFactory, ServiceUri); return(client); }
public WcfServiceRemotingClientFactory(IServiceRemotingCallbackClient callbackImplementation, Binding clientBinding) { WcfFactory = new WcfCommunicationClientFactory<IServiceRemotingContract>(ServicePartitionResolver.GetDefault(), clientBinding, new CallbackReciver(callbackImplementation), new IExceptionHandler[] { new FaultExceptionHandler(this) }); WcfFactory.ClientConnected += OnClientConnected; WcfFactory.ClientDisconnected += OnClientDisconnected; }
// GET api/values/5 public CustomerProfile GetById(string id) { CustomerProfile _profile = null; Binding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); // Create a partition resolver IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); // create a WcfCommunicationClientFactory object. var wcfClientFactory = new WcfCommunicationClientFactory <INBKCentral> (clientBinding: binding, servicePartitionResolver: partitionResolver); // // Create a client for communicating with the ICalculator service that has been created with the // Singleton partition scheme. // var nbkcentralServiceCommunicationClient = new EAIP1CommunicationClient( wcfClientFactory, eaip1ServiceUri, ServicePartitionKey.Singleton); int _total = 0; // // Call the service to perform the operation. // DataSet _result = nbkcentralServiceCommunicationClient.InvokeWithRetry( client => client.Channel.Read("Customer_Process_Portfolio", "GetCustomerProfile", new NBK.Common.Foundations.Utilities.FilterCriteria[] { new NBK.Common.Foundations.Utilities.FilterCriteria { CompOp = NBK.Common.Foundations.Utilities.ComparisonOperator.Equal, CondOp = NBK.Common.Foundations.Utilities.ConditionalOperator.And, FieldName = "CustomerNo", FieldValue = new string[] { id }, SubExpr = NBK.Common.Foundations.Utilities.SubExpression.None } }, null, -1, -1, ref _total)); if (_result != null && _result.Tables.Count > 0 && _result.Tables[0].Rows.Count > 0) { DataRow _row = _result.Tables[0].Rows[0]; _profile = new CustomerProfile { CustomerNumber = _row["CustomerNumber"].ToString(), TotalCashLiability = _row["TotalCashLiability"].ToString(), TotalCashLimit = _row["TotalCashLimit"].ToString(), TotalCollateral = _row["TotalCollateral"].ToString(), TotalEarnedAssets = _row["TotalEarnedAssets"].ToString(), TotalFreeFunds = _row["TotalFreeFunds"].ToString(), TotalIndirectLiability = _row["TotalIndirectLiability"].ToString(), TotalNBKFunds = _row["TotalNBKFundValue"].ToString(), TotalNonCashLiability = _row["TotalNonCashLiability"].ToString(), TotalNonCashLimit = _row["TotalNonCashLimit"].ToString() }; } return(_profile); }
static void Main(string[] args) { Uri serviceUri = new Uri("fabric:/CalculatorApplication3/CalculatorService"); IServicePartitionResolver serviceResolver = ServicePartitionResolver.GetDefault(); Binding binding = WcfUtility.CreateTcpClientBinding(); var wcfClientFactory = new WcfCommunicationClientFactory <ICalculatorService>( clientBinding: binding, servicePartitionResolver: serviceResolver); var calcClient = new Client(wcfClientFactory, serviceUri); Console.WriteLine(calcClient.Add(3, 5).Result); Console.ReadKey(); }
private PresidentialServiceClient getPresidentialServiceClient() { // binding data Binding binding = new BindingConfig().GetBinding(); ServicePartitionResolver spr = new ServicePartitionResolver(() => new FabricClient()); WcfCommunicationClientFactory <IPresidentialService> communicationClientFactory = new WcfCommunicationClientFactory <IPresidentialService>(binding, servicePartitionResolver: spr); Uri uri = new Uri("fabric:/Political/PresidentialService"); PresidentialServiceClient presidentialServiceClient = new PresidentialServiceClient(communicationClientFactory, uri); return(presidentialServiceClient); }
private static async Task reportCancellation(string url) { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IStateAggregator>( clientBinding: binding, servicePartitionResolver: partitionResolver ); var jobClient = new ServicePartitionClient <WcfCommunicationClient <IStateAggregator> >( wcfClientFactory, new Uri("fabric:/AudioTranscriptionApp/StateAggregator")); await jobClient.InvokeWithRetryAsync(client => client.Channel.ReportCancellation(url)); }
private static async Task Run(Uri serviceName) { var serviceResolver = new ServicePartitionResolver(() => new FabricClient()); var clientFactory = new WcfCommunicationClientFactory <ITableStoreService>( serviceResolver, // ServicePartitionResolver ServiceBindings.TcpBinding, // Client binding null, // Callback object null); // do not retry Exception types var client = new ServicePartitionClient <WcfCommunicationClient <ITableStoreService> >( clientFactory, serviceName, partitionKey: 0); var tasks = new Task[32]; var iteration = (long)0; // Initialize. for (var i = 0; i < tasks.Length; ++i) { await Set(client, i.ToString(), iteration); } var timer = Stopwatch.StartNew(); while (true) { for (var i = 0; i < tasks.Length; ++i) { tasks[i] = CheckAndIncrement(client, i.ToString(), iteration); } await Task.WhenAll(tasks); var total = iteration * tasks.Length; if (iteration % 100 == 0) { //Console.Write('.'); Console.WriteLine($"{iteration} iterations in {timer.ElapsedMilliseconds}ms. {total * 1000/ ( timer.ElapsedMilliseconds)}/sec"); } if (iteration % 8000 == 0 && timer.ElapsedMilliseconds > 0) { Console.WriteLine(); Console.WriteLine($"{iteration} iterations in {timer.ElapsedMilliseconds}ms. {total*1000/(timer.ElapsedMilliseconds)}/sec"); } iteration++; } }
public TContract CreateClient <TClient, TContract>(Uri serviceUri, ServicePartitionKey servicePartition) where TContract : class, IService, IHealthChecker where TClient : WcfSeviceFabricClientBase <TContract> { var binding = WcfUtility.CreateTcpClientBinding(); var partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <TContract>(clientBinding: binding, servicePartitionResolver: partitionResolver); TContract client = (TContract)Activator.CreateInstance(typeof(TClient), new object[] { wcfClientFactory, serviceUri, servicePartition }); //CheckIsAlive(client, serviceUri); return(client); }
public async Task <IEnumerable <JobStatus> > Jobs() { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IStateAggregator>( clientBinding: binding, servicePartitionResolver: partitionResolver ); var jobClient = new ServicePartitionClient <WcfCommunicationClient <IStateAggregator> >( wcfClientFactory, new Uri("fabric:/AudioTranscriptionApp/StateAggregator")); var result = await jobClient.InvokeWithRetryAsync(client => client.Channel.ListJobs()); return(result); }
protected string GetTenantDBConnection(string tenant) { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IDbConnectionService>(clientBinding: binding, servicePartitionResolver: partitionResolver); var client = new ServicePartitionClient <WcfCommunicationClient <IDbConnectionService> >(wcfClientFactory, new Uri(SF_CONFIG_DBCONNECTION_SERVICE)); var results = client.InvokeWithRetry( c => c.Channel.IdentifyTenantDatabase(tenant) ); return(results); }
static void Main(string[] args) { Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <ICalculatorService> (clientBinding: null, servicePartitionResolver: partitionResolver); for (int i = 0; i < 10; i++) { var calculatorServiceCommunicationClient = new ServicePartitionClient <WcfCommunicationClient <ICalculatorService> > (wcfClientFactory, new Uri("fabric:/CalculatorApplication/CalculatorService")); var result = calculatorServiceCommunicationClient.InvokeWithRetryAsync(client => client.Channel.Add(2, 3)); Console.WriteLine(result.Result); } // Console.ReadLine(); }
public CIMAdapter() { NetTcpBinding binding = new NetTcpBinding(); // Create a partition resolver IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); // create a WcfCommunicationClientFactory object. var wcfClientFactory = new WcfCommunicationClientFactory <IOMSClient> (clientBinding: binding, servicePartitionResolver: partitionResolver); // // Create a client for communicating with the ICalculator service that has been created with the // Singleton partition scheme. // dispatcherClient = new DispatcherClient( wcfClientFactory, new Uri("fabric:/ServiceFabricOMS/TMStatelessService"), ServicePartitionKey.Singleton); }
public async Task VisitWcfAsync(ServiceMessage message) { var fabricClient = new FabricClient(FabricClientRole.Admin); var partitionList = await fabricClient.QueryManager.GetPartitionListAsync(new Uri(Service4Uri)); var bindings = WcfUtility.CreateTcpClientBinding(); var partitionResolver = ServicePartitionResolver.GetDefault(); message.StampThree.Visited = true; message.StampThree.TimeNow = DateTime.UtcNow; foreach (var partition in partitionList) { var partitionInfo = (Int64RangePartitionInformation)partition.PartitionInformation; var wcfClientProxy = new WcfCommunicationClientFactory <IServiceFour>(clientBinding: bindings, servicePartitionResolver: partitionResolver); var wcfClient = new SvcFourWcfCommunicationClient(wcfClientProxy, new Uri(Service4Uri), new ServicePartitionKey(partitionInfo.HighKey), listenerName: "WcfTcp"); await wcfClient.InvokeWithRetryAsync(client => client.Channel.VisitWcfAsync(message)); } }
/// <summary> /// Constructs a WCF based service remoting client factory. /// </summary> /// <param name="clientBinding"> /// WCF binding to use for the client. If the client binding is not specified or null, /// a default client binding is created using /// <see cref="Microsoft.ServiceFabric.Services.Communication.Wcf.WcfUtility.CreateTcpClientBinding"/> method /// which creates a <see cref="System.ServiceModel.NetTcpBinding"/> with no security. /// </param> /// <param name="callbackClient"> /// The callback client that receives the callbacks from the service. /// </param> /// <param name="exceptionHandlers"> /// Exception handlers to handle the exceptions encountered in communicating with the service. /// </param> /// <param name="servicePartitionResolver"> /// Service partition resolver to resolve the service endpoints. If not specified, a default /// service partition resolver returned by <see cref="ServicePartitionResolver.GetDefault"/> is used. /// </param> /// <param name="traceId"> /// Id to use in diagnostics traces from this component. /// </param> /// <param name="createWcfClientFactory"> /// Delegate function that creates <see cref="Microsoft.ServiceFabric.Services.Communication.Wcf.Client.WcfCommunicationClientFactory{TServiceContract}"/> using the /// <see cref="IServiceRemotingContract"/>. /// </param> /// <remarks> /// This factory uses <see cref="WcfExceptionHandler"/> and <see cref="ServiceRemotingExceptionHandler"/> in addition to the /// exception handlers supplied to the constructor. /// </remarks> public WcfServiceRemotingClientFactory( Binding clientBinding = null, IServiceRemotingCallbackClient callbackClient = null, IEnumerable <IExceptionHandler> exceptionHandlers = null, IServicePartitionResolver servicePartitionResolver = null, string traceId = null, Func < Binding, IEnumerable <IExceptionHandler>, IServicePartitionResolver, string, IServiceRemotingCallbackContract, WcfCommunicationClientFactory <IServiceRemotingContract> > createWcfClientFactory = null) { if (traceId == null) { traceId = Guid.NewGuid().ToString(); } if (createWcfClientFactory == null) { this.wcfFactory = new WcfCommunicationClientFactory <IServiceRemotingContract>( clientBinding, GetExceptionHandlers(exceptionHandlers, traceId), servicePartitionResolver, traceId, GetCallbackImplementation(callbackClient)); } else { this.wcfFactory = createWcfClientFactory( clientBinding, GetExceptionHandlers(exceptionHandlers, traceId), servicePartitionResolver, traceId, GetCallbackImplementation(callbackClient)); } this.wcfFactory.ClientConnected += this.OnClientConnected; this.wcfFactory.ClientDisconnected += this.OnClientDisconnected; }
static void CallWcf() { var ServiceUri = new Uri("fabric:/Application3/Stateful1"); // Create binding Binding binding = WcfUtility.CreateTcpClientBinding(); ServicePartitionResolver servicePartitionResolver = new ServicePartitionResolver(() => new FabricClient()); // Create a partition resolver IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); // create a WcfCommunicationClientFactory object. var wcfClientFactory = new WcfCommunicationClientFactory <ICalculator> (clientBinding: binding, servicePartitionResolver: servicePartitionResolver); // // Create a client for communicating with the ICalculator service that has been created with the // Singleton partition scheme. // var calculatorServiceCommunicationClient = new WcfCommunicationClient( wcfClientFactory, ServiceUri, new ServicePartitionKey(1)); // // Call the service to perform the operation. // Stopwatch stopwatch = new Stopwatch(); var total = 0.0; for (int i = 0; i < 1000; i++) { stopwatch.Restart(); var result = calculatorServiceCommunicationClient.InvokeWithRetryAsync( client => client.Channel.Add(2, 3)).Result; stopwatch.Stop(); var used = stopwatch.Elapsed.TotalMilliseconds; total += used; Console.WriteLine($"{i + 1} used: {used}ms, avg:{total / (i + 1)}, result:{result}"); } }
static void Main(string[] args) { Uri serviceName = new Uri("fabric:/SimpleStoreApplication/ShoppingCartService"); ServicePartitionResolver serviceResolver = new ServicePartitionResolver(() => new FabricClient()); NetTcpBinding binding = CreateClientConnectionBinding(); WcfCommunicationClientFactory <IShoppingCartService> factory = new WcfCommunicationClientFactory <IShoppingCartService>(binding, null, serviceResolver, null, null); Proxy proxy = new Proxy(factory, serviceName, 1); proxy.AddItem(new ShoppingCartItem { ProductName = "XBox One", UnitPrice = 329.0, Amount = 2 }).Wait(); PrintPartition(proxy); IList <ShoppingCartItem> items = proxy.GetItems().Result; Console.WriteLine(items.Count); PrintPartition(proxy); Console.ReadKey(); }
public TContract CreateClient <TClient, TContract>(Uri serviceUri, ServiceType serviceType, int partitionKey = 0) where TContract : class, IService where TClient : WcfSeviceFabricClientBase <TContract> { var binding = WcfUtility.CreateTcpClientBinding(); var partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <TContract>(clientBinding: binding, servicePartitionResolver: partitionResolver); ServicePartitionKey servicePartition; if (serviceType == ServiceType.STATEFUL_SERVICE) { servicePartition = new ServicePartitionKey(partitionKey); } else { servicePartition = ServicePartitionKey.Singleton; } TContract client = (TContract)Activator.CreateInstance(typeof(TClient), new object[] { wcfClientFactory, serviceUri, servicePartition }); return(client); }
static async Task Main(string[] args) { var serviceUri = new Uri("fabric:/ECommerce/ECommerce.Api.Orders"); var binding = WcfUtility.CreateTcpClientBinding(); var servicePartitionResolver = ServicePartitionResolver.GetDefault(); var wcfCommunicationClientFactory = new WcfCommunicationClientFactory <IOrdersService>(binding, null, servicePartitionResolver); var servicePartitionClient = new ServicePartitionClient <WcfCommunicationClient <IOrdersService> >(wcfCommunicationClientFactory, serviceUri); Console.WriteLine($"Please wait..."); var result = await servicePartitionClient.InvokeWithRetryAsync(client => client.Channel.GetOrdersAsync()); if (result != null && result.Any()) { foreach (var order in result) { Console.WriteLine($"{order.Id} {order.CustomerId} {order.OrderDate} {order.Total}"); } } }
private void CreateProxy() { NetTcpBinding binding = new NetTcpBinding(); // Create a partition resolver IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); //create calllback // duplex channel for DMS transaction // TransactionCallback CallBackTransactionDMS2 = new TransactionCallback(); // create a WcfCommunicationClientFactory object. var wcfClientFactory = new WcfCommunicationClientFactory <IPublishing> (clientBinding: BindingForTCP.CreateCustomNetTcp(), servicePartitionResolver: partitionResolver); // // Create a client for communicating with the ICalculator service that has been created with the // Singleton partition scheme. // proxyToCloud = new PublishServiceCloud( wcfClientFactory, new Uri("fabric:/ServiceFabricOMS/PubSubStatelessService"), ServicePartitionKey.Singleton, listenerName: "PublishingService"); //string address = ""; //try //{ // address = "net.tcp://localhost:7001/Pub"; // EndpointAddress endpointAddress = new EndpointAddress(address); // NetTcpBinding netTcpBinding = new NetTcpBinding(); // proxy = ChannelFactory<IPublishing>.CreateChannel(netTcpBinding, endpointAddress); //} //catch (Exception e) //{ // throw e; // //TODO log error; //} }
public async Task <IActionResult> Start(string id) { try { var serviceUri = this._context.CodePackageActivationContext.ApplicationName + "/" + ServiceName; var partitionList = await this._client.QueryManager.GetPartitionListAsync(new Uri(serviceUri)); var bindings = WcfUtility.CreateTcpClientBinding(); var partitionResolver = ServicePartitionResolver.GetDefault(); var message = new ServiceMessage(); message.CommChannel = "WcfNetTcp"; message.SessionId = id; message.StampOne.Visited = true; message.StampOne.TimeNow = DateTime.UtcNow; //var storage = await _manager.GetOrAddAsync<IReliableDictionary<string, ServiceMessage>>("storage"); //using (var tx = _manager.CreateTransaction()) //{ // await storage.AddAsync(tx, message.MessageId, message); // await tx.CommitAsync(); //} foreach (var partition in partitionList) { var partitionInfo = (Int64RangePartitionInformation)partition.PartitionInformation; var wcfClientFactory = new WcfCommunicationClientFactory <IServiceTwo>(clientBinding: bindings, servicePartitionResolver: partitionResolver); var wcfClient = new SvcTwoWcfCommunicationClient(wcfClientFactory, new Uri(serviceUri), new ServicePartitionKey(partitionInfo.HighKey), listenerName: "WcfTcp"); await wcfClient.InvokeWithRetryAsync( client => client.Channel.VisitWcfAsync(message)); } return(Ok(new { id = id })); } catch (Exception e) { return(BadRequest(e.Message)); } }
static void Main(string[] args) { const int bufferSize = 512000; //500KB NetTcpBinding binding = new NetTcpBinding(SecurityMode.None) { SendTimeout = TimeSpan.FromSeconds(30), ReceiveTimeout = TimeSpan.FromSeconds(30), CloseTimeout = TimeSpan.FromSeconds(30), MaxConnections = 1000, MaxReceivedMessageSize = bufferSize, MaxBufferSize = bufferSize, MaxBufferPoolSize = bufferSize * Environment.ProcessorCount, }; ServicePartitionResolver servicePartitionResolver = new ServicePartitionResolver(() => new FabricClient()); WcfCommunicationClientFactory <IPresidentialService> communicationClientFactory = new WcfCommunicationClientFactory <IPresidentialService>(binding, servicePartitionResolver: servicePartitionResolver); Uri uri = new Uri("fabric:/Politics/PresidentialService"); PresidentialServiceClient presidentialServiceClient = new PresidentialServiceClient(communicationClientFactory, uri); //v2.0.0 //while (true) //{ int presidentId = 44; string presidentName = presidentialServiceClient.PresidentName(presidentId).Result; Console.WriteLine("{0}th president is {1}", presidentId, presidentName); string presidents = presidentialServiceClient.Presidents().Result; Console.WriteLine("Last 5 presidents {0}", presidents); Console.ReadLine();//remove for v2.0.0 // Console.WriteLine(); // Thread.Sleep(1000); //} }
private async Task uploadTranscript(string fileName, string text, string user) { string connectionString = "[Storage Account Connection String]"; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("transcripts"); CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName + "transcript.txt"); using (var stream = new MemoryStream(Encoding.Default.GetBytes(text), false)) { await blockBlob.UploadFromStreamAsync(stream); } Binding binding = WcfUtility.CreateTcpClientBinding(); IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); var wcfClientFactory = new WcfCommunicationClientFactory <IStateAggregator>( clientBinding: binding, servicePartitionResolver: partitionResolver ); var jobClient = new ServicePartitionClient <WcfCommunicationClient <IStateAggregator> >( wcfClientFactory, new Uri("fabric:/AudioTranscriptionApp/StateAggregator")); await jobClient.InvokeWithRetryAsync(client => client.Channel.ReportCompletion(fileName, blockBlob.Uri.AbsoluteUri, user)); }
public async static Task Run() { Binding binding = WcfUtility.CreateTcpClientBinding(); // Create a partition resolver IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault(); //var partitionResolver = new ServicePartitionResolver("dctsfpoc.westeurope.cloudapp.azure.com:19080", // "dctsfpoc.westeurope.cloudapp.azure.com:20188", "dctsfpoc.westeurope.cloudapp.azure.com:19000"); // create a WcfCommunicationClientFactory object. var wcfClientFactory = new WcfCommunicationClientFactory <IReferenceDataService> (clientBinding: binding, servicePartitionResolver: partitionResolver); // // Create a client for communicating with the ICalculator service that has been created with the // Singleton partition scheme. // var dataServiceCommunicationClient = new WcfCommunicationClient( wcfClientFactory, new Uri("fabric:/DCT.ILR.Processing.POC/DCT.ILR.Data"), new ServicePartitionKey(1) ); var resolved = partitionResolver.ResolveAsync(new Uri("fabric:/DCT.ILR.Processing.POC/DCT.ILR.Data"), new ServicePartitionKey(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), CancellationToken.None).Result; //foreach (var endpoint in resolved.Endpoints) //{ // Console.WriteLine($"Discovered Service Endpoint:'{endpoint.Address}"); //} // ListEndpoints(partitionResolver); // // Call the service to perform the operation. // try { var correlationId = Guid.NewGuid(); //var processTimes = validationServiceCommunicationClient.InvokeWithRetryAsync( // client => client.Channel.GetResults(correlationId)).Result; Console.WriteLine("1. Insert ULns values, 2. Just get results "); var keyValue = Console.ReadKey(); if (keyValue.KeyChar != 50) { await dataServiceCommunicationClient.InvokeWithRetryAsync( client => client.Channel.InsertULNs()); } var ulns = new List <long>() { 1000000027, 1000000035, 1000000043, 1000000051, 1000000078, 1000000272, 1000000280, 1000000299, 1000000302, 1000000310, 1000000477, 1000000485, 1000000493, 1000000647, 1000000655, 1000000671, 1000000779, 1000000787, 1000000795, 1000000841 }; var value1 = new JumpSharding().GetShard("1000000795", 10); var value2 = new JumpSharding().GetShard("1000000795", 10); var validUlns = await dataServiceCommunicationClient.InvokeWithRetryAsync( client => client.Channel.GetULNs(ulns)); Console.WriteLine("1. Insert LARS values, 2. Just get results "); keyValue = Console.ReadKey(); if (keyValue.KeyChar != 50) { await dataServiceCommunicationClient.InvokeWithRetryAsync( client => client.Channel.InsertLARSData()); } var learnAimRefs = new List <string>() { "00100309", "00100325", "00100432", "00100525", "00100533", "00100567", "00100572", "00100573", "00228740", "00228761", "00228762", "00228763", "00228764", "00228787", "00228789", "00228790", "00230643", "00230644", "00230645", "00230646", "00230648", "00230680", "00230684", "00230698", "00230699", "00230703", "00230704", "00230712", "00230713", "00230718", "00230722", "00230761", "00230764", "00243034", "00243035", "00243042", "00243043", "00243045", "00243046", "00243047", "00243054", "00243057", "00243060", "00243064", "00243066", "00243067", "00243068", "00243071", "00243072", "00243073", "00243075", "00243076", "00243077", "00243078", "00243114", "J6018531", "J6018545", "J6018576", "J6018593", "J6018626", "J6018643", "J6018657", "J6018707", "J6018710", "J6018724", "J6018741", "J6018755", "J6018769", "J6018772", "J6018805", "J6018836", "J6018853", "J6018867", "L5068787", "L5068904", "L5070183", "L5070197", "L5070202", "L5070233", "L5070247", "L5070250", "L5070264", "L5070281", "L5070295", "L5070300", "Z0005494", "Z0005495", "Z0005496", "Z0005497", "Z0005498", "Z0005499", "Z0005500", "Z0005501", "Z0005502", "Z0005503", "Z0005504", "Z0005505", "Z0005506", "Z0005507", "Z0005508", "Z0005509", "Z0005510", "Z0005511", "Z0005512", }; var tasksList = new List <Task>(); foreach (var item in learnAimRefs) { tasksList.Add(dataServiceCommunicationClient.InvokeWithRetryAsync( client => client.Channel.GetLARSLearningDeliveriesAsync(new List <string>() { item }))); } try { await Task.WhenAll(tasksList.ToArray()); Console.WriteLine("failed tasks: " + tasksList.Count(x => x.IsFaulted)); //foreach (var task in tasksList) //{ // Console.WriteLine(task.Result); //} } catch (Exception iex) { Console.WriteLine(iex.ToString()); } Console.WriteLine(""); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.ReadLine(); } }
public ScadaCommandingClient(WcfCommunicationClientFactory <IScadaCommandingContract> clientFactory, Uri serviceUri, ServicePartitionKey servicePartition) : base(clientFactory, serviceUri, servicePartition, listenerName) { }
public WebAdapterClient(WcfCommunicationClientFactory <IWebAdapterContract> clientFactory, Uri serviceName, ServicePartitionKey servicePartition) : base(clientFactory, serviceName, servicePartition, listenerName) { }
public TopologyBuilderClient(WcfCommunicationClientFactory <ITopologyBuilderContract> clientFactory, Uri serviceUri, ServicePartitionKey servicePartition) : base(clientFactory, serviceUri, servicePartition, listenerName) { }
private static async Task Run(string[] args) { // The Fabric URI of the service. var serviceName = new Uri("fabric:/DistributedJournalApp/DistributedJournalService"); var serviceResolver = new ServicePartitionResolver(() => new FabricClient()); var clientFactory = new WcfCommunicationClientFactory<IKeyValueStore>( serviceResolver, ServiceBindings.TcpBinding); var client = new ServicePartitionClient<WcfCommunicationClient<IKeyValueStore>>( clientFactory, serviceName, partitionKey: 0L); Console.WriteLine("Calling set"); await Set(client, "test", 38); Console.WriteLine("Set complete, calling get"); Console.WriteLine($"Got {await Get(client, "test")}"); var numTasks = args.Length == 0 ? 1 : int.Parse(args[0]); var tasks = new Task[numTasks]; var iteration = (long)0; // Initialize. for (var i = 0; i < tasks.Length; ++i) { await Set(client, i.ToString(), iteration); } var timer = Stopwatch.StartNew(); var paused = false; while (true) { var total = iteration * tasks.Length; if (!paused) { for (var i = 0; i < tasks.Length; ++i) { tasks[i] = CheckAndIncrement(client, i.ToString(), iteration); } await Task.WhenAll(tasks); if (iteration % 8000 == 0 && iteration > 0) { Console.WriteLine(); } if (iteration % 100 == 0) { WriteProgress(iteration, timer, total); } iteration++; } // Process user input. if (Console.KeyAvailable || paused) { var consoleKey = Console.ReadKey(); switch (consoleKey.Key) { case ConsoleKey.Escape: return; case ConsoleKey.D: // Output debug data. var prefix = $"{iteration}_"; await client.InvokeWithRetry(_ => _.Channel.DumpDebugData(DebugDumpDirectory, prefix)); break; case ConsoleKey.P: // Toggle pause paused = !paused; break; case ConsoleKey.S: WriteProgress(iteration, timer, total); break; } } } }