public IEnumerable <string> Get() { //List<ActorInformation> l = this.GetAllActors(actorServicePath).Result; List <string> result = new List <string>(); /*foreach (ActorInformation a in l) * { * result.Add(a.ActorId.GetLongId().ToString()); * } * * IRuntimeStore helloWorldClient = ServiceProxy.Create<IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); * string message = helloWorldClient.HelloWorldAsync().Result; * * result.Add(message);*/ IRuntimeStore helloWorldClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); List <long> message = helloWorldClient.GetTenants().Result; foreach (var m in message) { result.Add(m.ToString()); } return(result); }
public void Post(int id) { /*ITenantUpdateActor tenantUpdateActor = ActorProxy.Create<ITenantUpdateActor>(new ActorId(id), actorServicePath); * Task t = tenantUpdateActor.SetCountAsync(1); * t.Wait();*/ IRuntimeStore helloWorldClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); helloWorldClient.AddTenant(id).Wait(); }
public string Get(int id) { /*ITenantUpdateActor tenantUpdateActor = ActorProxy.Create<ITenantUpdateActor>(new ActorId(id), actorServicePath); * Task<int> t1 = tenantUpdateActor.GetCountAsync(); * int k = t1.Result; * * return k.ToString();*/ IRuntimeStore helloWorldClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); long value = helloWorldClient.GetTenant(id).Result; return(value.ToString()); }
/// <summary> /// This is the main entry point for your service replica. /// This method executes when this replica of your service becomes primary and has write status. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { // TODO: Implement it with thread pool. IRuntimeStore runtimeStoreClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); while (true) { cancellationToken.ThrowIfCancellationRequested(); await this.RunAsyncInternal(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); } }
private async Task RunAsyncInternal(CancellationToken cancellationToken) { IRuntimeStore runtimeStoreClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); ServiceEventSource.Current.ServiceMessage(this.Context, "Service has woken up and executing now."); // Get the tenant id from Runtime store long actorId = await runtimeStoreClient.GetTenantInProgress(); if (actorId == -1) { ServiceEventSource.Current.ServiceMessage(this.Context, "No tenant found to work on."); return; } ServiceEventSource.Current.ServiceMessage(this.Context, "Got tenant {0} to work on.", actorId); ITenantUpdateActor tenantUpdateActor = ActorProxy.Create <ITenantUpdateActor>(new ActorId(actorId), actorServicePath); string currentState = await tenantUpdateActor.GetWorkflowState(); ServiceEventSource.Current.ServiceMessage(this.Context, "Current state of tenant {0} is {1}", actorId, currentState); if (currentState == "Completed")// any terminal { // Move tenant id in runtime store to Terminal Queue ServiceEventSource.Current.ServiceMessage(this.Context, "Moving the tenant to terminal state."); await runtimeStoreClient.TransitionTenantToTerminal(actorId, "Completed"); // Delete actor ServiceEventSource.Current.ServiceMessage(this.Context, "Deleting the actor {0} in service.", actorId); ActorId actorToDelete = new ActorId(actorId); IActorService myActorServiceProxy = ActorServiceProxy.Create(actorServicePath, actorToDelete); await myActorServiceProxy.DeleteActorAsync(actorToDelete, cancellationToken); } else { // TODO Call Execute, mainly to make sure that it is doing work and if needed, move to alerted state /*ServiceEventSource.Current.ServiceMessage(this.Context, "Executing the actor {0} in service.", actorId); * await tenantUpdateActor.Execute();*/ // Re-put to the in-progress queue await runtimeStoreClient.AddTenantInProgress(actorId, "InProgress"); } // If workflow running for long and still, not complete, set to terminal state }
private async Task RunAsyncInternal(CancellationToken cancellationToken) { IRuntimeStore runtimeStoreClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); ServiceEventSource.Current.ServiceMessage(this.Context, "InferenceEngine has woken up and executing now."); // Get the tenant id from Runtime store long actorId = await runtimeStoreClient.GetTenantInTerminalState(); if (actorId == -1) { ServiceEventSource.Current.ServiceMessage(this.Context, "InferenceEngine: No tenant found to infer for."); return; } ServiceEventSource.Current.ServiceMessage(this.Context, "InferenceEngine: Got tenant {0} to work on.", actorId); // If workflow running for long and still, not complete, set to terminal state }
public void Put(int tenantId) { IRuntimeStore helloWorldClient = ServiceProxy.Create <IRuntimeStore>(new Uri("fabric:/Prototype/RuntimeStore"), new ServicePartitionKey(0)); helloWorldClient.AddTenantInProgress(tenantId, "Begin"); }