public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { // Uninstall the instance. //NodeServiceInstance serviceInstance = SPFarm.Local.Services.GetValue<NodeServiceInstance>(); foreach (SPServer server in SPFarm.Local.Servers) { if (server.Role != SPServerRole.Invalid) { NodeServiceInstance serviceInstance = server.ServiceInstances.GetValue <NodeServiceInstance>(); if (serviceInstance != null) { serviceInstance.Delete(); } } } // Uninstall the service proxy. NodeServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <NodeServiceProxy>(); if (serviceProxy != null) { serviceProxy.Delete(); } // Uninstall the service. NodeService service = SPFarm.Local.Services.GetValue <NodeService>(); if (service != null) { service.Delete(); } }
public void Run() { Console.Title = "Server: " + _serverId; Console.WriteLine("Running base version"); var freezeUtilities = new FreezeUtilities(); var serverParameters = UrlParameters.From(_serverUrl); var serverService = new ServerService(_storage, freezeUtilities, _serverUrl, DelayMessage); var nodeService = new NodeService(freezeUtilities, DelayMessage, RegisterServers, RegisterPartitions); var registerSlavesService = new SlaveRegisteringService(_storage); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var server = new Grpc.Core.Server { Services = { DIDAService.BindService(serverService), NodeControlService.BindService(nodeService), RegisterSlaveToMasterService.BindService(registerSlavesService), BaseSlaveService.BindService(new BaseSlaveServerService(_storage)) }, Ports = { new ServerPort(serverParameters.Hostname, serverParameters.Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Server " + _serverId + " listening on port " + serverParameters.Port); ReadCommands(); server.ShutdownAsync().Wait(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { // Install the service. NodeService service = SPFarm.Local.Services.GetValue <NodeService>(); if (service == null) { service = new NodeService(SPFarm.Local); service.Update(); } // Install the service proxy. NodeServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <NodeServiceProxy>(); if (serviceProxy == null) { serviceProxy = new NodeServiceProxy(SPFarm.Local); serviceProxy.Update(true); } // With service added to the farm, install instance. foreach (SPServer server in SPFarm.Local.Servers) { if (server.Role != SPServerRole.Invalid) { NodeServiceInstance serviceInstance = new NodeServiceInstance(server, service); serviceInstance.Update(true); } } }
public void GetNodeByUrlOnSuccessReturnsNodeRecord() { //arrange var networkUrl = "networkurl"; var nodeUrl = "nodeurl"; var nodeRecord = new NodeRecord { Url = nodeUrl }; var repository = new Mock <INodeRepository>(); repository.Setup(r => r.GetNodeByUrl( It.Is <string>(url => url == nodeUrl), It.Is <string>(url => url == networkUrl) )) .Returns(nodeRecord); var service = new NodeService(repository.Object); //act var result = service.GetNodeByUrl(nodeUrl, networkUrl); //assert Assert.AreEqual(nodeUrl, result.Url); }
public checkExternal(external command) { this.command = command; pluginName = String.Format("ex_{0}", this.command.name); NodeService.log(String.Format("{0} initialized", pluginName)); }
public checkDisk() { pluginName = "checkDisk"; NodeService.log(String.Format("{0} initialized", pluginName)); foreach (module m in ((AppConfig)NodeService.config).moduleConfigs) { if (m.name.Equals(pluginName)) { if (m.warning != Int32.MinValue) { warning = m.warning; NodeService.log(String.Format("checkDisk warning level set to {0}", warning)); } if (m.warning != Int32.MinValue) { critical = m.critical; NodeService.log(String.Format("checkDisk critical level set to {0}", critical)); } break; } } drives = getAllDisks(); }
private void SetupNodeServiceApp() { // create a long running op.. using (SPLongOperation op = new SPLongOperation(this)) { op.Begin(); try { // get reference to the installed service NodeService service = SPFarm.Local.Services.GetValue <NodeService>(); // create the service application NodeServiceApplication serviceApp = CreateServiceApplication(service); // if the service instance isn't running, start it up StartServiceInstances(); // create service app proxy CreateServiceApplicationProxy(serviceApp); } catch (Exception e) { throw new SPException("Error creating Glyma Node service application.", e); } } }
public async Task ShouldReturnAllManagerNodesInfoWhenGetNodesCalled() { //Given var spec = new NodeUpdateParameters(); spec.Role = "manager"; _swarmClient.GetNodes().Returns(x => { return(Task.FromResult <IEnumerable <NodeListResponse> >(new [] { _any.Create <NodeListResponse>(), _any.Build <NodeListResponse>().With(t => t.Spec, spec).Create() })); }); var nodeService = new NodeService(_swarmClient, _loggerFactory); var nodeController = new NodeController(nodeService); //When var response = await nodeController.GetNode(null, SwarmRole.Manager); var jsonResult = response as JsonResult; var value = jsonResult?.Value as IEnumerable <NodeListResponse>; //Then Assert.NotNull(jsonResult); Assert.NotNull(value); Assert.Equal(200, jsonResult.StatusCode); Assert.Equal(1, value.Count()); }
protected override void OnReceive(object message) { var up = message as ClusterEvent.MemberUp; if (up != null) { var mem = up; Log.Info("Member is Up: {0}", mem.Member); NodeService.Add(mem.Member.UniqueAddress); } else if (message is ClusterEvent.UnreachableMember) { var unreachable = (ClusterEvent.UnreachableMember)message; Log.Info("Member detected as unreachable: {0}", unreachable.Member); } else if (message is ClusterEvent.MemberRemoved) { var removed = (ClusterEvent.MemberRemoved)message; Log.Info("Member is Removed: {0}", removed.Member); } else if (message is ClusterEvent.IMemberEvent) { //IGNORE } else { Unhandled(message); } }
public async Task OpenGraphItFile(InputFileChangeEventArgs e, bool overwrite) { Overwrite = overwrite; try { byte[] temp; Options newOptions = new Options(); using (var streamReader = new MemoryStream()) { await e.File.OpenReadStream().CopyToAsync(streamReader); temp = streamReader.ToArray(); } OpenPreference = false; string graph = DecodeAndInflate(temp); XmlDocument xmlData = new XmlDocument(); xmlData.LoadXml(graph); if (Overwrite) { Graph = new Graph(); } Traverse(xmlData, NodeService.NextId(Graph.Nodes), EdgeService.NextId(Graph.Edges)); await GraphChanged.InvokeAsync(Graph); if (Overwrite) { await OptionsChanged.InvokeAsync(Options); } } catch (ObjectDisposedException) { ErrorOpening = true; } }
protected async Task SubmitAsync() { if (!string.IsNullOrEmpty(Comment.Content) && Comment.Content != PreviousComment) { if (Id == null) { Comment.PostId = PostId; var contentActivity = new ContentActivity() { Node = Comment, Message = $"Added a new forum comment: {Comment.Snippet}" }; await NodeService.AddAsync(contentActivity); } else { var contentActivity = new ContentActivity() { Node = Comment, Message = $"Updated a new forum comment: {Comment.Snippet}" }; await NodeService.UpdateAsync(contentActivity); } await OnSave.InvokeAsync(Comment); PreviousComment = Comment.Content; Comment.Content = string.Empty; } }
protected override async Task OnParametersSetAsync() { var node = await NodeService.GetAsync(Id); Video = Models.Video.Create(node); var channelNode = await NodeService.GetAsync(Video.ParentId); Channel = Models.Channel.Create(channelNode); var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId(); var createdBy = node.CreatedBy; CanEditVideo = await SecurityService.AllowedAsync( loggedInUserId, createdBy, Constants.VideosModule, Constants.VideoType, Actions.Edit ); CanDeleteVideo = await SecurityService.AllowedAsync( loggedInUserId, createdBy, Constants.VideosModule, Constants.VideoType, Actions.Delete ); base.OnInitialized(); }
public static NodeServiceApplication Create(string name, NodeService service, SPIisWebServiceApplicationPool appPool) { if (name == null) { throw new ArgumentNullException("name"); } if (service == null) { throw new ArgumentNullException("service"); } if (appPool == null) { throw new ArgumentNullException("appPool"); } // Create the service application. NodeServiceApplication serviceApplication = new NodeServiceApplication(name, service, appPool); serviceApplication.Update(); // Register the supported endpoints. serviceApplication.AddServiceEndpoint("http", SPIisWebServiceBindingType.Http); serviceApplication.AddServiceEndpoint("https", SPIisWebServiceBindingType.Https, "secure"); return serviceApplication; }
protected override async Task OnParametersSetAsync() { var node = await NodeService.GetAsync(Id); Comment = Models.Comment.Create(node); CommentUserName = await UserService.GetUserNameAsync(node.CreatedBy); var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId(); CanEditComment = await SecurityService.AllowedAsync( loggedInUserId, Comment.CreatedBy, Constants.ForumsModule, Constants.CommentType, Actions.Edit ); CanDeleteComment = await SecurityService.AllowedAsync( loggedInUserId, Comment.CreatedBy, Constants.ForumsModule, Constants.CommentType, Actions.Delete ); CanVote = await SecurityService.AllowedAsync( loggedInUserId, null, Constants.ForumsModule, Constants.CommentType, Actions.Vote ); }
private void CreateRBipartite() { double x; double y = (SVGControl.Yaxis + SVGControl.Height / 2) + DefaultOptions.NodeRadius * 3; IList <Node> addedNodes1 = new List <Node>(); IList <Node> addedNodes2 = new List <Node>(); for (int i = 0; i < numNodes / 2; i++) { x = (SVGControl.Xaxis + SVGControl.Width / 2) + DefaultOptions.NodeRadius * 3 * (double)(numNodes / 2 - i); addedNodes1.Add(NodeService.AddNode(Graph.Nodes, DefaultOptions, x, y, (i + 1).ToString())); } y = (SVGControl.Yaxis + SVGControl.Height / 2) - DefaultOptions.NodeRadius * 3; for (int i = 0; i < numNodes / 2; i++) { x = (SVGControl.Xaxis + SVGControl.Width / 2) + DefaultOptions.NodeRadius * 3 * (double)(numNodes / 2 - i); addedNodes2.Add(NodeService.AddNode(Graph.Nodes, DefaultOptions, x, y, (i + 1).ToString())); } for (int i = 0; i < numNodes / 2; i++) { for (int k = 0; k < KValue; k++) { var xx = (i + k) % addedNodes2.Count; EdgeService.AddEdge(Graph.Edges, DefaultOptions, addedNodes1[i], addedNodes2[xx]); if (Graph.Directed) { EdgeService.AddEdge(Graph.Edges, DefaultOptions, addedNodes2[i], addedNodes1[xx]); } } } }
protected async Task SubmitAsync() { Article.Slug = Article.Title.ToSlug(); var existingArticle = await NodeService.GetBySlugAsync( Constants.ArticlesModule, Constants.ArticleType, Article.Slug, true); if (existingArticle == null || existingArticle.Id == Article.Id) { var contentActivity = new ContentActivity() { Node = Article, Message = $"Updated an article: {Article.Title}." }; await NodeService.UpdateAsync(contentActivity); NavigationManager.NavigateTo($"article/{Article.Slug}", true); } else { ValidationMessage = "A similar title already exists."; } }
protected async Task SubmitAsync() { var existingCategory = await NodeService.GetBySlugAsync( Constants.ArticlesModule, Constants.CategoryType, Category.Slug, true); if (existingCategory == null) { var contentActivity = new ContentActivity() { Node = Category, Message = $"Added a new article category: {Category.Name}." }; var response = await NodeService.AddAsync(contentActivity); if (response.StatusCode == HttpStatusCode.OK) { NavigationManager.NavigateTo($"articles/{Category.Slug}"); } else { ValidationMessage = "Unable to save."; } } else { ValidationMessage = "A similar name already exists."; } }
protected override async Task OnParametersSetAsync() { var node = await NodeService.GetBySlugAsync( Constants.ArticlesModule, Constants.ArticleType, Slug); Article = Models.Article.Create(node); var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId(); var createdBy = node.CreatedBy; CanEditArticle = await SecurityService.AllowedAsync( loggedInUserId, createdBy, Constants.ArticlesModule, Constants.ArticleType, Actions.Edit ); CanDeleteArticle = await SecurityService.AllowedAsync( loggedInUserId, createdBy, Constants.ArticlesModule, Constants.ArticleType, Actions.Delete ); var categoryNode = await NodeService.GetAsync(Article.CategoryId); Category = Models.Category.Create(categoryNode); }
public checkNetwork() { pluginName = "checkNetwork"; foreach (module m in ((AppConfig)NodeService.config).moduleConfigs) { if (m.name.Equals(pluginName)) { if (m.useNetworkAdapter) { perfObject = "Network Adapter"; } instance = m.networkInterface; NodeService.log(String.Format("Using {0} {1}", perfObject, instance)); break; } } String tmp = new Regex("[^a-z]").Replace(instance.ToLower(), ""); pluginName = String.Format("net_{0}", (tmp.Length == 0) ? "all" : tmp); openCounters(); NodeService.log(String.Format("{0} initialized", pluginName)); }
override public String[] getValues() { List <String> ret = new List <String>(); Double up = 0; Double down = 0; PerformanceCounter pc; try { for (int i = 0; i < counters.Count; i++) { pc = counters.ElementAt(i); NodeService.log(String.Format("Retrieving for {0}\\{1}", pc.InstanceName, pc.CounterName)); if (pc.CounterName.Equals(perfCounters[0])) { up += pc.NextValue(); } else { down += pc.NextValue(); } } } catch (Exception ex) { NodeService.log(ex.Message); } ret.Add(String.Format("down.value {0}\n", (Int32)down)); ret.Add(String.Format("up.value {0}\n", (Int32)up)); ret.Add(".\n"); return(ret.ToArray()); }
protected override async Task OnParametersSetAsync() { var topicNode = await NodeService.GetAsync(Id); Topic = Models.Topic.Create(topicNode); TopicUserName = !string.IsNullOrEmpty(topicNode.CreatedBy) ? await UserService.GetUserNameAsync(topicNode.CreatedBy) : string.Empty; var forumNode = await NodeService.GetAsync(Topic.ForumId); Forum = Models.Forum.Create(forumNode); Posts = new PostsModel(NodeService) { NodeSearch = new NodeSearch() { Module = Constants.ForumsModule, Type = Constants.PostType, ParentId = Topic.Id, OrderBy = new string[] { OrderBy.Hot, OrderBy.Latest } } }; await Posts.InitAsync(); var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId(); CanEditTopic = await SecurityService.AllowedAsync( loggedInUserId, Topic.CreatedBy, Constants.ForumsModule, Constants.TopicType, Actions.Edit ); CanDeleteTopic = await SecurityService.AllowedAsync( loggedInUserId, Topic.CreatedBy, Constants.ForumsModule, Constants.TopicType, Actions.Delete ); CanAddPost = await SecurityService.AllowedAsync( loggedInUserId, null, Constants.ForumsModule, Constants.PostType, Actions.Add ); CanVote = await SecurityService.AllowedAsync( loggedInUserId, null, Constants.ForumsModule, Constants.TopicType, Actions.Vote ); }
public virtual void DeleteRelationships(IRelationshipProxy[] relationshipsToDelete) { foreach (IRelationshipProxy relationship in relationshipsToDelete) { NodeService.DeleteRelationship(DomainId, relationship.Id); } }
protected async Task SubmitAsync() { Channel.Slug = Channel.Name.ToSlug(); var existingChannel = await NodeService.GetBySlugAsync( Constants.VideosModule, Constants.ChannelType, Channel.Slug, true); if (existingChannel == null) { var contentActivity = new ContentActivity() { Node = Channel, Message = $"Edited a video channel: {Channel.Name}." }; await NodeService.UpdateAsync(contentActivity); NavigationManager.NavigateTo($"videos/{Channel.Slug}"); } else { ValidationMessage = "A similar name already exists."; } }
public PaginatedMetaServiceImpl() { _previousPageService = new PreviousPageServiceImpl(); _nextPageService = new NextPageServiceImpl(); _nodeService = new NodeServiceImpl(); _pageInCollectionService = new LastPageInCollectionServiceImpl(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, NodeService nodeService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseHttpsRedirection(); app.UseRouting(); // app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "DFS Node API"); c.RoutePrefix = string.Empty; }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
protected async Task SubmitAsync() { Forum.ParentId = ParentId; var existingForum = await NodeService.GetBySlugAsync( Constants.ForumsModule, Constants.ForumType, Forum.Name, true); if (existingForum == null) { var contentActivity = new ContentActivity() { Node = Forum, Message = $"Added a new forum: {Forum.Name}." }; await NodeService.AddAsync(contentActivity); NavigationManager.NavigateTo($"forum/{Forum.Slug}"); } else { ValidationMessage = "A similar title already exists."; } }
public async Task ShouldReturnAllNodesWithSpecifiedNameWhenGetNodesCalled() { //Given const string hostname = "node1"; var desc = new NodeDescription(); desc.Hostname = hostname; _swarmClient.GetNodes().Returns(x => { return(Task.FromResult <IEnumerable <NodeListResponse> >(new [] { _any.Create <NodeListResponse>(), _any.Build <NodeListResponse>().With(t => t.Description, desc).Create() })); }); var nodeService = new NodeService(_swarmClient, _loggerFactory); var nodeController = new NodeController(nodeService); //When var response = await nodeController.GetNode(hostname, SwarmRole.Unknown); var jsonResult = response as JsonResult; var value = jsonResult?.Value as IEnumerable <NodeListResponse>; //Then Assert.NotNull(jsonResult); Assert.NotNull(value); Assert.Equal(200, jsonResult.StatusCode); Assert.Equal(1, value.Count()); }
public override string Execute(IList <string> parameters) { int nodeId; int loadCaseNumber; double loadValue; try { nodeId = int.Parse(parameters[0]); loadCaseNumber = int.Parse(parameters[1]); loadValue = double.Parse(parameters[2]); } catch { throw new ArgumentException("Failed to parse AssignForceY command parameters."); } Node node = base.dbctx.Nodes[nodeId]; ILoadCase loadCase = base.dbctx.LoadCases[loadCaseNumber]; INodalLoad nodeLoad = new ForceYDirection(loadCase, loadValue); NodeService.AddLoad(node, nodeLoad); return($"Nodal force load parallel to Y axis with intensity {loadValue} and Load Case Numeber {loadCaseNumber} has been assigned to node with ID {node.Number}."); }
public NodeServiceTests() { var configBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); _configuration = configBuilder.Build(); var services = new ServiceCollection(); services.AddOptions(); // this statement is required if you wanna use IOption Pattern. services.Configure <NodeConfiguration>(_configuration.GetSection(nameof(NodeConfiguration))); _serviceProvider = services.BuildServiceProvider(); IOptions <NodeConfiguration> optionAccessor = _serviceProvider.GetService <IOptions <NodeConfiguration> >(); _nodeConfiguration = optionAccessor.Value; IOptions <HostConfig> optionAccessorHost = _serviceProvider.GetService <IOptions <HostConfig> >(); _hostConfig = optionAccessorHost.Value; _nodeService = new NodeService(optionAccessor, optionAccessorHost); }
protected async Task SubmitAsync() { Post.Slug = Post.Title.ToSlug(); var existingPost = await NodeService.GetBySlugAsync( Constants.BlogsModule, Constants.PostType, Post.Slug, true); if (existingPost == null) { var contentActivity = new ContentActivity() { Node = Post, Message = $"Added a new post: {Post.Title}." }; await NodeService.AddAsync(contentActivity); NavigationManager.NavigateTo($"blog/post/{Post.Slug}"); } else { ValidationMessage = "A similar name already exists."; } }
public WarehouseServiceTests(TestFixture <Startup> fixture) { var entity = new List <Warehouse> { new Warehouse { Id = 1, Name = "Warehouse" } }; Repository = new Mock <INodeRepository <Warehouse> >(); Repository.Setup(x => x.GetAll()) .Returns(entity); Repository.Setup(x => x.GetById(It.IsAny <int>())) .Returns((int id) => entity.Find(s => s.Id == id)); Repository.Setup(x => x.Insert(It.IsAny <Warehouse>())) .Callback((Warehouse label) => entity.Add(label)); Repository.Setup(x => x.Update(It.IsAny <Warehouse>())) .Callback((Warehouse label) => entity[entity.FindIndex(x => x.Id == label.Id)] = label); Repository.Setup(x => x.Delete(It.IsAny <int>())) .Callback((int id) => entity.RemoveAt(entity.FindIndex(x => x.Id == id))); var mapper = (IMapper)fixture.Server.Host.Services.GetService(typeof(IMapper)); var baseService = new NodeService <Warehouse>(Repository.Object); Service = new WarehouseService(baseService, mapper); }
public void TestMetaTitleWithNoWebsite() { var umbracoHelperService = new Mock<IUmbracoHelperService>(); var publishedContentExtensionService = new Mock<IPublishedContentExtensionService>(); var nodeService = new NodeService(new UmbracoMapper(), umbracoHelperService.Object, publishedContentExtensionService.Object); umbracoHelperService.Setup(x => x.TypedContentAtXPath(It.IsAny<string>())) .Returns((IEnumerable<IPublishedContent>)null); OverrideRegisteredIUmbracoHelperService(umbracoHelperService.Object); OverrideRegisteredINodeService(nodeService); var queryService = Bootstrapper.Container.Resolve<IQueryService>(); MvcHtmlString metaTitle = queryService.ExecuteQuery(new MetaTitleSpecification(1052, PageTitle)); Assert.AreEqual(PageTitle, metaTitle.ToString()); }
private NodeServiceApplication CreateServiceApplication(NodeService service) { // create service app NodeServiceApplication serviceApp = NodeServiceApplication.Create( ServiceAppName.Text, service, ApplicationPoolSelection.GetOrCreateApplicationPool()); serviceApp.Update(); // start it if it isn't already started if (serviceApp.Status != SPObjectStatus.Online) { serviceApp.Status = SPObjectStatus.Online; } // configure service app endpoint serviceApp.AddServiceEndpoint(string.Empty, SPIisWebServiceBindingType.Http); serviceApp.Update(true); // now provision the service app serviceApp.Provision(); return serviceApp; }
public void TestGetPageExists() { const int id = 1; var umbracoHelperService = new Mock<IUmbracoHelperService>(); var publishedContentExtensionService = new Mock<IPublishedContentExtensionService>(); var nodeService = new NodeService(new UmbracoMapper(), umbracoHelperService.Object, publishedContentExtensionService.Object); umbracoHelperService.Setup(x => x.TypedContent(id)).Returns(new MockPublishedContent(id)); var baseDocumentType = nodeService.GetPage<BaseDocumentType>(id); Assert.AreEqual(id, baseDocumentType.Id); }
public void TestGetWebsitesEmpty() { var umbracoHelperService = new Mock<IUmbracoHelperService>(); var publishedContentExtensionService = new Mock<IPublishedContentExtensionService>(); var nodeService = new NodeService(new UmbracoMapper(), umbracoHelperService.Object, publishedContentExtensionService.Object); umbracoHelperService.Setup(x => x.TypedContent(It.IsAny<int>())) .Returns((IPublishedContent) null); var websites = nodeService.GetWebsites().ToList(); Assert.AreEqual(0, websites.Count); }
private NodeServiceApplication(string name, NodeService service, SPIisWebServiceApplicationPool appPool) : base(name, service, appPool) { }